Re: [PATCH v2 2/2] dir.c: don't exclude whole dir prematurely if neg pattern may match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 15, 2015 at 12:15 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Nguyễn Thái Ngọc Duy  <pclouds@xxxxxxxxx> writes:
>
>> diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
>> index 473623d..889a72a 100644
>> --- a/Documentation/gitignore.txt
>> +++ b/Documentation/gitignore.txt
>> @@ -82,12 +82,9 @@ PATTERN FORMAT
>>
>>   - An optional prefix "`!`" which negates the pattern; any
>>     matching file excluded by a previous pattern will become
>> +   included again. It is possible to re-include a file if a parent
>> +   directory of that file is excluded, with restrictions. See section
>> +   NOTES for detail.
>
> Sounds like a very useful thing.
>
>>   - If the pattern ends with a slash, it is removed for the
>>     purpose of the following description, but it would only find
>> @@ -141,6 +138,18 @@ not tracked by Git remain untracked.
>>  To stop tracking a file that is currently tracked, use
>>  'git rm --cached'.
>>
>> +To re-include a file when its parent directory is excluded, the
>> +following conditions must be met:
>> +
>> + - The directory part in the re-include rules must be literal (i.e. no
>> +   wildcards)
>> +
>> + - The rules to exclude the parent directory must not end with a
>> +   trailing slash.
>> +
>> + - The rules to exclude the parent directory must have at least one
>> +   slash.
>> +
>
> In this bulletted list, don't the readers also need to be told that
> having "/abc" in .gitignore (but not "!/abc/anything" in .gitignore)
> and "!foo" in abc/.gitignore would not cause us to descend into
> "/abc" just to examine "abc/.gitignore" with pessimistic assumption
> that there might be some exclusion in there?

Yeah I thought it was already mentioned. I guess it's just in my mind.
Will update.

>> diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh
>> index 3fc484e..9de49a6 100755
>> --- a/t/t3001-ls-files-others-exclude.sh
>> +++ b/t/t3001-ls-files-others-exclude.sh
>> @@ -305,4 +305,24 @@ test_expect_success 'ls-files with "**" patterns and no slashes' '
>>       test_cmp expect actual
>>  '
>>
>> +test_expect_success 'negative patterns' '
>> +     git init reinclude &&
>> +     (
>> +             cd reinclude &&
>> +             cat >.gitignore <<-\EOF &&
>> +             /foo
>> +             !foo/bar/bar
>> +             EOF
>> +             mkdir -p foo/bar &&
>> +             touch abc foo/def foo/bar/ghi foo/bar/bar &&
>> +             git ls-files -o --exclude-standard >../actual &&
>> +             cat >../expected <<-\EOF &&
>> +             .gitignore
>> +             abc
>> +             foo/bar/bar
>> +             EOF
>> +             test_cmp ../expected ../actual
>> +     )
>> +'
>
> And another test here may want to explicitly ensure that we are not
> overly pessimising the ignore processing, so that later changes will
> not break it, I think.

Yep. Will do.
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]