summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-06-06 11:40:14 -0700
committerJunio C Hamano <gitster@pobox.com>2011-06-06 11:40:14 -0700
commit456a4c08b8d8ddefda939014c15877ace3e3f499 (patch)
tree02e78225fadc62bb3585494b9cb418d833bd8e01
parent6c92972d7f5ab247a8cab5e4b88cb281bf201970 (diff)
parent28b9264dd6cbadcef8b3e48c24ffcb2893b668b3 (diff)
downloadgit-456a4c08b8d8ddefda939014c15877ace3e3f499.tar.gz
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
-rw-r--r--diff-lib.c4
-rw-r--r--diff.c7
-rw-r--r--diff.h2
-rwxr-xr-xt/t4040-whitespace-status.sh5
-rw-r--r--tree-diff.c3
5 files changed, 16 insertions, 5 deletions
diff --git a/diff-lib.c b/diff-lib.c
index 3b5f2242a5..9c29293bbc 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -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))
diff --git a/diff.c b/diff.c
index 8f4815bfd7..61bedaed57 100644
--- a/diff.c
+++ b/diff.c
@@ -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?
*
diff --git a/diff.h b/diff.h
index adb40ba273..6d303c1d50 100644
--- a/diff.h
+++ b/diff.h
@@ -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,
diff --git a/t/t4040-whitespace-status.sh b/t/t4040-whitespace-status.sh
index abc49348b1..3c728a3ebf 100755
--- a/t/t4040-whitespace-status.sh
+++ b/t/t4040-whitespace-status.sh
@@ -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
diff --git a/tree-diff.c b/tree-diff.c
index 3f4072525b..b3cc2e4753 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -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);