All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, Eric Sunshine <sunshine@sunshineco.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH v2 1/3] range-diff/format-patch: refactor check for commit range
Date: Mon, 25 Jan 2021 11:24:39 -0800	[thread overview]
Message-ID: <xmqqpn1syg3s.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20210125073508.l7ksohyfhcogch4x@pengutronix.de> ("Uwe =?utf-8?Q?Kleine-K=C3=B6nig=22's?= message of "Mon, 25 Jan 2021 08:35:08 +0100")

Uwe Kleine-König <u.kleine-koenig@pengutronix.de> writes:

>> > In preparation for allowing more sophisticated ways to specify commit
>> > ranges, let's refactor the check into its own function.
>> 
>> I think the sharing between the two makes sense, but the helper
>> function should make it clear in its name that this is "the kind of
>> commit range range-diff wants to take".  Among the commit range "git
>> log" and friends can take, range-diff can take only a subset of it,
>> and only a subset of it is meaningful to range-diff (e.g. HEAD^@ is
>> still a commit range you can give to "git log", but it would not
>> make much sense to give it to range-diff).
>
> Does it make so little sense to forbid passing HEAD^@ as a range to
> range-diff? I can imagine situations where is would make sense, e.g. I
> often create customer patch stacks from a set of topic branches using
> octopus merge. To compare two of these ^@ might be handy.

You can discuss for each individual syntax of a single-token range
and decide which ones are and are not suitable for range-diff, but I
suspect the reason behind this business started with dot-dot is to
perform a superficial "sanity check" at the command line parser
level before passing them to the revision machinery, and having to
deal with potential errors and/or having to compare unreasonably
large segments of history that the user did not intend.

Also I first thought that the command changes the behaviour, given
two tokens, depending on the shape of these two tokens (i.e. when
they satisfy the "is-range?" we are discussing, they are taken as
two ranges to be compared, and otherwise does something else), but
after revisiting the code and "git help range-diff", it always does
one thing when given 

 (1) one arg: gives a symmetric range and what is to be compared
     is its left and right half,

 (2) two args: each is meant to name a set of commits and these two
     are to be compared) or

 (3) three args: each is meant to name a commit, and the arg1..arg2
     and arg1..arg3 are the ranges to be compared.

so ...

> My POV is that if it's easy to use the same function (and so the same
> set of range descriptors) for git log and git range-diff then do so.
> This yields a consistent behaviour which is IMHO better than preventing
> people to do things that are considered strange today.

... I am OK with that point of view.  It certainly is simpler to
explain to end users.

Having said that, it would make it much harder to implement
efficiently, though.  For example, when your user says

	git range-diff A B

to compare "git log A" (all the way down to the root) and "git log
B" (likewise), you'd certainly optimize the older common part of the
history out, essentially turning it into

	git range-diff A..B B..A

or its moral equivalent

	git range-diff A...B

But you cannot apply such an optimization blindly.  When the user
gives A..B and B..A as two args, you somehow need to notice that 
you shouldn't rewrite it to "A..B...B..A", and for that, you'd still
need some "parsing" of these args.

So, I dunno.  Limiting the second form to only forms that the
implementation does not have to do such optimization would certainly
make it simpler for Dscho to implement ;-)

  reply	other threads:[~2021-01-26 20:46 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 [this message]
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
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=xmqqpn1syg3s.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johannes.schindelin@gmx.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.