@@ -65,7 +65,8 @@ test_expect_success 'setup .gitattributes' '
65
65
fileValue label=foo
66
66
fileWrongLabel label☺
67
67
EOF
68
- git add .gitattributes &&
68
+ echo fileSetLabel label1 >sub/.gitattributes &&
69
+ git add .gitattributes sub/.gitattributes &&
69
70
git commit -m "add attributes"
70
71
'
71
72
@@ -78,7 +79,17 @@ test_expect_success 'check specific set attr' '
78
79
test_cmp expect actual
79
80
'
80
81
81
- test_expect_success ' check specific set attr (2)' '
82
+ test_expect_success ' check set attr with pathspec pattern' '
83
+ echo sub/fileSetLabel >expect &&
84
+
85
+ git ls-files ":(attr:label)sub" >actual &&
86
+ test_cmp expect actual &&
87
+
88
+ git ls-files ":(attr:label)sub/" >actual &&
89
+ test_cmp expect actual
90
+ '
91
+
92
+ test_expect_success ' check specific set attr in tree-ish' '
82
93
cat <<-\EOF >expect &&
83
94
HEAD:fileSetLabel
84
95
HEAD:sub/fileSetLabel
@@ -87,6 +98,16 @@ test_expect_success 'check specific set attr (2)' '
87
98
test_cmp expect actual
88
99
'
89
100
101
+ test_expect_success ' check specific set attr with pathspec pattern in tree-ish' '
102
+ echo HEAD:sub/fileSetLabel >expect &&
103
+
104
+ git grep -l content HEAD ":(attr:label)sub" >actual &&
105
+ test_cmp expect actual &&
106
+
107
+ git grep -l content HEAD ":(attr:label)sub/" >actual &&
108
+ test_cmp expect actual
109
+ '
110
+
90
111
test_expect_success ' check specific unset attr' '
91
112
cat <<-\EOF >expect &&
92
113
fileUnsetLabel
@@ -137,6 +158,7 @@ test_expect_success 'check unspecified attr' '
137
158
fileC
138
159
fileNoLabel
139
160
fileWrongLabel
161
+ sub/.gitattributes
140
162
sub/fileA
141
163
sub/fileAB
142
164
sub/fileAC
@@ -161,6 +183,7 @@ test_expect_success 'check unspecified attr (2)' '
161
183
HEAD:fileC
162
184
HEAD:fileNoLabel
163
185
HEAD:fileWrongLabel
186
+ HEAD:sub/.gitattributes
164
187
HEAD:sub/fileA
165
188
HEAD:sub/fileAB
166
189
HEAD:sub/fileAC
@@ -180,6 +203,7 @@ test_expect_success 'check multiple unspecified attr' '
180
203
fileC
181
204
fileNoLabel
182
205
fileWrongLabel
206
+ sub/.gitattributes
183
207
sub/fileC
184
208
sub/fileNoLabel
185
209
sub/fileWrongLabel
@@ -253,4 +277,22 @@ test_expect_success 'backslash cannot be used as a value' '
253
277
test_i18ngrep "for value matching" actual
254
278
'
255
279
280
+ test_expect_success ' reading from .gitattributes in a subdirectory (1)' '
281
+ git ls-files ":(attr:label1)" >actual &&
282
+ test_write_lines "sub/fileSetLabel" >expect &&
283
+ test_cmp expect actual
284
+ '
285
+
286
+ test_expect_success ' reading from .gitattributes in a subdirectory (2)' '
287
+ git ls-files ":(attr:label1)sub" >actual &&
288
+ test_write_lines "sub/fileSetLabel" >expect &&
289
+ test_cmp expect actual
290
+ '
291
+
292
+ test_expect_success ' reading from .gitattributes in a subdirectory (3)' '
293
+ git ls-files ":(attr:label1)sub/" >actual &&
294
+ test_write_lines "sub/fileSetLabel" >expect &&
295
+ test_cmp expect actual
296
+ '
297
+
256
298
test_done
0 commit comments