From: Jeff King <peff@peff.net> To: "brian m. carlson" <sandals@crustytoothpaste.net> Cc: git@vger.kernel.org Subject: Re: [PATCH 0/3] --end-of-options marker Date: Thu, 8 Aug 2019 06:28:57 -0400 Message-ID: <20190808102857.GD12257@sigill.intra.peff.net> (raw) In-Reply-To: <20190807041749.GI118825@genre.crustytoothpaste.net> On Wed, Aug 07, 2019 at 04:17:49AM +0000, brian m. carlson wrote: > > I think if we at least choose the left-most "--" as the official > > end-of-options then they can't inject an option (they can only inject a > > rev as a path). I guess that's the same as with --end-of-options. But it > > somehow feels less clear to me than a separate marker. > > I suppose if there's more than two, then interpret the first one as the > end-of-options marker, the second one in the traditional way, and any > subsequent ones as pathspecs matching the file "--". Writing such a > command line would be silly, but we'd fail secure. Yeah, I think that could work. I'd be a little concerned that the implementation would end up complicated and confusing, just because there are other parts of the code that treat "--" specially. That's not a necessarily a reason to avoid it if there's a compelling reason, but I think I favor a unique marker anyway (or at least am otherwise ambivalent). > That's a good point. I don't have a strong view either way, but I > thought I'd ask about alternatives. Discussion of alternatives is very welcome. I think the most compelling alternative is the one I pointed out in one of the commit messages: git rev-list --revision=<whatever> which lets normal left-to-right parsing work without any complex reasoning. It is harder to use with "$@", though. Related, my proposal doesn't do anything for rev-parse. I think that: git rev-parse --end-of-options -xyz should probably return: --end-of-options <oid of -xyz> but I mostly consider that kind of use of rev-parse (pretending to be an options parser for rev-list) to be vestigial. The main use of rev-parse (in my experience) is "rev-parse --verify" to resolve a single name. There are still some gaps there. For instance: git rev-parse --verify --foo will treat "--foo" as an option (and then complain that there was no rev argument). I don't think you can do anything too mischievous from this, but it might be nice to tighten it up. I'm tempted to say that "--verify" should complain if there isn't exactly one argument, but technically things like this do work: git rev-parse --verify --sq "$rev" git rev-parse --verify --symbolic-full-name "$rev" I don't know if anybody cares or not. We could perhaps work around it by having --verify treat the final argument as a non-option, even if it starts with "-". That would allow those cases, but: git rev-parse --verify --symbolic-full-name would treat the latter as an argument (and currently that's always an error anyway). Looking at rev-parse, there are other weird bits to --verify, too. E.g., this: git rev-parse --verify a...b c shows a...b, ignoring that --verify was given, and then eventually "c". -Peff
prev parent reply other threads:[~2019-08-08 10:28 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-08-06 14:38 Jeff King 2019-08-06 14:39 ` [PATCH 1/3] revision: allow --end-of-options to end option parsing Jeff King 2019-08-06 14:40 ` [PATCH 2/3] parse-options: allow --end-of-options as a synonym for "--" Jeff King 2019-08-06 14:40 ` [PATCH 3/3] gitcli: document --end-of-options Jeff King 2019-08-06 16:24 ` [PATCH 0/3] --end-of-options marker Junio C Hamano 2019-08-06 16:36 ` Randall S. Becker 2019-08-06 17:38 ` Jeff King 2019-08-06 17:58 ` Randall S. Becker 2019-08-06 18:14 ` SZEDER Gábor 2019-08-08 10:03 ` Jeff King 2019-08-06 17:33 ` Jeff King 2019-08-06 22:58 ` brian m. carlson 2019-08-06 23:43 ` Jeff King 2019-08-07 4:17 ` brian m. carlson 2019-08-07 16:54 ` Taylor Blau 2019-08-08 10:28 ` Jeff King [this message]
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=20190808102857.GD12257@sigill.intra.peff.net \ --to=peff@peff.net \ --cc=git@vger.kernel.org \ --cc=sandals@crustytoothpaste.net \ /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
git@vger.kernel.org list mirror (unofficial, one of many) This inbox may be cloned and mirrored by anyone: git clone --mirror https://public-inbox.org/git git clone --mirror http://ou63pmih66umazou.onion/git git clone --mirror http://czquwvybam4bgbro.onion/git git clone --mirror http://hjrcffqmbrq6wope.onion/git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V1 git git/ https://public-inbox.org/git \ git@vger.kernel.org public-inbox-index git Example config snippet for mirrors. Newsgroups are available over NNTP: nntp://news.public-inbox.org/inbox.comp.version-control.git nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git nntp://news.gmane.io/gmane.comp.version-control.git note: .onion URLs require Tor: https://www.torproject.org/ code repositories for the project(s) associated with this inbox: https://80x24.org/mirrors/git.git AGPL code for this site: git clone https://public-inbox.org/public-inbox.git