4 #include "parse-options.h"
7 static const char * const builtin_rebase_helper_usage
[] = {
8 N_("git rebase--helper [<options>]"),
12 int cmd_rebase__helper(int argc
, const char **argv
, const char *prefix
)
14 struct replay_opts opts
= REPLAY_OPTS_INIT
;
17 CONTINUE
= 1, ABORT
, MAKE_SCRIPT
, SHORTEN_SHA1S
, EXPAND_SHA1S
,
20 struct option options
[] = {
21 OPT_BOOL(0, "ff", &opts
.allow_ff
, N_("allow fast-forward")),
22 OPT_BOOL(0, "keep-empty", &keep_empty
, N_("keep empty commits")),
23 OPT_CMDMODE(0, "continue", &command
, N_("continue rebase"),
25 OPT_CMDMODE(0, "abort", &command
, N_("abort rebase"),
27 OPT_CMDMODE(0, "make-script", &command
,
28 N_("make rebase script"), MAKE_SCRIPT
),
29 OPT_CMDMODE(0, "shorten-ids", &command
,
30 N_("shorten SHA-1s in the todo list"), SHORTEN_SHA1S
),
31 OPT_CMDMODE(0, "expand-ids", &command
,
32 N_("expand SHA-1s in the todo list"), EXPAND_SHA1S
),
33 OPT_CMDMODE(0, "check-todo-list", &command
,
34 N_("check the todo list"), CHECK_TODO_LIST
),
38 git_config(git_default_config
, NULL
);
40 opts
.action
= REPLAY_INTERACTIVE_REBASE
;
44 argc
= parse_options(argc
, argv
, NULL
, options
,
45 builtin_rebase_helper_usage
, PARSE_OPT_KEEP_ARGV0
);
47 if (command
== CONTINUE
&& argc
== 1)
48 return !!sequencer_continue(&opts
);
49 if (command
== ABORT
&& argc
== 1)
50 return !!sequencer_remove_state(&opts
);
51 if (command
== MAKE_SCRIPT
&& argc
> 1)
52 return !!sequencer_make_script(keep_empty
, stdout
, argc
, argv
);
53 if (command
== SHORTEN_SHA1S
&& argc
== 1)
54 return !!transform_todo_ids(1);
55 if (command
== EXPAND_SHA1S
&& argc
== 1)
56 return !!transform_todo_ids(0);
57 if (command
== CHECK_TODO_LIST
&& argc
== 1)
58 return !!check_todo_list();
59 usage_with_options(builtin_rebase_helper_usage
, options
);