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

Re: [PATCH v3 3/4] name-rev: provide debug output

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 31, 2017, 19:10 UTC
Message-ID
<xmqqshltxnwt.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<14D0E7F4-0DC7-42ED-8DEE-B0338ECBA80D@grubix.eu>
Michael J Gruber <git@grubix.eu> writes:
Show 10 quoted lines
>>What problem are you solving?  
>
> Sorry, I forgot about that change and failed to mention it.
>
> It makes no difference in the non-debug case which cares about the
> Boolean only. In the debug case, I want to distinguish between
> annotated and lightweight tags, just like describe --debug
> does. By adding 1 via deref and passing this down, I know that an
> annotated tag gets the value 2, a lightweight tag 1 and everything
> else 0, just like describe --tags.

If you want to only affect debug display, perhaps you should start with a patch like the attached, before adding any debug code as a preparatory step. Then add your debugging thing, _WITHOUT_ the increment in name_rev(), that uses from_tag to choose between lightweight and annotated as a separate step.

When we decide that it would make sense to give precedence to annotated ones over lightweight ones in is_better_name(), the comparison can be further tweaked to actually compare values of the from_tag thing in *name and the current candidate. That would have to be a separate step, as it changes the semantics (I suspect it would be a better change but it may not be).

How does that sound?
-- >8 --
Subject: name-rev: allow to tell annotated and lightweight tags apart

We do not use this feature yet, but from_tag that is passed around and kept in the rev_name structure now takes three values, instead of a boolean "did this come from refs/tags/ hierarchy?". A new value '2' is "this is an annotated tag that came from refs/tags/ hierarchy".

---
 builtin/name-rev.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index bf7ed015ae..fe2d306e7c 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -41,7 +41,7 @@ static int is_better_name(struct rev_name *name,
 	 * We know that at least one of them is a non-tag at this point.
 	 * favor a tag over a non-tag.
 	 */
-	if (name->from_tag != from_tag)
+	if (!!name->from_tag != !!from_tag)
 		return from_tag;
 
 	/*
@@ -247,8 +247,11 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo
 	}
 	if (o && o->type == OBJ_COMMIT) {
 		struct commit *commit = (struct commit *)o;
-		int from_tag = starts_with(path, "refs/tags/");
-
+		int from_tag;
+		if (starts_with(path, "refs/tags/"))
+			from_tag = 1 + deref;
+		else
+			from_tag = 0;
 		if (taggerdate == ULONG_MAX)
 			taggerdate = ((struct commit *)o)->date;
 		path = name_ref_abbrev(path, can_abbreviate_output);
Previous: Junio C HamanoNext: Michael J Gruber
Message 29 of 46 in “describe --contains sanity”
  1. 0/3 describe --contains sanityMichael J Gruber, Mar 15, 2017
  2. 3/3 name-rev: Allow lightweight tags and branch refsMichael J Gruber, Mar 15, 2017
  3. Junio C HamanoMar 15, 2017
  4. Junio C HamanoMar 15, 2017
  5. Junio C HamanoMar 15, 2017
  6. 0/2 Teach name-rev to pay more attention to lightweight tagsJunio C Hamano, Mar 15, 2017
  7. 2/2 name-rev: favor describing with tags and use committer date to tiebreakJunio C Hamano, Mar 15, 2017
  8. Lars SchneiderMar 17, 2017
  9. Junio C HamanoMar 17, 2017
  10. Junio C HamanoMar 17, 2017
  11. Lars SchneiderMar 17, 2017
  12. Junio C HamanoMar 17, 2017
  13. Junio C HamanoMar 17, 2017
  14. 2/3 name-rev: favor describing with tags and use committer date to tiebreakMichael J Gruber, Mar 29, 2017
  15. 0/3 name-rev sanityMichael J Gruber, Mar 29, 2017
  16. Junio C HamanoMar 29, 2017
  17. Junio C HamanoMar 29, 2017
  18. Michael J GruberMar 30, 2017
  19. Junio C HamanoMar 30, 2017
  20. 3/4 name-rev: provide debug outputMichael J Gruber, Mar 31, 2017
  21. Junio C HamanoMar 31, 2017
  22. Junio C HamanoMar 31, 2017
  23. Michael J GruberMar 31, 2017
  24. Junio C HamanoMar 31, 2017
  25. Junio C HamanoMar 31, 2017
  26. Michael J GruberApr 3, 2017
  27. Junio C HamanoApr 3, 2017
  28. Junio C HamanoMay 20, 2017
  29. Junio C HamanoMar 31, 2017
  30. 4/4 describe: pass --debug down to name-revMichael J Gruber, Mar 31, 2017
  31. 0/4 name-rev sanityMichael J Gruber, Mar 31, 2017
  32. 1/4 name-rev: refactor logic to see if a new candidate is a better nameMichael J Gruber, Mar 31, 2017
  33. 2/4 name-rev: favor describing with tags and use committer date to tiebreakMichael J Gruber, Mar 31, 2017
  34. 1/3 name-rev: refactor logic to see if a new candidate is a better nameMichael J Gruber, Mar 29, 2017
  35. 3/3 name-rev: provide debug outputMichael J Gruber, Mar 29, 2017
  36. Michael J GruberMar 17, 2017
  37. Junio C HamanoMar 17, 2017
  38. 1/2 name-rev: refactor logic to see if a new candidate is a better nameJunio C Hamano, Mar 15, 2017
  39. Stefan BellerMar 16, 2017
  40. Jacob KellerMar 16, 2017
  41. 1/3 describe: debug is incompatible with containsMichael J Gruber, Mar 15, 2017
  42. Junio C HamanoMar 15, 2017
  43. Michael J GruberMar 17, 2017
  44. 2/3 git-prompt: add a describe style for any tagsMichael J Gruber, Mar 15, 2017
  45. Junio C HamanoMar 15, 2017
  46. Michael J GruberMar 17, 2017

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.