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

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

From
Bryan Turner <bturner@atlassian.com>
Date
Aug 20, 2019, 21:39 UTC
Message-ID
<CAGyf7-F_89u-913P0znH_3NCzNZNarb3u_3Vpwt5-QMiFCK+Tg@mail.gmail.com>
In-Reply-To
<xmqq8srowfkv.fsf@gitster-ct.c.googlers.com>
On Mon, Aug 19, 2019 at 10:50 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
>
> Bryan Turner <bturner@atlassian.com> writes:
>
> > Is there any way, with "git for-each-ref", to output the "fully"
> > peeled SHA of a tag's ultimate target, regardless of how many layers
> > must be traversed?
>
>
> If %(*<stuff>) does not peel fully (I do not recall what I did
> offhand), because all other things in Git (like $X~0, $X^{tree},
> etc.) fully peel the outer object until they get to what they want,
> it may even be OK to declare it a bug and "fix" the notation to
> fully peel tags.  I dunno.
%(*<stuff>) definitely doesn't fully peel.

$ git for-each-ref --format="%(refname) %(objectname) -> %(*objectname) (%(*objecttype))" refs/tags/ refs/tags/backdated_annotated_tag 80aa5be5ecf39660f798858482254f7a2ae9110e -> 57150c54c38d6570b2fd5e6d6cfc19476de44e84 (commit) refs/tags/retagged_signed_tag 9b4e781dea0769888fe270e06ad76675f73851b1 -> 12ebe2a58367347cd39f19f5a72f3cbec7b8f9a9 (tag) refs/tags/signed_tag 12ebe2a58367347cd39f19f5a72f3cbec7b8f9a9 -> 0a943a29376f2336b78312d99e65da17048951db (commit)

"retagged_signed_tag" is tagging "signed_tag", and you can see that %(*objectname) for it is "signed_tag"'s hash and %(*objecttype) is tag.

$ git rev-parse retagged_signed_tag~0 0a943a29376f2336b78312d99e65da17048951db

I don't know that this use case is common enough for it to warrant "fixing". I'm not even sure most would call it a "bug"; I hadn't considered it that way, at least. I was just interested in whether there might be an out-of-the-box approach I wasn't aware of for getting fully peeled results.

Thanks for taking the time to answer, and to provide a bit of history!

Best regards, Bryan Turner

Previous: Junio C HamanoNext: Jeff King
Message 3 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.