# [ENHANCEMENT] Allow '**' pattern in .gitignore

9 messages from 2012-10-02 to 2012-10-04. Participants: Ramkumar Ramachandra, Stefano Lattarini, Nguyen Thai Ngoc Duy, Jens Lehmann, Joshua Jensen.
Thread: https://gitlist.dev/t/31708

## Ramkumar Ramachandra, 2012-10-02 07:21

Subject: [ENHANCEMENT] Allow '**' pattern in .gitignore
Message-ID: <CALkWK0nXfeAnFfdFtdDNdEwtk0mMPtpYbg8sPzfrEXUpXsGQOA@mail.gmail.com>
URL: https://gitlist.dev/e/CALkWK0nXfeAnFfdFtdDNdEwtk0mMPtpYbg8sPzfrEXUpXsGQOA%40mail.gmail.com

```
Hi,

I've often found the '**' (extended) shell glob useful for matching
any string crossing directory boundaries: it's especially useful if
you only have a toplevel .gitignore, as opposed to a per-directory
.gitignore.  Unfortunately, .gitignore currently uses fnmatch(3), and
doesn't recognize '**'.  Would extending the .gitignore format to
accept this be a useful feature?  Would it involve re-implementing and
extending fnmatch, or is there some other way?

Ram

```

## Stefano Lattarini, 2012-10-02 07:58

Subject: Re: [ENHANCEMENT] Allow '**' pattern in .gitignore
Message-ID: <506A9EA6.9010303@gmail.com>
URL: https://gitlist.dev/e/506A9EA6.9010303%40gmail.com
In-Reply-To: <CALkWK0nXfeAnFfdFtdDNdEwtk0mMPtpYbg8sPzfrEXUpXsGQOA@mail.gmail.com>

```
On 10/02/2012 09:21 AM, Ramkumar Ramachandra wrote:
> Hi,
> 
> I've often found the '**' (extended) shell glob useful for matching
> any string crossing directory boundaries: it's especially useful if
> you only have a toplevel .gitignore, as opposed to a per-directory
> .gitignore.  Unfortunately, .gitignore currently uses fnmatch(3), and
> doesn't recognize '**'.  Would extending the .gitignore format to
> accept this be a useful feature?  Would it involve re-implementing and
> extending fnmatch, or is there some other way?
>
I think there is a topic in flight about this:

    <http://thread.gmane.org/gmane.comp.version-control.git/206406>

HTH,
  Stefano

```

## Ramkumar Ramachandra, 2012-10-02 08:24

Subject: Re: [ENHANCEMENT] Allow '**' pattern in .gitignore
Message-ID: <CALkWK0=X5nJ6Shwa0+6Jk2cgvvo25j=mKLRs4v=eQY7x9+XvFw@mail.gmail.com>
URL: https://gitlist.dev/e/CALkWK0%3DX5nJ6Shwa0%2B6Jk2cgvvo25j%3DmKLRs4v%3DeQY7x9%2BXvFw%40mail.gmail.com
In-Reply-To: <506A9EA6.9010303@gmail.com>

```
Stefano Lattarini wrote:
> On 10/02/2012 09:21 AM, Ramkumar Ramachandra wrote:
>> Hi,
>>
>> I've often found the '**' (extended) shell glob useful for matching
>> any string crossing directory boundaries: it's especially useful if
>> you only have a toplevel .gitignore, as opposed to a per-directory
>> .gitignore.  Unfortunately, .gitignore currently uses fnmatch(3), and
>> doesn't recognize '**'.  Would extending the .gitignore format to
>> accept this be a useful feature?  Would it involve re-implementing and
>> extending fnmatch, or is there some other way?
>>
> I think there is a topic in flight about this:
>
>     <http://thread.gmane.org/gmane.comp.version-control.git/206406>

Ah, yes.  Thanks.

Ram

```

## Nguyen Thai Ngoc Duy, 2012-10-03 11:35

