{"thread":{"id":"60011","subject":"[PATCH] reset: reject --no-(mixed|soft|hard|merge|keep) option","startedAt":"2023-07-19T13:37:44Z","lastAt":"2023-07-19T16:57:22Z","messageCount":2,"participants":["Junio C Hamano","Taylor Blau"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"479633","messageId":"xmqq1qh4c998.fsf@gitster.g","threadId":"60011","inReplyTo":null,"subject":"[PATCH] reset: reject --no-(mixed|soft|hard|merge|keep) option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-07-19T13:37:39Z","receivedAt":"2023-07-19T13:37:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"git reset --no-mixed\" behaved exactly like \"git reset --mixed\",\nwhich was nonsense.\n\nIf there were only two kinds, e.g. \"mixed\" vs \"separate\", it might\nhave made sense to make \"git reset --no-mixed\" behave identically to\n\"git reset --separate\" and vice-versa, but because we have many\ntypes of reset, lets just forbid \"--no-mixed\" and negated form of\nother types.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/reset.c  | 29 ++++++++++++++++++-----------\n t/t7102-reset.sh | 10 ++++++++++\n 2 files changed, 28 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex f99f32d580..ac4901e003 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -334,18 +334,25 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \t\tOPT__QUIET(&quiet, N_(\"be quiet, only report errors\")),\n \t\tOPT_BOOL(0, \"no-refresh\", &no_refresh,\n \t\t\t\tN_(\"skip refreshing the index after reset\")),\n-\t\tOPT_SET_INT(0, \"mixed\", &reset_type,\n-\t\t\t\t\t\tN_(\"reset HEAD and index\"), MIXED),\n-\t\tOPT_SET_INT(0, \"soft\", &reset_type, N_(\"reset only HEAD\"), SOFT),\n-\t\tOPT_SET_INT(0, \"hard\", &reset_type,\n-\t\t\t\tN_(\"reset HEAD, index and working tree\"), HARD),\n-\t\tOPT_SET_INT(0, \"merge\", &reset_type,\n-\t\t\t\tN_(\"reset HEAD, index and working tree\"), MERGE),\n-\t\tOPT_SET_INT(0, \"keep\", &reset_type,\n-\t\t\t\tN_(\"reset HEAD but keep local changes\"), KEEP),\n+\t\tOPT_SET_INT_F(0, \"mixed\", &reset_type,\n+\t\t\t      N_(\"reset HEAD and index\"),\n+\t\t\t      MIXED, PARSE_OPT_NONEG),\n+\t\tOPT_SET_INT_F(0, \"soft\", &reset_type,\n+\t\t\t      N_(\"reset only HEAD\"),\n+\t\t\t      SOFT, PARSE_OPT_NONEG),\n+\t\tOPT_SET_INT_F(0, \"hard\", &reset_type,\n+\t\t\t      N_(\"reset HEAD, index and working tree\"),\n+\t\t\t      HARD, PARSE_OPT_NONEG),\n+\t\tOPT_SET_INT_F(0, \"merge\", &reset_type,\n+\t\t\t      N_(\"reset HEAD, index and working tree\"),\n+\t\t\t      MERGE, PARSE_OPT_NONEG),\n+\t\tOPT_SET_INT_F(0, \"keep\", &reset_type,\n+\t\t\t      N_(\"reset HEAD but keep local changes\"),\n+\t\t\t      KEEP, PARSE_OPT_NONEG),\n \t\tOPT_CALLBACK_F(0, \"recurse-submodules\", NULL,\n-\t\t\t    \"reset\", \"control recursive updating of submodules\",\n-\t\t\t    PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater),\n+\t\t\t       \"reset\", \"control recursive updating of submodules\",\n+\t\t\t       PARSE_OPT_OPTARG,\n+\t\t\t       option_parse_recurse_submodules_worktree_updater),\n \t\tOPT_BOOL('p', \"patch\", &patch_mode, N_(\"select hunks interactively\")),\n \t\tOPT_BOOL('N', \"intent-to-add\", &intent_to_add,\n \t\t\t\tN_(\"record only the fact that removed paths will be added later\")),\ndiff --git a/t/t7102-reset.sh b/t/t7102-reset.sh\nindex 22477f3a31..4287863ae6 100755\n--- a/t/t7102-reset.sh\n+++ b/t/t7102-reset.sh\n@@ -71,6 +71,16 @@ check_changes () {\n\tdone | test_cmp .cat_expect -\n }\n \n+# no negated form for various type of resets\n+for opt in soft mixed hard merge keep\n+do\n+\ttest_expect_success \"no 'git reset --no-$opt'\" '\n+\t\ttest_when_finished \"rm -f err\" &&\n+\t\ttest_must_fail git reset --no-$opt 2>err &&\n+\t\tgrep \"error: unknown option .no-$opt.\" err\n+\t'\n+done\n+\n test_expect_success 'reset --hard message' '\n \thex=$(git log -1 --format=\"%h\") &&\n \tgit reset --hard >.actual &&\n-- \n2.41.0-376-gcba07a324d\n\n"},{"id":"479644","messageId":"ZLgV7EdEox9r1RvK@nand.local","threadId":"60011","inReplyTo":"xmqq1qh4c998.fsf@gitster.g","subject":"Re: [PATCH] reset: reject --no-(mixed|soft|hard|merge|keep) option","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2023-07-19T16:57:16Z","receivedAt":"2023-07-19T16:57:22Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Wed, Jul 19, 2023 at 06:37:39AM -0700, Junio C Hamano wrote:\n> ---\n>  builtin/reset.c  | 29 ++++++++++++++++++-----------\n>  t/t7102-reset.sh | 10 ++++++++++\n>  2 files changed, 28 insertions(+), 11 deletions(-)\n\nSeems all very sane to me, LGTM.\n\nThanks,\nTaylor\n"}]}