summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2007-04-16 04:15:12 +0000
committerAndreas Gruenbacher <agruen@suse.de>2007-04-16 04:15:12 +0000
commit005fb7e539503be9ee56165436d6ec2ec0ec573c (patch)
tree83c7eafbe6e2a1f8edf7e0a7dd4c9b4f3e364c21 /lib
parent250a8b619749f3fccae25a36993c8b791fe93c74 (diff)
downloadquilt-005fb7e539503be9ee56165436d6ec2ec0ec573c.tar.gz
- lib/backup-files.c: Do not modify the original file whenever
possible: previously, a ``quilt add'' usually linked the file to he backup and then copied the backup over the file to ensure a link count of one. Recognize this case, and create a copy in the first place instead.
Diffstat (limited to 'lib')
-rw-r--r--lib/backup-files.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/backup-files.c b/lib/backup-files.c
index b989bde..c7c716d 100644
--- a/lib/backup-files.c
+++ b/lib/backup-files.c
@@ -320,10 +320,13 @@ process_file(const char *file)
} else {
if (!opt_silent)
printf("Copying %s\n", file);
- if (link_or_copy_file(file, &st, backup))
- goto fail;
- if (opt_nolinks) {
- if (ensure_nolinks(file))
+ if (opt_nolinks && st.st_nlink == 1) {
+ if (copy_file(file, &st, backup))
+ goto fail;
+ } else {
+ if (link_or_copy_file(file, &st, backup))
+ goto fail;
+ if (opt_nolinks && ensure_nolinks(file))
goto fail;
}
if (opt_touch)
@@ -356,14 +359,17 @@ process_file(const char *file)
if (!opt_silent)
printf("Restoring %s\n", file);
unlink(file);
- if (link_or_copy_file(backup, &st, file))
- goto fail;
- unlink(backup);
- remove_parents(backup);
- if (opt_nolinks) {
- if (ensure_nolinks(file))
+ if (opt_nolinks && st.st_nlink != 1) {
+ if (copy_file(backup, &st, file))
+ goto fail;
+ } else {
+ if (link_or_copy_file(backup, &st, file))
+ goto fail;
+ if (opt_nolinks && ensure_nolinks(file))
goto fail;
}
+ unlink(backup);
+ remove_parents(backup);
if (opt_touch)
(void) utime(file, NULL);
else {