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
9 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
10 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
14 if ! test_have_prereq REBASE_P; then
15 skip_all='skipping git rebase -p tests, as asked for'
19 GIT_AUTHOR_EMAIL=bogus_email_address
20 export GIT_AUTHOR_EMAIL
22 # Clone 2 (conflicting merge):
24 # A1--A2--B3 <-- origin/main
30 # Clone 3 (no-ff merge):
32 # A1--A2--B3 <-- origin/main
40 # Clone 4 (same as Clone 3)
42 test_expect_success 'setup for merge-preserving rebase' \
45 git commit -m "Add A1" &&
46 git checkout -b topic &&
49 git commit -m "Add B1" &&
50 git checkout -f main &&
52 git commit -a -m "Modify A2" &&
55 git commit -m "Add different B" &&
57 git clone ./. clone2 &&
60 git checkout -b topic origin/topic &&
61 test_must_fail git merge origin/main &&
64 git commit -m "Merge origin/main into topic"
67 git clone ./. clone3 &&
70 git checkout -b topic2 origin/topic &&
72 git commit -a -m "Modify A3" &&
73 git checkout -b topic origin/topic &&
74 git merge --no-ff topic2
77 git clone ./. clone4 &&
80 git checkout -b topic2 origin/topic &&
82 git commit -a -m "Modify A3" &&
83 git checkout -b topic origin/topic &&
84 git merge --no-ff topic2
89 git commit -a -m "Modify B2"
92 test_expect_success '--continue works after a conflict' '
96 test_must_fail git rebase -p origin/topic &&
97 test 2 = $(git ls-files B | wc -l) &&
98 echo Resolved again > B &&
99 test_must_fail git rebase --continue &&
100 grep "^@@@ " .git/rebase-merge/patch &&
102 git rebase --continue &&
103 test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
104 test 1 = $(git rev-list --all --pretty=oneline | grep "Add different" | wc -l) &&
105 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge origin" | wc -l)
109 test_expect_success 'rebase -p preserves no-ff merges' '
113 git rebase -p origin/topic &&
114 test 3 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
115 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge branch" | wc -l)
119 test_expect_success 'rebase -p ignores merge.log config' '
123 git -c merge.log=1 rebase -p origin/topic &&
125 git log --format="%b" -1 >current &&
126 test_cmp expected current