git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jiang Xin <worldhello.net@gmail.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>,
	Jiang Xin <worldhello.net@gmail.com>,
	Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
	Git List <git@vger.kernel.org>,
	Jiang Xin <zhiyou.jx@alibaba-inc.com>
Subject: Re: [PATCH] revision: allow pseudo options after --end-of-options
Date: Fri, 9 Jul 2021 09:33:23 +0800	[thread overview]
Message-ID: <CANYiYbGYzbMoU_2wb4duppASoYUjGLsJsr692Xe3GaVBOXUsBA@mail.gmail.com> (raw)
In-Reply-To: <YOcvaFL7+6qcIOUa@camp.crustytoothpaste.net>

brian m. carlson <sandals@crustytoothpaste.net> 于2021年7月9日周五 上午1:02写道:
>
> On 2021-07-08 at 15:03:16, Jiang Xin wrote:
> > From: Jiang Xin <zhiyou.jx@alibaba-inc.com>
> >
> > Options and revisions can be seperated by the option "--end-of-options"
> > by introducing commit 19e8789b23 (revision: allow --end-of-options to
> > end option parsing, 2019-08-06).  The following command will show
> > revisions which have changes on file "bar" on a branch named "--foo":
> >
> >     git rev-list --oneline --end-of-options --foo -- bar
> >
> > If we want to see revisions between two revisions (rev1 and rev2), we
> > can use the following command:
> >
> >     git rev-list --oneline --end-of-options rev1..rev2 --
> >
> > We know that "rev1..rev2" is a shorthand for "rev2 --not rev1", but
> > we can not use the longer expression with option "--not" after the
> > "--end-of-options" option.  This is because the parser will not consume
> > revision pseudo options after seeing "--end-of-option".
> >
> > Allow parsing revision pseudo options after "--end-of-options", the
> > following command is valid:
> >
> >     git rev-list --oneline --end-of-options rev2 --not rev2 --
>
> I don't think we want to do this.  The goal of --end-of-options is to
> prevent parsing all future items as options, so if someone specifies a
> revision starting with a dash, we don't end up with it being interpreted
> as an option.

New test case in t6000 covered this case. Branch "--output=yikes"
which starts with a dash is used as revision after the option
"--end-of-options", and it won't be interpreted as an option.

    test_expect_success 'parse pseudo option "--not" after "--end-of-options"' '
        cat >expect <<-EOF &&
        > three
        EOF
        git log --pretty="%m %s" --end-of-options \
                HEAD --not --output=yikes -- \
                two/three >actual &&
        test_cmp expect actual
    '

But for the original implementation, because pseudo revision options
(--branches, --tags, --not, ..., etc) can not be used after the
"--end-of-options" option, we have to put "--end-of-options" at the
end of revisions, such as:

    git log --pretty="%m %s" rev1 --not rev2 rev3 rev4 \
            --end-of-options -- path/file

We can see from the above command, the option "--end-of-options" is
immediately followed by a dashdash. That is very strange.  DashDash is
designed to separate pathspecs from args, and "--end-of-options" is
designed to separate revisions from options. But because of the pseudo
revision options, "--end-of-options" is meaningless for commands
calling "setup_revisions()".

Yes, "--end-of-options" must be used if there is a revision which
starts with dash, such as branch "--output=yikes" in t6000. That's
even stranger, for we have to write  command in the middle of
revisions like this:

    git log --pretty="%m %s" rev1 --not rev2 rev3 \
            --end-of-options --output=yikes -- path/file

I know "rev1..rev2" and "rev2 ^rev1", but I prefer to use "rev1 --not
rev2 rev3" instead of "rev1 ^rev2 ^rev3".

  reply	other threads:[~2021-07-09  1:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08 15:03 [PATCH] revision: allow pseudo options after --end-of-options Jiang Xin
2021-07-08 17:01 ` brian m. carlson
2021-07-09  1:33   ` Jiang Xin [this message]
2021-07-10 21:54     ` brian m. carlson
2021-07-12 17:54       ` Jeff King
2021-07-12 18:47         ` Junio C Hamano
2021-07-12 19:47           ` Jeff King
2021-07-12 20:09             ` Junio C Hamano
2021-07-13  8:57         ` Jiang Xin
2021-07-13 21:13           ` Jeff King
2021-07-27  6:10             ` Patrick Steinhardt

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=CANYiYbGYzbMoU_2wb4duppASoYUjGLsJsr692Xe3GaVBOXUsBA@mail.gmail.com \
    --to=worldhello.net@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=sandals@crustytoothpaste.net \
    --cc=zhiyou.jx@alibaba-inc.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).