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>
Ramkumar Ramachandra committed
May 30, 2013 at 00:51 UTC
35ee69c0f6c77f293b66125d334467d9692ef866
1 file changed
+8
-6
builtin/push.c
+8
-6
@@ -113,17 +113,19 @@ static NORETURN int die_push_simple(struct branch *branch, struct remote *remote
113
remote->name, branch->name, advice_maybe);
114
}
115
116
+static const char message_detached_head_die[] =
117
+ N_("You are not currently on a branch.\n"
118
+ "To push the history leading to the current (detached HEAD)\n"
119
+ "state now, use\n"
120
+ "\n"
121
+ " git push %s HEAD:<name-of-remote-branch>\n");
122
+
123
static void setup_push_upstream(struct remote *remote, int simple)
124
{
125
struct strbuf refspec = STRBUF_INIT;
126
struct branch *branch = branch_get(NULL);
127
if (!branch)
121
- die(_("You are not currently on a branch.\n"
122
- "To push the history leading to the current (detached HEAD)\n"
123
- "state now, use\n"
124
- "\n"
125
- " git push %s HEAD:<name-of-remote-branch>\n"),
126
- remote->name);
128
+ die(_(message_detached_head_die), remote->name);
129
if (!branch->merge_nr || !branch->merge || !branch->remote_name)
130
die(_("The current branch %s has no upstream branch.\n"
131
"To push the current branch and set the remote as upstream, use\n"