]> Dogcows Code - chaz/tar/commitdiff
(dump_file0): The conditional at line
authorSergey Poznyakoff <gray@gnu.org.ua>
Sat, 21 Feb 2004 09:33:58 +0000 (09:33 +0000)
committerSergey Poznyakoff <gray@gnu.org.ua>
Sat, 21 Feb 2004 09:33:58 +0000 (09:33 +0000)
1296 prevented incremental backups on individual files
from working, as reported by Andreas Schuldei
<andreas@schuldei.org>.

This is due to the condition

  (0 < top_level || !incremental_option)

Removing it makes incremental backups work for individual
files as well as for directories. On the other hand, it does
not affect other functionality, as shown by the reasoning below:

To begin with, the two parts of this condition are mutually
superfluous, because

  1) when top_level < 0, incremental_option == 1
  so the condition yields false
  2) when top_level >= 0, incremental_option == 0
  so the condition yields true.

In other words, it is completely equivalent to

      (!incremental_option)

Now, let's consider the effect of its removal. There are two cases:

1) when incremental_option==1
This means incremental backup in progress. In this case dump_file
is invoked only for directories or for files marked with 'Y' by
get_directory_contents. The latter are those that did not meet the
condition in incremen.c:242, which is exactly the same condition
as this at create.c:1296. So, for these files the check
(!incremental_option) is useless, since the rest of the
conditional will yield false anyway. On the other hand, if
dump_file is invoked on a directory, the conditional will yield
false due to !S_ISDIR assertion, so these will be processed as usual.

Thus, for this case the extra condition (!incremental_option) is
irrelevant, and its removal won't alter the behavior of tar,
*except* that it will enable incremental backups on individual
files, which is the wanted effect.

2) when incremental_option==0
In this case the condition yields true and its removal does not
affect the functionality.

src/create.c

index cc75bb8bf059d90906ff365d6188db687faea592..59231ac51d466c1f6456ee1a4316996389956f11 100644 (file)
@@ -972,8 +972,8 @@ dump_dir0 (char *directory,
     return;
 
   if (one_file_system_option
-          && !top_level
-          && parent_device != stat->stat.st_dev)
+      && !top_level
+      && parent_device != stat->stat.st_dev)
     {
       if (verbose_option)
        WARN ((0, 0,
@@ -1293,12 +1293,11 @@ dump_file0 (struct tar_stat_info *stat, char *p,
   /* See if we want only new files, and check if this one is too old to
      put in the archive.  */
 
-  if ((0 < top_level || !incremental_option)
-      && !S_ISDIR (stat->stat.st_mode)
+  if (!S_ISDIR (stat->stat.st_mode)
       && stat->stat.st_mtime < newer_mtime_option
       && (!after_date_option || stat->stat.st_ctime < newer_ctime_option))
     {
-      if (0 < top_level)
+      if (0 < top_level) /* equivalent to !incremental_option */
        WARN ((0, 0, _("%s: file is unchanged; not dumped"),
               quotearg_colon (p)));
       /* FIXME: recheck this return.  */
This page took 0.026004 seconds and 4 git commands to generate.