diff options
-rwxr-xr-x | t/t6132-pathspec-exclude.sh | 17 | ||||
-rw-r--r-- | tree-walk.c | 11 |
2 files changed, 25 insertions, 3 deletions
diff --git a/t/t6132-pathspec-exclude.sh b/t/t6132-pathspec-exclude.sh index eb829fce97..2462b19ddd 100755 --- a/t/t6132-pathspec-exclude.sh +++ b/t/t6132-pathspec-exclude.sh @@ -194,4 +194,21 @@ test_expect_success 'multiple exclusions' ' test_cmp expect actual ' +test_expect_success 't_e_i() exclude case #8' ' + git init case8 && + ( + cd case8 && + echo file >file1 && + echo file >file2 && + git add file1 file2 && + git commit -m twofiles && + git grep -l file HEAD :^file2 >actual && + echo HEAD:file1 >expected && + test_cmp expected actual && + git grep -l file HEAD :^file1 >actual && + echo HEAD:file2 >expected && + test_cmp expected actual + ) +' + test_done diff --git a/tree-walk.c b/tree-walk.c index 77b37f36fa..79bafbd1a2 100644 --- a/tree-walk.c +++ b/tree-walk.c @@ -1107,7 +1107,7 @@ enum interesting tree_entry_interesting(const struct name_entry *entry, * 5 | file | 1 | 1 | 0 * 6 | file | 1 | 2 | 0 * 7 | file | 2 | -1 | 2 - * 8 | file | 2 | 0 | 2 + * 8 | file | 2 | 0 | 1 * 9 | file | 2 | 1 | 0 * 10 | file | 2 | 2 | -1 * -----+-------+----------+----------+------- @@ -1118,7 +1118,7 @@ enum interesting tree_entry_interesting(const struct name_entry *entry, * 15 | dir | 1 | 1 | 1 (*) * 16 | dir | 1 | 2 | 0 * 17 | dir | 2 | -1 | 2 - * 18 | dir | 2 | 0 | 2 + * 18 | dir | 2 | 0 | 1 * 19 | dir | 2 | 1 | 1 (*) * 20 | dir | 2 | 2 | -1 * @@ -1134,7 +1134,12 @@ enum interesting tree_entry_interesting(const struct name_entry *entry, negative = do_match(entry, base, base_offset, ps, 1); - /* #3, #4, #7, #8, #13, #14, #17, #18 */ + /* #8, #18 */ + if (positive == all_entries_interesting && + negative == entry_not_interesting) + return entry_interesting; + + /* #3, #4, #7, #13, #14, #17 */ if (negative <= entry_not_interesting) return positive; |