git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>,
	git@vger.kernel.org,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Eric Sunshine" <sunshine@sunshineco.com>
Subject: Re: [PATCH v5 2/3] range-diff/format-patch: handle commit ranges other than A..B
Date: Fri, 5 Feb 2021 15:09:04 +0100 (CET)	[thread overview]
Message-ID: <nycvar.QRO.7.76.6.2102051504080.54@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <xmqqim772tal.fsf@gitster.c.googlers.com>

Hi Junio,

On Thu, 4 Feb 2021, Junio C Hamano wrote:

> Junio C Hamano <gitster@pobox.com> writes:
>
> > Ah, I didn't think of adding this inside the same loop.  As long as
> > the pending objects are independent, this should work, but it is
> > unsafe, I think.
>
> Here is what I added on top of the 3-patch series for tonight's
> pushout.
>
>  * No need to count positive/negative; just seeing both exists is
>    sufficient and there is no need to examine any later elements, if
>    any.

Your code is substantially harder to read. I really dislike that `npmask`
idea.

>  * Clearing commit marks needs to be done after we have seen enough,
>    or it can clear the stuff we would want to inspect before we
>    have a chance to.  Do it in a separate post-cleaning loop.

I implemented that.

>  * Dedent by judicious use of 'goto'.

Not necessary: the code is short and narrow enough.

>  * The last parameter to setup_revisions() is a pointer, so spell it
>    NULL not 0.

I had missed that in your review. Fixed, too.

>  * "rang" -> "range" typofix (it might be even better to look for
>    "range:")

Technically, it is not necessary, as we're only verifying that the
intended error message is shown, and that "e" does not make any
difference.

But it _was_ a typo, so I fixed it, too.

Next iteration is coming soon,
Dscho

