Skip to content

Commit 1d2c14d

Browse files
frasertweedalegitster
authored andcommitted
push: fix segfault when HEAD points nowhere
After a push of a branch other than the current branch fails in a no-ff error and if you are still on an unborn branch, the code recently added to report the failure dereferenced a null pointer while checking the name of the current branch. Signed-off-by: Fraser Tweedale <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f25950f commit 1d2c14d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ void transport_print_push_status(const char *dest, struct ref *refs,
744744
n += print_one_push_status(ref, dest, n, porcelain);
745745
if (ref->status == REF_STATUS_REJECT_NONFASTFORWARD &&
746746
*nonfastforward != NON_FF_HEAD) {
747-
if (!strcmp(head, ref->name))
747+
if (head != NULL && !strcmp(head, ref->name))
748748
*nonfastforward = NON_FF_HEAD;
749749
else
750750
*nonfastforward = NON_FF_OTHER;

0 commit comments

Comments
 (0)