git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Emanuele Giaquinta <e.giaquinta@glauco.it>,
	git@vger.kernel.org
Subject: Re: [PATCH 2/3] cvsimport: use show-ref to support packed refs
Date: Wed, 28 Nov 2007 14:23:13 -0800	[thread overview]
Message-ID: <7v4pf63t7y.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20071128194423.GB11396@coredump.intra.peff.net> (Jeff King's message of "Wed, 28 Nov 2007 14:44:23 -0500")

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

  parent reply	other threads:[~2007-11-28 22:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-27 15:01 git-cvsimport bug Emanuele Giaquinta
2007-11-28 16:57 ` Jeff King
2007-11-28 18:55   ` Jeff King
2007-11-28 18:55     ` [PATCH 1/3] Add basic cvsimport tests Jeff King
2007-11-28 22:14       ` Junio C Hamano
2007-11-28 22:20         ` David Kastrup
2007-11-29  9:12         ` Andreas Ericsson
2007-11-28 18:56     ` [PATCH 2/3] cvsimport: use show-ref to support packed refs Jeff King
2007-11-28 19:16       ` Johannes Schindelin
2007-11-28 19:44         ` Jeff King
2007-11-28 20:37           ` Johannes Schindelin
2007-11-28 22:23           ` Junio C Hamano [this message]
2007-11-28 22:43             ` Jeff King
2007-11-28 22:52               ` Jeff King
2007-11-28 18:56     ` [PATCH 3/3] cvsimport: miscellaneous packed-ref fixes Jeff King
2007-11-29  0:52       ` Junio C Hamano
2007-11-29 14:19         ` Jeff King
2007-11-30 18:41     ` git-cvsimport bug Emanuele Giaquinta

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=7v4pf63t7y.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=e.giaquinta@glauco.it \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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).