Re: Expected behaviour for pathspecs matching attributes in subdirectories
- From
- Matthew Hughes <mhughes@uw.co.uk>
- Date
- Jul 6, 2023, 20:54 UTC
- Message-ID
- <CAEzX-aC=UDkf6nevLbN0bNyGXujZVDuqtCp3YcYhAPD6zvYZiQ@mail.gmail.com>
- In-Reply-To
- <xmqq7crddjtq.fsf@gitster.g>
On Thu, 6 Jul 2023 at 18:35, Junio C Hamano <gitster@pobox.com> wrote:
> I wonder if this serves a good addition to the tests?
Good idea, that would help clear up what's expected.
What about some tests for the case of attributes defined in a subdirectory? I'm still trying to understand what's expected in that case, specifically the test_must_be_empty case (the 'rm' at the end is just to avoid polluting any other tests with extra attributes, not sure if there's a more standard way of doing this):
diff --git a/t/t6135-pathspec-with-attrs.sh b/t/t6135-pathspec-with-attrs.sh index 457cc167c7..7a7502a6eb 100755 --- a/t/t6135-pathspec-with-attrs.sh +++ b/t/t6135-pathspec-with-attrs.sh @@ -87,6 +87,23 @@ test_expect_success 'check specific set attr (2)' ' test_cmp expect actual ' +test_expect_success 'check specific set attr nested .gitattributes' ' + cat <<-\EOF >sub/.gitattributes && + fileSetLabel otherLabel + EOF + test_write_lines sub/fileSetLabel >expect && + git ls-files ":(attr:otherLabel)" >actual && + test_cmp expect actual && + + git ls-files ":(attr:otherLabel)sub" >actual && + test_cmp expect actual && + + git ls-files ":(attr:otherLabel)sub/" >actual && + test_must_be_empty actual && + + rm sub/.gitattributes +' + test_expect_success 'check specific unset attr' ' cat <<-\EOF >expect && fileUnsetLabel