Re: Change in .gitignore handling: intended or bug?
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Mar 10, 2016, 00:26 UTC
- Message-ID
- <CACsJy8D=OjLBN-EXyKM4NnGhSGftYX+RAaR9fg8ML3QWAAb+iQ@mail.gmail.com>
- In-Reply-To
- <xmqqk2lbil7k.fsf@gitster.mtv.corp.google.com>
On Thu, Mar 10, 2016 at 1:02 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 34 quoted lines
> Duy Nguyen <pclouds@gmail.com> writes: > >> On Wed, Mar 9, 2016 at 1:10 AM, Junio C Hamano <gitster@pobox.com> wrote: >>> diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt >>> index 3ded6fd..91d1ce2 100644 >>> --- a/Documentation/gitignore.txt >>> +++ b/Documentation/gitignore.txt >>> @@ -148,7 +148,43 @@ excluded, the following conditions must be met: >>> be in the same .gitignore file. >>> >>> - The directory part in the re-include rules must be literal (i.e. no >>> - wildcards) >>> + wildcards and has to start with a `/`). >> >> Technically '/' can just appear anywhere in the pattern, except at the >> end. But because the patterns in question must look like this >> >> dir # or any pattern, even "*" >> !dir/someth*ng >> >> even if there is a slash at the end (and is ignored), we are still >> good. Not sure how to phrase that though. > > Post 2.8, we'd be correcting this properly anyway, we should aim for > the simplest-to-explain way to work around the limitation in the > current code, that will still work once the bug is fixed. I am not > sure if "Technically it can be other things" helps, unless it makes > it a lot easier to use. > > With that in mind, do you think we need to find a better phrase to > loosen what I wrote that is overly-strict? That is, is "must begin > with '/' to anchor it to the level .gitignore appears" too strict to > make it too hard to use? >
If we can name rules from the syntax part, then we can simply say "patterns that meet rules x and y".
A bit off topic, but these two paragraphs may need rephrasing, I don't really understand what it's trying to say
- 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).
Not sure why "relative to the location of .gitignore file" matters. We basically just take `basename $path` out and try to match it.
- Otherwise, Git treats the pattern as a shell glob suitable
for consumption by fnmatch(3) with the FNM_PATHNAME flag:
wildcards in the pattern will not match a / in the pathname.
For example, "Documentation/{asterisk}.html" matches
"Documentation/git.html" but not "Documentation/ppc/ppc.html"
or "tools/perf/Documentation/perf.html".Perhaps "Otherwise" can be stated explicitly that "if the pattern does contain any slash, besides the trailing one". The "wildcards not matching /" is also true for the "pattern does not contain a slash" rule above. We can make it a generic note about wildcards and remove this "otherwise" rule, maybe...
-- Duy