]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3409-rebase-preserve-merges.sh
merge-recursive: Cleanup and consolidation of rename_conflict_info
[thirdparty/git.git] / t / t3409-rebase-preserve-merges.sh
1 #!/bin/sh
2 #
3 # Copyright(C) 2008 Stephen Habermann & Andreas Ericsson
4 #
5 test_description='git rebase -p should preserve merges
6
7 Run "git rebase -p" and check that merges are properly carried along
8 '
9 . ./test-lib.sh
10
11 GIT_AUTHOR_EMAIL=bogus_email_address
12 export GIT_AUTHOR_EMAIL
13
14 # Clone 1 (trivial merge):
15 #
16 # A1--A2 <-- origin/master
17 # \ \
18 # B1--M <-- topic
19 # \
20 # B2 <-- origin/topic
21 #
22 # Clone 2 (conflicting merge):
23 #
24 # A1--A2--B3 <-- origin/master
25 # \ \
26 # B1------M <-- topic
27 # \
28 # B2 <-- origin/topic
29 #
30 # Clone 3 (no-ff merge):
31 #
32 # A1--A2--B3 <-- origin/master
33 # \
34 # B1------M <-- topic
35 # \ /
36 # \--A3 <-- topic2
37 # \
38 # B2 <-- origin/topic
39 #
40 # In all cases, 'topic' is rebased onto 'origin/topic'.
41
42 test_expect_success 'setup for merge-preserving rebase' \
43 'echo First > A &&
44 git add A &&
45 git commit -m "Add A1" &&
46 git checkout -b topic &&
47 echo Second > B &&
48 git add B &&
49 git commit -m "Add B1" &&
50 git checkout -f master &&
51 echo Third >> A &&
52 git commit -a -m "Modify A2" &&
53
54 git clone ./. clone1 &&
55 (cd clone1 &&
56 git checkout -b topic origin/topic &&
57 git merge origin/master
58 ) &&
59
60 echo Fifth > B &&
61 git add B &&
62 git commit -m "Add different B" &&
63
64 git clone ./. clone2 &&
65 (
66 cd clone2 &&
67 git checkout -b topic origin/topic &&
68 test_must_fail git merge origin/master &&
69 echo Resolved >B &&
70 git add B &&
71 git commit -m "Merge origin/master into topic"
72 ) &&
73
74 git clone ./. clone3 &&
75 (
76 cd clone3 &&
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
84 git checkout topic &&
85 echo Fourth >> B &&
86 git commit -a -m "Modify B2"
87 '
88
89 test_expect_success 'rebase -p fakes interactive rebase' '
90 (
91 cd clone1 &&
92 git fetch &&
93 git rebase -p origin/topic &&
94 test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
95 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge remote-tracking branch " | wc -l)
96 )
97 '
98
99 test_expect_success '--continue works after a conflict' '
100 (
101 cd clone2 &&
102 git fetch &&
103 test_must_fail git rebase -p origin/topic &&
104 test 2 = $(git ls-files B | wc -l) &&
105 echo Resolved again > B &&
106 test_must_fail git rebase --continue &&
107 grep "^@@@ " .git/rebase-merge/patch &&
108 git add B &&
109 git rebase --continue &&
110 test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
111 test 1 = $(git rev-list --all --pretty=oneline | grep "Add different" | wc -l) &&
112 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge origin" | wc -l)
113 )
114 '
115
116 test_expect_success 'rebase -p preserves no-ff merges' '
117 (
118 cd clone3 &&
119 git fetch &&
120 git rebase -p origin/topic &&
121 test 3 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
122 test 1 = $(git rev-list --all --pretty=oneline | grep "Merge branch" | wc -l)
123 )
124 '
125
126 test_done