3 test_description
=gitattributes
12 git check-attr
test -- "$path" >actual
&&
13 echo "$path: test: $2" >expect
&&
14 test_cmp expect actual
19 test_expect_success
'setup' '
23 echo "[attr]notest !test"
26 echo "onoff test -test"
27 echo "offon -test test"
33 ) >a/.gitattributes &&
35 echo "h test=a/b/h" &&
36 echo "d/* test=a/b/d/*"
38 ) >a/b/.gitattributes &&
40 echo "global test=global"
41 ) >"$HOME"/global-gitattributes
45 test_expect_success
'command line checks' '
47 test_must_fail git check-attr &&
48 test_must_fail git check-attr -- &&
49 test_must_fail git check-attr test &&
50 test_must_fail git check-attr test -- &&
51 test_must_fail git check-attr -- f &&
52 echo "f" | test_must_fail git check-attr --stdin &&
53 echo "f" | test_must_fail git check-attr --stdin -- f &&
54 echo "f" | test_must_fail git check-attr --stdin test -- f &&
55 echo "f" | test_must_fail git check-attr --stdin test f &&
56 test_must_fail git check-attr "" -- f
60 test_expect_success
'attribute test' '
66 attr_check a/b/g a/b/g &&
67 attr_check b/g unspecified &&
68 attr_check a/b/h a/b/h &&
69 attr_check a/b/d/g "a/b/d/*" &&
70 attr_check onoff unset &&
71 attr_check offon set &&
72 attr_check no unspecified &&
73 attr_check a/b/d/no "a/b/d/*" &&
74 attr_check a/b/d/yes unspecified
78 test_expect_success
'core.attributesfile' '
79 attr_check global unspecified &&
80 git config core.attributesfile "$HOME/global-gitattributes" &&
81 attr_check global global &&
82 git config core.attributesfile "~/global-gitattributes" &&
83 attr_check global global &&
84 echo "global test=precedence" >> .gitattributes &&
85 attr_check global precedence
88 test_expect_success
'attribute test: read paths from stdin' '
96 b/g: test: unspecified
98 a/b/d/g: test: a/b/d/*
101 no: test: unspecified
102 a/b/d/no: test: a/b/d/*
103 a/b/d/yes: test: unspecified
106 sed -e "s/:.*//" < expect | git check-attr --stdin test > actual &&
107 test_cmp expect actual
110 test_expect_success
'root subdir attribute test' '
112 attr_check a/i a/i &&
113 attr_check subdir/a/i unspecified
117 test_expect_success
'setup bare' '
119 git clone --bare . bare.git &&
124 test_expect_success
'bare repository: check that .gitattribute is ignored' '
130 attr_check f unspecified &&
131 attr_check a/f unspecified &&
132 attr_check a/c/f unspecified &&
133 attr_check a/i unspecified &&
134 attr_check subdir/a/i unspecified
138 test_expect_success
'bare repository: test info/attributes' '
143 ) >info/attributes &&
146 attr_check a/c/f f &&
147 attr_check a/i a/i &&
148 attr_check subdir/a/i unspecified