Fix tar -c -l file file

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.
This commit is contained in:
Sergey Poznyakoff
2014-12-10 04:34:02 +02:00
parent e7b6f8e3ae
commit 1209e0ebff
2 changed files with 7 additions and 2 deletions

View 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);