]>
Commit | Line | Data |
---|---|---|
c93be3b5 JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='Test merge without common ancestors' | |
4 | . ./test-lib.sh | |
5 | ||
6 | # This scenario is based on a real-world repository of Shawn Pearce. | |
7 | ||
8 | # 1 - A - D - F | |
9 | # \ X / | |
10 | # B X | |
11 | # X \ | |
12 | # 2 - C - E - G | |
13 | ||
7d2ba122 EW |
14 | GIT_COMMITTER_DATE="2006-12-12 23:28:00 +0100" |
15 | export GIT_COMMITTER_DATE | |
16 | ||
17 | test_expect_success "setup tests" ' | |
18 | echo 1 > a1 && | |
19 | git add a1 && | |
20 | GIT_AUTHOR_DATE="2006-12-12 23:00:00" git commit -m 1 a1 && | |
21 | ||
22 | git checkout -b A master && | |
23 | echo A > a1 && | |
24 | GIT_AUTHOR_DATE="2006-12-12 23:00:01" git commit -m A a1 && | |
25 | ||
26 | git checkout -b B master && | |
27 | echo B > a1 && | |
28 | GIT_AUTHOR_DATE="2006-12-12 23:00:02" git commit -m B a1 && | |
29 | ||
30 | git checkout -b D A && | |
5be60078 | 31 | git rev-parse B > .git/MERGE_HEAD && |
7d2ba122 EW |
32 | echo D > a1 && |
33 | git update-index a1 && | |
34 | GIT_AUTHOR_DATE="2006-12-12 23:00:03" git commit -m D && | |
35 | ||
36 | git symbolic-ref HEAD refs/heads/other && | |
37 | echo 2 > a1 && | |
38 | GIT_AUTHOR_DATE="2006-12-12 23:00:04" git commit -m 2 a1 && | |
39 | ||
40 | git checkout -b C && | |
41 | echo C > a1 && | |
42 | GIT_AUTHOR_DATE="2006-12-12 23:00:05" git commit -m C a1 && | |
43 | ||
44 | git checkout -b E C && | |
5be60078 | 45 | git rev-parse B > .git/MERGE_HEAD && |
7d2ba122 EW |
46 | echo E > a1 && |
47 | git update-index a1 && | |
48 | GIT_AUTHOR_DATE="2006-12-12 23:00:06" git commit -m E && | |
49 | ||
50 | git checkout -b G E && | |
5be60078 | 51 | git rev-parse A > .git/MERGE_HEAD && |
7d2ba122 EW |
52 | echo G > a1 && |
53 | git update-index a1 && | |
54 | GIT_AUTHOR_DATE="2006-12-12 23:00:07" git commit -m G && | |
55 | ||
56 | git checkout -b F D && | |
5be60078 | 57 | git rev-parse C > .git/MERGE_HEAD && |
7d2ba122 EW |
58 | echo F > a1 && |
59 | git update-index a1 && | |
c93be3b5 | 60 | GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F |
7d2ba122 | 61 | ' |
c93be3b5 | 62 | |
41ac414e | 63 | test_expect_success "combined merge conflicts" "! git merge -m final G" |
c93be3b5 | 64 | |
f953831e | 65 | cat > expect << EOF |
e0ec1819 | 66 | <<<<<<< HEAD:a1 |
f953831e JS |
67 | F |
68 | ======= | |
69 | G | |
e0ec1819 | 70 | >>>>>>> G:a1 |
f953831e JS |
71 | EOF |
72 | ||
5bd74506 | 73 | test_expect_success "result contains a conflict" "git diff expect a1" |
f953831e | 74 | |
c93be3b5 JH |
75 | git ls-files --stage > out |
76 | cat > expect << EOF | |
e0ec1819 | 77 | 100644 da056ce14a2241509897fa68bb2b3b6e6194ef9e 1 a1 |
c93be3b5 JH |
78 | 100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2 a1 |
79 | 100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1 | |
80 | EOF | |
81 | ||
5bd74506 | 82 | test_expect_success "virtual trees were processed" "git diff expect out" |
c93be3b5 | 83 | |
9f30855d | 84 | test_expect_success 'refuse to merge binary files' ' |
c3b088d9 | 85 | git reset --hard && |
9f30855d JS |
86 | printf "\0" > binary-file && |
87 | git add binary-file && | |
88 | git commit -m binary && | |
89 | git checkout G && | |
90 | printf "\0\0" > binary-file && | |
91 | git add binary-file && | |
92 | git commit -m binary2 && | |
93 | ! git merge F > merge.out 2> merge.err && | |
94 | grep "Cannot merge binary files: HEAD:binary-file vs. F:binary-file" \ | |
95 | merge.err | |
96 | ' | |
97 | ||
c93be3b5 | 98 | test_done |