]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3409-rebase-preserve-merges.sh
quote-stress-test: offer to test quoting arguments for MSYS2 sh
[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
11GIT_AUTHOR_EMAIL=bogus_email_address
12export GIT_AUTHOR_EMAIL
13
03c48293
JS
14# Clone 2 (conflicting merge):
15#
16# A1--A2--B3 <-- origin/master
17# \ \
18# B1------M <-- topic
19# \
20# B2 <-- origin/topic
21#
c192f9c8
AW
22# Clone 3 (no-ff merge):
23#
24# A1--A2--B3 <-- origin/master
25# \
26# B1------M <-- topic
27# \ /
28# \--A3 <-- topic2
29# \
30# B2 <-- origin/topic
a9f739c1
RT
31#
32# Clone 4 (same as Clone 3)
f8cca019
AE
33
34test_expect_success 'setup for merge-preserving rebase' \
35 'echo First > A &&
36 git add A &&
5d59a401 37 git commit -m "Add A1" &&
f8cca019
AE
38 git checkout -b topic &&
39 echo Second > B &&
40 git add B &&
5d59a401 41 git commit -m "Add B1" &&
f8cca019
AE
42 git checkout -f master &&
43 echo Third >> A &&
5d59a401 44 git commit -a -m "Modify A2" &&
03c48293
JS
45 echo Fifth > B &&
46 git add B &&
47 git commit -m "Add different B" &&
f8cca019 48
03c48293 49 git clone ./. clone2 &&
18a82692
JN
50 (
51 cd clone2 &&
52 git checkout -b topic origin/topic &&
53 test_must_fail git merge origin/master &&
54 echo Resolved >B &&
55 git add B &&
56 git commit -m "Merge origin/master into topic"
fd4ec4f2 57 ) &&
f8cca019 58
c192f9c8
AW
59 git clone ./. clone3 &&
60 (
61 cd clone3 &&
62 git checkout -b topic2 origin/topic &&
63 echo Sixth > A &&
64 git commit -a -m "Modify A3" &&
65 git checkout -b topic origin/topic &&
66 git merge --no-ff topic2
67 ) &&
68
a9f739c1
RT
69 git clone ./. clone4 &&
70 (
71 cd clone4 &&
72 git checkout -b topic2 origin/topic &&
73 echo Sixth > A &&
74 git commit -a -m "Modify A3" &&
75 git checkout -b topic origin/topic &&
76 git merge --no-ff topic2
77 ) &&
78
f8cca019
AE
79 git checkout topic &&
80 echo Fourth >> B &&
81 git commit -a -m "Modify B2"
82'
83
f5b49ea6 84test_expect_success '--continue works after a conflict' '
03c48293
JS
85 (
86 cd clone2 &&
87 git fetch &&
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 &&
4fb1a19d 92 grep "^@@@ " .git/rebase-merge/patch &&
03c48293
JS
93 git add B &&
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)
98 )
f8cca019
AE
99'
100
c192f9c8
AW
101test_expect_success 'rebase -p preserves no-ff merges' '
102 (
103 cd clone3 &&
104 git fetch &&
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)
108 )
109'
110
a9f739c1
RT
111test_expect_success 'rebase -p ignores merge.log config' '
112 (
113 cd clone4 &&
114 git fetch &&
115 git -c merge.log=1 rebase -p origin/topic &&
116 echo >expected &&
117 git log --format="%b" -1 >current &&
118 test_cmp expected current
119 )
120'
121
f8cca019 122test_done