]> rtime.felk.cvut.cz Git - git.git/blob - t/t0003-attributes.sh
Merge branch 'jn/gitweb-syntax-highlight'
[git.git] / t / t0003-attributes.sh
1 #!/bin/sh
2
3 test_description=gitattributes
4
5 . ./test-lib.sh
6
7 attr_check () {
8
9         path="$1"
10         expect="$2"
11
12         git check-attr test -- "$path" >actual &&
13         echo "$path: test: $2" >expect &&
14         test_cmp expect actual
15
16 }
17
18
19 test_expect_success 'setup' '
20
21         mkdir -p a/b/d a/c &&
22         (
23                 echo "[attr]notest !test"
24                 echo "f test=f"
25                 echo "a/i test=a/i"
26                 echo "onoff test -test"
27                 echo "offon -test test"
28                 echo "no notest"
29         ) >.gitattributes &&
30         (
31                 echo "g test=a/g" &&
32                 echo "b/g test=a/b/g"
33         ) >a/.gitattributes &&
34         (
35                 echo "h test=a/b/h" &&
36                 echo "d/* test=a/b/d/*"
37                 echo "d/yes notest"
38         ) >a/b/.gitattributes
39
40 '
41
42 test_expect_success 'attribute test' '
43
44         attr_check f f &&
45         attr_check a/f f &&
46         attr_check a/c/f f &&
47         attr_check a/g a/g &&
48         attr_check a/b/g a/b/g &&
49         attr_check b/g unspecified &&
50         attr_check a/b/h a/b/h &&
51         attr_check a/b/d/g "a/b/d/*"
52         attr_check onoff unset
53         attr_check offon set
54         attr_check no unspecified
55         attr_check a/b/d/no "a/b/d/*"
56         attr_check a/b/d/yes unspecified
57
58 '
59
60 test_expect_success 'attribute test: read paths from stdin' '
61
62         cat <<EOF > expect
63 f: test: f
64 a/f: test: f
65 a/c/f: test: f
66 a/g: test: a/g
67 a/b/g: test: a/b/g
68 b/g: test: unspecified
69 a/b/h: test: a/b/h
70 a/b/d/g: test: a/b/d/*
71 onoff: test: unset
72 offon: test: set
73 no: test: unspecified
74 a/b/d/no: test: a/b/d/*
75 a/b/d/yes: test: unspecified
76 EOF
77
78         sed -e "s/:.*//" < expect | git check-attr --stdin test > actual &&
79         test_cmp expect actual
80 '
81
82 test_expect_success 'root subdir attribute test' '
83
84         attr_check a/i a/i &&
85         attr_check subdir/a/i unspecified
86
87 '
88
89 test_expect_success 'setup bare' '
90
91         git clone --bare . bare.git &&
92         cd bare.git
93
94 '
95
96 test_expect_success 'bare repository: check that .gitattribute is ignored' '
97
98         (
99                 echo "f test=f"
100                 echo "a/i test=a/i"
101         ) >.gitattributes &&
102         attr_check f unspecified &&
103         attr_check a/f unspecified &&
104         attr_check a/c/f unspecified &&
105         attr_check a/i unspecified &&
106         attr_check subdir/a/i unspecified
107
108 '
109
110 test_expect_success 'bare repository: test info/attributes' '
111
112         (
113                 echo "f test=f"
114                 echo "a/i test=a/i"
115         ) >info/attributes &&
116         attr_check f f &&
117         attr_check a/f f &&
118         attr_check a/c/f f &&
119         attr_check a/i a/i &&
120         attr_check subdir/a/i unspecified
121
122 '
123
124 test_done