Re: [PATCH 5/6] gitignore: do not do basename match with patterns that have '**'
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Oct 5, 2012, 11:23 UTC
- Message-ID
- <CACsJy8BTWEeWvdwCDGBdoLndh8hXpgCgXrQxhWeaO1m9Qrqvgw@mail.gmail.com>
- In-Reply-To
- <506E85BF.8010302@viscovery.net>
On Fri, Oct 5, 2012 at 2:01 PM, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 11 quoted lines
> Am 10/4/2012 9:39, schrieb Nguyễn Thái Ngọc Duy: >> - - If the pattern does not contain a slash '/', git treats it as >> - a shell glob pattern and checks for a match against the >> - pathname relative to the location of the `.gitignore` file >> - (relative to the toplevel of the work tree if not from a >> - `.gitignore` file). >> + - If the pattern does not contain a slash '/' nor '**', git >> + treats it as a shell glob pattern and checks for a match >> + against the pathname relative to the location of the >> + `.gitignore` file (relative to the toplevel of the work tree >> + if not from a `.gitignore` file).
I think in the latest round, we forbid this case (i.e. a/**, **/b and a/**/b are ok, but a**b is not), exactly because it's hard to define how it should do. Thanks for another example.
Show 13 quoted lines
>> +test_expect_success '"**" with no slashes test' ' >> + echo "a**f foo=bar" >.gitattributes && >> + cat <<\EOF >expect && >> +f: foo: unspecified >> +a/f: foo: bar >> +a/b/f: foo: bar >> +a/b/c/f: foo: bar >> +EOF > > Should the above .gitattributes match nested paths, such as b/a/c/f? > > I think it should, because the user can easily say "/a**f" that nested > paths should not be matched.
The user can also say **/a/**f to match b/a/c/f.
-- Duy