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 # Clone 4 (same as Clone 3)
34 test_expect_success 'setup for merge-preserving rebase' \
37 git commit -m "Add A1" &&
38 git checkout -b topic &&
41 git commit -m "Add B1" &&
42 git checkout -f master &&
44 git commit -a -m "Modify A2" &&
47 git commit -m "Add different B" &&
49 git clone ./. clone2 &&
52 git checkout -b topic origin/topic &&
53 test_must_fail git merge origin/master &&
56 git commit -m "Merge origin/master into topic"
59 git clone ./. clone3 &&
62 git checkout -b topic2 origin/topic &&
64 git commit -a -m "Modify A3" &&
65 git checkout -b topic origin/topic &&
66 git merge --no-ff topic2
69 git clone ./. clone4 &&
72 git checkout -b topic2 origin/topic &&
74 git commit -a -m "Modify A3" &&
75 git checkout -b topic origin/topic &&
76 git merge --no-ff topic2
81 git commit -a -m "Modify B2"
84 test_expect_success '--continue works after a conflict' '
88 test_must_fail git rebase -p origin/topic &&
89 test 2 = $(git ls-files B | wc -l) &&
90 echo Resolved again > B &&
91 test_must_fail git rebase --continue &&
92 grep "^@@@ " .git/rebase-merge/patch &&
94 git rebase --continue &&
95 test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
96 test 1 = $(git rev-list --all --pretty=oneline | grep "Add different" | wc -l) &&
97 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge origin" | wc -l)
101 test_expect_success 'rebase -p preserves no-ff merges' '
105 git rebase -p origin/topic &&
106 test 3 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
107 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge branch" | wc -l)
111 test_expect_success 'rebase -p ignores merge.log config' '
115 git -c merge.log=1 rebase -p origin/topic &&
117 git log --format="%b" -1 >current &&
118 test_cmp expected current