Skip to content

Commit 5b6cd0f

Browse files
committed
Merge branch 'af/rebase-i-merge-options'
"git rebase -i" now honors --strategy and -X options. * af/rebase-i-merge-options: Do not ignore merge options in interactive rebase
2 parents d26792a + db2b3b8 commit 5b6cd0f

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

git-rebase--interactive.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ amend="$state_dir"/amend
8080
rewritten_list="$state_dir"/rewritten-list
8181
rewritten_pending="$state_dir"/rewritten-pending
8282

83+
strategy_args=
84+
if test -n "$do_merge"
85+
then
86+
strategy_args=${strategy:+--strategy=$strategy}
87+
eval '
88+
for strategy_opt in '"$strategy_opts"'
89+
do
90+
strategy_args="$strategy_args -X$(git rev-parse --sq-quote "${strategy_opt#--}")"
91+
done
92+
'
93+
fi
94+
8395
GIT_CHERRY_PICK_HELP="$resolvemsg"
8496
export GIT_CHERRY_PICK_HELP
8597

@@ -239,7 +251,7 @@ pick_one () {
239251

240252
test -d "$rewritten" &&
241253
pick_one_preserving_merges "$@" && return
242-
output git cherry-pick $empty_args $ff "$@"
254+
output eval git cherry-pick "$strategy_args" $empty_args $ff "$@"
243255
}
244256

245257
pick_one_preserving_merges () {
@@ -340,17 +352,16 @@ pick_one_preserving_merges () {
340352
msg_content="$(commit_message $sha1)"
341353
# No point in merging the first parent, that's HEAD
342354
new_parents=${new_parents# $first_parent}
343-
if ! do_with_author output \
344-
git merge --no-ff ${strategy:+-s $strategy} -m \
345-
"$msg_content" $new_parents
355+
if ! do_with_author output eval \
356+
'git merge --no-ff $strategy_args -m "$msg_content" $new_parents'
346357
then
347358
printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG
348359
die_with_patch $sha1 "Error redoing merge $sha1"
349360
fi
350361
echo "$sha1 $(git rev-parse HEAD^0)" >> "$rewritten_list"
351362
;;
352363
*)
353-
output git cherry-pick "$@" ||
364+
output eval git cherry-pick "$strategy_args" "$@" ||
354365
die_with_patch $sha1 "Could not pick $sha1"
355366
;;
356367
esac

t/t3404-rebase-interactive.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,4 +950,15 @@ test_expect_success 'rebase -i, with <onto> and <upstream> specified as :/quuxer
950950
git checkout branch1
951951
'
952952

953+
test_expect_success 'rebase -i with --strategy and -X' '
954+
git checkout -b conflict-merge-use-theirs conflict-branch &&
955+
git reset --hard HEAD^ &&
956+
echo five >conflict &&
957+
echo Z >file1 &&
958+
git commit -a -m "one file conflict" &&
959+
EDITOR=true git rebase -i --strategy=recursive -Xours conflict-branch &&
960+
test $(git show conflict-branch:conflict) = $(cat conflict) &&
961+
test $(cat file1) = Z
962+
'
963+
953964
test_done

0 commit comments

Comments
 (0)