Hello!
I've found that patterns from a file specified via the --exclude-ignore
option are excluded from subdirectories too, which contradicts the
manual. The problem was encountered in tar 1.28 and confirmed in the
latest tar from the git.savannah.gnu.org/tar.git.
The manual says (6.4):
"`--exclude-ignore=file'
Before dumping a directory, |tar| checks if it contains file. If so,
exclusion patterns are read from this file. The patterns affect only
the directory itself."
How to reproduce:
mkdir test test/a
touch test/b test/a/b
echo b > test/.ign
tar -cvf test.tar --exclude-ignore=.ign test
Current result:
test/
test/.ign
test/a/
Expected result: test/a/b must not be excluded.
I'm not familiar with the source code, but after quick debugging I
suspect a bug in info_attach_exclist() (exclist.c:117 from the git HEAD
(1d2674b)):
ent = xmalloc (sizeof (*ent));
ent->excluded = ex;
ent->flags = file->flags == EXCL_DEFAULT
? file->flags : vcsfile->flags;
ent->prev = tail;
ent->next = NULL;
It looks like file->flags are propagated to ent->flags only when they're
equal to EXCL_DEFAULT (0x00), so EXCL_NON_RECURSIVE (0x02) pertaining to
--exclude-ignore is dropped, which prevents the condition in
excluded_name() (exclist.c:172) from skipping non-recursive entries from
distant ancestors.
--
WBR, Kirill Pushkaryov.