blob: a6a04b6b90d290a445ed7c33e5928a9a168ed28b [file] [log] [blame]
Junio C Hamano934f9302009-09-20 11:49:56 -07001#!/bin/sh
2
3test_description='read-tree D/F conflict corner cases'
4
5. ./test-lib.sh
Jens Lehmannea5070c2011-05-25 22:10:41 +02006. "$TEST_DIRECTORY"/lib-read-tree.sh
Junio C Hamano934f9302009-09-20 11:49:56 -07007
8maketree () {
9 (
10 rm -f .git/index .git/index.lock &&
11 git clean -d -f -f -q -x &&
12 name="$1" &&
13 shift &&
14 for it
15 do
16 path=$(expr "$it" : '\([^:]*\)') &&
17 mkdir -p $(dirname "$path") &&
18 echo "$it" >"$path" &&
19 git update-index --add "$path" || exit
20 done &&
21 git tag "$name" $(git write-tree)
22 )
23}
24
25settree () {
26 rm -f .git/index .git/index.lock &&
27 git clean -d -f -f -q -x &&
28 git read-tree "$1" &&
29 git checkout-index -f -q -u -a &&
30 git update-index --refresh
31}
32
33checkindex () {
34 git ls-files -s |
35 sed "s|^[0-7][0-7]* $_x40 \([0-3]\) |\1 |" >current &&
36 cat >expect &&
37 test_cmp expect current
38}
39
40test_expect_success setup '
41 maketree O-000 a/b-2/c/d a/b/c/d a/x &&
42 maketree A-000 a/b-2/c/d a/b/c/d a/x &&
43 maketree A-001 a/b-2/c/d a/b/c/d a/b/c/e a/x &&
44 maketree B-000 a/b-2/c/d a/b a/x &&
45
46 maketree O-010 t-0 t/1 t/2 t=3 &&
47 maketree A-010 t-0 t t=3 &&
48 maketree B-010 t/1: t=3: &&
49
50 maketree O-020 ds/dma/ioat.c ds/dma/ioat_dca.c &&
51 maketree A-020 ds/dma/ioat/Makefile ds/dma/ioat/registers.h &&
52 :
53'
54
Junio C Hamano730f7282009-09-20 00:03:39 -070055test_expect_success '3-way (1)' '
Junio C Hamano934f9302009-09-20 11:49:56 -070056 settree A-000 &&
Jens Lehmannea5070c2011-05-25 22:10:41 +020057 read_tree_u_must_succeed -m -u O-000 A-000 B-000 &&
Junio C Hamano934f9302009-09-20 11:49:56 -070058 checkindex <<-EOF
59 3 a/b
60 0 a/b-2/c/d
61 1 a/b/c/d
62 2 a/b/c/d
63 0 a/x
64 EOF
65'
66
Junio C Hamano730f7282009-09-20 00:03:39 -070067test_expect_success '3-way (2)' '
Junio C Hamano934f9302009-09-20 11:49:56 -070068 settree A-001 &&
Jens Lehmannea5070c2011-05-25 22:10:41 +020069 read_tree_u_must_succeed -m -u O-000 A-001 B-000 &&
Junio C Hamano934f9302009-09-20 11:49:56 -070070 checkindex <<-EOF
71 3 a/b
72 0 a/b-2/c/d
73 1 a/b/c/d
74 2 a/b/c/d
75 2 a/b/c/e
76 0 a/x
77 EOF
78'
79
Junio C Hamano730f7282009-09-20 00:03:39 -070080test_expect_success '3-way (3)' '
Junio C Hamano934f9302009-09-20 11:49:56 -070081 settree A-010 &&
Jens Lehmannea5070c2011-05-25 22:10:41 +020082 read_tree_u_must_succeed -m -u O-010 A-010 B-010 &&
Junio C Hamano934f9302009-09-20 11:49:56 -070083 checkindex <<-EOF
84 2 t
85 1 t-0
86 2 t-0
87 1 t/1
88 3 t/1
89 1 t/2
90 0 t=3
91 EOF
92'
93
Junio C Hamano730f7282009-09-20 00:03:39 -070094test_expect_success '2-way (1)' '
Junio C Hamano934f9302009-09-20 11:49:56 -070095 settree O-020 &&
Jens Lehmannea5070c2011-05-25 22:10:41 +020096 read_tree_u_must_succeed -m -u O-020 A-020 &&
Junio C Hamano934f9302009-09-20 11:49:56 -070097 checkindex <<-EOF
98 0 ds/dma/ioat/Makefile
99 0 ds/dma/ioat/registers.h
100 EOF
101'
102
103test_done