diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-03-16 15:46:08 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-03-16 15:57:19 -0700 |
commit | 2cfe8a68ccba86f046080f890102a9a43361cfdd (patch) | |
tree | afcc58df52da5b238ed6649acab672ea874d6d76 | |
parent | 90b1994170900514a1ce7a3345e25cb7216915cc (diff) | |
download | git-2cfe8a68ccba86f046080f890102a9a43361cfdd.tar.gz git-2cfe8a68ccba86f046080f890102a9a43361cfdd.tar.xz |
diff --quiet: disable optimization when --diff-filter=X is used
The code notices that the caller does not want any detail of the changes
and only wants to know if there is a change or not by specifying --quiet.
And it breaks out of the loop when it knows it already found any change.
When you have a post-process filter (e.g. --diff-filter), however, the
path we found to be different in the previous round and set HAS_CHANGES
bit may end up being uninteresting, and there may be no output at the end.
The optimization needs to be disabled for such case.
Note that the f245194 (diff: change semantics of "ignore whitespace"
options, 2009-05-22) already disables this optimization by refraining
from setting HAS_CHANGES when post-process filters that need to inspect
the contents of the files (e.g. -S, -w) in diff_change() function.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | diff-lib.c | 3 | ||||
-rwxr-xr-x | t/t4037-whitespace-status.sh | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/diff-lib.c b/diff-lib.c index b7813af61..bfa650337 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -74,7 +74,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option) int changed; if (DIFF_OPT_TST(&revs->diffopt, QUICK) && - DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES)) + !revs->diffopt.filter && + DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES)) break; if (!ce_path_match(ce, revs->prune_data)) diff --git a/t/t4037-whitespace-status.sh b/t/t4037-whitespace-status.sh index a30b03bcf..abc49348b 100755 --- a/t/t4037-whitespace-status.sh +++ b/t/t4037-whitespace-status.sh @@ -60,4 +60,11 @@ test_expect_success 'diff-files -b -p --exit-code' ' git diff-files -b -p --exit-code ' +test_expect_success 'diff-files --diff-filter --quiet' ' + git reset --hard && + rm a/d && + echo x >>b/e && + test_must_fail git diff-files --diff-filter=M --quiet +' + test_done |