Making pathspec limited log play nicer with --first-parent
[git/gitweb.git] / t / t0003-attributes.sh
blob61b5a2eba633d52ebf53efb3c0539f8abf4094ea
1 #!/bin/sh
3 test_description=gitattributes
5 . ./test-lib.sh
7 attr_check () {
9 path="$1"
10 expect="$2"
12 git check-attr test -- "$path" >actual &&
13 echo "$path: test: $2" >expect &&
14 test_cmp expect actual
19 test_expect_success 'setup' '
21 mkdir -p a/b/d a/c &&
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 &&
31 echo "g test=a/g" &&
32 echo "b/g test=a/b/g"
33 ) >a/.gitattributes &&
35 echo "h test=a/b/h" &&
36 echo "d/* test=a/b/d/*"
37 echo "d/yes notest"
38 ) >a/b/.gitattributes
40 echo "global test=global"
41 ) >"$HOME"/global-gitattributes
45 test_expect_success 'attribute test' '
47 attr_check f f &&
48 attr_check a/f f &&
49 attr_check a/c/f f &&
50 attr_check a/g a/g &&
51 attr_check a/b/g a/b/g &&
52 attr_check b/g unspecified &&
53 attr_check a/b/h a/b/h &&
54 attr_check a/b/d/g "a/b/d/*" &&
55 attr_check onoff unset &&
56 attr_check offon set &&
57 attr_check no unspecified &&
58 attr_check a/b/d/no "a/b/d/*" &&
59 attr_check a/b/d/yes unspecified
63 test_expect_success 'prefixes are not confused with leading directories' '
64 attr_check a_plus/g unspecified &&
65 cat >expect <<-\EOF &&
66 a/g: test: a/g
67 a_plus/g: test: unspecified
68 EOF
69 git check-attr test a/g a_plus/g >actual &&
70 test_cmp expect actual
73 test_expect_success 'core.attributesfile' '
74 attr_check global unspecified &&
75 git config core.attributesfile "$HOME/global-gitattributes" &&
76 attr_check global global &&
77 git config core.attributesfile "~/global-gitattributes" &&
78 attr_check global global &&
79 echo "global test=precedence" >> .gitattributes &&
80 attr_check global precedence
83 test_expect_success 'attribute test: read paths from stdin' '
85 cat <<EOF > expect &&
86 f: test: f
87 a/f: test: f
88 a/c/f: test: f
89 a/g: test: a/g
90 a/b/g: test: a/b/g
91 b/g: test: unspecified
92 a/b/h: test: a/b/h
93 a/b/d/g: test: a/b/d/*
94 onoff: test: unset
95 offon: test: set
96 no: test: unspecified
97 a/b/d/no: test: a/b/d/*
98 a/b/d/yes: test: unspecified
99 EOF
101 sed -e "s/:.*//" < expect | git check-attr --stdin test > actual &&
102 test_cmp expect actual
105 test_expect_success 'root subdir attribute test' '
107 attr_check a/i a/i &&
108 attr_check subdir/a/i unspecified
112 test_expect_success 'setup bare' '
114 git clone --bare . bare.git &&
115 cd bare.git
119 test_expect_success 'bare repository: check that .gitattribute is ignored' '
122 echo "f test=f"
123 echo "a/i test=a/i"
124 ) >.gitattributes &&
125 attr_check f unspecified &&
126 attr_check a/f unspecified &&
127 attr_check a/c/f unspecified &&
128 attr_check a/i unspecified &&
129 attr_check subdir/a/i unspecified
133 test_expect_success 'bare repository: test info/attributes' '
136 echo "f test=f"
137 echo "a/i test=a/i"
138 ) >info/attributes &&
139 attr_check f f &&
140 attr_check a/f f &&
141 attr_check a/c/f f &&
142 attr_check a/i a/i &&
143 attr_check subdir/a/i unspecified
147 test_done