]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1012-read-tree-df.sh
The fifteenth batch
[thirdparty/git.git] / t / t1012-read-tree-df.sh
CommitLineData
934f930b
JH
1#!/bin/sh
2
3test_description='read-tree D/F conflict corner cases'
4
98300c81 5TEST_PASSES_SANITIZE_LEAK=true
934f930b 6. ./test-lib.sh
ea5070c9 7. "$TEST_DIRECTORY"/lib-read-tree.sh
934f930b
JH
8
9maketree () {
10 (
11 rm -f .git/index .git/index.lock &&
12 git clean -d -f -f -q -x &&
13 name="$1" &&
14 shift &&
15 for it
16 do
17 path=$(expr "$it" : '\([^:]*\)') &&
18 mkdir -p $(dirname "$path") &&
19 echo "$it" >"$path" &&
20 git update-index --add "$path" || exit
21 done &&
22 git tag "$name" $(git write-tree)
23 )
24}
25
26settree () {
27 rm -f .git/index .git/index.lock &&
28 git clean -d -f -f -q -x &&
29 git read-tree "$1" &&
30 git checkout-index -f -q -u -a &&
31 git update-index --refresh
32}
33
34checkindex () {
35 git ls-files -s |
2ece6ad2 36 sed "s|^[0-7][0-7]* $OID_REGEX \([0-3]\) |\1 |" >current &&
934f930b
JH
37 cat >expect &&
38 test_cmp expect current
39}
40
41test_expect_success setup '
42 maketree O-000 a/b-2/c/d a/b/c/d a/x &&
43 maketree A-000 a/b-2/c/d a/b/c/d a/x &&
44 maketree A-001 a/b-2/c/d a/b/c/d a/b/c/e a/x &&
45 maketree B-000 a/b-2/c/d a/b a/x &&
46
47 maketree O-010 t-0 t/1 t/2 t=3 &&
48 maketree A-010 t-0 t t=3 &&
49 maketree B-010 t/1: t=3: &&
50
51 maketree O-020 ds/dma/ioat.c ds/dma/ioat_dca.c &&
52 maketree A-020 ds/dma/ioat/Makefile ds/dma/ioat/registers.h &&
53 :
54'
55
730f7284 56test_expect_success '3-way (1)' '
934f930b 57 settree A-000 &&
ea5070c9 58 read_tree_u_must_succeed -m -u O-000 A-000 B-000 &&
934f930b
JH
59 checkindex <<-EOF
60 3 a/b
61 0 a/b-2/c/d
62 1 a/b/c/d
63 2 a/b/c/d
64 0 a/x
65 EOF
66'
67
730f7284 68test_expect_success '3-way (2)' '
934f930b 69 settree A-001 &&
ea5070c9 70 read_tree_u_must_succeed -m -u O-000 A-001 B-000 &&
934f930b
JH
71 checkindex <<-EOF
72 3 a/b
73 0 a/b-2/c/d
74 1 a/b/c/d
75 2 a/b/c/d
76 2 a/b/c/e
77 0 a/x
78 EOF
79'
80
730f7284 81test_expect_success '3-way (3)' '
934f930b 82 settree A-010 &&
ea5070c9 83 read_tree_u_must_succeed -m -u O-010 A-010 B-010 &&
934f930b
JH
84 checkindex <<-EOF
85 2 t
86 1 t-0
87 2 t-0
88 1 t/1
89 3 t/1
90 1 t/2
91 0 t=3
92 EOF
93'
94
730f7284 95test_expect_success '2-way (1)' '
934f930b 96 settree O-020 &&
ea5070c9 97 read_tree_u_must_succeed -m -u O-020 A-020 &&
934f930b
JH
98 checkindex <<-EOF
99 0 ds/dma/ioat/Makefile
100 0 ds/dma/ioat/registers.h
101 EOF
102'
103
104test_done