git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/3] --end-of-options marker

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 6, 2019, 16:24 UTC
Message-ID
<xmqqa7cml0s9.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20190806143829.GA515@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 8 quoted lines
> It's hard for scripted uses of rev-list, etc, to avoid option injection
> from untrusted arguments, because revision arguments must come before
> any "--" separator. I.e.:
>
>   git rev-list "$revision" -- "$path"
>
> might mistake "$revision" for an option (with rev-list, that would make
> it an error, but something like git-log would default to HEAD).

Just to make sure I understand what I just read, let me paraphrase. We would want to accept

	git rev-list --max-parents=4 \
		--end-of-options \
		--count -- docs/

so that '--count' would go thru the usual "as we have -- later, it must be a rev and we do not even disambiguate. What does get_sha1() say it is?" and "docs/" would be taken as a pathspec.

"git rev-list --max-parents=4 --count -- docs/" would have treated "--count" as an option and would error out due to lack of any starting revision.

On the other hand, "git log --count -- docs/" would take "--count" as an option, but does not complain about lack of any revs. It just starts digging from HEAD and ends up ignoring the "--count" branch (or is this feature meant to support tags? As far as I recall, we do not allow branch names that begin with a dash).

Show 14 quoted lines
> This series provides an alternative to "--" to stop option parsing
> without indicating that further arguments are pathspecs.
>
>   [1/3]: revision: allow --end-of-options to end option parsing
>   [2/3]: parse-options: allow --end-of-options as a synonym for "--"
>   [3/3]: gitcli: document --end-of-options
>
>  Documentation/gitcli.txt | 6 ++++++
>  parse-options.c          | 3 ++-
>  revision.c               | 8 +++++++-
>  t/t0040-parse-options.sh | 7 +++++++
>  t/t4202-log.sh           | 7 +++++++
>  t/t6000-rev-list-misc.sh | 8 ++++++++
>  6 files changed, 37 insertions(+), 2 deletions(-)
Previous: Jeff KingNext: Randall S. Becker
Message 5 of 16 in “--end-of-options marker”
  1. 0/3 --end-of-options markerJeff King, Aug 6, 2019
  2. 1/3 revision: allow --end-of-options to end option parsingJeff King, Aug 6, 2019
  3. 2/3 parse-options: allow --end-of-options as a synonym for "--"Jeff King, Aug 6, 2019
  4. 3/3 gitcli: document --end-of-optionsJeff King, Aug 6, 2019
  5. Junio C HamanoAug 6, 2019
  6. Randall S. BeckerAug 6, 2019
  7. Jeff KingAug 6, 2019
  8. Randall S. BeckerAug 6, 2019
  9. SZEDER GáborAug 6, 2019
  10. Jeff KingAug 8, 2019
  11. Jeff KingAug 6, 2019
  12. brian m. carlsonAug 6, 2019
  13. Jeff KingAug 6, 2019
  14. brian m. carlsonAug 7, 2019
  15. Taylor BlauAug 7, 2019
  16. Jeff KingAug 8, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.