tests: include detailed trace logs with --write-junit-xml upon failure
[git.git] / t / t3409-rebase-preserve-merges.sh
blob3b340f1ece3601b0729d09ea1f976db5b3a8ef65
1 #!/bin/sh
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 . ./test-lib.sh
11 if ! test_have_prereq REBASE_P; then
12 skip_all='skipping git rebase -p tests, as asked for'
13 test_done
16 GIT_AUTHOR_EMAIL=bogus_email_address
17 export GIT_AUTHOR_EMAIL
19 # Clone 2 (conflicting merge):
21 # A1--A2--B3 <-- origin/master
22 # \ \
23 # B1------M <-- topic
24 # \
25 # B2 <-- origin/topic
27 # Clone 3 (no-ff merge):
29 # A1--A2--B3 <-- origin/master
30 # \
31 # B1------M <-- topic
32 # \ /
33 # \--A3 <-- topic2
34 # \
35 # B2 <-- origin/topic
37 # Clone 4 (same as Clone 3)
39 test_expect_success 'setup for merge-preserving rebase' \
40 'echo First > A &&
41 git add A &&
42 git commit -m "Add A1" &&
43 git checkout -b topic &&
44 echo Second > B &&
45 git add B &&
46 git commit -m "Add B1" &&
47 git checkout -f master &&
48 echo Third >> A &&
49 git commit -a -m "Modify A2" &&
50 echo Fifth > B &&
51 git add B &&
52 git commit -m "Add different B" &&
54 git clone ./. clone2 &&
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"
62 ) &&
64 git clone ./. clone3 &&
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 ) &&
74 git clone ./. clone4 &&
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 ) &&
84 git checkout topic &&
85 echo Fourth >> B &&
86 git commit -a -m "Modify B2"
89 test_expect_success '--continue works after a conflict' '
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 &&
97 grep "^@@@ " .git/rebase-merge/patch &&
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)
106 test_expect_success 'rebase -p preserves no-ff merges' '
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)
116 test_expect_success 'rebase -p ignores merge.log config' '
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
127 test_done