[PATCH 1/2] builtin: remove merge short flag for switch and restore

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Both git-switch(1) and git-restore(1) inherit some common options from
git-checkout(1). One such option is the `--merge` flag and its
accompanying short flag `-m`.

In previous discussion[1] around removing the experimental marker for
git-switch(1), it has been suggested that this short flag could instead
be used for an option similar to `--move` from git-branch(1). Such a
feature is not yet implemented for this command, but reserving a short
flag for an uncommon option is unnecessary and hinders potential future
extension.

While these commands are still marked as experimental, remove the `-m`
flag from both git-switch(1) and git-restore(1) and update the
documentation accordingly. The `--conflict` flag is also now defined
explicitly for each command as to remain alongside its related `--merge`
companion.

[1]: https://lore.kernel.org/git/877dkdwgfe.fsf@xxxxxxxxxxxxxxxxxxx/

Signed-off-by: Justin Tobler <jltobler@xxxxxxxxx>
---
 Documentation/git-restore.adoc |  1 -
 Documentation/git-switch.adoc  |  1 -
 builtin/checkout.c             | 24 ++++++++++++++++--------
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/Documentation/git-restore.adoc b/Documentation/git-restore.adoc
index 877b7772e66..96de9bb5ed7 100644
--- a/Documentation/git-restore.adoc
+++ b/Documentation/git-restore.adoc
@@ -82,7 +82,6 @@ Note that during `git rebase` and `git pull --rebase`, `ours` and
 `theirs` may appear swapped. See the explanation of the same options
 in linkgit:git-checkout[1] for details.
 
-`-m`::
 `--merge`::
 	When restoring files on the working tree from the index,
 	recreate the conflicted merge in the unmerged paths.
diff --git a/Documentation/git-switch.adoc b/Documentation/git-switch.adoc
index 9f62abf9e2b..7b24450f841 100644
--- a/Documentation/git-switch.adoc
+++ b/Documentation/git-switch.adoc
@@ -123,7 +123,6 @@ variable.
 	submodule content is also restored to match the switching
 	target. This is used to throw away local changes.
 
-`-m`::
 `--merge`::
 	If you have local modifications to one or more files that are
 	different between the current branch and the branch to which
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 0a90b86a729..0d5b182166e 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1689,13 +1689,9 @@ static struct option *add_common_options(struct checkout_opts *opts,
 	struct option options[] = {
 		OPT__QUIET(&opts->quiet, N_("suppress progress reporting")),
 		OPT_CALLBACK_F(0, "recurse-submodules", NULL,
-			    "checkout", "control recursive updating of submodules",
-			    PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater),
+			       "checkout", "control recursive updating of submodules",
+			       PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater),
 		OPT_BOOL(0, "progress", &opts->show_progress, N_("force progress reporting")),
-		OPT_BOOL('m', "merge", &opts->merge, N_("perform a 3-way merge with the new branch")),
-		OPT_CALLBACK(0, "conflict", opts, N_("style"),
-			     N_("conflict style (merge, diff3, or zdiff3)"),
-			     parse_opt_conflict),
 		OPT_END()
 	};
 	struct option *newopts = parse_options_concat(prevopts, options);
@@ -1976,6 +1972,10 @@ int cmd_checkout(int argc,
 		OPT_BOOL(0, "guess", &opts.dwim_new_local_branch,
 			 N_("second guess 'git checkout <no-such-branch>' (default)")),
 		OPT_BOOL(0, "overlay", &opts.overlay_mode, N_("use overlay mode (default)")),
+		OPT_BOOL('m', "merge", &opts.merge, N_("perform a 3-way merge with the new branch")),
+		OPT_CALLBACK(0, "conflict", &opts, N_("style"),
+			     N_("conflict style (merge, diff3, or zdiff3)"),
+			     parse_opt_conflict),
 		OPT_END()
 	};
 
@@ -2026,6 +2026,10 @@ int cmd_switch(int argc,
 			 N_("second guess 'git switch <no-such-branch>'")),
 		OPT_BOOL(0, "discard-changes", &opts.discard_changes,
 			 N_("throw away local modifications")),
+		OPT_BOOL(0, "merge", &opts.merge, N_("perform a 3-way merge with the new branch")),
+		OPT_CALLBACK(0, "conflict", &opts, N_("style"),
+			     N_("conflict style (merge, diff3, or zdiff3)"),
+			     parse_opt_conflict),
 		OPT_END()
 	};
 
@@ -2060,12 +2064,16 @@ int cmd_restore(int argc,
 		OPT_STRING('s', "source", &opts.from_treeish, "<tree-ish>",
 			   N_("which tree-ish to checkout from")),
 		OPT_BOOL('S', "staged", &opts.checkout_index,
-			   N_("restore the index")),
+			 N_("restore the index")),
 		OPT_BOOL('W', "worktree", &opts.checkout_worktree,
-			   N_("restore the working tree (default)")),
+			 N_("restore the working tree (default)")),
 		OPT_BOOL(0, "ignore-unmerged", &opts.ignore_unmerged,
 			 N_("ignore unmerged entries")),
 		OPT_BOOL(0, "overlay", &opts.overlay_mode, N_("use overlay mode")),
+		OPT_BOOL(0, "merge", &opts.merge, N_("perform a 3-way merge with the new branch")),
+		OPT_CALLBACK(0, "conflict", &opts, N_("style"),
+			     N_("conflict style (merge, diff3, or zdiff3)"),
+			     parse_opt_conflict),
 		OPT_END()
 	};
 
-- 
2.50.1.214.ga30f80fde9





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux