diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-01-18 15:12:14 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-18 15:12:14 -0800 |
commit | b85f79c7dd35b495ce94bf58b61832c6030751cf (patch) | |
tree | 5b8673406674992c4aea4336b023af663e30c433 /remote.c | |
parent | 5c924692cd1c45e9c1281516e9823f7c5c3c7cd8 (diff) | |
parent | b10731f43dc21fa47c275052e7c074c686335cd3 (diff) | |
download | git-b85f79c7dd35b495ce94bf58b61832c6030751cf.tar.gz |
Merge branch 'km/branch-get-push-while-detached'
"git <cmd> @{push}" on a detached HEAD used to segfault; it has
been corrected to error out with a message.
* km/branch-get-push-while-detached:
branch_get_push: do not segfault when HEAD is detached
Diffstat (limited to 'remote.c')
-rw-r--r-- | remote.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1716,9 +1716,6 @@ static const char *branch_get_push_1(struct branch *branch, struct strbuf *err) { struct remote *remote; - if (!branch) - return error_buf(err, _("HEAD does not point to a branch")); - remote = remote_get(pushremote_for_branch(branch, NULL)); if (!remote) return error_buf(err, @@ -1778,6 +1775,9 @@ static const char *branch_get_push_1(struct branch *branch, struct strbuf *err) const char *branch_get_push(struct branch *branch, struct strbuf *err) { + if (!branch) + return error_buf(err, _("HEAD does not point to a branch")); + if (!branch->push_tracking_ref) branch->push_tracking_ref = branch_get_push_1(branch, err); return branch->push_tracking_ref; |