Subject: Re: [ENHANCEMENT] Allow '**' pattern in .gitignore
Message-ID: <CACsJy8CUK0g4FhuJxzJqN7qS2apoO2zYdg_SGvWzEN5dGcHhaA@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8CUK0g4FhuJxzJqN7qS2apoO2zYdg_SGvWzEN5dGcHhaA%40mail.gmail.com
In-Reply-To: <CALkWK0=X5nJ6Shwa0+6Jk2cgvvo25j=mKLRs4v=eQY7x9+XvFw@mail.gmail.com>

```
On Tue, Oct 2, 2012 at 3:24 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> Stefano Lattarini wrote:
>> On 10/02/2012 09:21 AM, Ramkumar Ramachandra wrote:
>>> Hi,
>>>
>>> I've often found the '**' (extended) shell glob useful for matching
>>> any string crossing directory boundaries: it's especially useful if
>>> you only have a toplevel .gitignore, as opposed to a per-directory
>>> .gitignore.  Unfortunately, .gitignore currently uses fnmatch(3), and
>>> doesn't recognize '**'.  Would extending the .gitignore format to
>>> accept this be a useful feature?  Would it involve re-implementing and
>>> extending fnmatch, or is there some other way?
>>>
>> I think there is a topic in flight about this:
>>
>>     <http://thread.gmane.org/gmane.comp.version-control.git/206406>

While I'm behind this series, I have no use cases for it in my
repositories. It's tested in git test suite but that's about it. Some
feedback would be nice, especially on the performance side if you do a
lot of ignores.
-- 
Duy

```

## Jens Lehmann, 2012-10-03 13:35

Subject: Re: [ENHANCEMENT] Allow '**' pattern in .gitignore
Message-ID: <506C3F23.9000009@web.de>
URL: https://gitlist.dev/e/506C3F23.9000009%40web.de
In-Reply-To: <CACsJy8CUK0g4FhuJxzJqN7qS2apoO2zYdg_SGvWzEN5dGcHhaA@mail.gmail.com>

```
Am 03.10.2012 13:35, schrieb Nguyen Thai Ngoc Duy:
> On Tue, Oct 2, 2012 at 3:24 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
>> Stefano Lattarini wrote:
>>> On 10/02/2012 09:21 AM, Ramkumar Ramachandra wrote:
>>>> Hi,
>>>>
>>>> I've often found the '**' (extended) shell glob useful for matching
>>>> any string crossing directory boundaries: it's especially useful if
>>>> you only have a toplevel .gitignore, as opposed to a per-directory
>>>> .gitignore.  Unfortunately, .gitignore currently uses fnmatch(3), and
>>>> doesn't recognize '**'.  Would extending the .gitignore format to
>>>> accept this be a useful feature?  Would it involve re-implementing and
>>>> extending fnmatch, or is there some other way?
>>>>
>>> I think there is a topic in flight about this:
>>>
>>>     <http://thread.gmane.org/gmane.comp.version-control.git/206406>
> 
> While I'm behind this series, I have no use cases for it in my
> repositories. It's tested in git test suite but that's about it. Some
> feedback would be nice, especially on the performance side if you do a
> lot of ignores.

I really like it as we do have use cases at my dayjob. Due to our
naming conventions in subdirectories we have stuff like this in our
.gitignore files:

*/foo/bar
*/*/foo/bar
*/*/*/foo/bar

Using "**/foo/bar" instead would be a great improvement (I looked
into adding that myself some time ago, but decided it wasn't a low
hanging fruit).

Maybe I'll find time do do some performance measurements until the
weekend, what numbers are you interested in? Will a hot cache "time
git status" be sufficient or are you interested in other numbers too?

```

## Nguyen Thai Ngoc Duy, 2012-10-03 13:42

Subject: Re: [ENHANCEMENT] Allow '**' pattern in .gitignore
Message-ID: <CACsJy8DRxbjcRpbO30vOCo9D+TK_dDX_oiocZSOtnGAR2jAOFw@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8DRxbjcRpbO30vOCo9D%2BTK_dDX_oiocZSOtnGAR2jAOFw%40mail.gmail.com
In-Reply-To: <506C3F23.9000009@web.de>

