1#!/bin/sh
2
3test_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
14export GIT_COMMITTER_DATE="2006-12-12 23:28:00 +0100"
15echo 1 > a1
16git add a1
17GIT_AUTHOR_DATE="2006-12-12 23:00:00" git commit -m 1 a1
18
19git checkout -b A master
20echo A > a1
21GIT_AUTHOR_DATE="2006-12-12 23:00:01" git commit -m A a1
22
23git checkout -b B master
24echo B > a1
25GIT_AUTHOR_DATE="2006-12-12 23:00:02" git commit -m B a1
26
27git checkout -b D A
28git-rev-parse B > .git/MERGE_HEAD
29echo D > a1
30git update-index a1
31GIT_AUTHOR_DATE="2006-12-12 23:00:03" git commit -m D
32
33git symbolic-ref HEAD refs/heads/other
34echo 2 > a1
35GIT_AUTHOR_DATE="2006-12-12 23:00:04" git commit -m 2 a1
36
37git checkout -b C
38echo C > a1
39GIT_AUTHOR_DATE="2006-12-12 23:00:05" git commit -m C a1
40
41git checkout -b E C
42git-rev-parse B > .git/MERGE_HEAD
43echo E > a1
44git update-index a1
45GIT_AUTHOR_DATE="2006-12-12 23:00:06" git commit -m E
46
47git checkout -b G E
48git-rev-parse A > .git/MERGE_HEAD
49echo G > a1
50git update-index a1
51GIT_AUTHOR_DATE="2006-12-12 23:00:07" git commit -m G
52
53git checkout -b F D
54git-rev-parse C > .git/MERGE_HEAD
55echo F > a1
56git update-index a1
57GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F
58
59test_expect_failure "combined merge conflicts" "git merge -m final G"
60
61cat > expect << EOF
62<<<<<<< HEAD/a1
63F
64=======
65G
66>>>>>>> 26f86b677eb03d4d956dbe108b29cb77061c1e73/a1
67EOF
68
69test_expect_success "result contains a conflict" "diff -u expect a1"
70
71git ls-files --stage > out
72cat > expect << EOF
73100644 f16f906ab60483c100d1241dfc39868de9ec9fcb 1 a1
74100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2 a1
75100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1
76EOF
77
78test_expect_success "virtual trees were processed" "diff -u expect out"
79
80test_done