checkout: move 'confict_style' and 'dwim_..' to checkout_opts

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

Nguyễn Thái Ngọc Duy committed Mar 29, 2019 at 17:39 UTC 55cf704a9d139bca0cb5cca1bf047eb043e13bd2
1 file changed +10 -7
builtin/checkout.c
+10 -7
@@ -47,6 +47,8 @@ struct checkout_opts {
47 int show_progress;
48 int count_checkout_paths;
49 int overlay_mode;
50 + int no_dwim_new_local_branch;
51 +
52 /*
53 * If new checkout options are added, skip_merge_working_tree
54 * should be updated accordingly.
@@ -58,6 +60,7 @@ struct checkout_opts {
60 int new_branch_log;
61 enum branch_track track;
62 struct diff_options diff_options;
63 + char *conflict_style;
64
65 int branch_exists;
66 const char *prefix;
@@ -1344,8 +1347,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
1347 struct checkout_opts real_opts;
1348 struct checkout_opts *opts = &real_opts;
1349 struct branch_info new_branch_info;
1347 - char *conflict_style = NULL;
1348 - int dwim_new_local_branch, no_dwim_new_local_branch = 0;
1350 + int dwim_new_local_branch;
1351 int dwim_remotes_matched = 0;
1352 struct option options[] = {
1353 OPT__QUIET(&opts->quiet, N_("suppress progress reporting")),
@@ -1370,12 +1372,12 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
1372 OPT_BOOL_F(0, "overwrite-ignore", &opts->overwrite_ignore,
1373 N_("update ignored files (default)"),
1374 PARSE_OPT_NOCOMPLETE),
1373 - OPT_STRING(0, "conflict", &conflict_style, N_("style"),
1375 + OPT_STRING(0, "conflict", &opts->conflict_style, N_("style"),
1376 N_("conflict style (merge or diff3)")),
1377 OPT_BOOL('p', "patch", &opts->patch_mode, N_("select hunks interactively")),
1378 OPT_BOOL(0, "ignore-skip-worktree-bits", &opts->ignore_skipworktree,
1379 N_("do not limit pathspecs to sparse entries only")),
1378 - OPT_BOOL(0, "no-guess", &no_dwim_new_local_branch,
1380 + OPT_BOOL(0, "no-guess", &opts->no_dwim_new_local_branch,
1381 N_("do not second guess 'git checkout <no-such-branch>'")),
1382 OPT_BOOL(0, "ignore-other-worktrees", &opts->ignore_other_worktrees,
1383 N_("do not check if another worktree is holding the given ref")),
@@ -1393,6 +1395,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
1395 opts->prefix = prefix;
1396 opts->show_progress = -1;
1397 opts->overlay_mode = -1;
1398 + opts->no_dwim_new_local_branch = 0;
1399
1400 git_config(git_checkout_config, opts);
1401
@@ -1401,7 +1404,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
1404 argc = parse_options(argc, argv, prefix, options, checkout_usage,
1405 PARSE_OPT_KEEP_DASHDASH);
1406
1404 - dwim_new_local_branch = !no_dwim_new_local_branch;
1407 + dwim_new_local_branch = !opts->no_dwim_new_local_branch;
1408 if (opts->show_progress < 0) {
1409 if (opts->quiet)
1410 opts->show_progress = 0;
@@ -1409,9 +1412,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
1412 opts->show_progress = isatty(2);
1413 }
1414
1412 - if (conflict_style) {
1415 + if (opts->conflict_style) {
1416 opts->merge = 1; /* implied */
1414 - git_xmerge_config("merge.conflictstyle", conflict_style, NULL);
1417 + git_xmerge_config("merge.conflictstyle", opts->conflict_style, NULL);
1418 }
1419
1420 if ((!!opts->new_branch + !!opts->new_branch_force + !!opts->new_orphan_branch) > 1)