use strpbrk(3) to search for characters from a given set
[git/debian.git] / t / t6024-recursive-merge.sh
blob0c9e3c20e8ce6a88ff5fe672f3fec82adacaa940
1 #!/bin/sh
3 test_description='Test merge without common ancestors'
4 . ./test-lib.sh
6 # This scenario is based on a real-world repository of Shawn Pearce.
8 # 1 - A - D - F
9 # \ X /
10 # B X
11 # X \
12 # 2 - C - E - G
14 GIT_COMMITTER_DATE="2006-12-12 23:28:00 +0100"
15 export GIT_COMMITTER_DATE
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 &&
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 &&
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 &&
30 git checkout -b D A &&
31 git rev-parse B >.git/MERGE_HEAD &&
32 echo D >a1 &&
33 git update-index a1 &&
34 GIT_AUTHOR_DATE="2006-12-12 23:00:03" git commit -m D &&
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 &&
40 git checkout -b C &&
41 echo C >a1 &&
42 GIT_AUTHOR_DATE="2006-12-12 23:00:05" git commit -m C a1 &&
44 git checkout -b E C &&
45 git rev-parse B >.git/MERGE_HEAD &&
46 echo E >a1 &&
47 git update-index a1 &&
48 GIT_AUTHOR_DATE="2006-12-12 23:00:06" git commit -m E &&
50 git checkout -b G E &&
51 git rev-parse A >.git/MERGE_HEAD &&
52 echo G >a1 &&
53 git update-index a1 &&
54 GIT_AUTHOR_DATE="2006-12-12 23:00:07" git commit -m G &&
56 git checkout -b F D &&
57 git rev-parse C >.git/MERGE_HEAD &&
58 echo F >a1 &&
59 git update-index a1 &&
60 GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F
63 test_expect_success 'combined merge conflicts' '
64 test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git merge -m final G
67 test_expect_success 'result contains a conflict' '
68 cat >expect <<-\EOF &&
69 <<<<<<< HEAD
71 =======
73 >>>>>>> G
74 EOF
76 test_cmp expect a1
79 test_expect_success 'virtual trees were processed' '
80 git ls-files --stage >out &&
82 cat >expect <<-\EOF &&
83 100644 ec3fe2a791706733f2d8fa7ad45d9a9672031f5e 1 a1
84 100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2 a1
85 100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1
86 EOF
88 test_cmp expect out
91 test_expect_success 'refuse to merge binary files' '
92 git reset --hard &&
93 printf "\0" >binary-file &&
94 git add binary-file &&
95 git commit -m binary &&
96 git checkout G &&
97 printf "\0\0" >binary-file &&
98 git add binary-file &&
99 git commit -m binary2 &&
100 test_must_fail git merge F >merge.out 2>merge.err &&
101 grep "Cannot merge binary files: binary-file (HEAD vs. F)" merge.err
104 test_expect_success 'mark rename/delete as unmerged' '
106 git reset --hard &&
107 git checkout -b delete &&
108 git rm a1 &&
109 test_tick &&
110 git commit -m delete &&
111 git checkout -b rename HEAD^ &&
112 git mv a1 a2 &&
113 test_tick &&
114 git commit -m rename &&
115 test_must_fail git merge delete &&
116 test 1 = $(git ls-files --unmerged | wc -l) &&
117 git rev-parse --verify :2:a2 &&
118 test_must_fail git rev-parse --verify :3:a2 &&
119 git checkout -f delete &&
120 test_must_fail git merge rename &&
121 test 1 = $(git ls-files --unmerged | wc -l) &&
122 test_must_fail git rev-parse --verify :2:a2 &&
123 git rev-parse --verify :3:a2
126 test_done