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

Re: [PATCH v2] load_ref_decorations(): fix decoration with tags

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Jul 14, 2021, 08:13 UTC
Message-ID
<CAN0heSp1eJmeMTq-ECMUVh=hBPRTEkQeU0-3YXvtaDdZtU1sSA@mail.gmail.com>
In-Reply-To
<YO4SEp/B4826sc+j@coredump.intra.peff.net>
On Wed, 14 Jul 2021 at 00:22, Jeff King <peff@peff.net> wrote:
Show 27 quoted lines
>
> On Tue, Jul 13, 2021 at 11:52:53PM +0200, Martin Ågren wrote:
>
> > > Totally forgot about that one; thanks.
> >
> > Do you have any suggestions for how this could be explained better? I
> > waffled on whether to add that paragraph to the commit message and when
> > I finally did, it seems it got a little bit too succinct.
> >
> > I'm about to check out for today. Maybe in the morning I can think of
> > some clarification.
>
> My attempt is below. Most of the new explanation is near the end, but I
> tweaked a few other things.
>
> Your original said:
>
>   The reason this happens is in the loop where we try to peel the tags,
>   we won't necessarily have parsed that first object. If we haven't, its
>   `tag` will be NULL, so nothing will be displayed, and its `tagged`
>   will also be NULL, so we won't peel any further.
>
> and my earlier explanations were not thinking of the "tag" field at all,
> which made me worried there was another subtle bug in not parsing the
> tag earlier. But I don't think so. We don't look at the "tag" field for
> setting the annotation; it always comes from the refname. So the
> paragraph above should not mention "tag" at all.

Thanks for correcting that. The parsed-ness of "obj" affects whether the decoration is shown at all. I originally concluded that when the decorations are eventually displayed, it was something like "if ->tag is non-NULL, display it". But that's obviously not the case. It's more like "->tagged is NULL, so I have no idea where to place this decoration".

Show 6 quoted lines
> I also beefed up the test a bit. All this talk of parsing made me want
> to make sure we were covering tags-of-tags correctly (which I think we
> are both before and after the patch). After adding that, the expected
> decoration output was getting quite cluttered. So I tweaked the test to
> make a new commit, give the tags sensible names, and just look at that
> one commit.
> From: Martin Ågren <martin.agren@gmail.com>

At this point, I think it's fair to say that you've done most of the authoring here. I wouldn't be at all offended if you took the credit for this patch. It's your code diff, it's your test, and now it's even your *updated* test, plus half the commit message. :)

Here's that added half of the message:
Show 22 quoted lines
> The simplest way to do this is to just conditionally parse before the
> loop:
>
>   if (obj->type == OBJ_TAG)
>           parse_object(&obj->oid);
>
> But we can observe that our tag-peeling loop needs to peel already, to
> examine recursive tags-of-tags. So instead of introducing a new call to
> parse_object(), we can simply move the parsing higher in the loop:
> instead of parsing the new object before we loop, parse each tag object
> before we look at its "tagged" field.
>
> This has another beneficial side effect: if a tag points at a commit (or
> other non-tag type), we do not bother to parse the commit at all now.
> And we know it is a commit without calling oid_object_info(), because
> parsing the surrounding tag object will have created the correct in-core
> object based on the "type" field of the tag.
>
> Our test coverage for --decorate was obviously not good, since we missed
> this quite-basic regression. The new tests covers an annotated tag
> (showing the fix), but also that we correctly show annotations for
> lightweight tags and double-annotated tag-of-tags.
Very well described.
> Helped-by: Jeff King <peff@peff.net>
> Signed-off-by: Martin Ågren <martin.agren@gmail.com>
> Signed-off-by: Jeff King <peff@peff.net>
If you take authorship of this, I think this could be something like
Reported-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Martin Ågren <martin.agren@gmail.com>
Martin
Previous: Jeff KingNext: Jeff King
Message 11 of 12 in “load_ref_decorations(): fix decoration with tags”
  1. load_ref_decorations(): fix decoration with tagsMartin Ågren, Jul 12, 2021
  2. Jeff KingJul 13, 2021
  3. load_ref_decorations(): fix decoration with tagsMartin Ågren, Jul 13, 2021
  4. Jeff KingJul 13, 2021
  5. Martin ÅgrenJul 13, 2021
  6. Junio C HamanoJul 13, 2021
  7. Jeff KingJul 13, 2021
  8. Junio C HamanoJul 13, 2021
  9. Martin ÅgrenJul 13, 2021
  10. Jeff KingJul 13, 2021
  11. Martin ÅgrenJul 14, 2021
  12. load_ref_decorations(): fix decoration with tagsJeff King, Jul 14, 2021

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.