Makefile: propagate NATIVE_CRLF to C
[alt-git.git] / t / t3409-rebase-preserve-merges.sh
blob8c251c57a6827317a9c17fac2a0e99df3c9becf8
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 GIT_AUTHOR_EMAIL=bogus_email_address
12 export GIT_AUTHOR_EMAIL
14 # Clone 2 (conflicting merge):
16 # A1--A2--B3 <-- origin/master
17 # \ \
18 # B1------M <-- topic
19 # \
20 # B2 <-- origin/topic
22 # Clone 3 (no-ff merge):
24 # A1--A2--B3 <-- origin/master
25 # \
26 # B1------M <-- topic
27 # \ /
28 # \--A3 <-- topic2
29 # \
30 # B2 <-- origin/topic
32 # Clone 4 (same as Clone 3)
34 test_expect_success 'setup for merge-preserving rebase' \
35 'echo First > A &&
36 git add A &&
37 git commit -m "Add A1" &&
38 git checkout -b topic &&
39 echo Second > B &&
40 git add B &&
41 git commit -m "Add B1" &&
42 git checkout -f master &&
43 echo Third >> A &&
44 git commit -a -m "Modify A2" &&
45 echo Fifth > B &&
46 git add B &&
47 git commit -m "Add different B" &&
49 git clone ./. clone2 &&
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"
57 ) &&
59 git clone ./. clone3 &&
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 ) &&
69 git clone ./. clone4 &&
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 ) &&
79 git checkout topic &&
80 echo Fourth >> B &&
81 git commit -a -m "Modify B2"
84 test_expect_success '--continue works after a conflict' '
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 &&
92 grep "^@@@ " .git/rebase-merge/patch &&
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)
101 test_expect_success 'rebase -p preserves no-ff merges' '
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)
111 test_expect_success 'rebase -p ignores merge.log config' '
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
122 test_done