[v2,3/7] checkout: move 'confict_style' to checkout_opts
diff mbox series

Message ID 20181127165211.24763-4-pclouds@gmail.com
State New
Headers show
Series
  • Introduce new commands switch-branch and checkout-files
Related show

Commit Message

Duy Nguyen Nov. 27, 2018, 4:52 p.m. UTC
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/checkout.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Stefan Beller Nov. 27, 2018, 7:50 p.m. UTC | #1
On Tue, Nov 27, 2018 at 8:53 AM Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>

The last patches seemed self explanatory after the first RFC
and their commit message. This one is harder to reason about,
as --conflict is documented as "The same as --merge option
above, but ..." and --merge is "When switching branches, ..."
so ... ah my mind wandered off, expecting this to be a preparation
for the separate commands already, but this is just about ensuring
everything is in opts such that the split can be done later?

Patch
diff mbox series

diff --git a/builtin/checkout.c b/builtin/checkout.c
index 31245c1eb4..211a347a0c 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -55,6 +55,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;
@@ -1228,7 +1229,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[] = {
@@ -1254,7 +1254,7 @@  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,
@@ -1290,9 +1290,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)