Skip to content

Commit 2c657ed

Browse files
committed
Merge branch 'sb/rebase-x'
"git rebase -x" can be used without passing "-i" option. * sb/rebase-x: t3404: cleanup double empty lines between tests rebase: decouple --exec from --interactive
2 parents 3e95e47 + 8172c42 commit 2c657ed

File tree

3 files changed

+10
-22
lines changed

3 files changed

+10
-22
lines changed

‎Documentation/git-rebase.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,6 @@ idea unless you know what you are doing (see BUGS below).
391391
final history. <cmd> will be interpreted as one or more shell
392392
commands.
393393
+
394-
This option can only be used with the `--interactive` option
395-
(see INTERACTIVE MODE below).
396-
+
397394
You may execute several commands by either using one instance of `--exec`
398395
with several commands:
399396
+
@@ -406,6 +403,9 @@ or by giving more than one `--exec`:
406403
If `--autosquash` is used, "exec" lines will not be appended for
407404
the intermediate commits, and will only appear at the end of each
408405
squash/fixup series.
406+
+
407+
This uses the `--interactive` machinery internally, but it can be run
408+
without an explicit `--interactive`.
409409

410410
--root::
411411
Rebase all commits reachable from <branch>, instead of

‎git-rebase.sh‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ do
248248
;;
249249
--exec=*)
250250
cmd="${cmd}exec ${1#--exec=}${LF}"
251+
test -z "$interactive_rebase" && interactive_rebase=implied
251252
;;
252253
--interactive)
253254
interactive_rebase=explicit
@@ -348,12 +349,6 @@ do
348349
done
349350
test $# -gt 2 && usage
350351

351-
if test -n "$cmd" &&
352-
test "$interactive_rebase" != explicit
353-
then
354-
die "$(gettext "The --exec option must be used with the --interactive option")"
355-
fi
356-
357352
if test -n "$action"
358353
then
359354
test -z "$in_progress" && die "$(gettext "No rebase in progress?")"

‎t/t3404-rebase-interactive.sh‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,6 @@ test_expect_success 'rebase-i history with funny messages' '
771771
test_cmp expect actual
772772
'
773773

774-
775774
test_expect_success 'prepare for rebase -i --exec' '
776775
git checkout master &&
777776
git checkout -b execute &&
@@ -780,7 +779,6 @@ test_expect_success 'prepare for rebase -i --exec' '
780779
test_commit three_exec main.txt three_exec
781780
'
782781

783-
784782
test_expect_success 'running "git rebase -i --exec git show HEAD"' '
785783
set_fake_editor &&
786784
git rebase -i --exec "git show HEAD" HEAD~2 >actual &&
@@ -793,7 +791,6 @@ test_expect_success 'running "git rebase -i --exec git show HEAD"' '
793791
test_cmp expected actual
794792
'
795793

796-
797794
test_expect_success 'running "git rebase --exec git show HEAD -i"' '
798795
git reset --hard execute &&
799796
set_fake_editor &&
@@ -807,7 +804,6 @@ test_expect_success 'running "git rebase --exec git show HEAD -i"' '
807804
test_cmp expected actual
808805
'
809806

810-
811807
test_expect_success 'running "git rebase -ix git show HEAD"' '
812808
git reset --hard execute &&
813809
set_fake_editor &&
@@ -835,7 +831,6 @@ test_expect_success 'rebase -ix with several <CMD>' '
835831
test_cmp expected actual
836832
'
837833

838-
839834
test_expect_success 'rebase -ix with several instances of --exec' '
840835
git reset --hard execute &&
841836
set_fake_editor &&
@@ -850,7 +845,6 @@ test_expect_success 'rebase -ix with several instances of --exec' '
850845
test_cmp expected actual
851846
'
852847

853-
854848
test_expect_success 'rebase -ix with --autosquash' '
855849
git reset --hard execute &&
856850
git checkout -b autosquash &&
@@ -876,16 +870,15 @@ test_expect_success 'rebase -ix with --autosquash' '
876870
test_cmp expected actual
877871
'
878872

879-
880-
test_expect_success 'rebase --exec without -i shows error message' '
873+
test_expect_success 'rebase --exec works without -i ' '
881874
git reset --hard execute &&
882-
set_fake_editor &&
883-
test_must_fail git rebase --exec "git show HEAD" HEAD~2 2>actual &&
884-
echo "The --exec option must be used with the --interactive option" >expected &&
885-
test_i18ncmp expected actual
875+
rm -rf exec_output &&
876+
EDITOR="echo >invoked_editor" git rebase --exec "echo a line >>exec_output" HEAD~2 2>actual &&
877+
test_i18ngrep "Successfully rebased and updated" actual &&
878+
test_line_count = 2 exec_output &&
879+
test_path_is_missing invoked_editor
886880
'
887881

888-
889882
test_expect_success 'rebase -i --exec without <CMD>' '
890883
git reset --hard execute &&
891884
set_fake_editor &&

0 commit comments

Comments
 (0)