Re: [PATCH 2/3] cvsimport: use show-ref to support packed refs
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 28, 2007, 22:23 UTC
- Message-ID
- <7v4pf63t7y.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <20071128194423.GB11396@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> Since get_headref is useful in contexts where "$remote" is not always > prepended (see patch 3/3), I think the best solution is:
...
> + if ($branch eq $opt_o && !$index{branch} &&
> + !get_headref("$remote/$branch")) {
> + my $parent = get_headref("$remote/$last_branch");
> + if (my $sha1 = get_headref("$remote/$mparent")) {So the definition of get_headref() is to always take everything under but not including "refs/"? IOW, the tip of the master branch is asked with get_headref("heads/master")?
I think show-ref can easily be confused by its tail matching behaviour, and is a bad command to use in a context like this. To be safe, I think get_headref() should be:
sub get_headref {
my ($it) = (@_);
my $r = `git-rev-parse --verify "refs/$it"`;
return undef unless $? == 0;
chomp $r;
return $r;
}