diff options
authorFabian Ruch <>2015-12-11 20:30:36 (GMT)
committerJunio C Hamano <>2015-12-11 20:44:44 (GMT)
commit040fd39e672fce2b549b842895ceb4f5063026f3 (patch)
parent49e863b02ae177069ebe6c4bb3d0e14bef7ccf7a (diff)
rebase -i: remember merge options beyond continue actions
If the user explicitly specified a merge strategy or strategy options, continue to use that strategy/option after "rebase --continue". Add a test of the corrected behavior. If --merge is specified or implied by -s or -X, then "strategy and "strategy_opts" are set to values from which "strategy_args" can be derived; otherwise they are set to empty strings. Either way, their values are propagated from one step of an interactive rebase to the next via state files. "do_merge", on the other hand, is *not* propagated to later steps of an interactive rebase. Therefore, making the initialization of "strategy_args" conditional on "do_merge" being set prevents later steps of an interactive rebase from setting it correctly. Luckily, we don't need the "do_merge" guard at all. If the rebase was started without --merge, then "strategy" and "strategy_opts" are both the empty string, which results in "strategy_args" also being set to the empty string, which is just what we want in that situation. So remove the "do_merge" guard and derive "strategy_args" from "strategy" and "strategy_opts" every time. Reported-by: Diogo de Campos <> Signed-off-by: Fabian Ruch <> Helped-by: Michael Haggerty <> Signed-off-by: Ralf Thielow <> Signed-off-by: Junio C Hamano <>
2 files changed, 23 insertions, 11 deletions
diff --git a/ b/
index b938a6d..c0cfe88 100644
--- a/
+++ b/
@@ -81,17 +81,13 @@ rewritten_pending="$state_dir"/rewritten-pending
# and leaves CR at the end instead.
cr=$(printf "\015")
-if test -n "$do_merge"
- strategy_args=${strategy:+--strategy=$strategy}
- eval '
- for strategy_opt in '"$strategy_opts"'
- do
- strategy_args="$strategy_args -X$(git rev-parse --sq-quote "${strategy_opt#--}")"
- done
- '
+eval '
+ for strategy_opt in '"$strategy_opts"'
+ do
+ strategy_args="$strategy_args -X$(git rev-parse --sq-quote "${strategy_opt#--}")"
+ done
diff --git a/t/ b/t/
index 9067e02..544f9ad 100755
--- a/t/
+++ b/t/
@@ -1006,6 +1006,22 @@ test_expect_success 'rebase -i with --strategy and -X' '
test $(cat file1) = Z
+test_expect_success 'interrupted rebase -i with --strategy and -X' '
+ git checkout -b conflict-merge-use-theirs-interrupted conflict-branch &&
+ git reset --hard HEAD^ &&
+ >breakpoint &&
+ git add breakpoint &&
+ git commit -m "breakpoint for interactive mode" &&
+ echo five >conflict &&
+ echo Z >file1 &&
+ git commit -a -m "one file conflict" &&
+ set_fake_editor &&
+ FAKE_LINES="edit 1 2" git rebase -i --strategy=recursive -Xours conflict-branch &&
+ git rebase --continue &&
+ test $(git show conflict-branch:conflict) = $(cat conflict) &&
+ test $(cat file1) = Z
test_expect_success 'rebase -i error on commits with \ in message' '
current_head=$(git rev-parse HEAD) &&
test_when_finished "git rebase --abort; git reset --hard $current_head; rm -f error" &&