git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Jiri Slaby <jirislaby@gmail.com>, git@vger.kernel.org
Subject: [PATCH] gitignore.5: Clarify matching rules
Date: Fri, 5 Mar 2010 09:56:39 -0600	[thread overview]
Message-ID: <20100305155639.GA25080@progeny.tock> (raw)
In-Reply-To: <4B912469.8060705@viscovery.net>

Patterns containing a / are implicitly anchored to the directory
containing the relevant .gitignore file.

Patterns not containing a / are textual matches against the path
name relative to the directory containing .gitignore.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Johannes Sixt wrote:

> When the pattern "Documentation/*.html" matches
> "Documentation/git.html", then it cannot match
> "tools/perf/Documentation/perf-diff.html". This is because patterns that
> contain a slash (after stripping a trailing slash) are anchored at the
> directory that contains the .gitignore.

Oh!  The documentation could definitely use clarification here.

Thanks.

 Documentation/gitignore.txt |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
index 98c459d..e10fa88 100644
--- a/Documentation/gitignore.txt
+++ b/Documentation/gitignore.txt
@@ -83,16 +83,20 @@ Patterns have the following format:
 
  - If the pattern does not contain a slash '/', git treats it as
    a shell glob pattern and checks for a match against the
-   pathname without leading directories.
+   pathname relative to the location of the `.gitignore` file
+   (relative to the toplevel of the work tree if not from a
+   `.gitignore` file).
 
  - 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/\*.html" matches
-   "Documentation/git.html" but not
-   "Documentation/ppc/ppc.html".  A leading slash matches the
-   beginning of the pathname; for example, "/*.c" matches
-   "cat-file.c" but not "mozilla-sha1/sha1.c".
+   "Documentation/git.html" but not "Documentation/ppc/ppc.html"
+   or "tools/perf/Documentation/perf.html".
+
+ - A leading slash matches the beginning of the pathname.
+   For example, "/*.c" matches "cat-file.c" but not
+   "mozilla-sha1/sha1.c".
 
 An example:
 
-- 
1.7.0

  reply	other threads:[~2010-03-05 15:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-05  8:55 gitignore broken in git 1.7.0.1: slash checks leading dirs Jiri Slaby
2010-03-05  9:05 ` Johannes Sixt
2010-03-05  9:07   ` Jiri Slaby
2010-03-05  9:16     ` Johannes Sixt
2010-03-05  9:20       ` [PATCH 1/1] gitignore: do not ignore include/linux/ Jiri Slaby
2010-03-05 10:43         ` Jakub Narebski
2010-03-05 15:19           ` Jiri Slaby
2010-03-10 10:07             ` David Rientjes
2010-03-10 10:11               ` Américo Wang
2010-03-10 10:25                 ` David Rientjes
2010-03-08  2:08         ` Américo Wang
2010-03-05  9:29       ` gitignore broken in git 1.7.0.1: slash checks leading dirs Jiri Slaby
2010-03-05 17:25         ` Jonathan Nieder
2010-03-05 19:30           ` Jiri Slaby
2010-03-05 15:12   ` Jonathan Nieder
2010-03-05 15:15     ` Jonathan Nieder
2010-03-05 15:34     ` Johannes Sixt
2010-03-05 15:56       ` Jonathan Nieder [this message]
2010-03-05 17:01   ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20100305155639.GA25080@progeny.tock \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=j.sixt@viscovery.net \
    --cc=jirislaby@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).