Skip to content

Commit 2957709

Browse files
SyntevoAlexgitster
authored andcommitted
parse_branchname_arg(): extract part as new function
This is done for the next commit to avoid crazy 7x tab code padding. Signed-off-by: Alexandr Miloslavskiy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 53a06cf commit 2957709

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

builtin/checkout.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,22 @@ static void setup_new_branch_info_and_source_tree(
11131113
}
11141114
}
11151115

1116+
static const char *parse_remote_branch(const char *arg,
1117+
struct object_id *rev,
1118+
int could_be_checkout_paths,
1119+
int *dwim_remotes_matched)
1120+
{
1121+
const char *remote = unique_tracking_name(arg, rev, dwim_remotes_matched);
1122+
1123+
if (remote && could_be_checkout_paths) {
1124+
die(_("'%s' could be both a local file and a tracking branch.\n"
1125+
"Please use -- (and optionally --no-guess) to disambiguate"),
1126+
arg);
1127+
}
1128+
1129+
return remote;
1130+
}
1131+
11161132
static int parse_branchname_arg(int argc, const char **argv,
11171133
int dwim_new_local_branch_ok,
11181134
struct branch_info *new_branch_info,
@@ -1223,13 +1239,10 @@ static int parse_branchname_arg(int argc, const char **argv,
12231239
recover_with_dwim = 0;
12241240

12251241
if (recover_with_dwim) {
1226-
const char *remote = unique_tracking_name(arg, rev,
1227-
dwim_remotes_matched);
1242+
const char *remote = parse_remote_branch(arg, rev,
1243+
could_be_checkout_paths,
1244+
dwim_remotes_matched);
12281245
if (remote) {
1229-
if (could_be_checkout_paths)
1230-
die(_("'%s' could be both a local file and a tracking branch.\n"
1231-
"Please use -- (and optionally --no-guess) to disambiguate"),
1232-
arg);
12331246
*new_branch = arg;
12341247
arg = remote;
12351248
/* DWIMmed to create local branch, case (3).(b) */

0 commit comments

Comments
 (0)