Skip to content

Commit 0f075b2

Browse files
artagnongitster
authored andcommitted
push: make push.default = current use resolved HEAD
With this change, the output of the push (with push.default set to current) changes subtly from: $ git push ... * [new branch] HEAD -> push-current-head to: $ git push ... * [new branch] push-current-head -> push-current-head This patch was written with a different motivation. There is a problem unique to push.default = current: # on branch push-current-head $ git push # on another terminal $ git checkout master # return to the first terminal # the push tried to push master! This happens because the 'git checkout' on the second terminal races with the 'git push' on the first terminal. Although this patch does not solve the core problem (there is still no guarantee that 'git push' on the first terminal will resolve HEAD before 'git checkout' changes HEAD on the second), it works in practice. Signed-off-by: Ramkumar Ramachandra <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7b2ecd8 commit 0f075b2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static void setup_default_push_refspecs(struct remote *remote)
199199
branch = branch_get(NULL);
200200
if (!branch)
201201
die(_(message_detached_head_die), remote->name);
202-
add_refspec("HEAD");
202+
add_refspec(branch->name);
203203
break;
204204

205205
case PUSH_DEFAULT_NOTHING:

0 commit comments

Comments
 (0)