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 2 (conflicting merge):
16 # A1--A2--B3 <-- origin/master
22 # Clone 3 (no-ff merge):
24 # A1--A2--B3 <-- origin/master
32 test_expect_success 'setup for merge-preserving rebase' \
35 git commit -m "Add A1" &&
36 git checkout -b topic &&
39 git commit -m "Add B1" &&
40 git checkout -f master &&
42 git commit -a -m "Modify A2" &&
45 git commit -m "Add different B" &&
47 git clone ./. clone2 &&
50 git checkout -b topic origin/topic &&
51 test_must_fail git merge origin/master &&
54 git commit -m "Merge origin/master into topic"
57 git clone ./. clone3 &&
60 git checkout -b topic2 origin/topic &&
62 git commit -a -m "Modify A3" &&
63 git checkout -b topic origin/topic &&
64 git merge --no-ff topic2
69 git commit -a -m "Modify B2"
72 test_expect_success '--continue works after a conflict' '
76 test_must_fail git rebase -p origin/topic &&
77 test 2 = $(git ls-files B | wc -l) &&
78 echo Resolved again > B &&
79 test_must_fail git rebase --continue &&
80 grep "^@@@ " .git/rebase-merge/patch &&
82 git rebase --continue &&
83 test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
84 test 1 = $(git rev-list --all --pretty=oneline | grep "Add different" | wc -l) &&
85 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge origin" | wc -l)
89 test_expect_success 'rebase -p preserves no-ff merges' '
93 git rebase -p origin/topic &&
94 test 3 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
95 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge branch" | wc -l)