summaryrefslogtreecommitdiff
path: root/builtin/push.c
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2013-05-29 19:21:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-05-29 19:31:10 (GMT)
commit35ee69c0f6c77f293b66125d334467d9692ef866 (patch)
treea23b02502cc34070e0d195a2048ffd8bc36e1fd8 /builtin/push.c
parentedca4152560522a431a51fc0a06147fc680b5b18 (diff)
downloadgit-35ee69c0f6c77f293b66125d334467d9692ef866.zip
git-35ee69c0f6c77f293b66125d334467d9692ef866.tar.gz
git-35ee69c0f6c77f293b66125d334467d9692ef866.tar.bz2
push: factor out the detached HEAD error message
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/push.c')
-rw-r--r--builtin/push.c14
1 files 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"