builtin / rebase--helper.con commit t3512/t3513: remove KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT=1 (db9476b)
   1#include "builtin.h"
   2#include "cache.h"
   3#include "config.h"
   4#include "parse-options.h"
   5#include "sequencer.h"
   6
   7static const char * const builtin_rebase_helper_usage[] = {
   8        N_("git rebase--helper [<options>]"),
   9        NULL
  10};
  11
  12static int git_rebase_helper_config(const char *k, const char *v, void *cb)
  13{
  14        int status;
  15
  16        status = git_sequencer_config(k, v, NULL);
  17        if (status)
  18                return status;
  19
  20        return git_default_config(k, v, NULL);
  21}
  22
  23int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
  24{
  25        struct replay_opts opts = REPLAY_OPTS_INIT;
  26        int keep_empty = 0;
  27        enum {
  28                CONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_SHA1S, EXPAND_SHA1S,
  29                CHECK_TODO_LIST, SKIP_UNNECESSARY_PICKS, REARRANGE_SQUASH
  30        } command = 0;
  31        struct option options[] = {
  32                OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")),
  33                OPT_BOOL(0, "keep-empty", &keep_empty, N_("keep empty commits")),
  34                OPT_CMDMODE(0, "continue", &command, N_("continue rebase"),
  35                                CONTINUE),
  36                OPT_CMDMODE(0, "abort", &command, N_("abort rebase"),
  37                                ABORT),
  38                OPT_CMDMODE(0, "make-script", &command,
  39                        N_("make rebase script"), MAKE_SCRIPT),
  40                OPT_CMDMODE(0, "shorten-ids", &command,
  41                        N_("shorten SHA-1s in the todo list"), SHORTEN_SHA1S),
  42                OPT_CMDMODE(0, "expand-ids", &command,
  43                        N_("expand SHA-1s in the todo list"), EXPAND_SHA1S),
  44                OPT_CMDMODE(0, "check-todo-list", &command,
  45                        N_("check the todo list"), CHECK_TODO_LIST),
  46                OPT_CMDMODE(0, "skip-unnecessary-picks", &command,
  47                        N_("skip unnecessary picks"), SKIP_UNNECESSARY_PICKS),
  48                OPT_CMDMODE(0, "rearrange-squash", &command,
  49                        N_("rearrange fixup/squash lines"), REARRANGE_SQUASH),
  50                OPT_END()
  51        };
  52
  53        git_config(git_rebase_helper_config, NULL);
  54
  55        opts.action = REPLAY_INTERACTIVE_REBASE;
  56        opts.allow_ff = 1;
  57        opts.allow_empty = 1;
  58
  59        argc = parse_options(argc, argv, NULL, options,
  60                        builtin_rebase_helper_usage, PARSE_OPT_KEEP_ARGV0);
  61
  62        if (command == CONTINUE && argc == 1)
  63                return !!sequencer_continue(&opts);
  64        if (command == ABORT && argc == 1)
  65                return !!sequencer_remove_state(&opts);
  66        if (command == MAKE_SCRIPT && argc > 1)
  67                return !!sequencer_make_script(keep_empty, stdout, argc, argv);
  68        if (command == SHORTEN_SHA1S && argc == 1)
  69                return !!transform_todo_ids(1);
  70        if (command == EXPAND_SHA1S && argc == 1)
  71                return !!transform_todo_ids(0);
  72        if (command == CHECK_TODO_LIST && argc == 1)
  73                return !!check_todo_list();
  74        if (command == SKIP_UNNECESSARY_PICKS && argc == 1)
  75                return !!skip_unnecessary_picks();
  76        if (command == REARRANGE_SQUASH && argc == 1)
  77                return !!rearrange_squash();
  78        usage_with_options(builtin_rebase_helper_usage, options);
  79}