git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH/docs] make slash-rules more readable
@ 2019-04-05 20:00 Dr. Adam Nielsen
  2019-04-08  7:51 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Dr. Adam Nielsen @ 2019-04-05 20:00 UTC (permalink / raw)
  To: git; +Cc: Adam Nielsen, Adam J . N . Nielsen

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-04-17 15:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-05 20:00 [PATCH/docs] make slash-rules more readable Dr. Adam Nielsen
2019-04-08  7:51 ` 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

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