1
0
mirror of https://github.com/git/git synced 2024-07-05 00:58:49 +00:00

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>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2019-03-29 17:39:03 +07:00 committed by Junio C Hamano
parent b3edccb967
commit 55cf704a9d

View File

@ -47,6 +47,8 @@ struct checkout_opts {
int show_progress;
int count_checkout_paths;
int overlay_mode;
int no_dwim_new_local_branch;
/*
* If new checkout options are added, skip_merge_working_tree
* should be updated accordingly.
@ -58,6 +60,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;
@ -1344,8 +1347,7 @@ 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, no_dwim_new_local_branch = 0;
int dwim_new_local_branch;
int dwim_remotes_matched = 0;
struct option options[] = {
OPT__QUIET(&opts->quiet, N_("suppress progress reporting")),
@ -1370,12 +1372,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_BOOL(0, "no-guess", &no_dwim_new_local_branch,
OPT_BOOL(0, "no-guess", &opts->no_dwim_new_local_branch,
N_("do not 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")),
@ -1393,6 +1395,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
opts->prefix = prefix;
opts->show_progress = -1;
opts->overlay_mode = -1;
opts->no_dwim_new_local_branch = 0;
git_config(git_checkout_config, opts);
@ -1401,7 +1404,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, options, checkout_usage,
PARSE_OPT_KEEP_DASHDASH);
dwim_new_local_branch = !no_dwim_new_local_branch;
dwim_new_local_branch = !opts->no_dwim_new_local_branch;
if (opts->show_progress < 0) {
if (opts->quiet)
opts->show_progress = 0;
@ -1409,9 +1412,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)