branch: factor out "upstream is not a branch" error messages

This message is duplicated, and is quite long. Let's factor it out, which avoids the repetition and the long lines. It will also make future patches easier as we tweak the message. While we're at it, let's also mark it for translation. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Apr 2, 2013 at 15:03 UTC e2b6aa5f1b85d5f49f0cf280162cf216e55e1eba
1 file changed +5 -2
branch.c
+5 -2
@@ -197,6 +197,9 @@ int validate_new_branchname(const char *name, struct strbuf *ref,
197 return 1;
198 }
199
200 +static const char upstream_not_branch[] =
201 +N_("Cannot setup tracking information; starting point is not a branch.");
202 +
203 void create_branch(const char *head,
204 const char *name, const char *start_name,
205 int force, int reflog, int clobber_head,
@@ -231,14 +234,14 @@ void create_branch(const char *head,
234 case 0:
235 /* Not branching from any existing branch */
236 if (explicit_tracking)
234 - die("Cannot setup tracking information; starting point is not a branch.");
237 + die(_(upstream_not_branch));
238 break;
239 case 1:
240 /* Unique completion -- good, only if it is a real branch */
241 if (prefixcmp(real_ref, "refs/heads/") &&
242 prefixcmp(real_ref, "refs/remotes/")) {
243 if (explicit_tracking)
241 - die("Cannot setup tracking information; starting point is not a branch.");
244 + die(_(upstream_not_branch));
245 else
246 real_ref = NULL;
247 }