git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, "Taylor Blau" <me@ttaylorr.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Johannes Schindelin" <johannes.schindelin@gmx.de>
Subject: Re: [PATCH v2 3/3] diff-filter: be more careful when looking for negative bits
Date: Thu, 27 Jan 2022 17:16:46 -0800	[thread overview]
Message-ID: <xmqq35l8zmkh.fsf@gitster.g> (raw)
In-Reply-To: <b041d2b7a3bd4433e86438cddbd52857e5f375a6.1643310510.git.gitgitgadget@gmail.com> (Johannes Schindelin via GitGitGadget's message of "Thu, 27 Jan 2022 19:08:29 +0000")

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> diff --git a/diff.c b/diff.c
> index 5081052c431..4ab4299b817 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -4720,6 +4720,12 @@ void diff_setup_done(struct diff_options *options)
>  	if (!options->use_color || external_diff())
>  		options->color_moved = 0;
>  
> +	if (options->filter_not) {
> +		if (!options->filter)
> +			options->filter = ~filter_bit[DIFF_STATUS_FILTER_AON];

Unlike the original, options->filter will have excess higher bit all
on, in addition to all the filter bits except for the all-or-none
bit.  I do not know offhand if that makes the difference, but I
trust that you have audited all uses of the options->filter flag
word and these high bits are truly unused and the difference does
not matter.

> +		options->filter &= ~options->filter_not;
> +	}

>  	for (i = 0; (optch = optarg[i]) != '\0'; i++) {
>  		unsigned int bit;
>  		int negate;
> @@ -4851,7 +4842,7 @@ static int diff_opt_diff_filter(const struct option *option,
>  			return error(_("unknown change class '%c' in --diff-filter=%s"),
>  				     optarg[i], optarg);
>  		if (negate)
> -			opt->filter &= ~bit;
> +			opt->filter_not |= bit;
>  		else
>  			opt->filter |= bit;
>  	}

And this ... 

> diff --git a/diff.h b/diff.h
> index 8ba85c5e605..a70e7c478c1 100644
> --- a/diff.h
> +++ b/diff.h
> @@ -283,7 +283,7 @@ struct diff_options {
>  	struct diff_flags flags;
>  
>  	/* diff-filter bits */
> -	unsigned int filter;
> +	unsigned int filter, filter_not;

... is exactly I wrote in the NEEDSWORK comment I gave you in my
earlier review.  Excellent.

> +test_expect_success 'multiple --diff-filter bits' '
> +
> +	git log -M --pretty="format:%s" --diff-filter=R HEAD >expect &&
> +	git log -M --pretty="format:%s" --diff-filter=Ra HEAD >actual &&
> +	test_cmp expect actual &&
> +	git log -M --pretty="format:%s" --diff-filter=aR HEAD >actual &&
> +	test_cmp expect actual &&
> +	git log -M --pretty="format:%s" \
> +		--diff-filter=a --diff-filter=R HEAD >actual &&
> +	test_cmp expect actual
> +
> +'

Good.

Thanks for noticing and fixing the long-standing issue.

  reply	other threads:[~2022-01-28  1:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-25 22:29 [PATCH 0/2] Fix two --diff-filter bugs Johannes Schindelin via GitGitGadget
2022-01-25 22:29 ` [PATCH 1/2] docs(diff): lose incorrect claim about `diff-files --diff-filter=A` Johannes Schindelin via GitGitGadget
2022-01-26  7:03   ` Junio C Hamano
2022-01-25 22:29 ` [PATCH 2/2] diff-filter: be more careful when looking for negative bits Johannes Schindelin via GitGitGadget
2022-01-25 23:21   ` Taylor Blau
2022-01-28 11:52     ` Johannes Schindelin
2022-01-26  7:23   ` Junio C Hamano
2022-01-26 22:55     ` Taylor Blau
2022-01-26 23:36       ` Junio C Hamano
2022-01-28 11:54         ` Johannes Schindelin
2022-01-26 17:57   ` Ævar Arnfjörð Bjarmason
2022-01-27 19:08 ` [PATCH v2 0/3] Fix two --diff-filter bugs Johannes Schindelin via GitGitGadget
2022-01-27 19:08   ` [PATCH v2 1/3] docs(diff): lose incorrect claim about `diff-files --diff-filter=A` Johannes Schindelin via GitGitGadget
2022-01-27 19:08   ` [PATCH v2 2/3] diff.c: move the diff filter bits definitions up a bit Johannes Schindelin via GitGitGadget
2022-01-27 19:08   ` [PATCH v2 3/3] diff-filter: be more careful when looking for negative bits Johannes Schindelin via GitGitGadget
2022-01-28  1:16     ` Junio C Hamano [this message]
2022-01-28 12:01       ` Johannes Schindelin
2022-01-28 12:02   ` [PATCH v3 0/3] Fix two --diff-filter bugs Johannes Schindelin via GitGitGadget
2022-01-28 12:02     ` [PATCH v3 1/3] docs(diff): lose incorrect claim about `diff-files --diff-filter=A` Johannes Schindelin via GitGitGadget
2022-01-28 12:02     ` [PATCH v3 2/3] diff.c: move the diff filter bits definitions up a bit Johannes Schindelin via GitGitGadget
2022-01-28 12:02     ` [PATCH v3 3/3] diff-filter: be more careful when looking for negative bits Johannes Schindelin via GitGitGadget

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqq35l8zmkh.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=me@ttaylorr.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).