Skip to content

Commit 456a4c0

Browse files
committed
Merge branch 'jk/diff-not-so-quick'
* jk/diff-not-so-quick: diff: futureproof "stop feeding the backend early" logic diff_tree: disable QUICK optimization with diff filter Conflicts: diff.c
2 parents 6c92972 + 28b9264 commit 456a4c0

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

diff-lib.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
102102
int changed;
103103
unsigned dirty_submodule = 0;
104104

105-
if (DIFF_OPT_TST(&revs->diffopt, QUICK) &&
106-
!revs->diffopt.filter &&
107-
DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
105+
if (diff_can_quit_early(&revs->diffopt))
108106
break;
109107

110108
if (!ce_path_match(ce, &revs->prune_data))

diff.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4456,6 +4456,13 @@ int diff_result_code(struct diff_options *opt, int status)
44564456
return result;
44574457
}
44584458

4459+
int diff_can_quit_early(struct diff_options *opt)
4460+
{
4461+
return (DIFF_OPT_TST(opt, QUICK) &&
4462+
!opt->filter &&
4463+
DIFF_OPT_TST(opt, HAS_CHANGES));
4464+
}
4465+
44594466
/*
44604467
* Shall changes to this submodule be ignored?
44614468
*

diff.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ extern void diff_tree_combined_merge(const unsigned char *sha1, int, struct rev_
198198

199199
void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const char *b);
200200

201+
extern int diff_can_quit_early(struct diff_options *);
202+
201203
extern void diff_addremove(struct diff_options *,
202204
int addremove,
203205
unsigned mode,

t/t4040-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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
142142
strbuf_add(&base, base_str, baselen);
143143

144144
for (;;) {
145-
if (DIFF_OPT_TST(opt, QUICK) &&
146-
DIFF_OPT_TST(opt, HAS_CHANGES))
145+
if (diff_can_quit_early(opt))
147146
break;
148147
if (opt->pathspec.nr) {
149148
skip_uninteresting(t1, &base, opt, &t1_match);

0 commit comments

Comments
 (0)