@ -878,7 +878,8 @@ static int parse_branchname_arg(int argc, const char **argv,
int dwim_new_local_branch_ok,
int dwim_new_local_branch_ok,
struct branch_info *new_branch_info,
struct branch_info *new_branch_info,
struct checkout_opts *opts,
struct checkout_opts *opts,
struct object_id *rev)
struct object_id *rev,
int *dwim_remotes_matched)
{
{
struct tree **source_tree = &opts->source_tree;
struct tree **source_tree = &opts->source_tree;
const char **new_branch = &opts->new_branch;
const char **new_branch = &opts->new_branch;
@ -972,7 +973,8 @@ static int parse_branchname_arg(int argc, const char **argv,
recover_with_dwim = 0;
recover_with_dwim = 0;
if (recover_with_dwim) {
if (recover_with_dwim) {
const char *remote = unique_tracking_name(arg, rev);
const char *remote = unique_tracking_name(arg, rev,
dwim_remotes_matched);
if (remote) {
if (remote) {
*new_branch = arg;
*new_branch = arg;
arg = remote;
arg = remote;
@ -1109,6 +1111,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
struct branch_info new_branch_info;
struct branch_info new_branch_info;
char *conflict_style = NULL;
char *conflict_style = NULL;
int dwim_new_local_branch = 1;
int dwim_new_local_branch = 1;
int dwim_remotes_matched = 0;
struct option options[] = {
struct option options[] = {
OPT__QUIET(&opts.quiet, N_("suppress progress reporting")),
OPT__QUIET(&opts.quiet, N_("suppress progress reporting")),
OPT_STRING('b', NULL, &opts.new_branch, N_("branch"),
OPT_STRING('b', NULL, &opts.new_branch, N_("branch"),
@ -1219,7 +1222,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
opts.track == BRANCH_TRACK_UNSPECIFIED &&
opts.track == BRANCH_TRACK_UNSPECIFIED &&
!opts.new_branch;
!opts.new_branch;
int n = parse_branchname_arg(argc, argv, dwim_ok,
int n = parse_branchname_arg(argc, argv, dwim_ok,
&new_branch_info, &opts, &rev);
&new_branch_info, &opts, &rev,
&dwim_remotes_matched);
argv += n;
argv += n;
argc -= n;
argc -= n;
}
}