]>
Commit | Line | Data |
---|---|---|
4557f1ad JS |
1 | #include "builtin.h" |
2 | #include "cache.h" | |
b2141fc1 | 3 | #include "config.h" |
4557f1ad JS |
4 | #include "parse-options.h" |
5 | #include "sequencer.h" | |
6 | ||
7 | static const char * const builtin_rebase_helper_usage[] = { | |
8 | N_("git rebase--helper [<options>]"), | |
9 | NULL | |
10 | }; | |
11 | ||
12 | int cmd_rebase__helper(int argc, const char **argv, const char *prefix) | |
13 | { | |
14 | struct replay_opts opts = REPLAY_OPTS_INIT; | |
62db5247 | 15 | int keep_empty = 0; |
4557f1ad | 16 | enum { |
94399949 | 17 | CONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_SHA1S, EXPAND_SHA1S, |
c44a4c65 | 18 | CHECK_TODO_LIST, SKIP_UNNECESSARY_PICKS, REARRANGE_SQUASH |
4557f1ad JS |
19 | } command = 0; |
20 | struct option options[] = { | |
21 | OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")), | |
62db5247 | 22 | OPT_BOOL(0, "keep-empty", &keep_empty, N_("keep empty commits")), |
4557f1ad JS |
23 | OPT_CMDMODE(0, "continue", &command, N_("continue rebase"), |
24 | CONTINUE), | |
25 | OPT_CMDMODE(0, "abort", &command, N_("abort rebase"), | |
26 | ABORT), | |
62db5247 JS |
27 | OPT_CMDMODE(0, "make-script", &command, |
28 | N_("make rebase script"), MAKE_SCRIPT), | |
3546c8d9 JS |
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), | |
94399949 JS |
33 | OPT_CMDMODE(0, "check-todo-list", &command, |
34 | N_("check the todo list"), CHECK_TODO_LIST), | |
cdac2b01 JS |
35 | OPT_CMDMODE(0, "skip-unnecessary-picks", &command, |
36 | N_("skip unnecessary picks"), SKIP_UNNECESSARY_PICKS), | |
c44a4c65 JS |
37 | OPT_CMDMODE(0, "rearrange-squash", &command, |
38 | N_("rearrange fixup/squash lines"), REARRANGE_SQUASH), | |
4557f1ad JS |
39 | OPT_END() |
40 | }; | |
41 | ||
42 | git_config(git_default_config, NULL); | |
43 | ||
44 | opts.action = REPLAY_INTERACTIVE_REBASE; | |
45 | opts.allow_ff = 1; | |
46 | opts.allow_empty = 1; | |
47 | ||
48 | argc = parse_options(argc, argv, NULL, options, | |
49 | builtin_rebase_helper_usage, PARSE_OPT_KEEP_ARGV0); | |
50 | ||
51 | if (command == CONTINUE && argc == 1) | |
52 | return !!sequencer_continue(&opts); | |
53 | if (command == ABORT && argc == 1) | |
54 | return !!sequencer_remove_state(&opts); | |
62db5247 JS |
55 | if (command == MAKE_SCRIPT && argc > 1) |
56 | return !!sequencer_make_script(keep_empty, stdout, argc, argv); | |
3546c8d9 JS |
57 | if (command == SHORTEN_SHA1S && argc == 1) |
58 | return !!transform_todo_ids(1); | |
59 | if (command == EXPAND_SHA1S && argc == 1) | |
60 | return !!transform_todo_ids(0); | |
94399949 JS |
61 | if (command == CHECK_TODO_LIST && argc == 1) |
62 | return !!check_todo_list(); | |
cdac2b01 JS |
63 | if (command == SKIP_UNNECESSARY_PICKS && argc == 1) |
64 | return !!skip_unnecessary_picks(); | |
c44a4c65 JS |
65 | if (command == REARRANGE_SQUASH && argc == 1) |
66 | return !!rearrange_squash(); | |
4557f1ad JS |
67 | usage_with_options(builtin_rebase_helper_usage, options); |
68 | } |