summaryrefslogtreecommitdiff
path: root/builtin/checkout.c
diff options
context:
space:
mode:
authorAlexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>2019-12-30 18:38:12 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-01-07 21:15:37 (GMT)
commit2957709bd44a5b18d180ba4c3864a431a5aaed38 (patch)
tree50e661e9ed7668c7847e3bb1eca1dc44863b17c0 /builtin/checkout.c
parent53a06cf39b756eddfe4a2a34da93e3d04eb7b728 (diff)
downloadgit-2957709bd44a5b18d180ba4c3864a431a5aaed38.zip
git-2957709bd44a5b18d180ba4c3864a431a5aaed38.tar.gz
git-2957709bd44a5b18d180ba4c3864a431a5aaed38.tar.bz2
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>
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r--builtin/checkout.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 3634a3d..11fe4fa 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1113,6 +1113,22 @@ static void setup_new_branch_info_and_source_tree(
}
}
+static const char *parse_remote_branch(const char *arg,
+ struct object_id *rev,
+ int could_be_checkout_paths,
+ int *dwim_remotes_matched)
+{
+ const char *remote = unique_tracking_name(arg, rev, dwim_remotes_matched);
+
+ if (remote && could_be_checkout_paths) {
+ die(_("'%s' could be both a local file and a tracking branch.\n"
+ "Please use -- (and optionally --no-guess) to disambiguate"),
+ arg);
+ }
+
+ return remote;
+}
+
static int parse_branchname_arg(int argc, const char **argv,
int dwim_new_local_branch_ok,
struct branch_info *new_branch_info,
@@ -1223,13 +1239,10 @@ static int parse_branchname_arg(int argc, const char **argv,
recover_with_dwim = 0;
if (recover_with_dwim) {
- const char *remote = unique_tracking_name(arg, rev,
- dwim_remotes_matched);
+ const char *remote = parse_remote_branch(arg, rev,
+ could_be_checkout_paths,
+ dwim_remotes_matched);
if (remote) {
- if (could_be_checkout_paths)
- die(_("'%s' could be both a local file and a tracking branch.\n"
- "Please use -- (and optionally --no-guess) to disambiguate"),
- arg);
*new_branch = arg;
arg = remote;
/* DWIMmed to create local branch, case (3).(b) */