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

Re: Fully peel tags via for-each-ref?

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 22, 2019, 03:07 UTC
Message-ID
<xmqqmug1rj7y.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20190821230035.GA26107@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 14 quoted lines
> There's this gem in ref-filter.c, which blames back to your 9f613ddd21
> (Add git-for-each-ref: helper for language bindings, 2006-09-15):
>
>           /*
>            * NEEDSWORK: This derefs tag only once, which
>            * is good to deal with chains of trust, but
>            * is not consistent with what deref_tag() does
>            * which peels the onion to the core.
>            */
>           return get_object(ref, 1, &obj, &oi_deref, err);
>
> Which isn't to say it isn't useful to be able to do a single-layer peel,
> but I can't think of another part of the system which does so (unless
> you've asked to peel to a specific type, of course).

Quite honestly, I think the "only once" behaviour outlived its usefulness, without other "features" that may help make it more useful. To help a script that wants to do "chains of trust", it may first appear to be useful to peel only one layer, revealing that the tagged object is another tag, and that was the thinking behind the NEEDSWORK comment.

But after we learn that a ref "refs/tags/foo" points at a tag object that points at another tag object, what can the script do? It cannot feed the other tag found that way back into --format=%(*<thing>) machinery of for-each-ref, as the command and its variants, the "--list" mode of "branch" and "tag" commands, only work on the object at the tip of refs. The script must manually peel the tag one layer at a time.

And that "manually" has to be really manual. No ^{<type>} suffix allows scripts to peel just one layer, so inside a loop, the script has to say "cat-file tag <object>" and parse the "object" header from the output.

The only thing that gets affected if we changed %(*<thing>) to fully peel tags is a tag that points at another tag, and the traditional behaviour to peel only one layer, while it _might_ have been done as a good first step to add more support for chain of trust, is not all that useful for such a tag, I am not sure if the current behaviour is defensible.

Previous: Jeff KingNext: Jeff King
Message 5 of 6 in “Fully peel tags via for-each-ref?”
  1. Bryan TurnerAug 19, 2019
  2. Junio C HamanoAug 20, 2019
  3. Bryan TurnerAug 20, 2019
  4. Jeff KingAug 21, 2019
  5. Junio C HamanoAug 22, 2019
  6. Jeff KingAug 22, 2019

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.