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

Re: [PATCH] describe: output tag's ref instead of embedded name

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 19, 2020, 11:14 UTC
Message-ID
<xmqqftf6hlrt.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20200219035650.GA84414@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> I think a left a few things unsaid in my "v1.0-bob" example. I was
> imagining that there are _two_ v1.0 tags floating around. One that you
> consider "wrong", tagged by Bob, and one you like. You keep the latter
> in refs/tags/v1.0.
Ahh, OK.  
To continue playing devil's advocate and to step back a bit,
 - The "git describe" command finds that the given commit is
   "closest" to that tag Bob called "v1.0".
 - But if it outputs "v1.0" like the current code does, it cannot be
   fed back to get_oid() to name the right object, if the given commit
   is "at" the tag (i.e. there is no "-$number-g$objectname" suffix),
   which is a problem.  We want "git describe" to give an output
   usable with get_oid() and the name must refer to the correct
   object (i.e. the one given to "git describe" as an input).

There are multiple approaches to make it possible to feed the output back to get_oid() to obtain correct result:

 - We can describe it based on "v1.0-bob" (i.e. refname, not
   tagname), which is what the proposed patch wants to do.  
   This is nice as it simply exploits the fact that namespace of the
   refs ensures that there can locally be only one tag "v1.0".
 - We can always add "-$number-g$objectname" suffix when we need to
   base the output of "git describe" on such a tag whose name does
   not match its refname.  Both names "v1.0-bob-0-g0123456" and
   "v1.0-0-g0123456" would be accepted by get_oid() and refer to the
   same object 0123456.  
   If we do this, there is no longer any requirement that the
   "tagname" part alone of the output must be usable with get_oid()
   to name the correct object, and because "v1.0-bob" is merely a
   local name external people may not even know about, using
   "v1.0-bob-0-g0123456" may be less desirable than using
   "v1.0-0-g0123456".
 - We can skip the "wrong" tag and not use it to name anything.
   "git describe" may use some other tag that is stored in its right
   place, which may be a bit more distant than tag "v1.0-bob".  The
   warning message may indicate "we would have used this tag to name
   the object because it was the closest, but we skipped because of
   a tagname anomaly".  
   This may be what the person who moved Bob's "v1.0" to "v1.0-bob"
   intended---it is a "wrong" tag that is kept only to communicate
   _about_ the tag, not to be used to refer to other objects
   relative to it.

The "use the refname" and the "use -0-gXXXXXX suffix if using a tag at a wrong place" approaches are simple and would produce a more "correct" result than what we currently give. The "don't use it" approach simply sidesteps the problem altogether, which is sort-of attractive ;-)

Previous: Jeff KingNext: Jeff King
Message 14 of 23 in “git-describe --tags warning: 'X' is really 'Y' here”
  1. Roland HieberFeb 5, 2020
  2. Matheus Tavares BernardinoFeb 5, 2020
  3. Jeff KingFeb 14, 2020
  4. Junio C HamanoFeb 14, 2020
  5. describe: output tag's ref instead of embedded nameMatheus Tavares, Feb 15, 2020
  6. Jeff KingFeb 16, 2020
  7. Junio C HamanoFeb 18, 2020
  8. Jeff KingFeb 18, 2020
  9. Junio C HamanoFeb 18, 2020
  10. Junio C HamanoFeb 18, 2020
  11. Jeff KingFeb 19, 2020
  12. Junio C HamanoFeb 19, 2020
  13. Jeff KingFeb 19, 2020
  14. Junio C HamanoFeb 19, 2020
  15. Jeff KingFeb 20, 2020
  16. Junio C HamanoFeb 20, 2020
  17. Matheus Tavares BernardinoFeb 20, 2020
  18. Junio C HamanoFeb 20, 2020
  19. Matheus TavaresFeb 21, 2020
  20. Junio C HamanoFeb 21, 2020
  21. Jeff KingFeb 21, 2020
  22. Jeff KingFeb 21, 2020
  23. Roland HieberFeb 19, 2020

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.