Skip to content

Commit fd50030

Browse files
committed
Merge branch 'kb/status-ignored-optim-2' into maint
Fix recent regression of .gitignore files that list !directory to mark it not-ignored. * kb/status-ignored-optim-2: dir.c: fix ignore processing within not-ignored directories
2 parents 467b8fe + c3c327d commit fd50030

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

dir.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
821821
dir->basebuf, stk->baselen - 1,
822822
dir->basebuf + current, &dt);
823823
dir->basebuf[stk->baselen - 1] = '/';
824+
if (dir->exclude &&
825+
dir->exclude->flags & EXC_FLAG_NEGATIVE)
826+
dir->exclude = NULL;
824827
if (dir->exclude) {
825828
dir->basebuf[stk->baselen] = 0;
826829
dir->exclude_stack = stk;

t/t3001-ls-files-others-exclude.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,24 @@ test_expect_success 'negated exclude matches can override previous ones' '
175175
grep "^a.1" output
176176
'
177177

178+
test_expect_success 'excluded directory overrides content patterns' '
179+
180+
git ls-files --others --exclude="one" --exclude="!one/a.1" >output &&
181+
if grep "^one/a.1" output
182+
then
183+
false
184+
fi
185+
'
186+
187+
test_expect_success 'negated directory doesn'\''t affect content patterns' '
188+
189+
git ls-files --others --exclude="!one" --exclude="one/a.1" >output &&
190+
if grep "^one/a.1" output
191+
then
192+
false
193+
fi
194+
'
195+
178196
test_expect_success 'subdirectory ignore (setup)' '
179197
mkdir -p top/l1/l2 &&
180198
(

0 commit comments

Comments
 (0)