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.

--
Best regards,
 Vladimir

Reply via email to