@matheusbsbs / matheus-bagliano / commits / 2957709bd4
Fork 0

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 <alexandr.miloslavskiy@syntevo.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alexandr Miloslavskiy committed Dec 30, 2019 at 18:38 UTC 2957709bd44a5b18d180ba4c3864a431a5aaed38
1 file changed +19 -6
builtin/checkout.c
+19 -6
@@ -1113,6 +1113,22 @@ static void setup_new_branch_info_and_source_tree(
1113 }
1114 }
1115
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 +
1132 static int parse_branchname_arg(int argc, const char **argv,
1133 int dwim_new_local_branch_ok,
1134 struct branch_info *new_branch_info,
@@ -1223,13 +1239,10 @@ static int parse_branchname_arg(int argc, const char **argv,
1239 recover_with_dwim = 0;
1240
1241 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);
1245 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);
1246 *new_branch = arg;
1247 arg = remote;
1248 /* DWIMmed to create local branch, case (3).(b) */