1#include "builtin.h"
2#include "cache.h"
3#include "parse-options.h"
4#include "sequencer.h"
5
6static const char * const builtin_rebase_helper_usage[] = {
7 N_("git rebase--helper [<options>]"),
8 NULL
9};
10
11int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
12{
13 struct replay_opts opts = REPLAY_OPTS_INIT;
14 enum {
15 CONTINUE = 1, ABORT
16 } command = 0;
17 struct option options[] = {
18 OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")),
19 OPT_CMDMODE(0, "continue", &command, N_("continue rebase"),
20 CONTINUE),
21 OPT_CMDMODE(0, "abort", &command, N_("abort rebase"),
22 ABORT),
23 OPT_END()
24 };
25
26 git_config(git_default_config, NULL);
27
28 opts.action = REPLAY_INTERACTIVE_REBASE;
29 opts.allow_ff = 1;
30 opts.allow_empty = 1;
31
32 argc = parse_options(argc, argv, NULL, options,
33 builtin_rebase_helper_usage, PARSE_OPT_KEEP_ARGV0);
34
35 if (command == CONTINUE && argc == 1)
36 return !!sequencer_continue(&opts);
37 if (command == ABORT && argc == 1)
38 return !!sequencer_remove_state(&opts);
39 usage_with_options(builtin_rebase_helper_usage, options);
40}