Skip to content

Commit e31b018

Browse files
committed
Merge branch 'aw/maint-rebase-i-p-no-ff' into maint
* aw/maint-rebase-i-p-no-ff: git-rebase--interactive.sh: preserve-merges fails on merges created with no-ff
2 parents bc67ad8 + c192f9c commit e31b018

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

git-rebase--interactive.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ pick_one_preserving_merges () {
339339
# No point in merging the first parent, that's HEAD
340340
new_parents=${new_parents# $first_parent}
341341
if ! do_with_author output \
342-
git merge $STRATEGY -m "$msg" $new_parents
342+
git merge --no-ff $STRATEGY -m "$msg" $new_parents
343343
then
344344
printf "%s\n" "$msg" > "$GIT_DIR"/MERGE_MSG
345345
die_with_patch $sha1 "Error redoing merge $sha1"

t/t3409-rebase-preserve-merges.sh

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@ export GIT_AUTHOR_EMAIL
2727
# \
2828
# B2 <-- origin/topic
2929
#
30-
# In both cases, 'topic' is rebased onto 'origin/topic'.
30+
# Clone 3 (no-ff merge):
31+
#
32+
# A1--A2--B3 <-- origin/master
33+
# \
34+
# B1------M <-- topic
35+
# \ /
36+
# \--A3 <-- topic2
37+
# \
38+
# B2 <-- origin/topic
39+
#
40+
# In all cases, 'topic' is rebased onto 'origin/topic'.
3141

3242
test_expect_success 'setup for merge-preserving rebase' \
3343
'echo First > A &&
@@ -61,6 +71,16 @@ test_expect_success 'setup for merge-preserving rebase' \
6171
git commit -m "Merge origin/master into topic"
6272
) &&
6373
74+
git clone ./. clone3 &&
75+
(
76+
cd clone3 &&
77+
git checkout -b topic2 origin/topic &&
78+
echo Sixth > A &&
79+
git commit -a -m "Modify A3" &&
80+
git checkout -b topic origin/topic &&
81+
git merge --no-ff topic2
82+
) &&
83+
6484
git checkout topic &&
6585
echo Fourth >> B &&
6686
git commit -a -m "Modify B2"
@@ -93,4 +113,14 @@ test_expect_success '--continue works after a conflict' '
93113
)
94114
'
95115

116+
test_expect_success 'rebase -p preserves no-ff merges' '
117+
(
118+
cd clone3 &&
119+
git fetch &&
120+
git rebase -p origin/topic &&
121+
test 3 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
122+
test 1 = $(git rev-list --all --pretty=oneline | grep "Merge branch" | wc -l)
123+
)
124+
'
125+
96126
test_done

0 commit comments

Comments
 (0)