]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3409-rebase-preserve-merges.sh
hashmap: use *_entry APIs for iteration
[thirdparty/git.git] / t / t3409-rebase-preserve-merges.sh
CommitLineData
f8cca019
AE
1#!/bin/sh
2#
3# Copyright(C) 2008 Stephen Habermann & Andreas Ericsson
4#
5test_description='git rebase -p should preserve merges
6
7Run "git rebase -p" and check that merges are properly carried along
8'
9. ./test-lib.sh
10
11aad464
JS
11if ! test_have_prereq REBASE_P; then
12 skip_all='skipping git rebase -p tests, as asked for'
13 test_done
14fi
15
f8cca019
AE
16GIT_AUTHOR_EMAIL=bogus_email_address
17export GIT_AUTHOR_EMAIL
18
03c48293
JS
19# Clone 2 (conflicting merge):
20#
21# A1--A2--B3 <-- origin/master
22# \ \
23# B1------M <-- topic
24# \
25# B2 <-- origin/topic
26#
c192f9c8
AW
27# Clone 3 (no-ff merge):
28#
29# A1--A2--B3 <-- origin/master
30# \
31# B1------M <-- topic
32# \ /
33# \--A3 <-- topic2
34# \
35# B2 <-- origin/topic
a9f739c1
RT
36#
37# Clone 4 (same as Clone 3)
f8cca019
AE
38
39test_expect_success 'setup for merge-preserving rebase' \
40 'echo First > A &&
41 git add A &&
5d59a401 42 git commit -m "Add A1" &&
f8cca019
AE
43 git checkout -b topic &&
44 echo Second > B &&
45 git add B &&
5d59a401 46 git commit -m "Add B1" &&
f8cca019
AE
47 git checkout -f master &&
48 echo Third >> A &&
5d59a401 49 git commit -a -m "Modify A2" &&
03c48293
JS
50 echo Fifth > B &&
51 git add B &&
52 git commit -m "Add different B" &&
f8cca019 53
03c48293 54 git clone ./. clone2 &&
18a82692
JN
55 (
56 cd clone2 &&
57 git checkout -b topic origin/topic &&
58 test_must_fail git merge origin/master &&
59 echo Resolved >B &&
60 git add B &&
61 git commit -m "Merge origin/master into topic"
fd4ec4f2 62 ) &&
f8cca019 63
c192f9c8
AW
64 git clone ./. clone3 &&
65 (
66 cd clone3 &&
67 git checkout -b topic2 origin/topic &&
68 echo Sixth > A &&
69 git commit -a -m "Modify A3" &&
70 git checkout -b topic origin/topic &&
71 git merge --no-ff topic2
72 ) &&
73
a9f739c1
RT
74 git clone ./. clone4 &&
75 (
76 cd clone4 &&
77 git checkout -b topic2 origin/topic &&
78 echo Sixth > A &&
79 git commit -a -m "Modify A3" &&
80 git checkout -b topic origin/topic &&
81 git merge --no-ff topic2
82 ) &&
83
f8cca019
AE
84 git checkout topic &&
85 echo Fourth >> B &&
86 git commit -a -m "Modify B2"
87'
88
f5b49ea6 89test_expect_success '--continue works after a conflict' '
03c48293
JS
90 (
91 cd clone2 &&
92 git fetch &&
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 &&
4fb1a19d 97 grep "^@@@ " .git/rebase-merge/patch &&
03c48293
JS
98 git add B &&
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)
103 )
f8cca019
AE
104'
105
c192f9c8
AW
106test_expect_success 'rebase -p preserves no-ff merges' '
107 (
108 cd clone3 &&
109 git fetch &&
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)
113 )
114'
115
a9f739c1
RT
116test_expect_success 'rebase -p ignores merge.log config' '
117 (
118 cd clone4 &&
119 git fetch &&
120 git -c merge.log=1 rebase -p origin/topic &&
121 echo >expected &&
122 git log --format="%b" -1 >current &&
123 test_cmp expected current
124 )
125'
126
f8cca019 127test_done