@@ -71,44 +71,19 @@ static void verify_opt_compatible(const char *me, const char *base_opt, ...)
7171 die (_ ("%s: %s cannot be used with %s" ), me , this_opt , base_opt );
7272}
7373
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-
9774static void parse_args (int argc , const char * * argv , struct replay_opts * opts )
9875{
9976 const char * const * usage_str = revert_or_cherry_pick_usage (opts );
10077 const char * me = action_name (opts );
101- int remove_state = 0 ;
102- int contin = 0 ;
103- int rollback = 0 ;
78+ int cmd = 0 ;
10479 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" )),
11085 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:" )),
11287 OPT_INTEGER ('m' , "mainline" , & opts -> mainline , N_ ("parent number" )),
11388 OPT_RERERE_AUTOUPDATE (& opts -> allow_rerere_auto ),
11489 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)
12499
125100 if (opts -> action == REPLAY_PICK ) {
126101 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" )),
132107 OPT_END (),
133108 };
134109 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)
139114 PARSE_OPT_KEEP_ARGV0 |
140115 PARSE_OPT_KEEP_UNKNOWN );
141116
142- /* Check for incompatible subcommands */
143- verify_opt_mutually_compatible (me ,
144- "--quit" , remove_state ,
145- "--continue" , contin ,
146- "--abort" , rollback ,
147- NULL );
148-
149117 /* implies allow_empty */
150118 if (opts -> keep_redundant_commits )
151119 opts -> allow_empty = 1 ;
152120
153121 /* Set the subcommand */
154- if (remove_state )
122+ if (cmd == 'q' )
155123 opts -> subcommand = REPLAY_REMOVE_STATE ;
156- else if (contin )
124+ else if (cmd == 'c' )
157125 opts -> subcommand = REPLAY_CONTINUE ;
158- else if (rollback )
126+ else if (cmd == 'a' )
159127 opts -> subcommand = REPLAY_ROLLBACK ;
160128 else
161129 opts -> subcommand = REPLAY_NONE ;
0 commit comments