Merge branch 'jc/pathspec-match-with-common-prefix'
"git ls-files '(attr:X)D/'" that triggers the common prefix optimization codepath failed to read from "D/.gitattributes", which has been corrected. * jc/pathspec-match-with-common-prefix: dir: match "attr" pathspec magic with correct paths t6135: attr magic with path pattern
This commit is contained in:
2
dir.c
2
dir.c
@ -376,7 +376,7 @@ static int match_pathspec_item(struct index_state *istate,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (item->attr_match_nr &&
|
if (item->attr_match_nr &&
|
||||||
!match_pathspec_attrs(istate, name, namelen, item))
|
!match_pathspec_attrs(istate, name - prefix, namelen + prefix, item))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* If the match was just the prefix, we matched */
|
/* If the match was just the prefix, we matched */
|
||||||
|
@ -65,7 +65,8 @@ test_expect_success 'setup .gitattributes' '
|
|||||||
fileValue label=foo
|
fileValue label=foo
|
||||||
fileWrongLabel label☺
|
fileWrongLabel label☺
|
||||||
EOF
|
EOF
|
||||||
git add .gitattributes &&
|
echo fileSetLabel label1 >sub/.gitattributes &&
|
||||||
|
git add .gitattributes sub/.gitattributes &&
|
||||||
git commit -m "add attributes"
|
git commit -m "add attributes"
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -78,7 +79,17 @@ test_expect_success 'check specific set attr' '
|
|||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'check specific set attr (2)' '
|
test_expect_success 'check set attr with pathspec pattern' '
|
||||||
|
echo sub/fileSetLabel >expect &&
|
||||||
|
|
||||||
|
git ls-files ":(attr:label)sub" >actual &&
|
||||||
|
test_cmp expect actual &&
|
||||||
|
|
||||||
|
git ls-files ":(attr:label)sub/" >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'check specific set attr in tree-ish' '
|
||||||
cat <<-\EOF >expect &&
|
cat <<-\EOF >expect &&
|
||||||
HEAD:fileSetLabel
|
HEAD:fileSetLabel
|
||||||
HEAD:sub/fileSetLabel
|
HEAD:sub/fileSetLabel
|
||||||
@ -87,6 +98,16 @@ test_expect_success 'check specific set attr (2)' '
|
|||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'check specific set attr with pathspec pattern in tree-ish' '
|
||||||
|
echo HEAD:sub/fileSetLabel >expect &&
|
||||||
|
|
||||||
|
git grep -l content HEAD ":(attr:label)sub" >actual &&
|
||||||
|
test_cmp expect actual &&
|
||||||
|
|
||||||
|
git grep -l content HEAD ":(attr:label)sub/" >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'check specific unset attr' '
|
test_expect_success 'check specific unset attr' '
|
||||||
cat <<-\EOF >expect &&
|
cat <<-\EOF >expect &&
|
||||||
fileUnsetLabel
|
fileUnsetLabel
|
||||||
@ -137,6 +158,7 @@ test_expect_success 'check unspecified attr' '
|
|||||||
fileC
|
fileC
|
||||||
fileNoLabel
|
fileNoLabel
|
||||||
fileWrongLabel
|
fileWrongLabel
|
||||||
|
sub/.gitattributes
|
||||||
sub/fileA
|
sub/fileA
|
||||||
sub/fileAB
|
sub/fileAB
|
||||||
sub/fileAC
|
sub/fileAC
|
||||||
@ -161,6 +183,7 @@ test_expect_success 'check unspecified attr (2)' '
|
|||||||
HEAD:fileC
|
HEAD:fileC
|
||||||
HEAD:fileNoLabel
|
HEAD:fileNoLabel
|
||||||
HEAD:fileWrongLabel
|
HEAD:fileWrongLabel
|
||||||
|
HEAD:sub/.gitattributes
|
||||||
HEAD:sub/fileA
|
HEAD:sub/fileA
|
||||||
HEAD:sub/fileAB
|
HEAD:sub/fileAB
|
||||||
HEAD:sub/fileAC
|
HEAD:sub/fileAC
|
||||||
@ -180,6 +203,7 @@ test_expect_success 'check multiple unspecified attr' '
|
|||||||
fileC
|
fileC
|
||||||
fileNoLabel
|
fileNoLabel
|
||||||
fileWrongLabel
|
fileWrongLabel
|
||||||
|
sub/.gitattributes
|
||||||
sub/fileC
|
sub/fileC
|
||||||
sub/fileNoLabel
|
sub/fileNoLabel
|
||||||
sub/fileWrongLabel
|
sub/fileWrongLabel
|
||||||
@ -253,4 +277,22 @@ test_expect_success 'backslash cannot be used as a value' '
|
|||||||
test_i18ngrep "for value matching" actual
|
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
|
test_done
|
||||||
|
Reference in New Issue
Block a user