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 if ! test_have_prereq REBASE_P; then
12 skip_all='skipping git rebase -p tests, as asked for'
16 GIT_AUTHOR_EMAIL=bogus_email_address
17 export GIT_AUTHOR_EMAIL
19 # Clone 2 (conflicting merge):
21 # A1--A2--B3 <-- origin/master
27 # Clone 3 (no-ff merge):
29 # A1--A2--B3 <-- origin/master
37 # Clone 4 (same as Clone 3)
39 test_expect_success 'setup for merge-preserving rebase' \
42 git commit -m "Add A1" &&
43 git checkout -b topic &&
46 git commit -m "Add B1" &&
47 git checkout -f master &&
49 git commit -a -m "Modify A2" &&
52 git commit -m "Add different B" &&
54 git clone ./. clone2 &&
57 git checkout -b topic origin/topic &&
58 test_must_fail git merge origin/master &&
61 git commit -m "Merge origin/master into topic"
64 git clone ./. clone3 &&
67 git checkout -b topic2 origin/topic &&
69 git commit -a -m "Modify A3" &&
70 git checkout -b topic origin/topic &&
71 git merge --no-ff topic2
74 git clone ./. clone4 &&
77 git checkout -b topic2 origin/topic &&
79 git commit -a -m "Modify A3" &&
80 git checkout -b topic origin/topic &&
81 git merge --no-ff topic2
86 git commit -a -m "Modify B2"
89 test_expect_success '--continue works after a conflict' '
93 test_must_fail git rebase -p origin/topic &&
94 test 2 = $(git ls-files B | wc -l) &&
95 echo Resolved again > B &&
96 test_must_fail git rebase --continue &&
97 grep "^@@@ " .git/rebase-merge/patch &&
99 git rebase --continue &&
100 test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
101 test 1 = $(git rev-list --all --pretty=oneline | grep "Add different" | wc -l) &&
102 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge origin" | wc -l)
106 test_expect_success 'rebase -p preserves no-ff merges' '
110 git rebase -p origin/topic &&
111 test 3 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
112 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge branch" | wc -l)
116 test_expect_success 'rebase -p ignores merge.log config' '
120 git -c merge.log=1 rebase -p origin/topic &&
122 git log --format="%b" -1 >current &&
123 test_cmp expected current