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

Re: RFC: what should git rev-parse --flags HEAD do?

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 25, 2010, 17:54 UTC
Message-ID
<7vfwwxogiv.fsf@alter.siamese.dyndns.org>
In-Reply-To
<AANLkTimEToibgpUS1KTSruFRdggi3kbAJU5tfk9r6d2U@mail.gmail.com>
Jon Seymour <jon.seymour@gmail.com> writes:
Show 10 quoted lines
> The documentation for git rev-parse --flags currently states:
>
>     Do not output non-flag parameters.
>
> Therefore, one might expect:
>   $ git rev-parse --flags HEAD
>
> to produce no output.
>
> In fact, it outputs the sha1 hash of HEAD.
Perhaps you are missing --no-revs.
Linus wrote rev-parse to implement this in a shell script:
    git log [other-options-and-args] [revision-traversal-options-and-args]
which needs to be transformed to:
    git rev-list [revision-traversal-options-and-args] |
    git diff-tree --stdin [other-options-and-args]

so that it can parse "-p HEAD" with and without "--no-revs" to produce "HEAD" and "-p" respectively. It does so by knowing options that are relevant to rev-list invocation (shown by default, or --revs-only) and everything else (hidden when --no-revs is given).

"--flags" is an afterthought that filters out non-flags in other parts; I do not think it applied to the "rev" part (i.e. giving --no-revs at the same time would be a valid workaround if you know you do not want HEAD or any revision traversal argument) in any released version of git.

Previous: Jon SeymourNext: Jon Seymour
Message 2 of 4 in “RFC: what should git rev-parse --flags HEAD do?”
  1. Jon SeymourSep 25, 2010
  2. Junio C HamanoSep 25, 2010
  3. Jon SeymourSep 25, 2010
  4. Jon SeymourSep 25, 2010

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.