Skip to content

Commit af7b41c

Browse files
peffgitster
authored andcommitted
diff_tree: disable QUICK optimization with diff filter
We stop looking for changes early with QUICK, so our diff queue contains only a subset of the changes. However, we don't apply diff filters until later; it will appear at that point as though there are no changes matching our filter, when in reality we simply didn't keep looking for changes long enough. Commit 2cfe8a6 (diff --quiet: disable optimization when --diff-filter=X is used, 2011-03-16) fixes this in some cases by disabling the optimization when a filter is present. However, it only tweaked run_diff_files, missing the similar case in diff_tree. Thus the fix worked only for diffing the working tree and index, but not between trees. Noticed by Yasushi SHOJI. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2cfe8a6 commit af7b41c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

t/t4037-whitespace-status.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,9 @@ test_expect_success 'diff-files --diff-filter --quiet' '
6767
test_must_fail git diff-files --diff-filter=M --quiet
6868
'
6969

70+
test_expect_success 'diff-tree --diff-filter --quiet' '
71+
git commit -a -m "worktree state" &&
72+
test_must_fail git diff-tree --diff-filter=M --quiet HEAD^ HEAD
73+
'
74+
7075
test_done

tree-diff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, stru
287287

288288
for (;;) {
289289
if (DIFF_OPT_TST(opt, QUICK) &&
290+
!opt->filter &&
290291
DIFF_OPT_TST(opt, HAS_CHANGES))
291292
break;
292293
if (opt->nr_paths) {

0 commit comments

Comments
 (0)