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

Re: [PATCH 4/4] describe/name-rev: tell name-rev to peel the incoming object to commit first

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 9, 2013, 11:45 UTC
Message-ID
<7vr4f8vtwc.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130709053533.GA4395@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> Although I am still not clear on why it would not be up to the caller of
> git-describe in the first place to decide which they wanted.
Thanks for a dose of sanity.

Even though the part of the miniseries that makes sure that "X (Y)" output from "name-rev" always satisfies that "rev-parse" on X and Y give the same thing is an improvement, the whole thing about "describe" is misguided and wrong, I think.

It started from the observation that these do not match:
    $ git describe $(git rev-parse v1.8.3)
    v1.8.3
    $ git describe --contains $(git rev-parse v1.8.3)
    v1.8.3^0

and the miniseries veered in a wrong direction of "fixing" the latter to match the former.

But the thing is, what is incosistent from the rest of the world is the describe output without "--contains" for a commit that is exactly at a tag (i.e. the former), and there is no need to "fix" this "inconsistency", as we see below.

The form without "--contains" in general reads like this:
    $ git describe --long $(git rev-parse v1.8.3) a717d9e
    v1.8.3-0-gedca415
    v1.8.3-2-ga717d9e

They both name a commit object, but that is sort of an afterthought; the support for describe name came late at 7dd45e15 (sha1_name.c: understand "describe" output as a valid object name, 2006-09-20).

The primary purpose of "git describe" without "--contains" is to give a string that is suitable for a version number to be embedded in an executable. For that purpose, "v1.8.3" is more convenient than "v1.8.3-0-gedca415".

But this convenient format breaks the consistency. While any other describe name for a commmit names a commit, the output for a commit that is exactly at a tag does not (in ancient times, describe output were not even extended SHA-1 expressions, so this inconsistency did not matter, but the "afterthought" brought the consistency to the foreground). The user chooses the convenience over the consistency by not using "--long".

And the short form cannot be "v1.8.3^0" or "v1.8.3~0" for the sake of "consistency", as these are no more suitable as a version number than a short and sweet "v1.8.3".

The "--contains" form does not even aim to come up with a pleasant looking version string without using funny line noise characters, so it is perfectly fine for it to say:

    $ git describe --contains $(git rev-parse v1.8.3) a717d9e
    v1.8.3^0
    v1.8.3.1~9

and these are internally consistent (they both roundtrip via rev-parse). Stripping "^0" from the former will break the consistency, even though it may make the output look prettier, but the "--contains" output is not even meant to be "pretty" in the first place.

So let's drop 4/4; it is breaking the system by trying to solve a problem that does not exist.

Previous: Jeff KingNext: Ramkumar Ramachandra
Message 19 of 20 in “Make "git name-rev $(git rev-parse v1.8.3)" work”
  1. 0/4 Make "git name-rev $(git rev-parse v1.8.3)" workJunio C Hamano, Jul 7, 2013
  2. 1/4 name-ref: factor out name shortening logic from name_ref()Junio C Hamano, Jul 7, 2013
  3. Michael HaggertyJul 8, 2013
  4. Junio C HamanoJul 8, 2013
  5. 2/4 name-rev: allow converting the exact object name at the tip of a refJunio C Hamano, Jul 7, 2013
  6. Ramkumar RamachandraJul 8, 2013
  7. Junio C HamanoJul 8, 2013
  8. 3/4 describe: use argv-arrayJunio C Hamano, Jul 7, 2013
  9. Jeff KingJul 9, 2013
  10. Junio C HamanoJul 9, 2013
  11. Junio C HamanoJul 9, 2013
  12. Jeff KingJul 9, 2013
  13. 4/4 describe/name-rev: tell name-rev to peel the incoming object to commit firstJunio C Hamano, Jul 7, 2013
  14. Ramkumar RamachandraJul 8, 2013
  15. Jeff KingJul 9, 2013
  16. Jeff KingJul 9, 2013
  17. Junio C HamanoJul 9, 2013
  18. Jeff KingJul 9, 2013
  19. Junio C HamanoJul 9, 2013
  20. Ramkumar RamachandraJul 9, 2013

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.