diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2018-12-10 11:05:01 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-12-11 17:19:01 +0900 |
commit | 81ef8ee75d5f348d3c71ff633d13d302124e1a5e (patch) | |
tree | dfe951e0a92f21fc4d9bbe32c919f09742af392d /builtin/rebase.c | |
parent | rebase: add a config option to default to --reschedule-failed-exec (diff) | |
download | tgif-81ef8ee75d5f348d3c71ff633d13d302124e1a5e.tar.xz |
rebase: introduce a shortcut for --reschedule-failed-exec
It is a bit cumbersome to write out the `--reschedule-failed-exec`
option before `-x <cmd>` all the time; let's introduce a convenient
option to do both at the same time: `-y <cmd>`.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rebase.c')
-rw-r--r-- | builtin/rebase.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c index 4839e52555..1963076f60 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -754,6 +754,23 @@ static int parse_opt_interactive(const struct option *opt, const char *arg, return 0; } +struct opt_y { + struct string_list *list; + struct rebase_options *options; +}; + +static int parse_opt_y(const struct option *opt, const char *arg, int unset) +{ + struct opt_y *o = opt->value; + + if (unset || !arg) + return -1; + + o->options->reschedule_failed_exec = 1; + string_list_append(o->list, arg); + return 0; +} + static void NORETURN error_on_missing_default_upstream(void) { struct branch *current_branch = branch_get(NULL); @@ -834,6 +851,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) struct string_list strategy_options = STRING_LIST_INIT_NODUP; struct object_id squash_onto; char *squash_onto_name = NULL; + struct opt_y opt_y = { .list = &exec, .options = &options }; struct option builtin_rebase_options[] = { OPT_STRING(0, "onto", &options.onto_name, N_("revision"), @@ -911,6 +929,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) OPT_STRING_LIST('x', "exec", &exec, N_("exec"), N_("add exec lines after each commit of the " "editable list")), + { OPTION_CALLBACK, 'y', NULL, &opt_y, N_("<cmd>"), + N_("same as --reschedule-failed-exec -x <cmd>"), + PARSE_OPT_NONEG, parse_opt_y }, OPT_BOOL(0, "allow-empty-message", &options.allow_empty_message, N_("allow rebasing commits with empty messages")), |