Commit c3c327de authored by Karsten Blees's avatar Karsten Blees Committed by Junio C Hamano

dir.c: fix ignore processing within not-ignored directories

As of 95c6f271 "dir.c: unify is_excluded and is_path_excluded APIs", the
is_excluded API no longer recurses into directories that match an ignore
pattern, and returns the directory's ignored state for all contained paths.

This is OK for normal ignore patterns, i.e. ignoring a directory affects
the entire contents recursively.

Unfortunately, this also "works" for negated ignore patterns ('!dir'), i.e.
the entire contents is "not-ignored" recursively, regardless of ignore
patterns that match the contents directly.

In prep_exclude, skip recursing into a directory only if it is really
ignored (i.e. the ignore pattern is not negated).
Signed-off-by: default avatarKarsten Blees <blees@dcon.de>
Tested-by: default avatarØystein Walle <oystwa@gmail.com>
Reviewed-by: Duy Nguyen's avatarDuy Nguyen <pclouds@gmail.com>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent 0aaf62b6
......@@ -821,6 +821,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
dir->basebuf, stk->baselen - 1,
dir->basebuf + current, &dt);
dir->basebuf[stk->baselen - 1] = '/';
if (dir->exclude &&
dir->exclude->flags & EXC_FLAG_NEGATIVE)
dir->exclude = NULL;
if (dir->exclude) {
dir->basebuf[stk->baselen] = 0;
dir->exclude_stack = stk;
......
......@@ -175,6 +175,24 @@ test_expect_success 'negated exclude matches can override previous ones' '
grep "^a.1" output
'
test_expect_success 'excluded directory overrides content patterns' '
git ls-files --others --exclude="one" --exclude="!one/a.1" >output &&
if grep "^one/a.1" output
then
false
fi
'
test_expect_success 'negated directory doesn'\''t affect content patterns' '
git ls-files --others --exclude="!one" --exclude="one/a.1" >output &&
if grep "^one/a.1" output
then
false
fi
'
test_expect_success 'subdirectory ignore (setup)' '
mkdir -p top/l1/l2 &&
(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment