3 # Copyright(C) 2008 Stephen Habermann & Andreas Ericsson
5 test_description
='git rebase -p should preserve merges
7 Run "git rebase -p" and check that merges are properly carried along
11 GIT_AUTHOR_EMAIL
=bogus_email_address
12 export GIT_AUTHOR_EMAIL
14 # Clone 1 (trivial merge):
16 # A1--A2 <-- origin/master
22 # Clone 2 (conflicting merge):
24 # A1--A2--B3 <-- origin/master
30 # Clone 3 (no-ff merge):
32 # A1--A2--B3 <-- origin/master
40 # Clone 4 (merge using second parent as base):
42 # A1--A2--B3 <-- origin/master
50 test_expect_success
'setup for merge-preserving rebase' \
53 git commit -m "Add A1" &&
54 git checkout -b topic &&
57 git commit -m "Add B1" &&
58 git checkout -f master &&
60 git commit -a -m "Modify A2" &&
62 git clone ./. clone1 &&
64 git checkout -b topic origin/topic &&
65 git merge origin/master
68 git clone ./. clone4 &&
71 git checkout -b topic origin/topic &&
72 git merge origin/master
77 git commit -m "Add different B" &&
79 git clone ./. clone2 &&
82 git checkout -b topic origin/topic &&
83 test_must_fail git merge origin/master &&
86 git commit -m "Merge origin/master into topic"
89 git clone ./. clone3 &&
92 git checkout -b topic2 origin/topic &&
94 git commit -a -m "Modify A3" &&
95 git checkout -b topic origin/topic &&
96 git merge --no-ff topic2
101 git commit -a -m "Modify B2"
104 test_expect_success
'rebase -p fakes interactive rebase' '
108 git rebase -p origin/topic &&
109 test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
110 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge remote-tracking branch " | wc -l)
114 test_expect_success
'--continue works after a conflict' '
118 test_must_fail git rebase -p origin/topic &&
119 test 2 = $(git ls-files B | wc -l) &&
120 echo Resolved again > B &&
121 test_must_fail git rebase --continue &&
122 grep "^@@@ " .git/rebase-merge/patch &&
124 git rebase --continue &&
125 test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
126 test 1 = $(git rev-list --all --pretty=oneline | grep "Add different" | wc -l) &&
127 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge origin" | wc -l)
131 test_expect_success
'rebase -p preserves no-ff merges' '
135 git rebase -p origin/topic &&
136 test 3 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
137 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge branch" | wc -l)
141 test_expect_success
'rebase -p works when base inside second parent' '
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)