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>
Johannes Schindelin committed
Dec 10, 2018 at 11:05 UTC
81ef8ee75d5f348d3c71ff633d13d302124e1a5e
4 files changed
+36
Documentation/git-rebase.txt
+6
@@ -462,6 +462,12 @@ without an explicit `--interactive`.
462
+
463
See also INCOMPATIBLE OPTIONS below.
464
465
+-y <cmd>::
466
+ This is the same as passing `--reschedule-failed-exec` before
467
+ `-x <cmd>`, i.e. it appends the specified `exec` command and
468
+ turns on the mode where failed `exec` commands are automatically
469
+ rescheduled.
470
+
471
--root::
472
Rebase all commits reachable from <branch>, instead of
473
limiting them with an <upstream>. This allows you to rebase
builtin/rebase.c
+21
@@ -754,6 +754,23 @@ static int parse_opt_interactive(const struct option *opt, const char *arg,
754
return 0;
755
}
756
757
+struct opt_y {
758
+ struct string_list *list;
759
+ struct rebase_options *options;
760
+};
761
+
762
+static int parse_opt_y(const struct option *opt, const char *arg, int unset)
763
+{
764
+ struct opt_y *o = opt->value;
765
+
766
+ if (unset || !arg)
767
+ return -1;
768
+
769
+ o->options->reschedule_failed_exec = 1;
770
+ string_list_append(o->list, arg);
771
+ return 0;
772
+}
773
+
774
static void NORETURN error_on_missing_default_upstream(void)
775
{
776
struct branch *current_branch = branch_get(NULL);
@@ -834,6 +851,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
851
struct string_list strategy_options = STRING_LIST_INIT_NODUP;
852
struct object_id squash_onto;
853
char *squash_onto_name = NULL;
854
+ struct opt_y opt_y = { .list = &exec, .options = &options };
855
struct option builtin_rebase_options[] = {
856
OPT_STRING(0, "onto", &options.onto_name,
857
N_("revision"),
@@ -911,6 +929,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
929
OPT_STRING_LIST('x', "exec", &exec, N_("exec"),
930
N_("add exec lines after each commit of the "
931
"editable list")),
932
+ { OPTION_CALLBACK, 'y', NULL, &opt_y, N_("<cmd>"),
933
+ N_("same as --reschedule-failed-exec -x <cmd>"),
934
+ PARSE_OPT_NONEG, parse_opt_y },
935
OPT_BOOL(0, "allow-empty-message",
936
&options.allow_empty_message,
937
N_("allow rebasing commits with empty messages")),
git-legacy-rebase.sh
+6
@@ -26,6 +26,7 @@ f,force-rebase! cherry-pick all commits, even if unchanged
26
m,merge! use merging strategies to rebase
27
i,interactive! let the user edit the list of commits to rebase
28
x,exec=! add exec lines after each commit of the editable list
29
+y=! same as --reschedule-failed-exec -x
30
k,keep-empty preserve empty commits during rebase
31
allow-empty-message allow rebasing commits with empty messages
32
stat! display a diffstat of what changed upstream
@@ -262,6 +263,11 @@ do
263
cmd="${cmd}exec ${1#--exec=}${LF}"
264
test -z "$interactive_rebase" && interactive_rebase=implied
265
;;
266
+ -y*)
267
+ reschedule_failed_exec=--reschedule-failed-exec
268
+ cmd="${cmd}exec ${1#-y}${LF}"
269
+ test -z "$interactive_rebase" && interactive_rebase=implied
270
+ ;;
271
--interactive)
272
interactive_rebase=explicit
273
;;
t/t3418-rebase-continue.sh
+3
@@ -262,6 +262,9 @@ test_expect_success '--reschedule-failed-exec' '
262
test_must_fail git -c rebase.rescheduleFailedExec=true \
263
rebase -x false HEAD^ 2>err &&
264
grep "^exec false" .git/rebase-merge/git-rebase-todo &&
265
+ test_i18ngrep "has been rescheduled" err &&
266
+ git rebase --abort &&
267
+ test_must_fail git rebase -y false HEAD^ 2>err &&
268
test_i18ngrep "has been rescheduled" err
269
'
270