rebase -p: fix quoting when calling `git merge`

It has been reported that strategy arguments are not passed to `git merge` correctly when rebasing interactively, preserving merges. The reason is that the strategy arguments are already quoted, and then quoted again. This fixes https://github.com/git-for-windows/git/issues/1321 Original-patch-by: Kim Gybels <kgybels@infogroep.be> Also-reported-by: Matwey V. Kornilov <matwey.kornilov@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jan 4, 2018 at 22:31 UTC dd6fb0053ce5b6923505e64993d8061484665962
2 files changed +20 -3
git-rebase--interactive.sh
+6 -3
@@ -392,9 +392,12 @@ pick_one_preserving_merges () {
392 new_parents=${new_parents# $first_parent}
393 merge_args="--no-log --no-ff"
394 if ! do_with_author output eval \
395 - 'git merge ${gpg_sign_opt:+"$gpg_sign_opt"} \
396 - $allow_rerere_autoupdate $merge_args \
397 - $strategy_args -m "$msg_content" $new_parents'
395 + git merge ${gpg_sign_opt:+$(git rev-parse \
396 + --sq-quote "$gpg_sign_opt")} \
397 + $allow_rerere_autoupdate "$merge_args" \
398 + "$strategy_args" \
399 + -m $(git rev-parse --sq-quote "$msg_content") \
400 + "$new_parents"
401 then
402 printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG
403 die_with_patch $sha1 "$(eval_gettext "Error redoing merge \$sha1")"
t/t3418-rebase-continue.sh
+14
@@ -74,6 +74,20 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
74 test -f funny.was.run
75 '
76
77 +test_expect_success 'rebase passes merge strategy options correctly' '
78 + rm -fr .git/rebase-* &&
79 + git reset --hard commit-new-file-F3-on-topic-branch &&
80 + test_commit theirs-to-merge &&
81 + git reset --hard HEAD^ &&
82 + test_commit some-commit &&
83 + test_tick &&
84 + git merge --no-ff theirs-to-merge &&
85 + FAKE_LINES="1 edit 2 3" git rebase -i -f -p -m \
86 + -s recursive --strategy-option=theirs HEAD~2 &&
87 + test_commit force-change &&
88 + git rebase --continue
89 +'
90 +
91 test_expect_success 'setup rerere database' '
92 rm -fr .git/rebase-* &&
93 git reset --hard commit-new-file-F3-on-topic-branch &&