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

Re: [PATCH] Add git-findtags

From
Junio C Hamano <junkio@cox.net>
Date
Oct 13, 2005, 05:18 UTC
Message-ID
<7vbr1u6lmf.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<46a038f90510122117mb466722n531dc66bac141ea1@mail.gmail.com>
Martin Langhoff <martin.langhoff@gmail.com> writes:
Show 6 quoted lines
> On 10/12/05, Junio C Hamano <junkio@cox.net> wrote:
>> Martin Langhoff <martin@catalyst.net.nz> writes:
>
> I'm preparing a better patch based on your comments, but File::Find is
> _not_ my friend, really. I really feel stupid after failing for 1hr to
> use it.
Something like this?
    use strict;
    use File::Find qw(find);
    my $git_dir = $ENV{GIT_DIR} || '.git';
    my @tagfiles = ();
    find({
        follow => 1,
        wanted => sub {
            if (-f _) {
                push @tagfiles, $File::Find::name;
            }
        } }, "$git_dir/refs/tags");
    for (@tagfiles) {
        print "$_\n";
    }
Show 5 quoted lines
>> BTW, wouldn't it be easier for this particular script, and more
>> useful in general, if something like what 'git-rev-parse' does
>> for commit objects when given "REV^0" is supported for tags?
>
> I don't quite follow...
What I meant is this.

There is an existing notation "^0" which is a postfix "dereference until you get a commit" operator.

	git-rev-parse --verify refs/tags/v0.99^0
	git-cat-file -t refs/tags/v0.99^0
does:
	1. reads SHA1 from "refs/tags/v0.99", finds the object;
        2. if it is a tag object, find the object pointed by it;
           if the result is still a tag object, then dereference
           it repeatedly;
        3. if the resulting object is a commit, let the caller
           to use it; otherwise barf.

What _might_ be useful for your application is a similar operator, say, "refs/tags/junio-gpg-pub%", that does:

	1. reads SHA1 from "refs/tags/junio-gpg-pub", finds the
           object;
        2. if it is a tag object, find the object pointed by it;
           if the result is still a tag object, then dereference
           it repeatedly;
	3. do not worry about the type of the result.  Just
           output it.

Instead of reserving yet another letter '%', it might be better to use something like "refs/tags/junio-gpg-pub^{tag}" as a notation for this. If you had something like this, you would not have to read tag objects yourself and dereference them by hand.

Previous: Junio C Hamano
Message 3 of 3 in “Add git-findtags”
  1. Add git-findtagsMartin Langhoff, Oct 12, 2005
  2. Junio C HamanoOct 12, 2005
  3. Junio C HamanoOct 13, 2005

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.