threads / discuss / 41736

2.8.0 gitignore enhancement not working as expected

Subject: 2.8.0 gitignore enhancement not working as expected

## tl;dr

5 messages between Mar 18, 2016 and Mar 18, 2016.

replies: 4people: 2as markdown or json

Richard Furness -X (rfurness - ENSOFT LIMITED at Cisco)· Mar 18, 2016, 09:31 UTC · lore
Hi,
I've been testing out git 2.8.0 rc3 due to having a particular interest in this enhancement from the changelog:
" Another try to improve the ignore mechanism that lets you say "this
   is excluded" and then later say "oh, no, this part (that is a
   subset of the previous part) is not excluded".  This has still a
   known limitation, though."

Currently, in order to include ONLY the files under a/b/c I have the following in .gitignore: /* - Ignore everything !/a - Except directory "a" /a/* - Ignore all sub-directories of "a/" !/a/b - Except "a/b" /a/b/* - Ignore all sub-directories of "a/b/" !/a/b/c - Except "a/b/c"

My hope was that with this enhancement I could massively simplify this to: /* - Ignore everything !a/b/c - Except "a/b/c"

However this doesn't seem to work - instead I find that NOTHING is ignored (i.e. it's as if the 2nd line completely cancels the first).
Is this a bug or am I mis-understanding what the enhancement does? Or is this the known limitation referred to?
Thanks,
Richard
Duy Nguyen· Mar 18, 2016, 11:19 UTC · re: Richard Furness -X (rfurness - ENSOFT LIMITED at Cisco) · lore

Re: 2.8.0 gitignore enhancement not working as expected

On Fri, Mar 18, 2016 at 4:31 PM, Richard Furness -X (rfurness - ENSOFT LIMITED at Cisco) <rfurness@cisco.com> wrote:

Show 21 quoted lines
> Hi,
>
> I've been testing out git 2.8.0 rc3 due to having a particular interest in this enhancement from the changelog:
> " Another try to improve the ignore mechanism that lets you say "this
>    is excluded" and then later say "oh, no, this part (that is a
>    subset of the previous part) is not excluded".  This has still a
>    known limitation, though."
>
> Currently, in order to include ONLY the files under a/b/c I have the following in .gitignore:
> /*             - Ignore everything
> !/a             - Except directory "a"
> /a/*            - Ignore all sub-directories of "a/"
> !/a/b           - Except "a/b"
> /a/b/*          - Ignore all sub-directories of "a/b/"
> !/a/b/c         - Except "a/b/c"
>
> My hope was that with this enhancement I could massively simplify this to:
> /*             - Ignore everything
> !a/b/c      - Except "a/b/c"
>
> However this doesn't seem to work - instead I find that NOTHING is ignored (i.e. it's as if the 2nd line completely cancels the first).
Interesting. It seems to be working for me. This is my test setup
> /tmp/abc $ find * -type f

1 a/1 a/b/1 a/b/c

> /tmp/abc $ cat .gitignore

/* !a/b/c

and the results
> /tmp/abc $ ~/w/git/temp/git --version
git version 2.8.0.rc3
> /tmp/abc $ ~/w/git/temp/git ls-files -o --exclude-standard
a/b/c

Can you do "GIT_TRACE_EXCLUDE=1 git ls-files -o --exclude-standard" and post the output?

-- 
Duy
Richard Furness -X (rfurness - ENSOFT LIMITED at Cisco)· Mar 18, 2016, 14:32 UTC · re: Duy Nguyen · lore

RE: 2.8.0 gitignore enhancement not working as expected

Hi Duy,
I tried your exact example and it worked correctly. But then I tried adding some more files/dirs at the top level and I still see an issue:

cat .gitignore /* !a/b/c

find * -type f 1 2 3 a/1 a/b/1 a/b/c/1 d/1

git ls-files -o --exclude-standard .gitignore 2 3 a/b/c/1 d/1

Trace output below...
Thanks,
Richard

GIT_TRACE_EXCLUDE=1 git ls-files -o --exclude-standard 07:26:13.311793 dir.c:1848 exclude: [0] enter '' 07:26:13.312632 dir.c:1012 exclude: from .gitignore 07:26:13.312668 dir.c:1097 exclude: 1 vs /* at line 1 => yes 07:26:13.312673 dir.c:1012 exclude: from .gitignore 07:26:13.312677 dir.c:1089 exclude: a vs /* at line 1 => yes, forced open by a/b/c at line 2 => n/a 07:26:13.312681 dir.c:1012 exclude: from /users/rfurness/.gitignore_global 07:26:13.312684 dir.c:1062 exclude: a => n/a 07:26:13.312699 dir.c:1848 exclude: [1] enter 'a/' 07:26:13.312964 dir.c:1012 exclude: from .gitignore 07:26:13.312978 dir.c:1089 exclude: a vs /* at line 1 => yes, forced open by a/b/c at line 2 => n/a 07:26:13.312981 dir.c:1012 exclude: from /users/rfurness/.gitignore_global 07:26:13.312985 dir.c:1062 exclude: a => n/a 07:26:13.312991 dir.c:1012 exclude: from .gitignore 07:26:13.312995 dir.c:1097 exclude: a/1 vs /* at line 1 => yes (stuck) 07:26:13.312999 dir.c:1012 exclude: from .gitignore 07:26:13.313002 dir.c:1089 exclude: a/b vs /* at line 1 => yes, forced open by a/b/c at line 2 => n/a 07:26:13.313006 dir.c:1012 exclude: from /users/rfurness/.gitignore_global 07:26:13.313009 dir.c:1062 exclude: a/b => n/a 07:26:13.313016 dir.c:1848 exclude: [2] enter 'a/b/' 07:26:13.313259 dir.c:1012 exclude: from .gitignore 07:26:13.313272 dir.c:1089 exclude: a/b vs /* at line 1 => yes, forced open by a/b/c at line 2 => n/a 07:26:13.313275 dir.c:1012 exclude: from /users/rfurness/.gitignore_global 07:26:13.313279 dir.c:1062 exclude: a/b => n/a 07:26:13.313285 dir.c:1012 exclude: from .gitignore 07:26:13.313288 dir.c:1097 exclude: a/b/1 vs /* at line 1 => yes (stuck) 07:26:13.313292 dir.c:1012 exclude: from .gitignore 07:26:13.313295 dir.c:1097 exclude: a/b/c vs a/b/c at line 2 => no 07:26:13.313303 dir.c:1848 exclude: [3] enter 'a/b/c/' 07:26:13.313601 dir.c:1012 exclude: from .gitignore 07:26:13.313615 dir.c:1097 exclude: a/b/c vs a/b/c at line 2 => no 07:26:13.313632 dir.c:1012 exclude: from .gitignore 07:26:13.313636 dir.c:1097 exclude: a/b/c/1 vs a/b/c at line 2 => no 07:26:13.313645 dir.c:1914 exclude: [3] leave 'a/b/c/' 07:26:13.313650 dir.c:1914 exclude: [2] leave 'a/b/' 07:26:13.313655 dir.c:1914 exclude: [1] leave 'a/' 07:26:13.313716 dir.c:1012 exclude: from .gitignore 07:26:13.313720 dir.c:1062 exclude: .gitignore => n/a 07:26:13.313724 dir.c:1012 exclude: from /users/rfurness/.gitignore_global 07:26:13.313727 dir.c:1062 exclude: .gitignore => n/a 07:26:13.313742 dir.c:1012 exclude: from .gitignore 07:26:13.313746 dir.c:1062 exclude: 2 => n/a 07:26:13.313748 dir.c:1012 exclude: from /users/rfurness/.gitignore_global 07:26:13.313752 dir.c:1062 exclude: 2 => n/a 07:26:13.313789 dir.c:1012 exclude: from .gitignore 07:26:13.313793 dir.c:1062 exclude: 3 => n/a 07:26:13.313846 dir.c:1012 exclude: from /users/rfurness/.gitignore_global 07:26:13.313848 dir.c:1062 exclude: 3 => n/a 07:26:13.313852 dir.c:1012 exclude: from .gitignore 07:26:13.313855 dir.c:1062 exclude: d => n/a 07:26:13.313857 dir.c:1012 exclude: from /users/rfurness/.gitignore_global 07:26:13.313860 dir.c:1062 exclude: d => n/a 07:26:13.314145 dir.c:1848 exclude: [1] enter 'd/' 07:26:13.314395 dir.c:1012 exclude: from .gitignore 07:26:13.314425 dir.c:1062 exclude: d => n/a 07:26:13.314430 dir.c:1012 exclude: from /users/rfurness/.gitignore_global 07:26:13.314435 dir.c:1062 exclude: d => n/a 07:26:13.314455 dir.c:1012 exclude: from .gitignore 07:26:13.314459 dir.c:1062 exclude: d/1 => n/a 07:26:13.314462 dir.c:1012 exclude: from /users/rfurness/.gitignore_global 07:26:13.314465 dir.c:1062 exclude: d/1 => n/a 07:26:13.314471 dir.c:1914 exclude: [1] leave 'd/' 07:26:13.314475 dir.c:1914 exclude: [0] leave '' .gitignore 2 3 a/b/c/1 d/1

Show 57 quoted lines
> -----Original Message-----
> From: Duy Nguyen [mailto:pclouds@gmail.com]
> Sent: 18 March 2016 11:19
> To: Richard Furness -X (rfurness - ENSOFT LIMITED at Cisco)
> <rfurness@cisco.com>
> Cc: git@vger.kernel.org
> Subject: Re: 2.8.0 gitignore enhancement not working as expected
> 
> On Fri, Mar 18, 2016 at 4:31 PM, Richard Furness -X (rfurness - ENSOFT
> LIMITED at Cisco) <rfurness@cisco.com> wrote:
> > Hi,
> >
> > I've been testing out git 2.8.0 rc3 due to having a particular interest in this
> enhancement from the changelog:
> > " Another try to improve the ignore mechanism that lets you say "this
> >    is excluded" and then later say "oh, no, this part (that is a
> >    subset of the previous part) is not excluded".  This has still a
> >    known limitation, though."
> >
> > Currently, in order to include ONLY the files under a/b/c I have the
> following in .gitignore:
> > /*             - Ignore everything
> > !/a             - Except directory "a"
> > /a/*            - Ignore all sub-directories of "a/"
> > !/a/b           - Except "a/b"
> > /a/b/*          - Ignore all sub-directories of "a/b/"
> > !/a/b/c         - Except "a/b/c"
> >
> > My hope was that with this enhancement I could massively simplify this to:
> > /*             - Ignore everything
> > !a/b/c      - Except "a/b/c"
> >
> > However this doesn't seem to work - instead I find that NOTHING is
> ignored (i.e. it's as if the 2nd line completely cancels the first).
> 
> Interesting. It seems to be working for me. This is my test setup
> 
> > /tmp/abc $ find * -type f
> 1
> a/1
> a/b/1
> a/b/c
> > /tmp/abc $ cat .gitignore
> /*
> !a/b/c
> 
> and the results
> 
> > /tmp/abc $ ~/w/git/temp/git --version
> git version 2.8.0.rc3
> > /tmp/abc $ ~/w/git/temp/git ls-files -o --exclude-standard
> a/b/c
> 
> Can you do "GIT_TRACE_EXCLUDE=1 git ls-files -o --exclude-standard"
> and post the output?
> --
> Duy
Duy Nguyen· Mar 18, 2016, 14:52 UTC · re: Richard Furness -X (rfurness - ENSOFT LIMITED at Cisco) · lore

Re: 2.8.0 gitignore enhancement not working as expected

On Fri, Mar 18, 2016 at 9:32 PM, Richard Furness -X (rfurness - ENSOFT LIMITED at Cisco) <rfurness@cisco.com> wrote:

> Hi Duy,
>
> I tried your exact example and it worked correctly. But then I tried adding some more files/dirs at the top level and I still see an issue:

Thank you. Phew.. I bet you hit the same bug we found yesterday (your trace suggests so). Can you try this patch [1] just to confirm?

[1] http://article.gmane.org/gmane.comp.version-control.git/289101
-- 
Duy
Richard Furness -X (rfurness - ENSOFT LIMITED at Cisco)· Mar 18, 2016, 15:33 UTC · re: Duy Nguyen · lore

RE: 2.8.0 gitignore enhancement not working as expected

Hi Duy,
That seems to have fixed it :-)
Thanks for your help!
Richard
Show 21 quoted lines
> -----Original Message-----
> From: Duy Nguyen [mailto:pclouds@gmail.com]
> Sent: 18 March 2016 14:53
> To: Richard Furness -X (rfurness - ENSOFT LIMITED at Cisco)
> <rfurness@cisco.com>
> Cc: git@vger.kernel.org
> Subject: Re: 2.8.0 gitignore enhancement not working as expected
> 
> On Fri, Mar 18, 2016 at 9:32 PM, Richard Furness -X (rfurness - ENSOFT
> LIMITED at Cisco) <rfurness@cisco.com> wrote:
> > Hi Duy,
> >
> > I tried your exact example and it worked correctly. But then I tried adding
> some more files/dirs at the top level and I still see an issue:
> 
> Thank you. Phew.. I bet you hit the same bug we found yesterday (your
> trace suggests so). Can you try this patch [1] just to confirm?
> 
> [1] http://article.gmane.org/gmane.comp.version-control.git/289101
> --
> Duy

← back to recent threads