From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Subject: [PATCH 1/3] push: factor out the detached HEAD error message
Date: Tue, 21 May 2013 23:53:18 +0530 [thread overview]
Message-ID: <1369160600-22337-2-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1369160600-22337-1-git-send-email-artagnon@gmail.com>
With push.default set to upstream or simple, and a detached HEAD, git
push prints the following error:
$ git push
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push ram HEAD:<name-of-remote-branch>
This error is not unique to upstream or simple: current cannot push with
a detached HEAD either. So, factor out the error string in preparation
for using it in current.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
builtin/push.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/builtin/push.c b/builtin/push.c
index 909c34d..ef3aa97 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -113,17 +113,19 @@ static NORETURN int die_push_simple(struct branch *branch, struct remote *remote
remote->name, branch->name, advice_maybe);
}
+static const char message_detached_head_die[] =
+ N_("You are not currently on a branch.\n"
+ "To push the history leading to the current (detached HEAD)\n"
+ "state now, use\n"
+ "\n"
+ " git push %s HEAD:<name-of-remote-branch>\n");
+
static void setup_push_upstream(struct remote *remote, int simple)
{
struct strbuf refspec = STRBUF_INIT;
struct branch *branch = branch_get(NULL);
if (!branch)
- die(_("You are not currently on a branch.\n"
- "To push the history leading to the current (detached HEAD)\n"
- "state now, use\n"
- "\n"
- " git push %s HEAD:<name-of-remote-branch>\n"),
- remote->name);
+ die(_(message_detached_head_die), remote->name);
if (!branch->merge_nr || !branch->merge || !branch->remote_name)
die(_("The current branch %s has no upstream branch.\n"
"To push the current branch and set the remote as upstream, use\n"
--
1.8.3.rc3.7.gc1ff30b
next prev parent reply other threads:[~2013-05-21 18:25 UTC|newest]
Thread overview: 18+ 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 ` Ramkumar Ramachandra [this message]
2013-05-21 18:23 ` [PATCH 2/3] push: fail early with detached HEAD and current Ramkumar Ramachandra
2013-05-21 18:23 ` [PATCH 3/3] push: don't push the volatile HEAD with current Ramkumar Ramachandra
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
-- strict thread matches above, loose matches on Subject: below --
2013-05-29 19:21 [PATCH v2 0/3] Early HEAD resolution " Ramkumar Ramachandra
2013-05-29 19:21 ` [PATCH 1/3] push: factor out the detached HEAD error message Ramkumar Ramachandra
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-2-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).