Merge branch 'kb/status-ignored-optim-2' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 10 Jun 2013 00:05:15 +0000 (17:05 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Jun 2013 00:05:15 +0000 (17:05 -0700)
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

dir.c
t/t3001-ls-files-others-exclude.sh
diff --git a/dir.c b/dir.c
index a5926fbd1aeafd468860da7dbd3d8a5d5999a650..13858fefa56b2d72f8ce6ce35f6bb8646f11ca81 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -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;
index 4e3735f0cb28d2b545f59a2464ea74bea4b626a1..f0421c09c700bc1203d2ef563c54157e94c83b33 100755 (executable)
@@ -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 &&
        (