blame: use find_commit_subject() instead of custom code
[git/debian.git] / t / t0003-attributes.sh
blob53bd7fcc4abbf6cb7db73b43d5dde477f5115f90
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
42 test_expect_success 'attribute test' '
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
60 test_expect_success 'attribute test: read paths from stdin' '
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
78 sed -e "s/:.*//" < expect | git check-attr --stdin test > actual &&
79 test_cmp expect actual
82 test_expect_success 'root subdir attribute test' '
84 attr_check a/i a/i &&
85 attr_check subdir/a/i unspecified
89 test_expect_success 'setup bare' '
91 git clone --bare . bare.git &&
92 cd bare.git
96 test_expect_success 'bare repository: check that .gitattribute is ignored' '
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
110 test_expect_success 'bare repository: test info/attributes' '
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
124 test_done