gnu-arch-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnu-arch-users] [BUG] set-tree-version does not break hard links


From: Mike Hearn
Subject: [Gnu-arch-users] [BUG] set-tree-version does not break hard links
Date: Tue, 30 Mar 2004 22:57:31 +0100
User-agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)

I can't see any reason that set-tree-version should not break hard links,
given that it's useful in the following scenario, so I wrote this patch.

I have a tree, that I have checked out and built in. I wish to branch said
tree, but I don't want to have to wait 20 mins for the code to rebuild
(this is a large codebase with many small changes being made). So, what I
can do is a cp -rlv tree1 tree2 then do a set-tree-version in tree2, of
course this breaks my original tree without this patch :)

thanks -mike


--- orig/libarch/project-tree.c
+++ mod/libarch/project-tree.c
@@ -158,7 +158,7 @@
 {
   t_uchar * default_version_file = 0;
   t_uchar * fqversion = 0;
-  int out_fd;
+  int out_fd, e = 0;
  
   invariant (arch_valid_archive_name (archive));
   invariant (arch_valid_package_name (version, arch_no_archive, 
arch_req_version, 0));
@@ -167,9 +167,11 @@
  
   fqversion = arch_fully_qualify (archive, version);
  
+  /* unlink so hardlinked tree duplicates work properly. we don't care if this 
fails */
+  vu_unlink (&e, default_version_file);
+
   out_fd = safe_open (default_version_file, O_WRONLY | O_CREAT, 0666);
  
-  safe_ftruncate (out_fd, (long)0);
   safe_printfmt (out_fd, "%s\n", fqversion);
  
   safe_close (out_fd);
 
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]