diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-02-27 13:57:14 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-27 13:57:14 -0800 |
commit | 098ed50e8a7c581e23cd51b737fb780228fe6f31 (patch) | |
tree | 708d472f3b40ea250e0c14d28005487614e91ada /builtin | |
parent | a04855bae8d75d22b0c909c7d1febedcd05ba9b1 (diff) | |
parent | 18633e1a22a68bbe8e6311a1039d13ebbf6fd041 (diff) | |
download | git-098ed50e8a7c581e23cd51b737fb780228fe6f31.tar.gz git-098ed50e8a7c581e23cd51b737fb780228fe6f31.tar.xz |
Merge branch 'js/rebase-helper'
"git rebase -i" starts using the recently updated "sequencer" code.
* js/rebase-helper:
rebase -i: use the rebase--helper builtin
rebase--helper: add a builtin helper for interactive rebases
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/rebase--helper.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c new file mode 100644 index 000000000..ca1ebb2fa --- /dev/null +++ b/builtin/rebase--helper.c @@ -0,0 +1,40 @@ +#include "builtin.h" +#include "cache.h" +#include "parse-options.h" +#include "sequencer.h" + +static const char * const builtin_rebase_helper_usage[] = { + N_("git rebase--helper [<options>]"), + NULL +}; + +int cmd_rebase__helper(int argc, const char **argv, const char *prefix) +{ + struct replay_opts opts = REPLAY_OPTS_INIT; + enum { + CONTINUE = 1, ABORT + } command = 0; + struct option options[] = { + OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")), + OPT_CMDMODE(0, "continue", &command, N_("continue rebase"), + CONTINUE), + OPT_CMDMODE(0, "abort", &command, N_("abort rebase"), + ABORT), + OPT_END() + }; + + git_config(git_default_config, NULL); + + opts.action = REPLAY_INTERACTIVE_REBASE; + opts.allow_ff = 1; + opts.allow_empty = 1; + + argc = parse_options(argc, argv, NULL, options, + builtin_rebase_helper_usage, PARSE_OPT_KEEP_ARGV0); + + if (command == CONTINUE && argc == 1) + return !!sequencer_continue(&opts); + if (command == ABORT && argc == 1) + return !!sequencer_remove_state(&opts); + usage_with_options(builtin_rebase_helper_usage, options); +} |