git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Martin Langhoff <martin.langhoff@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Add git-findtags
Date: Wed, 12 Oct 2005 22:18:00 -0700	[thread overview]
Message-ID: <7vbr1u6lmf.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <46a038f90510122117mb466722n531dc66bac141ea1@mail.gmail.com> (Martin Langhoff's message of "Thu, 13 Oct 2005 17:17:23 +1300")

Martin Langhoff <martin.langhoff@gmail.com> writes:

> 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";
    }

>> 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.

      parent reply	other threads:[~2005-10-13  5:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-12  3:19 [PATCH] Add git-findtags Martin Langhoff
2005-10-12  5:19 ` Junio C Hamano
     [not found]   ` <46a038f90510122117mb466722n531dc66bac141ea1@mail.gmail.com>
2005-10-13  5:18     ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vbr1u6lmf.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=martin.langhoff@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).