]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0003-attributes.sh
t/README: Add SMOKE_{COMMENT,TAGS}= to smoke_report target
[thirdparty/git.git] / t / t0003-attributes.sh
CommitLineData
cf94ccda
JH
1#!/bin/sh
2
3test_description=gitattributes
4
5. ./test-lib.sh
6
7attr_check () {
8
9 path="$1"
10 expect="$2"
11
12 git check-attr test -- "$path" >actual &&
13 echo "$path: test: $2" >expect &&
82ebb0b6 14 test_cmp expect actual
cf94ccda
JH
15
16}
17
18
19test_expect_success 'setup' '
20
21 mkdir -p a/b/d a/c &&
22 (
ec775c41 23 echo "[attr]notest !test"
cf94ccda 24 echo "f test=f"
82881b38 25 echo "a/i test=a/i"
969f9d73
HG
26 echo "onoff test -test"
27 echo "offon -test test"
ec775c41 28 echo "no notest"
cf94ccda
JH
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/*"
ec775c41 37 echo "d/yes notest"
cf94ccda
JH
38 ) >a/b/.gitattributes
39
40'
41
42test_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/*"
969f9d73
HG
52 attr_check onoff unset
53 attr_check offon set
ec775c41
HG
54 attr_check no unspecified
55 attr_check a/b/d/no "a/b/d/*"
56 attr_check a/b/d/yes unspecified
cf94ccda
JH
57
58'
59
b4666852
DP
60test_expect_success 'attribute test: read paths from stdin' '
61
62 cat <<EOF > expect
63f: test: f
64a/f: test: f
65a/c/f: test: f
66a/g: test: a/g
67a/b/g: test: a/b/g
68b/g: test: unspecified
69a/b/h: test: a/b/h
70a/b/d/g: test: a/b/d/*
969f9d73
HG
71onoff: test: unset
72offon: test: set
ec775c41
HG
73no: test: unspecified
74a/b/d/no: test: a/b/d/*
75a/b/d/yes: test: unspecified
b4666852
DP
76EOF
77
78 sed -e "s/:.*//" < expect | git check-attr --stdin test > actual &&
79 test_cmp expect actual
80'
81
82881b38
MO
82test_expect_success 'root subdir attribute test' '
83
84 attr_check a/i a/i &&
85 attr_check subdir/a/i unspecified
86
87'
88
2d35d556
RS
89test_expect_success 'setup bare' '
90
91 git clone --bare . bare.git &&
92 cd bare.git
93
94'
95
96test_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
110test_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
cf94ccda 124test_done