Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dir.c2
-rwxr-xr-xt/t6135-pathspec-with-attrs.sh24
2 files changed, 24 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index a7469df3ac..635d1b058c 100644
--- a/dir.c
+++ b/dir.c
@@ -374,7 +374,7 @@ static int match_pathspec_item(struct index_state *istate,
return 0;
if (item->attr_match_nr &&
- !match_pathspec_attrs(istate, name, namelen, item))
+ !match_pathspec_attrs(istate, name - prefix, namelen + prefix, item))
return 0;
/* If the match was just the prefix, we matched */
diff --git a/t/t6135-pathspec-with-attrs.sh b/t/t6135-pathspec-with-attrs.sh
index f63774094f..f70c395e75 100755
--- a/t/t6135-pathspec-with-attrs.sh
+++ b/t/t6135-pathspec-with-attrs.sh
@@ -65,7 +65,8 @@ test_expect_success 'setup .gitattributes' '
fileValue label=foo
fileWrongLabel label☺
EOF
- git add .gitattributes &&
+ echo fileSetLabel label1 >sub/.gitattributes &&
+ git add .gitattributes sub/.gitattributes &&
git commit -m "add attributes"
'
@@ -157,6 +158,7 @@ test_expect_success 'check unspecified attr' '
fileC
fileNoLabel
fileWrongLabel
+ sub/.gitattributes
sub/fileA
sub/fileAB
sub/fileAC
@@ -181,6 +183,7 @@ test_expect_success 'check unspecified attr (2)' '
HEAD:fileC
HEAD:fileNoLabel
HEAD:fileWrongLabel
+ HEAD:sub/.gitattributes
HEAD:sub/fileA
HEAD:sub/fileAB
HEAD:sub/fileAC
@@ -200,6 +203,7 @@ test_expect_success 'check multiple unspecified attr' '
fileC
fileNoLabel
fileWrongLabel
+ sub/.gitattributes
sub/fileC
sub/fileNoLabel
sub/fileWrongLabel
@@ -273,4 +277,22 @@ test_expect_success 'backslash cannot be used as a value' '
test_i18ngrep "for value matching" actual
'
+test_expect_success 'reading from .gitattributes in a subdirectory (1)' '
+ git ls-files ":(attr:label1)" >actual &&
+ test_write_lines "sub/fileSetLabel" >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'reading from .gitattributes in a subdirectory (2)' '
+ git ls-files ":(attr:label1)sub" >actual &&
+ test_write_lines "sub/fileSetLabel" >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'reading from .gitattributes in a subdirectory (3)' '
+ git ls-files ":(attr:label1)sub/" >actual &&
+ test_write_lines "sub/fileSetLabel" >expect &&
+ test_cmp expect actual
+'
+
test_done