Subject: Re: [PATCH 6/6] revision: add parents after child for ^!

From: Junio C Hamano <[email-masked]>
Date: Thu, 15 Sep 2022 10:53:37 -0700

René Scharfe <[email-masked]> writes:

> gitrevisions(7) says: "A suffix '^' followed by an exclamation mark is
> the same as giving commit '<rev>' and then all its parents prefixed with
> '^' to exclude them (and their ancestors)."

I did not mean to specify the order at all in that description when
I wrote ca5ee2d1 (Enumerate revision range specifiers in the
documentation, 2012-07-24) and I do not think it should be read as
such.

> handle_revision_arg_1() however adds the negated parents first.

I suspect that this was deliberately done so to match how A..B is
added to the pending commit list in revisions.c::handle_dotdot_1()
to tolerate "git diff A..B" as a synonym to "git diff A B", which
dates back to cd2bdc53 (Common option parsing for "git log --diff"
and friends, 2006-04-14).

> Split up the handling of ^! by moving the actual addition of the
> parents after the addition of the child.

I do not offhand think of anything other than the "diff" frontend
that cares about the order of these commits from the command line, I
am afraid that this might end up robbing Peter to pay paul.  

Can't we "fix" it at the consumer end, perhaps by checking where
these commits came from by looking at rev.cmdline?