From: Junio C Hamano <junkio@cox.net>
To: Martin Langhoff <martin@catalyst.net.nz>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Add git-findtags
Date: Tue, 11 Oct 2005 22:19:38 -0700 [thread overview]
Message-ID: <7vek6rmhw5.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: 1129087169926-git-send-email-martin@catalyst.net.nz
Martin Langhoff <martin@catalyst.net.nz> writes:
> +my @tagfiles = `find $git_dir/refs/tags -follow -type f`; # haystack
Please do this with File::Find(), unless you have a compelling
reason not to. $git_dir could contain shell metacharacters
and/or whitespace.
> + # grab the first 2 lines (the whole tag could be large)
> + my $tagobj = `git-cat-file tag $tagid | head -n2 `;
Careful; $tagfile could be a lightweight tag, and you would want
to consider it a hit if ($tagid eq $target).
BTW, does `` in Perl behave well upon SIGPIPE (hehe, we now have
Merlyn on the list so I can ask these silly Perl questions ;-))?
> + if ($tagobj =~ m/^type commit$/m) { # only deal with commits
> +
> + if ($tagobj =~ m/^object $target$/m) { # match on the commit
> + print basename($tagfile) . "\n";
Please show "tags/bl/ah" when ".git/refs/tags/bl/ah" points at
the target, not just "ah". Alternatively, "bl/ah" may also be
acceptable, since this command is about tags.
> + } elsif ( $opt_t && # follow the commit
> + $tagobj =~ m/^object (\S+)$/m) { # and try to match trees
I am not sure how useful '-t' would be in practice. If it is, I
wonder if it would also be useful to look for a subtree match..
> +sub quickread {
> + my $file = shift;
> + local $/; undef $/; # slurp mode
Nit -- "local $/;" without "undef $/;" would do just fine.
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 am uncertain the about syntax/notation, but just like "^0" is
a postfix operator for "peel the onion repeatedly until you get
a commit, or barf if you ended up with a non-commit", maybe if
we had "peel the onion repeatedly until you get a non-tag"
operator, let's call it '%', then you could say something like
this:
# This is pseudo-code -- it does not handle tagname with
# embedded $IFS letter very well.
# list local refs
git-rev-parse --symbolic --all |
# limit only to tags
sed -ne '/^refs\/tags\/p' |
while read tagname
do
if test $(git-rev-parse --verify "${tagname}%") = "$target"
then
echo "$tagname"
fi
done
next prev parent reply other threads:[~2005-10-12 5:20 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 [this message]
[not found] ` <46a038f90510122117mb466722n531dc66bac141ea1@mail.gmail.com>
2005-10-13 5:18 ` Junio C Hamano
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=7vek6rmhw5.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=martin@catalyst.net.nz \
/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).