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
19 struct option options
[] = {
20 OPT_BOOL(0, "ff", &opts
.allow_ff
, N_("allow fast-forward")),
21 OPT_BOOL(0, "keep-empty", &keep_empty
, N_("keep empty commits")),
22 OPT_CMDMODE(0, "continue", &command
, N_("continue rebase"),
24 OPT_CMDMODE(0, "abort", &command
, N_("abort rebase"),
26 OPT_CMDMODE(0, "make-script", &command
,
27 N_("make rebase script"), MAKE_SCRIPT
),
28 OPT_CMDMODE(0, "shorten-ids", &command
,
29 N_("shorten SHA-1s in the todo list"), SHORTEN_SHA1S
),
30 OPT_CMDMODE(0, "expand-ids", &command
,
31 N_("expand SHA-1s in the todo list"), EXPAND_SHA1S
),
35 git_config(git_default_config
, NULL
);
37 opts
.action
= REPLAY_INTERACTIVE_REBASE
;
41 argc
= parse_options(argc
, argv
, NULL
, options
,
42 builtin_rebase_helper_usage
, PARSE_OPT_KEEP_ARGV0
);
44 if (command
== CONTINUE
&& argc
== 1)
45 return !!sequencer_continue(&opts
);
46 if (command
== ABORT
&& argc
== 1)
47 return !!sequencer_remove_state(&opts
);
48 if (command
== MAKE_SCRIPT
&& argc
> 1)
49 return !!sequencer_make_script(keep_empty
, stdout
, argc
, argv
);
50 if (command
== SHORTEN_SHA1S
&& argc
== 1)
51 return !!transform_todo_ids(1);
52 if (command
== EXPAND_SHA1S
&& argc
== 1)
53 return !!transform_todo_ids(0);
54 usage_with_options(builtin_rebase_helper_usage
, options
);