Skip to content

Commit

Permalink
push: fix segfault for odd config
Browse files Browse the repository at this point in the history
If you have a branch.$X.merge config option, but no branch.$X.remote, and
your configuration tries to push tracking branches, git will segfault.

The problem is that even though branch->merge_nr is 1, you don't actually
have an upstream since there is no remote.  Other callsites generally
check explicitly that branch->merge is not NULL, so let's do that here,
too.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Feb 24, 2010
1 parent 5215374 commit db03b55
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion builtin-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void setup_push_tracking(void)
struct branch *branch = branch_get(NULL);
if (!branch)
die("You are not currently on a branch.");
if (!branch->merge_nr)
if (!branch->merge_nr || !branch->merge)
die("The current branch %s is not tracking anything.",
branch->name);
if (branch->merge_nr != 1)
Expand Down

0 comments on commit db03b55

Please sign in to comment.