Skip to content

Commit 78ec240

Browse files
stefanbellergitster
authored andcommitted
rebase: decouple --exec from --interactive
In the later steps of preparing a patch series I do not want to edit or reorder the patches any more, but just make sure the test suite passes after each patch and also to fix breakage right there if some of the steps fail. I could run EDITOR=true git rebase -i <anchor> -x "make test" but it would be simpler if it can be spelled like so: git rebase <anchor> -x "make test" Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 047057b commit 78ec240

3 files changed

Lines changed: 10 additions & 16 deletions

File tree

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 & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -876,16 +876,15 @@ test_expect_success 'rebase -ix with --autosquash' '
876876
test_cmp expected actual
877877
'
878878

879-
880-
test_expect_success 'rebase --exec without -i shows error message' '
879+
test_expect_success 'rebase --exec works without -i ' '
881880
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
881+
rm -rf exec_output &&
882+
EDITOR="echo >invoked_editor" git rebase --exec "echo a line >>exec_output" HEAD~2 2>actual &&
883+
test_i18ngrep "Successfully rebased and updated" actual &&
884+
test_line_count = 2 exec_output &&
885+
test_path_is_missing invoked_editor
886886
'
887887

888-
889888
test_expect_success 'rebase -i --exec without <CMD>' '
890889
git reset --hard execute &&
891890
set_fake_editor &&

0 commit comments

Comments
 (0)