revert: rename --reset option to --quit

The option to "git cherry-pick" and "git revert" to discard the sequencer state introduced by v1.7.8-rc0~141^2~6 (revert: Introduce --reset to remove sequencer state, 2011-08-04) has a confusing name. Change it now, while we still have the time. The new name for "cherry-pick, please get out of my way, since I've long forgotten about the sequence of commits I was cherry-picking when you wrote that old .git/sequencer directory" is --quit. Mnemonic: this is analagous to quiting a program the user is no longer using --- we just want to get out of the multiple-command cherry-pick procedure and not to reset HEAD or rewind any other old state. The "--reset" option is kept as a synonym to minimize the impact. We might consider dropping it for simplicity in a separate patch, though. Adjust documentation and tests to use the newly preferred name (--quit) instead of --reset. While at it, let's clarify the short descriptions of these operations in "-h" output. Before: --reset forget the current operation --continue continue the current operation After: --quit end revert or cherry-pick sequence --continue resume revert or cherry-pick sequence Noticed-by: Phil Hord <phil.hord@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Nov 22, 2011 at 05:14 UTC f80a87262aa4468b0941d38deffdb97a757307c5
7 files changed +49 -25
Documentation/git-cherry-pick.txt
+1 -1
@@ -9,8 +9,8 @@ SYNOPSIS
9 --------
10 [verse]
11 'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>...
12 -'git cherry-pick' --reset
12 'git cherry-pick' --continue
13 +'git cherry-pick' --quit
14
15 DESCRIPTION
16 -----------
Documentation/git-revert.txt
+1 -1
@@ -9,8 +9,8 @@ SYNOPSIS
9 --------
10 [verse]
11 'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>...
12 -'git revert' --reset
12 'git revert' --continue
13 +'git revert' --quit
14
15 DESCRIPTION
16 -----------
Documentation/sequencer.txt
+5 -5
@@ -1,9 +1,9 @@
1 ---reset::
2 - Forget about the current operation in progress. Can be used
3 - to clear the sequencer state after a failed cherry-pick or
4 - revert.
5 -
1 --continue::
2 Continue the operation in progress using the information in
3 '.git/sequencer'. Can be used to continue after resolving
4 conflicts in a failed cherry-pick or revert.
5 +
6 +--quit::
7 + Forget about the current operation in progress. Can be used
8 + to clear the sequencer state after a failed cherry-pick or
9 + revert.
builtin/revert.c
+14 -11
@@ -40,7 +40,7 @@ static const char * const cherry_pick_usage[] = {
40 };
41
42 enum replay_action { REVERT, CHERRY_PICK };
43 -enum replay_subcommand { REPLAY_NONE, REPLAY_RESET, REPLAY_CONTINUE };
43 +enum replay_subcommand { REPLAY_NONE, REPLAY_REMOVE_STATE, REPLAY_CONTINUE };
44
45 struct replay_opts {
46 enum replay_action action;
@@ -133,11 +133,11 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
133 {
134 const char * const * usage_str = revert_or_cherry_pick_usage(opts);
135 const char *me = action_name(opts);
136 - int reset = 0;
136 + int remove_state = 0;
137 int contin = 0;
138 struct option options[] = {
139 - OPT_BOOLEAN(0, "reset", &reset, "forget the current operation"),
140 - OPT_BOOLEAN(0, "continue", &contin, "continue the current operation"),
139 + OPT_BOOLEAN(0, "quit", &remove_state, "end revert or cherry-pick sequence"),
140 + OPT_BOOLEAN(0, "continue", &contin, "resume revert or cherry-pick sequence"),
141 OPT_BOOLEAN('n', "no-commit", &opts->no_commit, "don't automatically commit"),
142 OPT_BOOLEAN('e', "edit", &opts->edit, "edit the commit message"),
143 OPT_NOOP_NOARG('r', NULL),
@@ -147,6 +147,9 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
147 OPT_STRING(0, "strategy", &opts->strategy, "strategy", "merge strategy"),
148 OPT_CALLBACK('X', "strategy-option", &opts, "option",
149 "option for merge strategy", option_parse_x),
150 + { OPTION_BOOLEAN, 0, "reset", &remove_state, NULL,
151 + "alias for --quit (deprecated)",
152 + PARSE_OPT_HIDDEN | PARSE_OPT_NOARG },
153 OPT_END(),
154 OPT_END(),
155 OPT_END(),
@@ -168,13 +171,13 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
171
172 /* Check for incompatible subcommands */
173 verify_opt_mutually_compatible(me,
171 - "--reset", reset,
174 + "--quit", remove_state,
175 "--continue", contin,
176 NULL);
177
178 /* Set the subcommand */
176 - if (reset)
177 - opts->subcommand = REPLAY_RESET;
179 + if (remove_state)
180 + opts->subcommand = REPLAY_REMOVE_STATE;
181 else if (contin)
182 opts->subcommand = REPLAY_CONTINUE;
183 else
@@ -183,8 +186,8 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
186 /* Check for incompatible command line arguments */
187 if (opts->subcommand != REPLAY_NONE) {
188 char *this_operation;
186 - if (opts->subcommand == REPLAY_RESET)
187 - this_operation = "--reset";
189 + if (opts->subcommand == REPLAY_REMOVE_STATE)
190 + this_operation = "--quit";
191 else
192 this_operation = "--continue";
193
@@ -965,7 +968,7 @@ static int pick_revisions(struct replay_opts *opts)
968 * cherry-pick should be handled differently from an existing
969 * one that is being continued
970 */
968 - if (opts->subcommand == REPLAY_RESET) {
971 + if (opts->subcommand == REPLAY_REMOVE_STATE) {
972 remove_sequencer_state(1);
973 return 0;
974 } else if (opts->subcommand == REPLAY_CONTINUE) {
@@ -988,7 +991,7 @@ static int pick_revisions(struct replay_opts *opts)
991 if (create_seq_dir() < 0) {
992 error(_("A cherry-pick or revert is in progress."));
993 advise(_("Use --continue to continue the operation"));
991 - advise(_("or --reset to forget about it"));
994 + advise(_("or --quit to forget about it"));
995 return -1;
996 }
997 if (get_sha1("HEAD", sha1)) {
sequencer.h
+1 -1
@@ -13,7 +13,7 @@
13 *
14 * With the aggressive flag, it additionally removes SEQ_OLD_DIR,
15 * ignoring any errors. Inteded to be used by the sequencer's
16 - * '--reset' subcommand.
16 + * '--quit' subcommand.
17 */
18 void remove_sequencer_state(int aggressive);
19
t/t3510-cherry-pick-sequence.sh
+26 -5
@@ -13,7 +13,7 @@ test_description='Test cherry-pick continuation features
13 . ./test-lib.sh
14
15 pristine_detach () {
16 - git cherry-pick --reset &&
16 + git cherry-pick --quit &&
17 git checkout -f "$1^0" &&
18 git read-tree -u --reset HEAD &&
19 git clean -d -f -f -q -x
@@ -70,18 +70,39 @@ test_expect_success 'cherry-pick cleans up sequencer state upon success' '
70 test_path_is_missing .git/sequencer
71 '
72
73 -test_expect_success '--reset does not complain when no cherry-pick is in progress' '
73 +test_expect_success '--quit does not complain when no cherry-pick is in progress' '
74 pristine_detach initial &&
75 - git cherry-pick --reset
75 + git cherry-pick --quit
76 '
77
78 -test_expect_success '--reset cleans up sequencer state' '
78 +test_expect_success '--quit cleans up sequencer state' '
79 pristine_detach initial &&
80 test_must_fail git cherry-pick base..picked &&
81 - git cherry-pick --reset &&
81 + git cherry-pick --quit &&
82 test_path_is_missing .git/sequencer
83 '
84
85 +test_expect_success 'cherry-pick --reset (another name for --quit)' '
86 + pristine_detach initial &&
87 + cat >expect <<-\EOF &&
88 + OBJID
89 + :100644 100644 OBJID OBJID M unrelated
90 + OBJID
91 + :000000 100644 OBJID OBJID A foo
92 + :000000 100644 OBJID OBJID A unrelated
93 + EOF
94 + test_must_fail git cherry-pick base..picked &&
95 + git cherry-pick --reset &&
96 + test_path_is_missing .git/sequencer &&
97 + test_must_fail git update-index --refresh &&
98 + {
99 + git rev-list HEAD |
100 + git diff-tree --root --stdin |
101 + sed "s/$_x40/OBJID/g"
102 + } >actual &&
103 + test_cmp expect actual
104 +'
105 +
106 test_expect_success 'cherry-pick cleans up sequencer state when one commit is left' '
107 pristine_detach initial &&
108 test_must_fail git cherry-pick base..picked &&
t/t7106-reset-sequence.sh
+1 -1
@@ -12,7 +12,7 @@ test_description='Test interaction of reset --hard with sequencer
12 . ./test-lib.sh
13
14 pristine_detach () {
15 - git cherry-pick --reset &&
15 + git cherry-pick --quit &&
16 git checkout -f "$1^0" &&
17 git read-tree -u --reset HEAD &&
18 git clean -d -f -f -q -x