Merge branch 'jn/ignore-doc' into maint
[git/jnareb-git.git] / t / t1012-read-tree-df.sh
blob9811d467da5a54eefd68ecfad4c68b67e5b3734f
1 #!/bin/sh
3 test_description='read-tree D/F conflict corner cases'
5 . ./test-lib.sh
7 maketree () {
9 rm -f .git/index .git/index.lock &&
10 git clean -d -f -f -q -x &&
11 name="$1" &&
12 shift &&
13 for it
15 path=$(expr "$it" : '\([^:]*\)') &&
16 mkdir -p $(dirname "$path") &&
17 echo "$it" >"$path" &&
18 git update-index --add "$path" || exit
19 done &&
20 git tag "$name" $(git write-tree)
24 settree () {
25 rm -f .git/index .git/index.lock &&
26 git clean -d -f -f -q -x &&
27 git read-tree "$1" &&
28 git checkout-index -f -q -u -a &&
29 git update-index --refresh
32 checkindex () {
33 git ls-files -s |
34 sed "s|^[0-7][0-7]* $_x40 \([0-3]\) |\1 |" >current &&
35 cat >expect &&
36 test_cmp expect current
39 test_expect_success setup '
40 maketree O-000 a/b-2/c/d a/b/c/d a/x &&
41 maketree A-000 a/b-2/c/d a/b/c/d a/x &&
42 maketree A-001 a/b-2/c/d a/b/c/d a/b/c/e a/x &&
43 maketree B-000 a/b-2/c/d a/b a/x &&
45 maketree O-010 t-0 t/1 t/2 t=3 &&
46 maketree A-010 t-0 t t=3 &&
47 maketree B-010 t/1: t=3: &&
49 maketree O-020 ds/dma/ioat.c ds/dma/ioat_dca.c &&
50 maketree A-020 ds/dma/ioat/Makefile ds/dma/ioat/registers.h &&
54 test_expect_success '3-way (1)' '
55 settree A-000 &&
56 git read-tree -m -u O-000 A-000 B-000 &&
57 checkindex <<-EOF
58 3 a/b
59 0 a/b-2/c/d
60 1 a/b/c/d
61 2 a/b/c/d
62 0 a/x
63 EOF
66 test_expect_success '3-way (2)' '
67 settree A-001 &&
68 git read-tree -m -u O-000 A-001 B-000 &&
69 checkindex <<-EOF
70 3 a/b
71 0 a/b-2/c/d
72 1 a/b/c/d
73 2 a/b/c/d
74 2 a/b/c/e
75 0 a/x
76 EOF
79 test_expect_success '3-way (3)' '
80 settree A-010 &&
81 git read-tree -m -u O-010 A-010 B-010 &&
82 checkindex <<-EOF
83 2 t
84 1 t-0
85 2 t-0
86 1 t/1
87 3 t/1
88 1 t/2
89 0 t=3
90 EOF
93 test_expect_success '2-way (1)' '
94 settree O-020 &&
95 git read-tree -m -u O-020 A-020 &&
96 checkindex <<-EOF
97 0 ds/dma/ioat/Makefile
98 0 ds/dma/ioat/registers.h
99 EOF
102 test_done