From: "Dr. Adam Nielsen" <admin@in-ici.net>
To: git@vger.kernel.org
Cc: Adam Nielsen <admin@in-ici.net>,
"Adam J . N . Nielsen" <info@drnielsen.de>
Subject: [PATCH/docs] make slash-rules more readable
Date: Fri, 5 Apr 2019 22:00:45 +0200 [thread overview]
Message-ID: <20190405200045.10063-1-admin@in-ici.net> (raw)
From: Adam Nielsen <admin@in-ici.net>
gitignore.txt: make slash-rules more readable
Remove the addition `it is removed for the purpose of the following description` and
make clear in which situations a trailing slash is used or not. Increase readability
and make all paragraphs valid, even if they are not read in strict order.
Replace `otherwise` with the the concrete pattern that is considered in the paragraph to avoid
confusion.
Add simple examples to point out the significant difference between using or not using a trailing slash.
Signed-off-by: Adam J. N. Nielsen <info@drnielsen.de>
---
Documentation/gitignore.txt | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
index 1c94f08ff4..c6720b0ac4 100644
--- a/Documentation/gitignore.txt
+++ b/Documentation/gitignore.txt
@@ -89,22 +89,25 @@ PATTERN FORMAT
Put a backslash ("`\`") in front of the first "`!`" for patterns
that begin with a literal "`!`", for example, "`\!important!.txt`".
- - If the pattern ends with a slash, it is removed for the
- purpose of the following description, but it would only find
+ - If the pattern ends with a slash "`/`", it would only find
a match with a directory. In other words, `foo/` will match a
directory `foo` and paths underneath it, but will not match a
regular file or a symbolic link `foo` (this is consistent
with the way how pathspec works in general in Git).
- - 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).
+ - If the pattern contains no slash "`/`" other then a trailing slash,
+ then the pattern will match in all directories. In other words,
+ `foo/` will match `/bar/foo/` and `foo` will match `/bar/bar/foo`.
- - Otherwise, Git treats the pattern as a shell glob: "`*`" matches
- anything except "`/`", "`?`" matches any one character except "`/`"
- and "`[]`" matches one character in a selected range. See
+ - If the pattern contains a slash "`/`" other then a trailing slash, then
+ the pattern is always considered from the `.gitignore` file location.
+ In other words, `foo/bar` will match `/foo/bar` but not `/bar/foo/bar`.
+
+ - The character "`*`" matches anything except a non trailing slash "`/`".
+ For example, "foo/*" matches "foo/test.json" and "foo/bar/"
+ but not "foo/bar/test.json".
+ The character "`?`" matches any one character except "`/`".
+ The character "`[]`" matches one character in a selected range. See
fnmatch(3) and the FNM_PATHNAME flag for a more detailed
description.
--
2.17.1
next reply other threads:[~2019-04-05 20:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-05 20:00 Dr. Adam Nielsen [this message]
2019-04-08 7:51 ` [PATCH/docs] make slash-rules more readable Junio C Hamano
2019-04-08 10:27 ` Dr. Adam Nielsen
2019-04-09 7:01 ` Junio C Hamano
2019-04-09 12:19 ` Dr. Adam Nielsen
2019-04-09 16:21 ` Junio C Hamano
2019-04-10 7:39 ` Dr. Adam Nielsen
2019-04-17 15:49 ` Dr. Adam Nielsen
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=20190405200045.10063-1-admin@in-ici.net \
--to=admin@in-ici.net \
--cc=git@vger.kernel.org \
--cc=info@drnielsen.de \
/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).