git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakob Pfender <jpfender@elegosoft.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Jens.Lehmann@web.de, johannes.schindelin@gmx.de
Subject: Re: [PATCH] diff --quiet: disable optimization when --diff-filter=X is used
Date: Thu, 17 Mar 2011 12:15:07 +0100	[thread overview]
Message-ID: <4D81ED3B.3000500@elegosoft.com> (raw)
In-Reply-To: <7vmxku64sh.fsf_-_@alter.siamese.dyndns.org>



On 03/17/2011 12:09 AM, Junio C Hamano wrote:
> 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.

That fixes it nicely, thank you.

>
> Signed-off-by: Junio C Hamano<gitster@pobox.com>
> ---
>
>   * This time with tests, on top of 90b1994 (diff: Rename QUIET internal
>     option to QUICK, 2009-05-23), which was the last commit in the series
>     that introduced the incorrect optimization in the first place.
>
>     Note that the test script was renamed to t/t4040 in today's codebase,
>     but it merges cleanly.
>
>   diff-lib.c                   |    3 ++-
>   t/t4037-whitespace-status.sh |    7 +++++++
>   2 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/diff-lib.c b/diff-lib.c
> index b7813af..bfa6503 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 a30b03b..abc4934 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

      reply	other threads:[~2011-03-17 11:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-16 16:56 [PATCH] diff-lib.c: Fix diff-files --diff-filter --quiet exit code Jakob Pfender
2011-03-16 21:13 ` Junio C Hamano
2011-03-16 22:21   ` Re* " Junio C Hamano
2011-03-16 23:09     ` [PATCH] diff --quiet: disable optimization when --diff-filter=X is used Junio C Hamano
2011-03-17 11:15       ` Jakob Pfender [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D81ED3B.3000500@elegosoft.com \
    --to=jpfender@elegosoft.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).