From: Jeff King <peff@peff.net>
To: Mike Hommey <mh@glandium.org>
Cc: Daniel Barkalow <barkalow@iabervon.org>, git@vger.kernel.org
Subject: Re: [Crash] git-push $remote $non_ref:$anything
Date: Sun, 15 Jun 2008 15:55:41 -0400 [thread overview]
Message-ID: <20080615195541.GA7683@sigill.intra.peff.net> (raw)
In-Reply-To: <20080615193823.GA11218@glandium.org>
[cc'ing Daniel for remote.c advice]
On Sun, Jun 15, 2008 at 09:38:23PM +0200, Mike Hommey wrote:
> I somehow managed to get a segfault by running this:
>
> git push origin non-existant-branch-name:non-existant-branch-name
Hmm. The problem is the ref-guessing code. Given "git push foo:bar",
when we try to figure out what "bar" means we first try to find
refs/heads/bar or refs/heads/bar on the remote. But if that fails, we
are pushing a new item, so we try to use the same prefix as what "foo"
resolved to (e.g., if "foo" is a branch, we make it "refs/heads/bar").
So if "foo" doesn't resolve, we end up dereferencing NULL as part of our
guess. And the fix is obvious and the patch is below.
But it kind of makes me wonder why we bother looking at the dst side of
the refspec at all, since the src has already failed. Is there a good
reason not to just bail from match_explicit when we can't resolve the
src?
---
diff --git a/remote.c b/remote.c
index 91e3b11..fd8c71a 100644
--- a/remote.c
+++ b/remote.c
@@ -920,7 +920,8 @@ static int match_explicit(struct ref *src, struct ref *dst,
case 0:
if (!memcmp(dst_value, "refs/", 5))
matched_dst = make_linked_ref(dst_value, dst_tail);
- else if((dst_guess = guess_ref(dst_value, matched_src)))
+ else if(matched_src &&
+ (dst_guess = guess_ref(dst_value, matched_src)))
matched_dst = make_linked_ref(dst_guess, dst_tail);
else
error("unable to push to unqualified destination: %s\n"
next prev parent reply other threads:[~2008-06-15 19:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-15 19:38 [Crash] git-push $remote $non_ref:$anything Mike Hommey
2008-06-15 19:55 ` Jeff King [this message]
2008-06-15 21:06 ` Daniel Barkalow
2008-06-16 16:15 ` Jeff King
2008-06-16 16:17 ` Jeff King
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=20080615195541.GA7683@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=barkalow@iabervon.org \
--cc=git@vger.kernel.org \
--cc=mh@glandium.org \
/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