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 <frase@frase.id.au> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Fraser Tweedale committed Jan 31, 2013 at 22:22 UTC 1d2c14df1605a05118524b2382402d689f69d737
1 file changed +1 -1
transport.c
+1 -1
@@ -744,7 +744,7 @@ void transport_print_push_status(const char *dest, struct ref *refs,
744 n += print_one_push_status(ref, dest, n, porcelain);
745 if (ref->status == REF_STATUS_REJECT_NONFASTFORWARD &&
746 *nonfastforward != NON_FF_HEAD) {
747 - if (!strcmp(head, ref->name))
747 + if (head != NULL && !strcmp(head, ref->name))
748 *nonfastforward = NON_FF_HEAD;
749 else
750 *nonfastforward = NON_FF_OTHER;