From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Subject: [PATCH 3/3] push: don't push the volatile HEAD with current
Date: Tue, 21 May 2013 23:53:20 +0530 [thread overview]
Message-ID: <1369160600-22337-4-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1369160600-22337-1-git-send-email-artagnon@gmail.com>
Since a push does not lock the "HEAD" ref, there is no guarantee that it
will remain the same for the entire operation of the push. Practically,
this means that with push.default set to 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!
Avoid this confusion by adding the branch that HEAD resolves to as the
refspec to push (as opposed to the literal "HEAD"). With this change,
the output of the push changes subtly from:
$ git push
...
* [new branch] HEAD -> push-current-head
to:
$ git push
...
* [new branch] push-current-head -> push-current-head
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.rc3.7.gc1ff30b
next prev parent reply other threads:[~2013-05-21 18:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-21 18:23 [PATCH 0/3] Fixing volatile HEAD in push.default = current Ramkumar Ramachandra
2013-05-21 18:23 ` [PATCH 1/3] push: factor out the detached HEAD error message Ramkumar Ramachandra
2013-05-21 18:23 ` [PATCH 2/3] push: fail early with detached HEAD and current Ramkumar Ramachandra
2013-05-21 18:23 ` Ramkumar Ramachandra [this message]
2013-05-21 19:13 ` [PATCH 0/3] Fixing volatile HEAD in push.default = current Junio C Hamano
2013-05-21 19:52 ` Ramkumar Ramachandra
2013-05-21 20:04 ` Junio C Hamano
2013-05-21 20:24 ` Junio C Hamano
2013-05-21 21:09 ` Ramkumar Ramachandra
2013-05-22 14:26 ` Junio C Hamano
2013-05-22 14:43 ` Ramkumar Ramachandra
2013-05-22 17:11 ` Junio C Hamano
2013-05-23 7:55 ` Ramkumar Ramachandra
2013-05-23 8:53 ` Andreas Krey
2013-05-23 14:45 ` Junio C Hamano
2013-05-23 19:27 ` Andreas Krey
2013-05-23 14:49 ` Junio C Hamano
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=1369160600-22337-4-git-send-email-artagnon@gmail.com \
--to=artagnon@gmail.com \
--cc=git@vger.kernel.org \
/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).