@@ -142,81 +142,6 @@ static const char *action_names[] = { "undefined",
142
142
"edit_todo" ,
143
143
"show_current_patch" };
144
144
145
- static int add_exec_commands (struct string_list * commands )
146
- {
147
- const char * todo_file = rebase_path_todo ();
148
- struct todo_list todo_list = TODO_LIST_INIT ;
149
- int res ;
150
-
151
- if (strbuf_read_file (& todo_list .buf , todo_file , 0 ) < 0 )
152
- return error_errno (_ ("could not read '%s'." ), todo_file );
153
-
154
- if (todo_list_parse_insn_buffer (the_repository , todo_list .buf .buf ,
155
- & todo_list )) {
156
- todo_list_release (& todo_list );
157
- return error (_ ("unusable todo list: '%s'" ), todo_file );
158
- }
159
-
160
- todo_list_add_exec_commands (& todo_list , commands );
161
- res = todo_list_write_to_file (the_repository , & todo_list ,
162
- todo_file , NULL , NULL , -1 , 0 );
163
- todo_list_release (& todo_list );
164
-
165
- if (res )
166
- return error_errno (_ ("could not write '%s'." ), todo_file );
167
- return 0 ;
168
- }
169
-
170
- static int rearrange_squash_in_todo_file (void )
171
- {
172
- const char * todo_file = rebase_path_todo ();
173
- struct todo_list todo_list = TODO_LIST_INIT ;
174
- int res = 0 ;
175
-
176
- if (strbuf_read_file (& todo_list .buf , todo_file , 0 ) < 0 )
177
- return error_errno (_ ("could not read '%s'." ), todo_file );
178
- if (todo_list_parse_insn_buffer (the_repository , todo_list .buf .buf ,
179
- & todo_list )) {
180
- todo_list_release (& todo_list );
181
- return error (_ ("unusable todo list: '%s'" ), todo_file );
182
- }
183
-
184
- res = todo_list_rearrange_squash (& todo_list );
185
- if (!res )
186
- res = todo_list_write_to_file (the_repository , & todo_list ,
187
- todo_file , NULL , NULL , -1 , 0 );
188
-
189
- todo_list_release (& todo_list );
190
-
191
- if (res )
192
- return error_errno (_ ("could not write '%s'." ), todo_file );
193
- return 0 ;
194
- }
195
-
196
- static int transform_todo_file (unsigned flags )
197
- {
198
- const char * todo_file = rebase_path_todo ();
199
- struct todo_list todo_list = TODO_LIST_INIT ;
200
- int res ;
201
-
202
- if (strbuf_read_file (& todo_list .buf , todo_file , 0 ) < 0 )
203
- return error_errno (_ ("could not read '%s'." ), todo_file );
204
-
205
- if (todo_list_parse_insn_buffer (the_repository , todo_list .buf .buf ,
206
- & todo_list )) {
207
- todo_list_release (& todo_list );
208
- return error (_ ("unusable todo list: '%s'" ), todo_file );
209
- }
210
-
211
- res = todo_list_write_to_file (the_repository , & todo_list , todo_file ,
212
- NULL , NULL , -1 , flags );
213
- todo_list_release (& todo_list );
214
-
215
- if (res )
216
- return error_errno (_ ("could not write '%s'." ), todo_file );
217
- return 0 ;
218
- }
219
-
220
145
static int edit_todo_file (unsigned flags )
221
146
{
222
147
const char * todo_file = rebase_path_todo ();
@@ -408,119 +333,13 @@ static int run_rebase_interactive(struct rebase_options *opts,
408
333
409
334
break ;
410
335
}
411
- case ACTION_SHORTEN_OIDS :
412
- case ACTION_EXPAND_OIDS :
413
- ret = transform_todo_file (flags );
414
- break ;
415
- case ACTION_CHECK_TODO_LIST :
416
- ret = check_todo_list_from_file (the_repository );
417
- break ;
418
- case ACTION_REARRANGE_SQUASH :
419
- ret = rearrange_squash_in_todo_file ();
420
- break ;
421
- case ACTION_ADD_EXEC : {
422
- struct string_list commands = STRING_LIST_INIT_DUP ;
423
-
424
- split_exec_commands (opts -> cmd , & commands );
425
- ret = add_exec_commands (& commands );
426
- string_list_clear (& commands , 0 );
427
- break ;
428
- }
429
336
default :
430
337
BUG ("invalid command '%d'" , command );
431
338
}
432
339
433
340
return ret ;
434
341
}
435
342
436
- static const char * const builtin_rebase_interactive_usage [] = {
437
- N_ ("git rebase--interactive [<options>]" ),
438
- NULL
439
- };
440
-
441
- int cmd_rebase__interactive (int argc , const char * * argv , const char * prefix )
442
- {
443
- struct rebase_options opts = REBASE_OPTIONS_INIT ;
444
- struct object_id squash_onto = null_oid ;
445
- enum action command = ACTION_NONE ;
446
- struct option options [] = {
447
- OPT_NEGBIT (0 , "ff" , & opts .flags , N_ ("allow fast-forward" ),
448
- REBASE_FORCE ),
449
- OPT_BOOL (0 , "keep-empty" , & opts .keep_empty , N_ ("keep empty commits" )),
450
- OPT_BOOL (0 , "allow-empty-message" , & opts .allow_empty_message ,
451
- N_ ("allow commits with empty messages" )),
452
- OPT_BOOL (0 , "rebase-merges" , & opts .rebase_merges , N_ ("rebase merge commits" )),
453
- OPT_BOOL (0 , "rebase-cousins" , & opts .rebase_cousins ,
454
- N_ ("keep original branch points of cousins" )),
455
- OPT_BOOL (0 , "autosquash" , & opts .autosquash ,
456
- N_ ("move commits that begin with squash!/fixup!" )),
457
- OPT_BOOL (0 , "signoff" , & opts .signoff , N_ ("sign commits" )),
458
- OPT_BIT ('v' , "verbose" , & opts .flags ,
459
- N_ ("display a diffstat of what changed upstream" ),
460
- REBASE_NO_QUIET | REBASE_VERBOSE | REBASE_DIFFSTAT ),
461
- OPT_CMDMODE (0 , "continue" , & command , N_ ("continue rebase" ),
462
- ACTION_CONTINUE ),
463
- OPT_CMDMODE (0 , "skip" , & command , N_ ("skip commit" ), ACTION_SKIP ),
464
- OPT_CMDMODE (0 , "edit-todo" , & command , N_ ("edit the todo list" ),
465
- ACTION_EDIT_TODO ),
466
- OPT_CMDMODE (0 , "show-current-patch" , & command , N_ ("show the current patch" ),
467
- ACTION_SHOW_CURRENT_PATCH ),
468
- OPT_CMDMODE (0 , "shorten-ids" , & command ,
469
- N_ ("shorten commit ids in the todo list" ), ACTION_SHORTEN_OIDS ),
470
- OPT_CMDMODE (0 , "expand-ids" , & command ,
471
- N_ ("expand commit ids in the todo list" ), ACTION_EXPAND_OIDS ),
472
- OPT_CMDMODE (0 , "check-todo-list" , & command ,
473
- N_ ("check the todo list" ), ACTION_CHECK_TODO_LIST ),
474
- OPT_CMDMODE (0 , "rearrange-squash" , & command ,
475
- N_ ("rearrange fixup/squash lines" ), ACTION_REARRANGE_SQUASH ),
476
- OPT_CMDMODE (0 , "add-exec-commands" , & command ,
477
- N_ ("insert exec commands in todo list" ), ACTION_ADD_EXEC ),
478
- { OPTION_CALLBACK , 0 , "onto" , & opts .onto , N_ ("onto" ), N_ ("onto" ),
479
- PARSE_OPT_NONEG , parse_opt_commit , 0 },
480
- { OPTION_CALLBACK , 0 , "restrict-revision" , & opts .restrict_revision ,
481
- N_ ("restrict-revision" ), N_ ("restrict revision" ),
482
- PARSE_OPT_NONEG , parse_opt_commit , 0 },
483
- { OPTION_CALLBACK , 0 , "squash-onto" , & squash_onto , N_ ("squash-onto" ),
484
- N_ ("squash onto" ), PARSE_OPT_NONEG , parse_opt_object_id , 0 },
485
- { OPTION_CALLBACK , 0 , "upstream" , & opts .upstream , N_ ("upstream" ),
486
- N_ ("the upstream commit" ), PARSE_OPT_NONEG , parse_opt_commit ,
487
- 0 },
488
- OPT_STRING (0 , "head-name" , & opts .head_name , N_ ("head-name" ), N_ ("head name" )),
489
- { OPTION_STRING , 'S' , "gpg-sign" , & opts .gpg_sign_opt , N_ ("key-id" ),
490
- N_ ("GPG-sign commits" ),
491
- PARSE_OPT_OPTARG , NULL , (intptr_t ) "" },
492
- OPT_STRING (0 , "strategy" , & opts .strategy , N_ ("strategy" ),
493
- N_ ("rebase strategy" )),
494
- OPT_STRING (0 , "strategy-opts" , & opts .strategy_opts , N_ ("strategy-opts" ),
495
- N_ ("strategy options" )),
496
- OPT_STRING (0 , "switch-to" , & opts .switch_to , N_ ("switch-to" ),
497
- N_ ("the branch or commit to checkout" )),
498
- OPT_STRING (0 , "onto-name" , & opts .onto_name , N_ ("onto-name" ), N_ ("onto name" )),
499
- OPT_STRING (0 , "cmd" , & opts .cmd , N_ ("cmd" ), N_ ("the command to run" )),
500
- OPT_RERERE_AUTOUPDATE (& opts .allow_rerere_autoupdate ),
501
- OPT_BOOL (0 , "reschedule-failed-exec" , & opts .reschedule_failed_exec ,
502
- N_ ("automatically re-schedule any `exec` that fails" )),
503
- OPT_END ()
504
- };
505
-
506
- opts .rebase_cousins = -1 ;
507
-
508
- if (argc == 1 )
509
- usage_with_options (builtin_rebase_interactive_usage , options );
510
-
511
- argc = parse_options (argc , argv , prefix , options ,
512
- builtin_rebase_interactive_usage , PARSE_OPT_KEEP_ARGV0 );
513
-
514
- if (!is_null_oid (& squash_onto ))
515
- opts .squash_onto = & squash_onto ;
516
-
517
- if (opts .rebase_cousins >= 0 && !opts .rebase_merges )
518
- warning (_ ("--[no-]rebase-cousins has no effect without "
519
- "--rebase-merges" ));
520
-
521
- return !!run_rebase_interactive (& opts , command );
522
- }
523
-
524
343
static int is_interactive (struct rebase_options * opts )
525
344
{
526
345
return opts -> type == REBASE_INTERACTIVE ;
0 commit comments