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
maint
Junio C Hamano 2016-04-06 11:39:09 -07:00
commit 2c657edce7
3 changed files with 10 additions and 22 deletions

View File

@ -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 final history. <cmd> will be interpreted as one or more shell
commands. 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` You may execute several commands by either using one instance of `--exec`
with several commands: with several commands:
+ +
@ -406,6 +403,9 @@ or by giving more than one `--exec`:
If `--autosquash` is used, "exec" lines will not be appended for If `--autosquash` is used, "exec" lines will not be appended for
the intermediate commits, and will only appear at the end of each the intermediate commits, and will only appear at the end of each
squash/fixup series. squash/fixup series.
+
This uses the `--interactive` machinery internally, but it can be run
without an explicit `--interactive`.


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

View File

@ -248,6 +248,7 @@ do
;; ;;
--exec=*) --exec=*)
cmd="${cmd}exec ${1#--exec=}${LF}" cmd="${cmd}exec ${1#--exec=}${LF}"
test -z "$interactive_rebase" && interactive_rebase=implied
;; ;;
--interactive) --interactive)
interactive_rebase=explicit interactive_rebase=explicit
@ -348,12 +349,6 @@ do
done done
test $# -gt 2 && usage 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" if test -n "$action"
then then
test -z "$in_progress" && die "$(gettext "No rebase in progress?")" test -z "$in_progress" && die "$(gettext "No rebase in progress?")"

View File

@ -771,7 +771,6 @@ test_expect_success 'rebase-i history with funny messages' '
test_cmp expect actual test_cmp expect actual
' '



test_expect_success 'prepare for rebase -i --exec' ' test_expect_success 'prepare for rebase -i --exec' '
git checkout master && git checkout master &&
git checkout -b execute && git checkout -b execute &&
@ -780,7 +779,6 @@ test_expect_success 'prepare for rebase -i --exec' '
test_commit three_exec main.txt three_exec test_commit three_exec main.txt three_exec
' '



test_expect_success 'running "git rebase -i --exec git show HEAD"' ' test_expect_success 'running "git rebase -i --exec git show HEAD"' '
set_fake_editor && set_fake_editor &&
git rebase -i --exec "git show HEAD" HEAD~2 >actual && 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"' '
test_cmp expected actual test_cmp expected actual
' '



test_expect_success 'running "git rebase --exec git show HEAD -i"' ' test_expect_success 'running "git rebase --exec git show HEAD -i"' '
git reset --hard execute && git reset --hard execute &&
set_fake_editor && set_fake_editor &&
@ -807,7 +804,6 @@ test_expect_success 'running "git rebase --exec git show HEAD -i"' '
test_cmp expected actual test_cmp expected actual
' '



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



test_expect_success 'rebase -ix with several instances of --exec' ' test_expect_success 'rebase -ix with several instances of --exec' '
git reset --hard execute && git reset --hard execute &&
set_fake_editor && set_fake_editor &&
@ -850,7 +845,6 @@ test_expect_success 'rebase -ix with several instances of --exec' '
test_cmp expected actual test_cmp expected actual
' '



test_expect_success 'rebase -ix with --autosquash' ' test_expect_success 'rebase -ix with --autosquash' '
git reset --hard execute && git reset --hard execute &&
git checkout -b autosquash && git checkout -b autosquash &&
@ -876,16 +870,15 @@ test_expect_success 'rebase -ix with --autosquash' '
test_cmp expected actual test_cmp expected actual
' '



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



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