push: fix segfault for odd config
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>
Jeff King committed
Feb 24, 2010 at 12:08 UTC
db03b55781f23a9276234faf9a21922ff8c5678d
1 file changed
+1
-1
builtin-push.c
+1
-1
@@ -54,7 +54,7 @@ static void setup_push_tracking(void)
54
struct branch *branch = branch_get(NULL);
55
if (!branch)
56
die("You are not currently on a branch.");
57
- if (!branch->merge_nr)
57
+ if (!branch->merge_nr || !branch->merge)
58
die("The current branch %s is not tracking anything.",
59
branch->name);
60
if (branch->merge_nr != 1)