[PATCH/docs] make slash-rules more readable
- Date: Fri, 5 Apr 2019 22:00:45 +0200
- From: "Dr. Adam Nielsen" <admin@xxxxxxxxxx>
- Subject: [PATCH/docs] make slash-rules more readable
From: Adam Nielsen <admin@xxxxxxxxxx>
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
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@xxxxxxxxxxxx>
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
@@ -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