Re* [PATCH] diff-lib.c: Fix diff-files --diff-filter --quiet exit code
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 16, 2011, 22:21 UTC
- Message-ID
- <7vwrjy670r.fsf_-_@alter.siamese.dyndns.org>
- In-Reply-To
- <7v62ri7oqm.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 10 quoted lines
> The code notices that the caller, by specifying --quiet, does not want any > details of the changes and instead wants to know if there is a change or > not. And it breaks out of the loop because it already found what it > wanted to know, namely, there is a change. > > When you have a post-process filter (like -w or -S), the path we found to > be different here may be uninteresting and there may be no output (hence > we should exit with status 0). So it is true that the optimization you > are removing needs to be disabled in _some_ situations, and the current > code doesn't, and it needs fixing.
What I was hinting at was perhaps to do it something like the attached; it is totally untested, and merely for illustration purposes.
I didn't even try to cover -w/-S which may or may not involve inspecting DIFF_FROM_CONTENTS bit in the options.
diff-lib.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/diff-lib.c b/diff-lib.c index 1e22992..2870de4 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -103,7 +103,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option) unsigned dirty_submodule = 0; 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))