Skip to content

Commit 1a15d00

Browse files
peffgitster
authored andcommitted
branch: mention start_name in set-upstream error messages
If we refuse a branch operation because the tracking start_name the user gave us is bogus, we just print something like: fatal: Cannot setup tracking information; start point is not a branch If we mention the actual name we tried to use, that may help the user figure out why it didn't work (e.g., if they gave us the arguments in the wrong order). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a5e91c7 commit 1a15d00

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

branch.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ int validate_new_branchname(const char *name, struct strbuf *ref,
198198
}
199199

200200
static const char upstream_not_branch[] =
201-
N_("Cannot setup tracking information; starting point is not a branch.");
201+
N_("Cannot setup tracking information; starting point '%s' is not a branch.");
202202
static const char upstream_missing[] =
203-
N_("Cannot setup tracking information; starting point does not exist");
203+
N_("Cannot setup tracking information; starting point '%s' does not exist");
204204

205205
void create_branch(const char *head,
206206
const char *name, const char *start_name,
@@ -231,22 +231,22 @@ void create_branch(const char *head,
231231
real_ref = NULL;
232232
if (get_sha1(start_name, sha1)) {
233233
if (explicit_tracking)
234-
die(_(upstream_missing));
234+
die(_(upstream_missing), start_name);
235235
die("Not a valid object name: '%s'.", start_name);
236236
}
237237

238238
switch (dwim_ref(start_name, strlen(start_name), sha1, &real_ref)) {
239239
case 0:
240240
/* Not branching from any existing branch */
241241
if (explicit_tracking)
242-
die(_(upstream_not_branch));
242+
die(_(upstream_not_branch), start_name);
243243
break;
244244
case 1:
245245
/* Unique completion -- good, only if it is a real branch */
246246
if (prefixcmp(real_ref, "refs/heads/") &&
247247
prefixcmp(real_ref, "refs/remotes/")) {
248248
if (explicit_tracking)
249-
die(_(upstream_not_branch));
249+
die(_(upstream_not_branch), start_name);
250250
else
251251
real_ref = NULL;
252252
}

0 commit comments

Comments
 (0)