3 test_description
=gitattributes
12 git check-attr
test -- "$path" >actual
2>err
&&
13 echo "$path: test: $2" >expect
&&
14 test_cmp expect actual
&&
15 test_line_count
= 0 err
20 test_expect_success
'setup' '
22 mkdir -p a/b/d a/c b &&
24 echo "[attr]notest !test"
27 echo "onoff test -test"
28 echo "offon -test test"
34 ) >a/.gitattributes &&
36 echo "h test=a/b/h" &&
37 echo "d/* test=a/b/d/*"
39 ) >a/b/.gitattributes &&
41 echo "global test=global"
42 ) >"$HOME"/global-gitattributes &&
49 b/g: test: unspecified
51 a/b/d/g: test: a/b/d/*
57 a/b/d/no: test: a/b/d/*
58 a/b/d/yes: notest: set
59 a/b/d/yes: test: unspecified
64 test_expect_success
'command line checks' '
66 test_must_fail git check-attr &&
67 test_must_fail git check-attr -- &&
68 test_must_fail git check-attr test &&
69 test_must_fail git check-attr test -- &&
70 test_must_fail git check-attr -- f &&
71 echo "f" | test_must_fail git check-attr --stdin &&
72 echo "f" | test_must_fail git check-attr --stdin -- f &&
73 echo "f" | test_must_fail git check-attr --stdin test -- f &&
74 test_must_fail git check-attr "" -- f
78 test_expect_success
'attribute test' '
84 attr_check a/b/g a/b/g &&
85 attr_check b/g unspecified &&
86 attr_check a/b/h a/b/h &&
87 attr_check a/b/d/g "a/b/d/*" &&
88 attr_check onoff unset &&
89 attr_check offon set &&
90 attr_check no unspecified &&
91 attr_check a/b/d/no "a/b/d/*" &&
92 attr_check a/b/d/yes unspecified
96 test_expect_success
'unnormalized paths' '
99 attr_check ./a/g a/g &&
100 attr_check a/./g a/g &&
101 attr_check a/c/../b/g a/b/g
105 test_expect_success
'relative paths' '
107 (cd a && attr_check ../f f) &&
108 (cd a && attr_check f f) &&
109 (cd a && attr_check i a/i) &&
110 (cd a && attr_check g a/g) &&
111 (cd a && attr_check b/g a/b/g) &&
112 (cd b && attr_check ../a/f f) &&
113 (cd b && attr_check ../a/g a/g) &&
114 (cd b && attr_check ../a/b/g a/b/g)
118 test_expect_success
'core.attributesfile' '
119 attr_check global unspecified &&
120 git config core.attributesfile "$HOME/global-gitattributes" &&
121 attr_check global global &&
122 git config core.attributesfile "~/global-gitattributes" &&
123 attr_check global global &&
124 echo "global test=precedence" >> .gitattributes &&
125 attr_check global precedence
128 test_expect_success
'attribute test: read paths from stdin' '
130 grep -v notest < expect-all > expect &&
131 sed -e "s/:.*//" < expect | git check-attr --stdin test > actual &&
132 test_cmp expect actual
135 test_expect_success
'attribute test: --all option' '
137 grep -v unspecified < expect-all | sort > expect &&
138 sed -e "s/:.*//" < expect-all | uniq |
139 git check-attr --stdin --all | sort > actual &&
140 test_cmp expect actual
143 test_expect_success
'root subdir attribute test' '
145 attr_check a/i a/i &&
146 attr_check subdir/a/i unspecified
150 test_expect_success
'setup bare' '
152 git clone --bare . bare.git &&
157 test_expect_success
'bare repository: check that .gitattribute is ignored' '
163 attr_check f unspecified &&
164 attr_check a/f unspecified &&
165 attr_check a/c/f unspecified &&
166 attr_check a/i unspecified &&
167 attr_check subdir/a/i unspecified
171 test_expect_success
'bare repository: test info/attributes' '
176 ) >info/attributes &&
179 attr_check a/c/f f &&
180 attr_check a/i a/i &&
181 attr_check subdir/a/i unspecified