From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 3/3] push: make push.default = current use resolved HEAD
Date: Thu, 30 May 2013 00:51:51 +0530 [thread overview]
Message-ID: <1369855311-23367-4-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1369855311-23367-1-git-send-email-artagnon@gmail.com>
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>
---
builtin/push.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/push.c b/builtin/push.c
index a79038c..d819487 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -198,7 +198,7 @@ static void setup_default_push_refspecs(struct remote *remote)
case PUSH_DEFAULT_CURRENT:
if (!branch)
die(_(message_detached_head_die), remote->name);
- add_refspec("HEAD");
+ add_refspec(branch->name);
break;
case PUSH_DEFAULT_NOTHING:
--
1.8.3.12.gbd56588
prev parent reply other threads:[~2013-05-29 19:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-29 19:21 [PATCH v2 0/3] Early HEAD resolution in push.default = current Ramkumar Ramachandra
2013-05-29 19:21 ` [PATCH 1/3] push: factor out the detached HEAD error message Ramkumar Ramachandra
2013-05-29 19:21 ` [PATCH 2/3] push: fail early with detached HEAD and current Ramkumar Ramachandra
2013-05-29 19:34 ` Junio C Hamano
2013-05-29 19:37 ` Ramkumar Ramachandra
2013-05-29 19:59 ` Junio C Hamano
2013-05-29 20:04 ` Ramkumar Ramachandra
2013-05-29 19:21 ` Ramkumar Ramachandra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1369855311-23367-4-git-send-email-artagnon@gmail.com \
--to=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).