Re: How do I qualify paths in the .gitignore file w.r.t. the repo root directory?

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

 



On 2009-02-25, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Sitaram Chamarty <sitaramc@xxxxxxxxx> writes:

>> This is _how_ the patterns match:
>>
>>  - The wildcards (`*` and `?`) do not match slashes, but
>>    otherwise the patterns are normal shell globs as defined
>>    by fnmatch(3) with the FNM_PATHNAME flag set.
>
> I had to read this twice and run "man 3 fnmatch" to clear my head.
>
>  - In normal shell globs, wildcards '*' and '?' do not match slashes;
>
>  - fnmatch(3) with FNM_PATHNAME implements the normal shell globs;
>
>  - wildcards do not match slashes in gitignore either.
>
> Given these three, I am very confused why you say "but otherwise".  I
> would understand it if it were:
>
>     The patterns are treated as normal shell globs defined by fnmatch(3) with
>     FNM_PATHNAME; in other words, the wildcards (`*` and `?`) do not match
>     slashes.

I'll use that.

This confusing statement existed in the previous (shorter)
version also.  My fault; I use [[ path == patt ]] far more
often than plain globs so I had a thinko.  (Perversely, that
one does *not* use FNM_PATHNAME... go figure!)

>>  - An optional prefix '!' negates the pattern; any matching
>>    file excluded by a previous pattern will become included
>>    again.  If a negated pattern matches, this will override
>>    lower precedence patterns sources.
>
> '!' is not part of _how_ the patterns match.  It is _what happens_ when a
> pattern marked as such matches (meaning, the syntax for a line in
> gitignore file is "an optional '!' followed by a pattern").
>
>     An optional prefix '!' is not a part of the pattern and it does not
>     affect the match.  When a path matches such a pattern, instead of
>     being ignored, it is unignored.

I can use this.  Can we keep it in the same section, despite
being technically not a '_how_'?  It fits the other sections
even less, and the sectioning is the main thing in all this.

> It would be good to clarify that '!' is not part of the pattern, as I'd
> like to take J6t's patch that says gitattributes uses the same pattern as
> gitignore uses.
>
>> This is _what_ the patterns match:
>>
>>  - If the pattern ends with a slash, it matches only
>>    directories (and their contents), otherwise it matches
>>    regular files and symlinks also.
>
> Do we want "(and their contents)" here?  Once a directory is ignored like
> this, none of its contents, including .gitignore file in it, is examined
> because we do not even descend into it.

Do we not want to specify that we don't descend?  The
original text does say '...will match a directory foo and
paths underneath it'.

>> This is _where_ the patterns match (a trailing slash is
>> ignored for these rules):
>>
>>  - If there is a slash at the start or within the pattern,
>>    it matches paths relative to the .gitignore file in which
>>    the pattern is found, or to the root of the working tree
>>    if the pattern is from one of the other pattern sources
>>    (i.e., `.git/info/exclude`, `core.excludesfile`)
>
> "at the start or within but not at the end of the pattern"?

Isn't that confusing?  'if there is a slash ... not at the
end of the pattern' can easily sound like "there *should
not* be a trailing slash", which is quite different from "we
don't care if there *is* a trailing slash; it's the *other*
slashes that matter here".

And it'll _seem to_ contradict what we say, just above, that
a trailing slash is ignored for these rules.

>
>>  - Otherwise, it matches a path at any depth in the tree

--
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]

  Powered by Linux