@@ -59,6 +59,26 @@ enum empty_type {
59
59
EMPTY_ASK
60
60
};
61
61
62
+ enum action {
63
+ ACTION_NONE = 0 ,
64
+ ACTION_CONTINUE ,
65
+ ACTION_SKIP ,
66
+ ACTION_ABORT ,
67
+ ACTION_QUIT ,
68
+ ACTION_EDIT_TODO ,
69
+ ACTION_SHOW_CURRENT_PATCH
70
+ };
71
+
72
+ static const char * action_names [] = {
73
+ "undefined" ,
74
+ "continue" ,
75
+ "skip" ,
76
+ "abort" ,
77
+ "quit" ,
78
+ "edit_todo" ,
79
+ "show_current_patch"
80
+ };
81
+
62
82
struct rebase_options {
63
83
enum rebase_type type ;
64
84
enum empty_type empty ;
@@ -85,7 +105,7 @@ struct rebase_options {
85
105
REBASE_INTERACTIVE_EXPLICIT = 1 <<4 ,
86
106
} flags ;
87
107
struct strvec git_am_opts ;
88
- const char * action ;
108
+ enum action action ;
89
109
int signoff ;
90
110
int allow_rerere_autoupdate ;
91
111
int keep_empty ;
@@ -156,24 +176,6 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts)
156
176
return replay ;
157
177
}
158
178
159
- enum action {
160
- ACTION_NONE = 0 ,
161
- ACTION_CONTINUE ,
162
- ACTION_SKIP ,
163
- ACTION_ABORT ,
164
- ACTION_QUIT ,
165
- ACTION_EDIT_TODO ,
166
- ACTION_SHOW_CURRENT_PATCH
167
- };
168
-
169
- static const char * action_names [] = { "undefined" ,
170
- "continue" ,
171
- "skip" ,
172
- "abort" ,
173
- "quit" ,
174
- "edit_todo" ,
175
- "show_current_patch" };
176
-
177
179
static int edit_todo_file (unsigned flags )
178
180
{
179
181
const char * todo_file = rebase_path_todo ();
@@ -310,8 +312,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
310
312
return ret ;
311
313
}
312
314
313
- static int run_sequencer_rebase (struct rebase_options * opts ,
314
- enum action command )
315
+ static int run_sequencer_rebase (struct rebase_options * opts )
315
316
{
316
317
unsigned flags = 0 ;
317
318
int abbreviate_commands = 0 , ret = 0 ;
@@ -326,7 +327,7 @@ static int run_sequencer_rebase(struct rebase_options *opts,
326
327
flags |= opts -> reapply_cherry_picks ? TODO_LIST_REAPPLY_CHERRY_PICKS : 0 ;
327
328
flags |= opts -> flags & REBASE_NO_QUIET ? TODO_LIST_WARN_SKIPPED_CHERRY_PICKS : 0 ;
328
329
329
- switch (command ) {
330
+ switch (opts -> action ) {
330
331
case ACTION_NONE : {
331
332
if (!opts -> onto && !opts -> upstream )
332
333
die (_ ("a base commit must be provided with --upstream or --onto" ));
@@ -359,7 +360,7 @@ static int run_sequencer_rebase(struct rebase_options *opts,
359
360
break ;
360
361
}
361
362
default :
362
- BUG ("invalid command '%d'" , command );
363
+ BUG ("invalid command '%d'" , opts -> action );
363
364
}
364
365
365
366
return ret ;
@@ -617,7 +618,7 @@ static int run_am(struct rebase_options *opts)
617
618
strvec_push (& am .args , "am" );
618
619
strvec_pushf (& am .env , GIT_REFLOG_ACTION_ENVIRONMENT "=%s (pick)" ,
619
620
getenv (GIT_REFLOG_ACTION_ENVIRONMENT ));
620
- if (opts -> action && ! strcmp ( "continue" , opts -> action ) ) {
621
+ if (opts -> action == ACTION_CONTINUE ) {
621
622
strvec_push (& am .args , "--resolved" );
622
623
strvec_pushf (& am .args , "--resolvemsg=%s" , resolvemsg );
623
624
if (opts -> gpg_sign_opt )
@@ -628,7 +629,7 @@ static int run_am(struct rebase_options *opts)
628
629
629
630
return move_to_original_branch (opts );
630
631
}
631
- if (opts -> action && ! strcmp ( "skip" , opts -> action ) ) {
632
+ if (opts -> action == ACTION_SKIP ) {
632
633
strvec_push (& am .args , "--skip" );
633
634
strvec_pushf (& am .args , "--resolvemsg=%s" , resolvemsg );
634
635
status = run_command (& am );
@@ -637,7 +638,7 @@ static int run_am(struct rebase_options *opts)
637
638
638
639
return move_to_original_branch (opts );
639
640
}
640
- if (opts -> action && ! strcmp ( "show-current-patch" , opts -> action ) ) {
641
+ if (opts -> action == ACTION_SHOW_CURRENT_PATCH ) {
641
642
strvec_push (& am .args , "--show-current-patch" );
642
643
return run_command (& am );
643
644
}
@@ -730,7 +731,7 @@ static int run_am(struct rebase_options *opts)
730
731
return status ;
731
732
}
732
733
733
- static int run_specific_rebase (struct rebase_options * opts , enum action action )
734
+ static int run_specific_rebase (struct rebase_options * opts )
734
735
{
735
736
int status ;
736
737
@@ -748,7 +749,7 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action)
748
749
opts -> gpg_sign_opt = tmp ;
749
750
}
750
751
751
- status = run_sequencer_rebase (opts , action );
752
+ status = run_sequencer_rebase (opts );
752
753
} else if (opts -> type == REBASE_APPLY )
753
754
status = run_am (opts );
754
755
else
@@ -1025,7 +1026,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1025
1026
struct strbuf buf = STRBUF_INIT ;
1026
1027
struct object_id branch_base ;
1027
1028
int ignore_whitespace = 0 ;
1028
- enum action action = ACTION_NONE ;
1029
1029
const char * gpg_sign = NULL ;
1030
1030
struct string_list exec = STRING_LIST_INIT_NODUP ;
1031
1031
const char * rebase_merges = NULL ;
@@ -1074,18 +1074,18 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1074
1074
OPT_BIT (0 , "no-ff" , & options .flags ,
1075
1075
N_ ("cherry-pick all commits, even if unchanged" ),
1076
1076
REBASE_FORCE ),
1077
- OPT_CMDMODE (0 , "continue" , & action , N_ ("continue" ),
1077
+ OPT_CMDMODE (0 , "continue" , & options . action , N_ ("continue" ),
1078
1078
ACTION_CONTINUE ),
1079
- OPT_CMDMODE (0 , "skip" , & action ,
1079
+ OPT_CMDMODE (0 , "skip" , & options . action ,
1080
1080
N_ ("skip current patch and continue" ), ACTION_SKIP ),
1081
- OPT_CMDMODE (0 , "abort" , & action ,
1081
+ OPT_CMDMODE (0 , "abort" , & options . action ,
1082
1082
N_ ("abort and check out the original branch" ),
1083
1083
ACTION_ABORT ),
1084
- OPT_CMDMODE (0 , "quit" , & action ,
1084
+ OPT_CMDMODE (0 , "quit" , & options . action ,
1085
1085
N_ ("abort but keep HEAD where it is" ), ACTION_QUIT ),
1086
- OPT_CMDMODE (0 , "edit-todo" , & action , N_ ("edit the todo list "
1086
+ OPT_CMDMODE (0 , "edit-todo" , & options . action , N_ ("edit the todo list "
1087
1087
"during an interactive rebase" ), ACTION_EDIT_TODO ),
1088
- OPT_CMDMODE (0 , "show-current-patch" , & action ,
1088
+ OPT_CMDMODE (0 , "show-current-patch" , & options . action ,
1089
1089
N_ ("show the patch file being applied or merged" ),
1090
1090
ACTION_SHOW_CURRENT_PATCH ),
1091
1091
OPT_CALLBACK_F (0 , "apply" , & options , NULL ,
@@ -1174,7 +1174,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1174
1174
} else if (is_directory (merge_dir ())) {
1175
1175
strbuf_reset (& buf );
1176
1176
strbuf_addf (& buf , "%s/rewritten" , merge_dir ());
1177
- if (!(action == ACTION_ABORT ) && is_directory (buf .buf )) {
1177
+ if (!(options . action == ACTION_ABORT ) && is_directory (buf .buf )) {
1178
1178
die (_ ("`rebase --preserve-merges` (-p) is no longer supported.\n"
1179
1179
"Use `git rebase --abort` to terminate current rebase.\n"
1180
1180
"Or downgrade to v2.33, or earlier, to complete the rebase." ));
@@ -1201,7 +1201,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1201
1201
"Note: Your `pull.rebase` configuration may also be set to 'preserve',\n"
1202
1202
"which is no longer supported; use 'merges' instead" ));
1203
1203
1204
- if (action != ACTION_NONE && total_argc != 2 ) {
1204
+ if (options . action != ACTION_NONE && total_argc != 2 ) {
1205
1205
usage_with_options (builtin_rebase_usage ,
1206
1206
builtin_rebase_options );
1207
1207
}
@@ -1232,11 +1232,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1232
1232
if (options .root && options .fork_point > 0 )
1233
1233
die (_ ("options '%s' and '%s' cannot be used together" ), "--root" , "--fork-point" );
1234
1234
1235
- if (action != ACTION_NONE && !in_progress )
1235
+ if (options . action != ACTION_NONE && !in_progress )
1236
1236
die (_ ("No rebase in progress?" ));
1237
1237
setenv (GIT_REFLOG_ACTION_ENVIRONMENT , "rebase" , 0 );
1238
1238
1239
- if (action == ACTION_EDIT_TODO && !is_merge (& options ))
1239
+ if (options . action == ACTION_EDIT_TODO && !is_merge (& options ))
1240
1240
die (_ ("The --edit-todo action can only be used during "
1241
1241
"interactive rebase." ));
1242
1242
@@ -1246,16 +1246,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1246
1246
else if (exec .nr )
1247
1247
trace2_cmd_mode ("interactive-exec" );
1248
1248
else
1249
- trace2_cmd_mode (action_names [action ]);
1249
+ trace2_cmd_mode (action_names [options . action ]);
1250
1250
}
1251
1251
1252
- switch (action ) {
1252
+ switch (options . action ) {
1253
1253
case ACTION_CONTINUE : {
1254
1254
struct object_id head ;
1255
1255
struct lock_file lock_file = LOCK_INIT ;
1256
1256
int fd ;
1257
1257
1258
- options .action = "continue" ;
1259
1258
/* Sanity check */
1260
1259
if (get_oid ("HEAD" , & head ))
1261
1260
die (_ ("Cannot read HEAD" ));
@@ -1281,7 +1280,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1281
1280
case ACTION_SKIP : {
1282
1281
struct string_list merge_rr = STRING_LIST_INIT_DUP ;
1283
1282
1284
- options .action = "skip" ;
1285
1283
rerere_clear (the_repository , & merge_rr );
1286
1284
string_list_clear (& merge_rr , 1 );
1287
1285
ropts .flags = RESET_HEAD_HARD ;
@@ -1296,7 +1294,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1296
1294
struct string_list merge_rr = STRING_LIST_INIT_DUP ;
1297
1295
struct strbuf head_msg = STRBUF_INIT ;
1298
1296
1299
- options .action = "abort" ;
1300
1297
rerere_clear (the_repository , & merge_rr );
1301
1298
string_list_clear (& merge_rr , 1 );
1302
1299
@@ -1336,17 +1333,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1336
1333
goto cleanup ;
1337
1334
}
1338
1335
case ACTION_EDIT_TODO :
1339
- options .action = "edit-todo" ;
1340
1336
options .dont_finish_rebase = 1 ;
1341
1337
goto run_rebase ;
1342
1338
case ACTION_SHOW_CURRENT_PATCH :
1343
- options .action = "show-current-patch" ;
1344
1339
options .dont_finish_rebase = 1 ;
1345
1340
goto run_rebase ;
1346
1341
case ACTION_NONE :
1347
1342
break ;
1348
1343
default :
1349
- BUG ("action: %d" , action );
1344
+ BUG ("action: %d" , options . action );
1350
1345
}
1351
1346
1352
1347
/* Make sure no rebase is in progress */
@@ -1370,7 +1365,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1370
1365
}
1371
1366
1372
1367
if ((options .flags & REBASE_INTERACTIVE_EXPLICIT ) ||
1373
- (action != ACTION_NONE ) ||
1368
+ (options . action != ACTION_NONE ) ||
1374
1369
(exec .nr > 0 ) ||
1375
1370
options .autosquash ) {
1376
1371
allow_preemptive_ff = 0 ;
@@ -1815,7 +1810,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1815
1810
options .revisions = revisions .buf ;
1816
1811
1817
1812
run_rebase :
1818
- ret = run_specific_rebase (& options , action );
1813
+ ret = run_specific_rebase (& options );
1819
1814
1820
1815
cleanup :
1821
1816
strbuf_release (& buf );
0 commit comments