@@ -119,6 +119,29 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts)
119
119
return replay ;
120
120
}
121
121
122
+ enum action {
123
+ ACTION_NONE = 0 ,
124
+ ACTION_CONTINUE ,
125
+ ACTION_SKIP ,
126
+ ACTION_ABORT ,
127
+ ACTION_QUIT ,
128
+ ACTION_EDIT_TODO ,
129
+ ACTION_SHOW_CURRENT_PATCH ,
130
+ ACTION_SHORTEN_OIDS ,
131
+ ACTION_EXPAND_OIDS ,
132
+ ACTION_CHECK_TODO_LIST ,
133
+ ACTION_REARRANGE_SQUASH ,
134
+ ACTION_ADD_EXEC
135
+ };
136
+
137
+ static const char * action_names [] = { "undefined" ,
138
+ "continue" ,
139
+ "skip" ,
140
+ "abort" ,
141
+ "quit" ,
142
+ "edit_todo" ,
143
+ "show_current_patch" };
144
+
122
145
static int add_exec_commands (struct string_list * commands )
123
146
{
124
147
const char * todo_file = rebase_path_todo ();
@@ -347,10 +370,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
347
370
unsigned flags = 0 ;
348
371
int abbreviate_commands = 0 , ret = 0 ;
349
372
struct object_id squash_onto = null_oid ;
350
- enum {
351
- NONE = 0 , CONTINUE , SKIP , EDIT_TODO , SHOW_CURRENT_PATCH ,
352
- SHORTEN_OIDS , EXPAND_OIDS , CHECK_TODO_LIST , REARRANGE_SQUASH , ADD_EXEC
353
- } command = 0 ;
373
+ enum action command = ACTION_NONE ;
354
374
struct option options [] = {
355
375
OPT_NEGBIT (0 , "ff" , & opts .flags , N_ ("allow fast-forward" ),
356
376
REBASE_FORCE ),
@@ -367,22 +387,22 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
367
387
N_ ("display a diffstat of what changed upstream" ),
368
388
REBASE_NO_QUIET | REBASE_VERBOSE | REBASE_DIFFSTAT ),
369
389
OPT_CMDMODE (0 , "continue" , & command , N_ ("continue rebase" ),
370
- CONTINUE ),
371
- OPT_CMDMODE (0 , "skip" , & command , N_ ("skip commit" ), SKIP ),
390
+ ACTION_CONTINUE ),
391
+ OPT_CMDMODE (0 , "skip" , & command , N_ ("skip commit" ), ACTION_SKIP ),
372
392
OPT_CMDMODE (0 , "edit-todo" , & command , N_ ("edit the todo list" ),
373
- EDIT_TODO ),
393
+ ACTION_EDIT_TODO ),
374
394
OPT_CMDMODE (0 , "show-current-patch" , & command , N_ ("show the current patch" ),
375
- SHOW_CURRENT_PATCH ),
395
+ ACTION_SHOW_CURRENT_PATCH ),
376
396
OPT_CMDMODE (0 , "shorten-ids" , & command ,
377
- N_ ("shorten commit ids in the todo list" ), SHORTEN_OIDS ),
397
+ N_ ("shorten commit ids in the todo list" ), ACTION_SHORTEN_OIDS ),
378
398
OPT_CMDMODE (0 , "expand-ids" , & command ,
379
- N_ ("expand commit ids in the todo list" ), EXPAND_OIDS ),
399
+ N_ ("expand commit ids in the todo list" ), ACTION_EXPAND_OIDS ),
380
400
OPT_CMDMODE (0 , "check-todo-list" , & command ,
381
- N_ ("check the todo list" ), CHECK_TODO_LIST ),
401
+ N_ ("check the todo list" ), ACTION_CHECK_TODO_LIST ),
382
402
OPT_CMDMODE (0 , "rearrange-squash" , & command ,
383
- N_ ("rearrange fixup/squash lines" ), REARRANGE_SQUASH ),
403
+ N_ ("rearrange fixup/squash lines" ), ACTION_REARRANGE_SQUASH ),
384
404
OPT_CMDMODE (0 , "add-exec-commands" , & command ,
385
- N_ ("insert exec commands in todo list" ), ADD_EXEC ),
405
+ N_ ("insert exec commands in todo list" ), ACTION_ADD_EXEC ),
386
406
{ OPTION_CALLBACK , 0 , "onto" , & opts .onto , N_ ("onto" ), N_ ("onto" ),
387
407
PARSE_OPT_NONEG , parse_opt_commit , 0 },
388
408
{ OPTION_CALLBACK , 0 , "restrict-revision" , & opts .restrict_revision ,
@@ -428,36 +448,36 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
428
448
flags |= abbreviate_commands ? TODO_LIST_ABBREVIATE_CMDS : 0 ;
429
449
flags |= opts .rebase_merges ? TODO_LIST_REBASE_MERGES : 0 ;
430
450
flags |= opts .rebase_cousins > 0 ? TODO_LIST_REBASE_COUSINS : 0 ;
431
- flags |= command == SHORTEN_OIDS ? TODO_LIST_SHORTEN_IDS : 0 ;
451
+ flags |= command == ACTION_SHORTEN_OIDS ? TODO_LIST_SHORTEN_IDS : 0 ;
432
452
433
453
if (opts .rebase_cousins >= 0 && !opts .rebase_merges )
434
454
warning (_ ("--[no-]rebase-cousins has no effect without "
435
455
"--rebase-merges" ));
436
456
437
457
switch (command ) {
438
- case NONE : {
458
+ case ACTION_NONE : {
439
459
if (!opts .onto && !opts .upstream )
440
460
die (_ ("a base commit must be provided with --upstream or --onto" ));
441
461
442
462
ret = do_interactive_rebase (& opts , flags );
443
463
break ;
444
464
}
445
- case SKIP : {
465
+ case ACTION_SKIP : {
446
466
struct string_list merge_rr = STRING_LIST_INIT_DUP ;
447
467
448
468
rerere_clear (the_repository , & merge_rr );
449
469
}
450
470
/* fallthrough */
451
- case CONTINUE : {
471
+ case ACTION_CONTINUE : {
452
472
struct replay_opts replay_opts = get_replay_opts (& opts );
453
473
454
474
ret = sequencer_continue (the_repository , & replay_opts );
455
475
break ;
456
476
}
457
- case EDIT_TODO :
477
+ case ACTION_EDIT_TODO :
458
478
ret = edit_todo_file (flags );
459
479
break ;
460
- case SHOW_CURRENT_PATCH : {
480
+ case ACTION_SHOW_CURRENT_PATCH : {
461
481
struct child_process cmd = CHILD_PROCESS_INIT ;
462
482
463
483
cmd .git_cmd = 1 ;
@@ -466,17 +486,17 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
466
486
467
487
break ;
468
488
}
469
- case SHORTEN_OIDS :
470
- case EXPAND_OIDS :
489
+ case ACTION_SHORTEN_OIDS :
490
+ case ACTION_EXPAND_OIDS :
471
491
ret = transform_todo_file (flags );
472
492
break ;
473
- case CHECK_TODO_LIST :
493
+ case ACTION_CHECK_TODO_LIST :
474
494
ret = check_todo_list_from_file (the_repository );
475
495
break ;
476
- case REARRANGE_SQUASH :
496
+ case ACTION_REARRANGE_SQUASH :
477
497
ret = rearrange_squash_in_todo_file ();
478
498
break ;
479
- case ADD_EXEC : {
499
+ case ACTION_ADD_EXEC : {
480
500
struct string_list commands = STRING_LIST_INIT_DUP ;
481
501
482
502
split_exec_commands (opts .cmd , & commands );
@@ -1417,22 +1437,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1417
1437
struct strbuf revisions = STRBUF_INIT ;
1418
1438
struct strbuf buf = STRBUF_INIT ;
1419
1439
struct object_id merge_base ;
1420
- enum {
1421
- NO_ACTION ,
1422
- ACTION_CONTINUE ,
1423
- ACTION_SKIP ,
1424
- ACTION_ABORT ,
1425
- ACTION_QUIT ,
1426
- ACTION_EDIT_TODO ,
1427
- ACTION_SHOW_CURRENT_PATCH ,
1428
- } action = NO_ACTION ;
1429
- static const char * action_names [] = { "undefined" ,
1430
- "continue" ,
1431
- "skip" ,
1432
- "abort" ,
1433
- "quit" ,
1434
- "edit_todo" ,
1435
- "show_current_patch" };
1440
+ enum action action = ACTION_NONE ;
1436
1441
const char * gpg_sign = NULL ;
1437
1442
struct string_list exec = STRING_LIST_INIT_NODUP ;
1438
1443
const char * rebase_merges = NULL ;
@@ -1599,7 +1604,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1599
1604
builtin_rebase_options ,
1600
1605
builtin_rebase_usage , 0 );
1601
1606
1602
- if (action != NO_ACTION && total_argc != 2 ) {
1607
+ if (action != ACTION_NONE && total_argc != 2 ) {
1603
1608
usage_with_options (builtin_rebase_usage ,
1604
1609
builtin_rebase_options );
1605
1610
}
@@ -1608,7 +1613,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1608
1613
usage_with_options (builtin_rebase_usage ,
1609
1614
builtin_rebase_options );
1610
1615
1611
- if (action != NO_ACTION && !in_progress )
1616
+ if (action != ACTION_NONE && !in_progress )
1612
1617
die (_ ("No rebase in progress?" ));
1613
1618
setenv (GIT_REFLOG_ACTION_ENVIRONMENT , "rebase" , 0 );
1614
1619
@@ -1708,7 +1713,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1708
1713
options .action = "show-current-patch" ;
1709
1714
options .dont_finish_rebase = 1 ;
1710
1715
goto run_rebase ;
1711
- case NO_ACTION :
1716
+ case ACTION_NONE :
1712
1717
break ;
1713
1718
default :
1714
1719
BUG ("action: %d" , action );
0 commit comments