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

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

From
Jeff King <peff@peff.net>
Date
Aug 22, 2019, 04:24 UTC
Message-ID
<20190822042445.GB4347@sigill.intra.peff.net>
In-Reply-To
<xmqqmug1rj7y.fsf@gitster-ct.c.googlers.com>
On Wed, Aug 21, 2019 at 08:07:29PM -0700, Junio C Hamano wrote:
Show 18 quoted lines
> 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.

Yeah, well said, and I think this is the heart of the matter. There isn't good tooling for this case, but even if there was, for-each-ref is definitely not the place for it.

I took a brief look at making a patch, and it's unfortunately non-trivial because of the way the deref logic in ref-filter is implemented. So it may not be worth digging too far into for now if nobody cares much either way.

I still have dreams of writing a more efficient and more reusable version of ref-filter, and it would probably make sense to use peel_ref() as part of that rewrite.

-Peff
Previous: Junio C Hamano
Message 6 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.