Skip to content

Commit 824f4a9

Browse files
committed
Merge branch 'aw/rebase-i-p' into maint
* aw/rebase-i-p: rebase -i -p: include non-first-parent commits in todo list
2 parents f253376 + 12bf828 commit 824f4a9

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

git-rebase--interactive.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,6 @@ then
713713
# parents to rewrite and skipping dropped commits would
714714
# prematurely end our probe
715715
merges_option=
716-
first_after_upstream="$(git rev-list --reverse --first-parent $upstream..$orig_head | head -n 1)"
717716
else
718717
merges_option="--no-merges --cherry-pick"
719718
fi
@@ -746,7 +745,7 @@ do
746745
preserve=t
747746
for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)
748747
do
749-
if test -f "$rewritten"/$p -a \( $p != $onto -o $sha1 = $first_after_upstream \)
748+
if test -f "$rewritten"/$p
750749
then
751750
preserve=f
752751
fi

t/t3404-rebase-interactive.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ test_expect_success 'preserve merges with -p' '
295295
'
296296

297297
test_expect_success 'edit ancestor with -p' '
298-
FAKE_LINES="1 edit 2 3 4" git rebase -i -p HEAD~3 &&
298+
FAKE_LINES="1 2 edit 3 4" git rebase -i -p HEAD~3 &&
299299
echo 2 > unrelated-file &&
300300
test_tick &&
301301
git commit -m L2-modified --amend unrelated-file &&

t/t3409-rebase-preserve-merges.sh

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ export GIT_AUTHOR_EMAIL
3737
# \
3838
# B2 <-- origin/topic
3939
#
40-
# In all cases, 'topic' is rebased onto 'origin/topic'.
40+
# Clone 4 (merge using second parent as base):
41+
#
42+
# A1--A2--B3 <-- origin/master
43+
# \
44+
# B1--A3--M <-- topic
45+
# \ /
46+
# \--A4 <-- topic2
47+
# \
48+
# B2 <-- origin/topic
4149

4250
test_expect_success 'setup for merge-preserving rebase' \
4351
'echo First > A &&
@@ -57,6 +65,13 @@ test_expect_success 'setup for merge-preserving rebase' \
5765
git merge origin/master
5866
) &&
5967
68+
git clone ./. clone4 &&
69+
(
70+
cd clone4 &&
71+
git checkout -b topic origin/topic &&
72+
git merge origin/master
73+
) &&
74+
6075
echo Fifth > B &&
6176
git add B &&
6277
git commit -m "Add different B" &&
@@ -123,4 +138,15 @@ test_expect_success 'rebase -p preserves no-ff merges' '
123138
)
124139
'
125140

141+
test_expect_success 'rebase -p works when base inside second parent' '
142+
(
143+
cd clone4 &&
144+
git fetch &&
145+
git rebase -p HEAD^2 &&
146+
test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
147+
test 1 = $(git rev-list --all --pretty=oneline | grep "Modify B" | wc -l) &&
148+
test 1 = $(git rev-list --all --pretty=oneline | grep "Merge remote-tracking branch " | wc -l)
149+
)
150+
'
151+
126152
test_done

t/t3411-rebase-preserve-around-merges.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test_expect_success 'setup' '
3737
# -- C1 --
3838
#
3939
test_expect_success 'squash F1 into D1' '
40-
FAKE_LINES="1 squash 3 2" git rebase -i -p B1 &&
40+
FAKE_LINES="1 squash 4 2 3" git rebase -i -p B1 &&
4141
test "$(git rev-parse HEAD^2)" = "$(git rev-parse C1)" &&
4242
test "$(git rev-parse HEAD~2)" = "$(git rev-parse B1)" &&
4343
git tag E2

0 commit comments

Comments
 (0)