Skip to content

Commit

Permalink
push: make push.default = current use resolved HEAD
Browse files Browse the repository at this point in the history
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 <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Ramkumar Ramachandra authored and Junio C Hamano committed May 29, 2013
1 parent 7b2ecd8 commit 0f075b2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion builtin/push.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static void setup_default_push_refspecs(struct remote *remote)
branch = branch_get(NULL);
if (!branch)
die(_(message_detached_head_die), remote->name);
add_refspec("HEAD");
add_refspec(branch->name);
break;

case PUSH_DEFAULT_NOTHING:
Expand Down

0 comments on commit 0f075b2

Please sign in to comment.