@@ -71,44 +71,19 @@ static void verify_opt_compatible(const char *me, const char *base_opt, ...)
71
71
die (_ ("%s: %s cannot be used with %s" ), me , this_opt , base_opt );
72
72
}
73
73
74
- LAST_ARG_MUST_BE_NULL
75
- static void verify_opt_mutually_compatible (const char * me , ...)
76
- {
77
- const char * opt1 , * opt2 = NULL ;
78
- va_list ap ;
79
-
80
- va_start (ap , me );
81
- while ((opt1 = va_arg (ap , const char * ))) {
82
- if (va_arg (ap , int ))
83
- break ;
84
- }
85
- if (opt1 ) {
86
- while ((opt2 = va_arg (ap , const char * ))) {
87
- if (va_arg (ap , int ))
88
- break ;
89
- }
90
- }
91
- va_end (ap );
92
-
93
- if (opt1 && opt2 )
94
- die (_ ("%s: %s cannot be used with %s" ), me , opt1 , opt2 );
95
- }
96
-
97
74
static void parse_args (int argc , const char * * argv , struct replay_opts * opts )
98
75
{
99
76
const char * const * usage_str = revert_or_cherry_pick_usage (opts );
100
77
const char * me = action_name (opts );
101
- int remove_state = 0 ;
102
- int contin = 0 ;
103
- int rollback = 0 ;
78
+ int cmd = 0 ;
104
79
struct option options [] = {
105
- OPT_BOOLEAN (0 , "quit" , & remove_state , N_ ("end revert or cherry-pick sequence" )),
106
- OPT_BOOLEAN (0 , "continue" , & contin , N_ ("resume revert or cherry-pick sequence" )),
107
- OPT_BOOLEAN (0 , "abort" , & rollback , N_ ("cancel revert or cherry-pick sequence" )),
108
- OPT_BOOLEAN ('n' , "no-commit" , & opts -> no_commit , N_ ("don't automatically commit" )),
109
- OPT_BOOLEAN ('e' , "edit" , & opts -> edit , N_ ("edit the commit message" )),
80
+ OPT_CMDMODE (0 , "quit" , & cmd , N_ ("end revert or cherry-pick sequence" ), 'q' ),
81
+ OPT_CMDMODE (0 , "continue" , & cmd , N_ ("resume revert or cherry-pick sequence" ), 'c' ),
82
+ OPT_CMDMODE (0 , "abort" , & cmd , N_ ("cancel revert or cherry-pick sequence" ), 'a' ),
83
+ OPT_BOOL ('n' , "no-commit" , & opts -> no_commit , N_ ("don't automatically commit" )),
84
+ OPT_BOOL ('e' , "edit" , & opts -> edit , N_ ("edit the commit message" )),
110
85
OPT_NOOP_NOARG ('r' , NULL ),
111
- OPT_BOOLEAN ('s' , "signoff" , & opts -> signoff , N_ ("add Signed-off-by:" )),
86
+ OPT_BOOL ('s' , "signoff" , & opts -> signoff , N_ ("add Signed-off-by:" )),
112
87
OPT_INTEGER ('m' , "mainline" , & opts -> mainline , N_ ("parent number" )),
113
88
OPT_RERERE_AUTOUPDATE (& opts -> allow_rerere_auto ),
114
89
OPT_STRING (0 , "strategy" , & opts -> strategy , N_ ("strategy" ), N_ ("merge strategy" )),
@@ -124,11 +99,11 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
124
99
125
100
if (opts -> action == REPLAY_PICK ) {
126
101
struct option cp_extra [] = {
127
- OPT_BOOLEAN ('x' , NULL , & opts -> record_origin , N_ ("append commit name" )),
128
- OPT_BOOLEAN (0 , "ff" , & opts -> allow_ff , N_ ("allow fast-forward" )),
129
- OPT_BOOLEAN (0 , "allow-empty" , & opts -> allow_empty , N_ ("preserve initially empty commits" )),
130
- OPT_BOOLEAN (0 , "allow-empty-message" , & opts -> allow_empty_message , N_ ("allow commits with empty messages" )),
131
- OPT_BOOLEAN (0 , "keep-redundant-commits" , & opts -> keep_redundant_commits , N_ ("keep redundant, empty commits" )),
102
+ OPT_BOOL ('x' , NULL , & opts -> record_origin , N_ ("append commit name" )),
103
+ OPT_BOOL (0 , "ff" , & opts -> allow_ff , N_ ("allow fast-forward" )),
104
+ OPT_BOOL (0 , "allow-empty" , & opts -> allow_empty , N_ ("preserve initially empty commits" )),
105
+ OPT_BOOL (0 , "allow-empty-message" , & opts -> allow_empty_message , N_ ("allow commits with empty messages" )),
106
+ OPT_BOOL (0 , "keep-redundant-commits" , & opts -> keep_redundant_commits , N_ ("keep redundant, empty commits" )),
132
107
OPT_END (),
133
108
};
134
109
if (parse_options_concat (options , ARRAY_SIZE (options ), cp_extra ))
@@ -139,23 +114,16 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
139
114
PARSE_OPT_KEEP_ARGV0 |
140
115
PARSE_OPT_KEEP_UNKNOWN );
141
116
142
- /* Check for incompatible subcommands */
143
- verify_opt_mutually_compatible (me ,
144
- "--quit" , remove_state ,
145
- "--continue" , contin ,
146
- "--abort" , rollback ,
147
- NULL );
148
-
149
117
/* implies allow_empty */
150
118
if (opts -> keep_redundant_commits )
151
119
opts -> allow_empty = 1 ;
152
120
153
121
/* Set the subcommand */
154
- if (remove_state )
122
+ if (cmd == 'q' )
155
123
opts -> subcommand = REPLAY_REMOVE_STATE ;
156
- else if (contin )
124
+ else if (cmd == 'c' )
157
125
opts -> subcommand = REPLAY_CONTINUE ;
158
- else if (rollback )
126
+ else if (cmd == 'a' )
159
127
opts -> subcommand = REPLAY_ROLLBACK ;
160
128
else
161
129
opts -> subcommand = REPLAY_NONE ;
0 commit comments