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

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

From
Vladimir Panteleev <thecybershadow@gmail.com>
Date
Jan 20, 2017, 20:26 UTC
Message-ID
<1bf9a446-0b00-f27a-4625-0bc8c25356fe@gmail.com>
In-Reply-To
<xmqqa8aly2o4.fsf@gitster.mtv.corp.google.com>
Hi Junio,
On 2017-01-20 19:03, Junio C Hamano wrote:
Show 6 quoted lines
> 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.

-- 
Best regards,
  Vladimir
Previous: Junio C HamanoNext: Vladimir Panteleev
Message 3 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.