```
On Wed, Oct 3, 2012 at 8:35 PM, Jens Lehmann <Jens.Lehmann@web.de> wrote:
> */foo/bar
> */*/foo/bar
> */*/*/foo/bar
>
> Using "**/foo/bar" instead would be a great improvement

If this "**/foo/bar" (i.e. no wildcards except one ** at the
beginning) is popular, we could optimize this case, turning fmatch()
into strncmp(), just like what we do for "foobar*"
-- 
Duy

```

## Jens Lehmann, 2012-10-03 13:51

Subject: Re: [ENHANCEMENT] Allow '**' pattern in .gitignore
Message-ID: <506C42CB.90903@web.de>
URL: https://gitlist.dev/e/506C42CB.90903%40web.de
In-Reply-To: <CACsJy8DRxbjcRpbO30vOCo9D+TK_dDX_oiocZSOtnGAR2jAOFw@mail.gmail.com>

```
Am 03.10.2012 15:42, schrieb Nguyen Thai Ngoc Duy:
> On Wed, Oct 3, 2012 at 8:35 PM, Jens Lehmann <Jens.Lehmann@web.de> wrote:
>> */foo/bar
>> */*/foo/bar
>> */*/*/foo/bar
>>
>> Using "**/foo/bar" instead would be a great improvement
> 
> If this "**/foo/bar" (i.e. no wildcards except one ** at the
> beginning) is popular, we could optimize this case, turning fmatch()
> into strncmp(), just like what we do for "foobar*"

I expect the logic "ignore <pattern including a slash> in any
directory depth you find it" to be one of the major use cases for
"**", so I think optimization makes sense here.

```

## Joshua Jensen, 2012-10-03 17:51

Subject: Re: [ENHANCEMENT] Allow '**' pattern in .gitignore
Message-ID: <506C7B37.3080804@workspacewhiz.com>
URL: https://gitlist.dev/e/506C7B37.3080804%40workspacewhiz.com
In-Reply-To: <CACsJy8DRxbjcRpbO30vOCo9D+TK_dDX_oiocZSOtnGAR2jAOFw@mail.gmail.com>

```
----- Original Message -----
From: Nguyen Thai Ngoc Duy
Date: 10/3/2012 7:42 AM
> On Wed, Oct 3, 2012 at 8:35 PM, Jens Lehmann <Jens.Lehmann@web.de> wrote:
>> */foo/bar
>> */*/foo/bar
>> */*/*/foo/bar
>>
>> Using "**/foo/bar" instead would be a great improvement
> If this "**/foo/bar" (i.e. no wildcards except one ** at the
> beginning) is popular, we could optimize this case, turning fmatch()
> into strncmp(), just like what we do for "foobar*"
FWIW, I would like to see this in .gitattributes as well.  I have a 
version of .gitattributes that supports recursive wildcards that I use 
for specifying filters.

-Josh

```

## Nguyen Thai Ngoc Duy, 2012-10-04 01:34

Subject: Re: [ENHANCEMENT] Allow '**' pattern in .gitignore
Message-ID: <CACsJy8C2QcNPte+C9aFHOD1oTqopqdX2=6KG13s4dPrPoONYVg@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8C2QcNPte%2BC9aFHOD1oTqopqdX2%3D6KG13s4dPrPoONYVg%40mail.gmail.com
In-Reply-To: <506C7B37.3080804@workspacewhiz.com>

```
On Thu, Oct 4, 2012 at 12:51 AM, Joshua Jensen
<jjensen@workspacewhiz.com> wrote:
> FWIW, I would like to see this in .gitattributes as well.  I have a version
> of .gitattributes that supports recursive wildcards that I use for
> specifying filters.

.gitattributes also learns about "**" in nd/wildmatch topic.
-- 
Duy

```
