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

Re: [PATCH] show-ref: Allow --head to work with --verify

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 20, 2017, 22:22 UTC
Message-ID
<xmqqefzxwew9.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1bf9a446-0b00-f27a-4625-0bc8c25356fe@gmail.com>
Vladimir Panteleev <thecybershadow@gmail.com> writes:
Show 38 quoted lines
> Hi Junio,
>
> On 2017-01-20 19:03, Junio C Hamano wrote:
>> Having said all that, using --verify on HEAD does not make much
>> sense, because if HEAD is missing in .git/, I do not think Git
>> considers that directory as a Git repository to begin with.  So from
>> that point of view, I am not sure what value this change adds to the
>> system, even though the change is almost correct (modulo the "quiet"
>> thing).
>
> My use case was the following series of steps:
>
> Q1: How do I resolve a full ref name to a commit SHA1?
> A1: Use show-ref <full-ref-name>.
>
> Q2: How to make git show-ref also work when HEAD is specified as the
> reference?
> A2: Add --head.
>
> Q3: How do I make git show-ref only look for the exact full ref name
> specified, instead of doing a pattern/substring search, and thus
> output at most one result?
> A3: Add --verify.
>
> However, A2 and A3 are incompatible. Thus, there doesn't seem to be a
> way to e.g. make a simple alias which looks up a ref only by its full
> ref name, where said ref might or might not be HEAD. The obvious
> workaround is to check if the ref is HEAD in the rev-parse caller,
> however it seemed more logical to fix it in git instead.
>
> The documentation for show-ref also makes no mention that --head is
> ignored if --verify is specified, and the combination was not covered
> by any tests, therefore this seemed to me as a simple omission in
> --verify's logic.
>
> There is also rev-parse, which also has a --verify switch, however it
> does something else, and I don't see a way to ask rev-parse to only
> consider full refs.

Your log message for the patch needs to be updated by summarizing the above better. I couldn't read the motivation behind the change fully from the original (even though I guessed it correctly).

Previous: Vladimir PanteleevNext: Junio C Hamano
Message 5 of 11 in “show-ref: Allow --head to work with --verify”
  1. show-ref: Allow --head to work with --verifyVladimir Panteleev, Jan 20, 2017
  2. Junio C HamanoJan 20, 2017
  3. Vladimir PanteleevJan 20, 2017
  4. Vladimir PanteleevJan 20, 2017
  5. Junio C HamanoJan 20, 2017
  6. Junio C HamanoJan 20, 2017
  7. Junio C HamanoJan 20, 2017
  8. Vladimir PanteleevJan 20, 2017
  9. Junio C HamanoJan 20, 2017
  10. Junio C HamanoJan 20, 2017
  11. Vladimir PanteleevJan 21, 2017

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.