1#!/bin/sh
23
test_description='read-tree D/F conflict corner cases'
45
. ./test-lib.sh
6. "$TEST_DIRECTORY"/lib-read-tree.sh
78
maketree () {
9(
10rm -f .git/index .git/index.lock &&
11git clean -d -f -f -q -x &&
12name="$1" &&
13shift &&
14for it
15do
16path=$(expr "$it" : '\([^:]*\)') &&
17mkdir -p $(dirname "$path") &&
18echo "$it" >"$path" &&
19git update-index --add "$path" || exit
20done &&
21git tag "$name" $(git write-tree)
22)
23}
2425
settree () {
26rm -f .git/index .git/index.lock &&
27git clean -d -f -f -q -x &&
28git read-tree "$1" &&
29git checkout-index -f -q -u -a &&
30git update-index --refresh
31}
3233
checkindex () {
34git ls-files -s |
35sed "s|^[0-7][0-7]* $_x40 \([0-3]\) |\1 |" >current &&
36cat >expect &&
37test_cmp expect current
38}
3940
test_expect_success setup '
41maketree O-000 a/b-2/c/d a/b/c/d a/x &&
42maketree A-000 a/b-2/c/d a/b/c/d a/x &&
43maketree A-001 a/b-2/c/d a/b/c/d a/b/c/e a/x &&
44maketree B-000 a/b-2/c/d a/b a/x &&
4546
maketree O-010 t-0 t/1 t/2 t=3 &&
47maketree A-010 t-0 t t=3 &&
48maketree B-010 t/1: t=3: &&
4950
maketree O-020 ds/dma/ioat.c ds/dma/ioat_dca.c &&
51maketree A-020 ds/dma/ioat/Makefile ds/dma/ioat/registers.h &&
52:
53'
5455
test_expect_success '3-way (1)' '
56settree A-000 &&
57read_tree_u_must_succeed -m -u O-000 A-000 B-000 &&
58checkindex <<-EOF
593 a/b
600 a/b-2/c/d
611 a/b/c/d
622 a/b/c/d
630 a/x
64EOF
65'
6667
test_expect_success '3-way (2)' '
68settree A-001 &&
69read_tree_u_must_succeed -m -u O-000 A-001 B-000 &&
70checkindex <<-EOF
713 a/b
720 a/b-2/c/d
731 a/b/c/d
742 a/b/c/d
752 a/b/c/e
760 a/x
77EOF
78'
7980
test_expect_success '3-way (3)' '
81settree A-010 &&
82read_tree_u_must_succeed -m -u O-010 A-010 B-010 &&
83checkindex <<-EOF
842 t
851 t-0
862 t-0
871 t/1
883 t/1
891 t/2
900 t=3
91EOF
92'
9394
test_expect_success '2-way (1)' '
95settree O-020 &&
96read_tree_u_must_succeed -m -u O-020 A-020 &&
97checkindex <<-EOF
980 ds/dma/ioat/Makefile
990 ds/dma/ioat/registers.h
100EOF
101'
102103
test_done