Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stefan Beller authored and Junio C Hamano committed Mar 18, 2016
1 parent 047057b commit 78ec240
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Documentation/git-rebase.txt
Expand Up @@ -391,9 +391,6 @@ idea unless you know what you are doing (see BUGS below).
final history. <cmd> will be interpreted as one or more shell
commands.
+
This option can only be used with the `--interactive` option
(see INTERACTIVE MODE below).
+
You may execute several commands by either using one instance of `--exec`
with several commands:
+
Expand All @@ -406,6 +403,9 @@ or by giving more than one `--exec`:
If `--autosquash` is used, "exec" lines will not be appended for
the intermediate commits, and will only appear at the end of each
squash/fixup series.
+
This uses the `--interactive` machinery internally, but it can be run
without an explicit `--interactive`.

--root::
Rebase all commits reachable from <branch>, instead of
Expand Down
7 changes: 1 addition & 6 deletions git-rebase.sh
Expand Up @@ -248,6 +248,7 @@ do
;;
--exec=*)
cmd="${cmd}exec ${1#--exec=}${LF}"
test -z "$interactive_rebase" && interactive_rebase=implied
;;
--interactive)
interactive_rebase=explicit
Expand Down Expand Up @@ -348,12 +349,6 @@ do
done
test $# -gt 2 && usage

if test -n "$cmd" &&
test "$interactive_rebase" != explicit
then
die "$(gettext "The --exec option must be used with the --interactive option")"
fi

if test -n "$action"
then
test -z "$in_progress" && die "$(gettext "No rebase in progress?")"
Expand Down
13 changes: 6 additions & 7 deletions t/t3404-rebase-interactive.sh
Expand Up @@ -876,16 +876,15 @@ test_expect_success 'rebase -ix with --autosquash' '
test_cmp expected actual
'


test_expect_success 'rebase --exec without -i shows error message' '
test_expect_success 'rebase --exec works without -i ' '
git reset --hard execute &&
set_fake_editor &&
test_must_fail git rebase --exec "git show HEAD" HEAD~2 2>actual &&
echo "The --exec option must be used with the --interactive option" >expected &&
test_i18ncmp expected actual
rm -rf exec_output &&
EDITOR="echo >invoked_editor" git rebase --exec "echo a line >>exec_output" HEAD~2 2>actual &&
test_i18ngrep "Successfully rebased and updated" actual &&
test_line_count = 2 exec_output &&
test_path_is_missing invoked_editor
'


test_expect_success 'rebase -i --exec without <CMD>' '
git reset --hard execute &&
set_fake_editor &&
Expand Down

0 comments on commit 78ec240

Please sign in to comment.