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

Re: [PATCH] sha1_name: accept output of git-describe

From
Shawn Pearce <spearce@spearce.org>
Date
Sep 20, 2006, 21:34 UTC
Message-ID
<20060920213410.GC24415@spearce.org>
In-Reply-To
<7v64figrhu.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
Show 7 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > Now, 'git log $(git describe)' does the same as 'git log'.
> >
> > NOTE: it might be possible that the unique abbreviation generated by
> > git-describe is no longer unique at a later stage. Evidently, in this
> > case the sha1 resolution fails.
[snip]
> Shouldn't you also verify the leading ref (most likely a tag)
> exists (and optionally check that it precedes the commit you
> decoded into, but that is probably more expensive than it's
> worth)?

I thought the same thing when I first posted that it was probably an easy change to this code (and then didn't do it myself) and again when I read Johannes' implementation. Both times I agreed with you Junio that it was probably too expensive and not worth doing.

Most of the time we assume not only that the SHA1 itself is unique but also that it some hex character prefix is unique (such as 6 or 8 digits). One might be able to argue that if we have duplicate commits (when abbreviated) that you might be able to break the tie by looking at the tag but even then you may not always be able to do so.

So no, probably not worth it...
-- 
Shawn.
Previous: Johannes Schindelin
Message 4 of 4 in “sha1_name: accept output of git-describe”
  1. sha1_name: accept output of git-describeJohannes Schindelin, Sep 20, 2006
  2. Junio C HamanoSep 20, 2006
  3. Johannes SchindelinSep 20, 2006
  4. Shawn PearceSep 20, 2006

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.