Merge branch 'ft/transport-report-segv'
authorJunio C Hamano <gitster@pobox.com>
Wed, 6 Feb 2013 00:12:32 +0000 (16:12 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Feb 2013 00:12:33 +0000 (16:12 -0800)
A failure to push due to non-ff while on an unborn branch
dereferenced a NULL pointer when showing an error message.

* ft/transport-report-segv:
  push: fix segfault when HEAD points nowhere

1  2 
transport.c

diff --cc transport.c
index 384ff9acf1e1c6e192f1f3f75d5fb20c431053ce,af442af329275a693fa713aa5ae9af759f4d4a2a..886ffd8b1e1c9dbb31f3156844790ff98d5ecde3
@@@ -751,17 -742,12 +751,17 @@@ void transport_print_push_status(const 
                    ref->status != REF_STATUS_UPTODATE &&
                    ref->status != REF_STATUS_OK)
                        n += print_one_push_status(ref, dest, n, porcelain);
 -              if (ref->status == REF_STATUS_REJECT_NONFASTFORWARD &&
 -                  *nonfastforward != NON_FF_HEAD) {
 +              if (ref->status == REF_STATUS_REJECT_NONFASTFORWARD) {
-                       if (!strcmp(head, ref->name))
+                       if (head != NULL && !strcmp(head, ref->name))
 -                              *nonfastforward = NON_FF_HEAD;
 +                              *reject_reasons |= REJECT_NON_FF_HEAD;
                        else
 -                              *nonfastforward = NON_FF_OTHER;
 +                              *reject_reasons |= REJECT_NON_FF_OTHER;
 +              } else if (ref->status == REF_STATUS_REJECT_ALREADY_EXISTS) {
 +                      *reject_reasons |= REJECT_ALREADY_EXISTS;
 +              } else if (ref->status == REF_STATUS_REJECT_FETCH_FIRST) {
 +                      *reject_reasons |= REJECT_FETCH_FIRST;
 +              } else if (ref->status == REF_STATUS_REJECT_NEEDS_FORCE) {
 +                      *reject_reasons |= REJECT_NEEDS_FORCE;
                }
        }
  }