Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Sitaram Chamarty <sitaramc@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: How do I qualify paths in the .gitignore file w.r.t. the repo root  directory?
Date: Wed, 25 Feb 2009 00:36:10 -0800	[thread overview]
Message-ID: <7vab8aap6t.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <slrngq9es5.ik0.sitaramc@sitaramc.homelinux.net> (Sitaram Chamarty's message of "Wed, 25 Feb 2009 03:31:17 +0000 (UTC)")

Sitaram Chamarty <sitaramc@gmail.com> writes:

> Please tell me what you think.  If you like it, I'll send in
> this patch.  If you prefer the previous one, I'll send that
> in.
> ...
> The files containing the patterns have the following format:
>
>  - A blank line matches no files, so it can serve as a
>    separator for readability.
>
>  - A line starting with # serves as a comment.
>
> 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.

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

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.

> 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"?

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

  reply	other threads:[~2009-02-25  8:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-24  6:47 How do I qualify paths in the .gitignore file w.r.t. the repo root directory? Brent Goodrick
2009-02-24  7:06 ` Junio C Hamano
2009-02-24  9:07   ` Sitaram Chamarty
2009-02-24 17:33     ` Junio C Hamano
2009-02-24 18:31       ` Sitaram Chamarty
2009-02-25  3:31       ` Sitaram Chamarty
2009-02-25  8:36         ` Junio C Hamano [this message]
2009-02-25 11:17           ` Sitaram Chamarty
2009-02-25 21:25             ` Junio C Hamano
2009-02-26  0:45               ` Björn Steinbrink
2009-02-26  1:23               ` Sitaram Chamarty
2009-02-26  3:48                 ` Sitaram Chamarty
2009-02-26 17:04                   ` Junio C Hamano
2009-02-25  1:14   ` Brent Goodrick
2009-02-25  4:01     ` Sitaram Chamarty

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vab8aap6t.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=sitaramc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox