Skip to content

Commit 1e4a714

Browse files
committed
Merge branch 'nd/tree-walk-path-exclusion'
Pathspec matching against a tree object were buggy when negative pathspec elements were involved, which has been fixed. * nd/tree-walk-path-exclusion: tree-walk.c: fix overoptimistic inclusion in :(exclude) matching
2 parents 57f06d5 + b7845ce commit 1e4a714

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

t/t6132-pathspec-exclude.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,21 @@ test_expect_success 'multiple exclusions' '
194194
test_cmp expect actual
195195
'
196196

197+
test_expect_success 't_e_i() exclude case #8' '
198+
git init case8 &&
199+
(
200+
cd case8 &&
201+
echo file >file1 &&
202+
echo file >file2 &&
203+
git add file1 file2 &&
204+
git commit -m twofiles &&
205+
git grep -l file HEAD :^file2 >actual &&
206+
echo HEAD:file1 >expected &&
207+
test_cmp expected actual &&
208+
git grep -l file HEAD :^file1 >actual &&
209+
echo HEAD:file2 >expected &&
210+
test_cmp expected actual
211+
)
212+
'
213+
197214
test_done

tree-walk.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
11071107
* 5 | file | 1 | 1 | 0
11081108
* 6 | file | 1 | 2 | 0
11091109
* 7 | file | 2 | -1 | 2
1110-
* 8 | file | 2 | 0 | 2
1110+
* 8 | file | 2 | 0 | 1
11111111
* 9 | file | 2 | 1 | 0
11121112
* 10 | file | 2 | 2 | -1
11131113
* -----+-------+----------+----------+-------
@@ -1118,7 +1118,7 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
11181118
* 15 | dir | 1 | 1 | 1 (*)
11191119
* 16 | dir | 1 | 2 | 0
11201120
* 17 | dir | 2 | -1 | 2
1121-
* 18 | dir | 2 | 0 | 2
1121+
* 18 | dir | 2 | 0 | 1
11221122
* 19 | dir | 2 | 1 | 1 (*)
11231123
* 20 | dir | 2 | 2 | -1
11241124
*
@@ -1134,7 +1134,12 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
11341134

11351135
negative = do_match(entry, base, base_offset, ps, 1);
11361136

1137-
/* #3, #4, #7, #8, #13, #14, #17, #18 */
1137+
/* #8, #18 */
1138+
if (positive == all_entries_interesting &&
1139+
negative == entry_not_interesting)
1140+
return entry_interesting;
1141+
1142+
/* #3, #4, #7, #13, #14, #17 */
11381143
if (negative <= entry_not_interesting)
11391144
return positive;
11401145

0 commit comments

Comments
 (0)