mirror of
https://github.com/git/git.git
synced 2024-11-24 02:17:02 +08:00
Merge branch 'km/branch-get-push-while-detached' into maint
"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
This commit is contained in:
commit
f5f55a1046
6
remote.c
6
remote.c
@ -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;
|
||||
|
@ -60,4 +60,10 @@ test_expect_success '@{push} with push refspecs' '
|
||||
resolve topic@{push} refs/remotes/origin/magic/topic
|
||||
'
|
||||
|
||||
test_expect_success 'resolving @{push} fails with a detached HEAD' '
|
||||
git checkout HEAD^0 &&
|
||||
test_when_finished "git checkout -" &&
|
||||
test_must_fail git rev-parse @{push}
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Loading…
Reference in New Issue
Block a user