]> Dogcows Code - chaz/tar/commitdiff
Fix tar -c -l file file
authorSergey Poznyakoff <gray@gnu.org.ua>
Wed, 10 Dec 2014 02:34:02 +0000 (04:34 +0200)
committerSergey Poznyakoff <gray@gnu.org.ua>
Wed, 10 Dec 2014 02:34:02 +0000 (04:34 +0200)
When the same file is added several times to the archive, count
correctly the number of hard links.  See also 37ddfb0b.

* src/create.c (dump_hard_link): Don't decrease nlink if it is 0.
* tests/link04.at: Test -cl options.

src/create.c
tests/link04.at

index 0d1a5ffe99315f52410f1ca9ab9172fa3286d6d6..1b08e0b21fd3e5f34675c01b8ad1f43b8477ca9c 100644 (file)
@@ -1472,8 +1472,8 @@ dump_hard_link (struct tar_stat_info *st)
          /* We found a link.  */
          char const *link_name = safer_name_suffix (duplicate->name, true,
                                                     absolute_names_option);
-
-         duplicate->nlink--;
+         if (duplicate->nlink)
+           duplicate->nlink--;
 
          block_ordinal = current_block_ordinal ();
          assign_string (&st->link_name, link_name);
index 03697bd6d33d8b47de865d4f4728e3a0be6699fb..53ca31ca00c02f4086a583cb3434de965287460c 100644 (file)
@@ -39,6 +39,10 @@ tar tvf archive | sed '
   s,.*[[0-9]] dir/,dir/,
 ' | sort
 
+echo --
+
+tar cfl archive dir dir
+
 echo ==
 
 tar chf archive dir
@@ -55,6 +59,7 @@ dir/file
 dir/file link to dir/file
 dir/symlink -> file
 dir/symlink link to dir/symlink
+--
 ==
 dir/
 dir/FOO
This page took 0.026823 seconds and 4 git commands to generate.