Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin/checkout.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 211a347a0c..a50c51f287 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -44,6 +44,8 @@ struct checkout_opts { int ignore_skipworktree; int ignore_other_worktrees; int show_progress; + int dwim_new_local_branch; + /* * If new checkout options are added, skip_merge_working_tree * should be updated accordingly. @@ -1229,7 +1231,6 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) struct checkout_opts real_opts; struct checkout_opts *opts = &real_opts; struct branch_info new_branch_info; - int dwim_new_local_branch = 1; int dwim_remotes_matched = 0; struct option options[] = { OPT__QUIET(&opts->quiet, N_("suppress progress reporting")), @@ -1259,7 +1260,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) OPT_BOOL('p', "patch", &opts->patch_mode, N_("select hunks interactively")), OPT_BOOL(0, "ignore-skip-worktree-bits", &opts->ignore_skipworktree, N_("do not limit pathspecs to sparse entries only")), - OPT_HIDDEN_BOOL(0, "guess", &dwim_new_local_branch, + OPT_HIDDEN_BOOL(0, "guess", &opts->dwim_new_local_branch, N_("second guess 'git checkout <no-such-branch>'")), OPT_BOOL(0, "ignore-other-worktrees", &opts->ignore_other_worktrees, N_("do not check if another worktree is holding the given ref")), @@ -1275,6 +1276,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) opts->overwrite_ignore = 1; opts->prefix = prefix; opts->show_progress = -1; + opts->dwim_new_local_branch = 1; git_config(git_checkout_config, opts); @@ -1339,7 +1341,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) struct object_id rev; int dwim_ok = !opts->patch_mode && - dwim_new_local_branch && + opts->dwim_new_local_branch && opts->track == BRANCH_TRACK_UNSPECIFIED && !opts->new_branch; int n = parse_branchname_arg(argc, argv, dwim_ok, -- 2.19.1.1327.g328c130451.dirty