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
Matheus Tavares <matheus.bernardino@usp.br>
Date
Feb 21, 2020, 01:33 UTC
Message-ID
<20200221013357.26795-1-matheus.bernardino@usp.br>
In-Reply-To
<xmqqftf49862.fsf@gitster-ct.c.googlers.com>
On Thu, Feb 20, 2020 at 7:59 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
>
> Matheus Tavares Bernardino <matheus.bernardino@usp.br> writes:
>
> > I now this is just an illustration, but shouldn't this example be "git
> > describe --contains v1.0-bob~1"?
>
> No, none of the patches discussed in this thread would not affect
> anything in --contains (as it is a completely different program).
Ok, thanks for the clarification.
Show 5 quoted lines
> > Another case that came to my mind is when the user runs `git describe
> > --abrev=0 HEAD` and v1.0-bob points to HEAD~. In this case, v1.0 will
> > be displayed without suffix,...
>
> In this case, v1.0-1- is followed by the full object name, I think.

I might be doing something wrong, but this is how I tried to test this: First I set the desired scenario with:

$ git tag -am "" v1.0 HEAD~ $ mv .git/refs/tags/v1.0 .git/refs/tags/v1.0-bob

Then, running git-describe on v1.0-bob^0 I got what we want, which is the forced long output (even with --abbrev=0):

$ git describe --abbrev=0 HEAD~ warning: tag 'v1.0-bob' is externally known as 'v1.0' v1.0-0-g310a1f27be54ecf16fd36ff987304c1a2f8524b5

But running on the commit after v1.0-bob^0, I got:

$ git describe --abbrev=0 HEAD warning: tag 'v1.0-bob' is externally known as 'v1.0' v1.0

Then we cannot directly use the output. I think we can fix this forcing the long output for this case as well, which can be done with:

diff --git a/builtin/describe.c b/builtin/describe.c
index 5e8484f654..f71bddff4a 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -452,7 +452,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
 	}
 
 	append_name(all_matches[0].name, dst);
-	if (abbrev)
+	if (all_matches[0].name->misnamed || abbrev)
 		append_suffix(all_matches[0].depth, &cmit->object.oid, dst);
 	if (suffix)
 		strbuf_addstr(dst, suffix);
Previous: Junio C HamanoNext: Junio C Hamano
Message 19 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.