Skip to content

Commit f80a872

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0f64a5a commit f80a872

File tree

7 files changed

+49
-25
lines changed

7 files changed

+49
-25
lines changed

Documentation/git-cherry-pick.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>...
12-
'git cherry-pick' --reset
1312
'git cherry-pick' --continue
13+
'git cherry-pick' --quit
1414

1515
DESCRIPTION
1616
-----------

Documentation/git-revert.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>...
12-
'git revert' --reset
1312
'git revert' --continue
13+
'git revert' --quit
1414

1515
DESCRIPTION
1616
-----------

Documentation/sequencer.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
61
--continue::
72
Continue the operation in progress using the information in
83
'.git/sequencer'. Can be used to continue after resolving
94
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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static const char * const cherry_pick_usage[] = {
4040
};
4141

4242
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 };
4444

4545
struct replay_opts {
4646
enum replay_action action;
@@ -133,11 +133,11 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
133133
{
134134
const char * const * usage_str = revert_or_cherry_pick_usage(opts);
135135
const char *me = action_name(opts);
136-
int reset = 0;
136+
int remove_state = 0;
137137
int contin = 0;
138138
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"),
141141
OPT_BOOLEAN('n', "no-commit", &opts->no_commit, "don't automatically commit"),
142142
OPT_BOOLEAN('e', "edit", &opts->edit, "edit the commit message"),
143143
OPT_NOOP_NOARG('r', NULL),
@@ -147,6 +147,9 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
147147
OPT_STRING(0, "strategy", &opts->strategy, "strategy", "merge strategy"),
148148
OPT_CALLBACK('X', "strategy-option", &opts, "option",
149149
"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 },
150153
OPT_END(),
151154
OPT_END(),
152155
OPT_END(),
@@ -168,13 +171,13 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
168171

169172
/* Check for incompatible subcommands */
170173
verify_opt_mutually_compatible(me,
171-
"--reset", reset,
174+
"--quit", remove_state,
172175
"--continue", contin,
173176
NULL);
174177

175178
/* Set the subcommand */
176-
if (reset)
177-
opts->subcommand = REPLAY_RESET;
179+
if (remove_state)
180+
opts->subcommand = REPLAY_REMOVE_STATE;
178181
else if (contin)
179182
opts->subcommand = REPLAY_CONTINUE;
180183
else
@@ -183,8 +186,8 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
183186
/* Check for incompatible command line arguments */
184187
if (opts->subcommand != REPLAY_NONE) {
185188
char *this_operation;
186-
if (opts->subcommand == REPLAY_RESET)
187-
this_operation = "--reset";
189+
if (opts->subcommand == REPLAY_REMOVE_STATE)
190+
this_operation = "--quit";
188191
else
189192
this_operation = "--continue";
190193

@@ -965,7 +968,7 @@ static int pick_revisions(struct replay_opts *opts)
965968
* cherry-pick should be handled differently from an existing
966969
* one that is being continued
967970
*/
968-
if (opts->subcommand == REPLAY_RESET) {
971+
if (opts->subcommand == REPLAY_REMOVE_STATE) {
969972
remove_sequencer_state(1);
970973
return 0;
971974
} else if (opts->subcommand == REPLAY_CONTINUE) {
@@ -988,7 +991,7 @@ static int pick_revisions(struct replay_opts *opts)
988991
if (create_seq_dir() < 0) {
989992
error(_("A cherry-pick or revert is in progress."));
990993
advise(_("Use --continue to continue the operation"));
991-
advise(_("or --reset to forget about it"));
994+
advise(_("or --quit to forget about it"));
992995
return -1;
993996
}
994997
if (get_sha1("HEAD", sha1)) {

sequencer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* With the aggressive flag, it additionally removes SEQ_OLD_DIR,
1515
* ignoring any errors. Inteded to be used by the sequencer's
16-
* '--reset' subcommand.
16+
* '--quit' subcommand.
1717
*/
1818
void remove_sequencer_state(int aggressive);
1919

t/t3510-cherry-pick-sequence.sh

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test_description='Test cherry-pick continuation features
1313
. ./test-lib.sh
1414

1515
pristine_detach () {
16-
git cherry-pick --reset &&
16+
git cherry-pick --quit &&
1717
git checkout -f "$1^0" &&
1818
git read-tree -u --reset HEAD &&
1919
git clean -d -f -f -q -x
@@ -70,18 +70,39 @@ test_expect_success 'cherry-pick cleans up sequencer state upon success' '
7070
test_path_is_missing .git/sequencer
7171
'
7272

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' '
7474
pristine_detach initial &&
75-
git cherry-pick --reset
75+
git cherry-pick --quit
7676
'
7777

78-
test_expect_success '--reset cleans up sequencer state' '
78+
test_expect_success '--quit cleans up sequencer state' '
7979
pristine_detach initial &&
8080
test_must_fail git cherry-pick base..picked &&
81-
git cherry-pick --reset &&
81+
git cherry-pick --quit &&
8282
test_path_is_missing .git/sequencer
8383
'
8484

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+
85106
test_expect_success 'cherry-pick cleans up sequencer state when one commit is left' '
86107
pristine_detach initial &&
87108
test_must_fail git cherry-pick base..picked &&

t/t7106-reset-sequence.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test_description='Test interaction of reset --hard with sequencer
1212
. ./test-lib.sh
1313

1414
pristine_detach () {
15-
git cherry-pick --reset &&
15+
git cherry-pick --quit &&
1616
git checkout -f "$1^0" &&
1717
git read-tree -u --reset HEAD &&
1818
git clean -d -f -f -q -x

0 commit comments

Comments
 (0)