>
> ----- >8 ---------- >8 ---------- >8 ---------- >8 ---------- >8 ---------- >8 -----
> Subject: [PATCH] fixup! range-diff/format-patch: handle commit ranges other than A..B
>
>  range-diff.c          | 30 +++++++++++++++++-------------
>  t/t3206-range-diff.sh |  2 +-
>  2 files changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/range-diff.c b/range-diff.c
> index c307bca9de..7a38dc8715 100644
> --- a/range-diff.c
> +++ b/range-diff.c
> @@ -570,24 +570,28 @@ int is_range_diff_range(const char *arg)
>  {
>  	char *copy = xstrdup(arg); /* setup_revisions() modifies it */
>  	const char *argv[] = { "", copy, "--", NULL };
> -	int i, positive = 0, negative = 0;
> +	int i;
>  	struct rev_info revs;
> +	unsigned npmask = 0;
>
>  	init_revisions(&revs, NULL);
> -	if (setup_revisions(3, argv, &revs, 0) == 1)
> -		for (i = 0; i < revs.pending.nr; i++) {
> -			struct object *obj = revs.pending.objects[i].item;
> +	if (setup_revisions(3, argv, &revs, NULL) != 1)
> +		goto cleanup;
>
> -			if (obj->flags & UNINTERESTING)
> -				negative++;
> -			else
> -				positive++;
> -			if (obj->type == OBJ_COMMIT)
> -				clear_commit_marks((struct commit *)obj,
> -						   ALL_REV_FLAGS);
> -		}
> +	for (i = 0; i < revs.pending.nr && npmask != 3; i++) {
> +		struct object *obj = revs.pending.objects[i].item;
> +
> +		npmask |= (obj->flags & UNINTERESTING) ? 01 : 02;
> +	}
> +
> +	for (i = 0; i < revs.pending.nr; i++) {
> +		struct object *obj = revs.pending.objects[i].item;
> +		if (obj->type == OBJ_COMMIT)
> +			clear_commit_marks((struct commit *)obj, ALL_REV_FLAGS);
> +	}
>
> +cleanup:
>  	free(copy);
>  	object_array_clear(&revs.pending);
> -	return negative > 0 && positive > 0;
> +	return npmask == 3;
>  }
> diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh
> index 45f21ee215..2b518378d4 100755
> --- a/t/t3206-range-diff.sh
> +++ b/t/t3206-range-diff.sh
> @@ -160,7 +160,7 @@ test_expect_success 'A^! and A^-<n> (unmodified)' '
>
>  test_expect_success 'A^{/..} is not mistaken for a range' '
>  	test_must_fail git range-diff topic^.. topic^{/..} 2>error &&
> -	test_i18ngrep "not a commit rang" error
> +	test_i18ngrep "not a commit range" error
>  '
>
>  test_expect_success 'trivial reordering' '
> --
> 2.30.0-601-g9b6178ed87
>
>

  reply	other threads:[~2021-02-05 22:31 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-21 22:20 [PATCH 0/3] Range diff with ranges lacking dotdot Johannes Schindelin via GitGitGadget
2021-01-21 22:20 ` [PATCH 1/3] range-diff: refactor check for commit range Johannes Schindelin via GitGitGadget
2021-01-21 23:27   ` Junio C Hamano
2021-01-22 19:12   ` Phillip Wood
2021-01-22 21:59     ` Junio C Hamano
2021-01-23 15:59       ` Phillip Wood
2021-01-26 15:19         ` Johannes Schindelin
2021-01-21 22:20 ` [PATCH 2/3] range-diff: handle commit ranges other than A..B Johannes Schindelin via GitGitGadget
2021-01-21 23:37   ` Eric Sunshine
2021-01-22 16:12     ` Johannes Schindelin
2021-01-21 23:42   ` Junio C Hamano
2021-01-22 16:20     ` Johannes Schindelin
2021-01-21 22:20 ` [PATCH 3/3] range-diff(docs): explain how to specify commit ranges Johannes Schindelin via GitGitGadget
2021-01-21 23:46   ` Junio C Hamano
2021-01-22 16:21     ` Johannes Schindelin
2021-01-22 18:21       ` Junio C Hamano
2021-01-27  3:01         ` Johannes Schindelin
2021-01-28  5:43           ` Junio C Hamano
2021-01-22 18:20   ` Uwe Kleine-König
2021-01-26 15:22     ` Johannes Schindelin
2021-01-22  7:31 ` [PATCH 0/3] Range diff with ranges lacking dotdot Uwe Kleine-König
2021-01-22 18:16 ` [PATCH v2 " Johannes Schindelin via GitGitGadget
2021-01-22 18:16   ` [PATCH v2 1/3] range-diff/format-patch: refactor check for commit range Johannes Schindelin via GitGitGadget
2021-01-22 20:27     ` Junio C Hamano
2021-01-25  7:35       ` Uwe Kleine-König
2021-01-25 19:24         ` Junio C Hamano
2021-01-25 21:25           ` Uwe Kleine-König
2021-01-26 19:25             ` Junio C Hamano
2021-01-22 18:16   ` [PATCH v2 2/3] range-diff/format-patch: handle commit ranges other than A..B Johannes Schindelin via GitGitGadget
2021-01-22 20:32     ` Junio C Hamano
2021-01-27  2:57       ` Johannes Schindelin
2021-01-28  5:57         ` Junio C Hamano
2021-01-28 15:38           ` Johannes Schindelin
     [not found]             ` <xmqqim7gx41d.fsf@gitster.c.googlers.com>
2021-02-06  0:39               ` Johannes Schindelin
2021-01-22 18:16   ` [PATCH v2 3/3] range-diff(docs): explain how to specify commit ranges Johannes Schindelin via GitGitGadget
2021-01-27 16:37   ` [PATCH v3 0/3] Range diff with ranges lacking dotdot Johannes Schindelin via GitGitGadget
2021-01-27 16:37     ` [PATCH v3 1/3] range-diff/format-patch: refactor check for commit range Johannes Schindelin via GitGitGadget
2021-01-27 16:37     ` [PATCH v3 2/3] range-diff/format-patch: handle commit ranges other than A..B Johannes Schindelin via GitGitGadget
2021-01-27 16:37     ` [PATCH v3 3/3] range-diff(docs): explain how to specify commit ranges Johannes Schindelin via GitGitGadget
2021-02-04  9:31     ` [PATCH v4 0/3] Range diff with ranges lacking dotdot Johannes Schindelin via GitGitGadget
2021-02-04  9:31       ` [PATCH v4 1/3] range-diff/format-patch: refactor check for commit range Johannes Schindelin via GitGitGadget
2021-02-04 18:56         ` Junio C Hamano
2021-02-04 19:27           ` Johannes Schindelin
2021-02-04  9:31       ` [PATCH v4 2/3] range-diff/format-patch: handle commit ranges other than A..B Johannes Schindelin via GitGitGadget
2021-02-04 18:51         ` Junio C Hamano
2021-02-04 21:42           ` Johannes Schindelin
2021-02-04 18:58         ` Junio C Hamano
2021-02-04 21:57           ` Johannes Schindelin
2021-02-04  9:31       ` [PATCH v4 3/3] range-diff(docs): explain how to specify commit ranges Johannes Schindelin via GitGitGadget
2021-02-04 18:53         ` Junio C Hamano
2021-02-04 21:58           ` Johannes Schindelin
2021-02-04 22:42             ` Junio C Hamano
2021-02-04 23:29       ` [PATCH v5 0/3] Range diff with ranges lacking dotdot Johannes Schindelin via GitGitGadget
2021-02-04 23:29         ` [PATCH v5 1/3] range-diff/format-patch: refactor check for commit range Johannes Schindelin via GitGitGadget
2021-02-04 23:29         ` [PATCH v5 2/3] range-diff/format-patch: handle commit ranges other than A..B Johannes Schindelin via GitGitGadget
2021-02-05  1:07           ` Junio C Hamano
2021-02-05  1:32             ` Junio C Hamano
2021-02-05 14:09               ` Johannes Schindelin [this message]
2021-02-04 23:29         ` [PATCH v5 3/3] range-diff(docs): explain how to specify commit ranges Johannes Schindelin via GitGitGadget
2021-02-05 14:44         ` [PATCH v6 0/3] Range diff with ranges lacking dotdot Johannes Schindelin via GitGitGadget
2021-02-05 14:44           ` [PATCH v6 1/3] range-diff/format-patch: refactor check for commit range Johannes Schindelin via GitGitGadget
2021-02-05 14:44           ` [PATCH v6 2/3] range-diff/format-patch: handle commit ranges other than A..B Johannes Schindelin via GitGitGadget
2021-02-05 14:44           ` [PATCH v6 3/3] range-diff(docs): explain how to specify commit ranges 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

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

  git send-email \
    --in-reply-to=nycvar.QRO.7.76.6.2102051504080.54@tvgsbejvaqbjf.bet \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=sunshine@sunshineco.com \
    --cc=u.kleine-koenig@pengutronix.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).