Subject: Re: [PATCH v3 03/16] builtin/update-ref: skip ambiguity checks when parsing object IDs

From: Patrick Steinhardt <[email-masked]>
Date: Thu, 27 Feb 2025 12:57:29 +0100

On Wed, Feb 26, 2025 at 02:26:59PM -0800, Junio C Hamano wrote:
> Patrick Steinhardt <[email-masked]> writes:
> 
> > Most of the commands in git-update-ref(1) accept an old and/or new
> > object ID to update a specific reference to. These object IDs get parsed
> > via `repo_get_oid()`, which not only handles plain object IDs, but also
> > those that have a suffix like "~" or "^2". More surprisingly though, it
> > even knows to resolve references, despite the fact that its manpage does
> > not mention this fact even once.
> 
> Are you referring to <new-oid> and other placeholders with "oid" in
> their names?  I do think "oid" in our documentation implies that
> only full hexadecimal object names are allowed.  The glossary agrees
> by saying that <object id> is a synonym for <object name> that is
> usually 40-hex SHA-1.  However, that is not strictly enforced and we
> say <object> (or its typed variants like <commit-ish>) even when a
> command takes any extended SHA-1 expression, as described in
> Documentation/revisions.{txt,adoc}, not limited to full hexadecimal
> object name.
> 
> So, I am somewhat sympathetic to your confusion, but not that much.
> When we wrote the command and documented it back in 2005, we did
> mean to take any object name that is spelled in any way, not just
> full hexadecimal.  You may want to update the manual to emphasize
> that we encourage the use of full hexadecimal for this command and
> elsewhere where it is more appropriate.

Yeah. I have been aware of the behaviour beforehand, but an unsuspecting
user that reads through the manpage wouldn't be able to figure out at
all that this is the case. I guess this is something we should improve,
but I think it's outside of the scope of this series. #leftoverbits

Patrick