Skip to content
/ git Public
forked from git/git

Commit

Permalink
Merge branch 'jk/diff-not-so-quick'
Browse files Browse the repository at this point in the history
* jk/diff-not-so-quick:
  diff: futureproof "stop feeding the backend early" logic
  diff_tree: disable QUICK optimization with diff filter

Conflicts:
	diff.c
  • Loading branch information
gitster committed Jun 6, 2011
2 parents 6c92972 + 28b9264 commit 456a4c0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
4 changes: 1 addition & 3 deletions diff-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
int changed;
unsigned dirty_submodule = 0;

if (DIFF_OPT_TST(&revs->diffopt, QUICK) &&
!revs->diffopt.filter &&
DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
if (diff_can_quit_early(&revs->diffopt))
break;

if (!ce_path_match(ce, &revs->prune_data))
Expand Down
7 changes: 7 additions & 0 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -4456,6 +4456,13 @@ int diff_result_code(struct diff_options *opt, int status)
return result;
}

int diff_can_quit_early(struct diff_options *opt)
{
return (DIFF_OPT_TST(opt, QUICK) &&
!opt->filter &&
DIFF_OPT_TST(opt, HAS_CHANGES));
}

/*
* Shall changes to this submodule be ignored?
*
Expand Down
2 changes: 2 additions & 0 deletions diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ extern void diff_tree_combined_merge(const unsigned char *sha1, int, struct rev_

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

extern int diff_can_quit_early(struct diff_options *);

extern void diff_addremove(struct diff_options *,
int addremove,
unsigned mode,
Expand Down
5 changes: 5 additions & 0 deletions t/t4040-whitespace-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@ test_expect_success 'diff-files --diff-filter --quiet' '
test_must_fail git diff-files --diff-filter=M --quiet
'

test_expect_success 'diff-tree --diff-filter --quiet' '
git commit -a -m "worktree state" &&
test_must_fail git diff-tree --diff-filter=M --quiet HEAD^ HEAD
'

test_done
3 changes: 1 addition & 2 deletions tree-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
strbuf_add(&base, base_str, baselen);

for (;;) {
if (DIFF_OPT_TST(opt, QUICK) &&
DIFF_OPT_TST(opt, HAS_CHANGES))
if (diff_can_quit_early(opt))
break;
if (opt->pathspec.nr) {
skip_uninteresting(t1, &base, opt, &t1_match);
Expand Down

0 comments on commit 456a4c0

Please sign in to comment.