These local variables are referenced by struct option[]. This struct
will soon be broken down, moved away and we can't rely on local
variables anymore. Move these two to struct checkout_opts in
preparation for that.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@gmail.com>
---
 builtin/checkout.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index 1b19328d0a..2423fdbf94 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.
@@ -55,6 +57,7 @@ struct checkout_opts {
        int new_branch_log;
        enum branch_track track;
        struct diff_options diff_options;
+       char *conflict_style;
 
        int branch_exists;
        const char *prefix;
@@ -1239,8 +1242,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;
-       char *conflict_style = NULL;
-       int dwim_new_local_branch = 1;
        int dwim_remotes_matched = 0;
        struct option options[] = {
                OPT__QUIET(&opts->quiet, N_("suppress progress reporting")),
@@ -1265,12 +1266,12 @@ int cmd_checkout(int argc, const char **argv, const 
char *prefix)
                OPT_BOOL_F(0, "overwrite-ignore", &opts->overwrite_ignore,
                           N_("update ignored files (default)"),
                           PARSE_OPT_NOCOMPLETE),
-               OPT_STRING(0, "conflict", &conflict_style, N_("style"),
+               OPT_STRING(0, "conflict", &opts->conflict_style, N_("style"),
                           N_("conflict style (merge or diff3)")),
                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")),
@@ -1286,6 +1287,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);
 
@@ -1301,9 +1303,9 @@ int cmd_checkout(int argc, const char **argv, const char 
*prefix)
                        opts->show_progress = isatty(2);
        }
 
-       if (conflict_style) {
+       if (opts->conflict_style) {
                opts->merge = 1; /* implied */
-               git_xmerge_config("merge.conflictstyle", conflict_style, NULL);
+               git_xmerge_config("merge.conflictstyle", opts->conflict_style, 
NULL);
        }
 
        if ((!!opts->new_branch + !!opts->new_branch_force + 
!!opts->new_orphan_branch) > 1)
@@ -1350,7 +1352,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.20.0.rc1.380.g3eb999425c.dirty

Reply via email to