[PATCH] reset: disallow --no-{mixed,soft,hard,merge,keep}
Since 5eee6b28b5 (Make builtin-reset.c use parse_options., 2008-03-04)
git reset has accepted the options --no-mixed, --no-soft and --no-hard,
9e8eceab73 (Add 'merge' mode to 'git reset', 2008-12-01) and 9bc454df08
(reset: add option "--keep" to "git reset", 2010-01-19) added --no-merge
and --no-keep, respectively. They all do the same as --mixed, because
they are defined using OPT_SET_INT and the value of MIXED happens to be
0. That's surprising and not very useful. Disallow the negated forms.
Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
---
builtin/reset.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/builtin/reset.c b/builtin/reset.c
index 7f18dc03b8..6292859d3c 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -338,15 +338,21 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
OPT__QUIET(&quiet, N_("be quiet, only report errors")),
OPT_BOOL(0, "no-refresh", &no_refresh,
N_("skip refreshing the index after reset")),
- OPT_SET_INT(0, "mixed", &reset_type,
- N_("reset HEAD and index"), MIXED),
- OPT_SET_INT(0, "soft", &reset_type, N_("reset only HEAD"), SOFT),
- OPT_SET_INT(0, "hard", &reset_type,
- N_("reset HEAD, index and working tree"), HARD),
- OPT_SET_INT(0, "merge", &reset_type,
- N_("reset HEAD, index and working tree"), MERGE),
- OPT_SET_INT(0, "keep", &reset_type,
- N_("reset HEAD but keep local changes"), KEEP),
+ OPT_SET_INT_F(0, "mixed", &reset_type,
+ N_("reset HEAD and index"), MIXED,
+ PARSE_OPT_NONEG),
+ OPT_SET_INT_F(0, "soft", &reset_type,
+ N_("reset only HEAD"), SOFT,
+ PARSE_OPT_NONEG),
+ OPT_SET_INT_F(0, "hard", &reset_type,
+ N_("reset HEAD, index and working tree"), HARD,
+ PARSE_OPT_NONEG),
+ OPT_SET_INT_F(0, "merge", &reset_type,
+ N_("reset HEAD, index and working tree"), MERGE,
+ PARSE_OPT_NONEG),
+ OPT_SET_INT_F(0, "keep", &reset_type,
+ N_("reset HEAD but keep local changes"), KEEP,
+ PARSE_OPT_NONEG),
OPT_CALLBACK_F(0, "recurse-submodules", NULL,
"reset", "control recursive updating of submodules",
PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater),
--
2.41.0