{"thread":{"id":"51221","subject":"[PATCH] make slash-rules more readable","startedAt":"2019-06-02T09:04:39Z","lastAt":"2019-06-02T09:04:39Z","messageCount":1,"participants":["Dr. Adam Nielsen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"376540","messageId":"20190602090415.5889-1-admin@in-ici.net","threadId":"51221","inReplyTo":null,"subject":"[PATCH] make slash-rules more readable","fromName":"Dr. Adam Nielsen","fromEmail":"admin@in-ici.net","sentAt":"2019-06-02T09:04:15Z","receivedAt":"2019-06-02T09:04:39Z","isPatch":true,"sender":{"key":"admin@in-ici.net","avatar":"https://avatars.githubusercontent.com/u/1765602?v=4"},"body":"gitignore.txt: make slash-rules more readable\n\nRemove meta-rule in a paragraph for trailing-slash.\nBe precise whenever a trailing slash would make a \ndifference. Improve or add paragraphs relevant \nfor pattern with slash. Add some slash examples \nin example section.\n\nSigned-off-by: Dr. Adam Nielsen <admin@in-ici.net>\n\n---\n Documentation/gitignore.txt | 69 ++++++++++++++++++++++++++-----------\n 1 file changed, 48 insertions(+), 21 deletions(-)\n\ndiff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt\nindex b5bc9dbff0..46195649f1 100644\n--- a/Documentation/gitignore.txt\n+++ b/Documentation/gitignore.txt\n@@ -89,28 +89,39 @@ PATTERN FORMAT\n    Put a backslash (\"`\\`\") in front of the first \"`!`\" for patterns\n    that begin with a literal \"`!`\", for example, \"`\\!important!.txt`\".\n \n- - If the pattern ends with a slash, it is removed for the\n-   purpose of the following description, but it would only find\n+ - A slash `/` is used as a directory separator. A leading and trailing\n+   slash have special meaning and are explained in the following.\n+\n+ - If the pattern ends with a slash, it would only find\n    a match with a directory.  In other words, `foo/` will match a\n-   directory `foo` and paths underneath it, but will not match a\n-   regular file or a symbolic link `foo` (this is consistent\n-   with the way how pathspec works in general in Git).\n-\n- - If the pattern does not contain a slash '/', Git treats it as\n-   a shell glob pattern and checks for a match against the\n-   pathname relative to the location of the `.gitignore` file\n-   (relative to the toplevel of the work tree if not from a\n-   `.gitignore` file).\n-\n- - Otherwise, Git treats the pattern as a shell glob: \"`*`\" matches\n-   anything except \"`/`\", \"`?`\" matches any one character except \"`/`\"\n-   and \"`[]`\" matches one character in a selected range. See\n-   fnmatch(3) and the FNM_PATHNAME flag for a more detailed\n-   description.\n-\n- - A leading slash matches the beginning of the pathname.\n-   For example, \"/{asterisk}.c\" matches \"cat-file.c\" but not\n-   \"mozilla-sha1/sha1.c\".\n+   directory `foo`, but will not match a regular file or a\n+   symbolic link `foo` (this is consistent with the way how\n+   pathspec works in general in Git).\n+\n+ - If the pattern does not end with a slash, it would find a match\n+   with a file or directory.\n+\n+ - The pattern is matched relative to the location of\n+   the `.gitignore` file. Except if the pattern contains\n+   no slash (or no slash but a trailing slash), then the pattern is\n+   matched against all files and folders (recursively)\n+   from the location of the `.gitignore` file.\n+   For example, `doc/frotz/` matches `doc/frotz` directory, but not\n+   a/doc/frotz`; however `frotz/` matches `frotz` and `a/frotz` that\n+   is a directory (all paths are relative from the `.gitignore` file).\n+\n+ - If the pattern contains a leading slash, the pattern\n+   is matched relative to the location of the\n+   `.gitignore` file (this is actually a direct consequence\n+   of the previous paragraph). For example, `/bar` only matches\n+   the file or folder `bar` but not `a/bar`,\n+   whereas the pattern `bar` would match both.\n+\n+ - An asterisk \"`*`\" matches anything except a slash.\n+   The character \"`?`\" matches any one character except \"`/`\".\n+   The range notation, e.g. `[a-zA-Z]`, can be used to match\n+   one of the characters in a range. See fnmatch(3) and the\n+   FNM_PATHNAME flag for a more detailed description.\n \n Two consecutive asterisks (\"`**`\") in patterns matched against\n full pathname may have special meaning:\n@@ -152,6 +163,22 @@ To stop tracking a file that is currently tracked, use\n EXAMPLES\n --------\n \n+ - The pattern 'hello.*' matches any file or folder\n+   whose name begins with 'hello'. If one wants to restrict\n+   this only to the directory and not in its subdirectories,\n+   one can prepend the pattern with a slash, i.e. '/hello.*';\n+   the pattern now matches 'hello.txt', 'hello.c' but not\n+   'a/hello.java'.\n+\n+ - The pattern `doc/frotz` and `/doc/frotz` have the same effect\n+   in any `.gitignore` file. Both pattern match relative to the\n+   location of the `.gitignore` file.\n+\n+ - The pattern \"foo/*\", matches \"foo/test.json\"\n+   (a regular file), \"foo/bar\" (a directory), but it does not match\n+   \"foo/bar/hello.c\" (a regular file), as the asterisk in the\n+   pattern does not match \"bar/hello.c\" which has a slash in it.\n+\n --------------------------------------------------------------\n     $ git status\n     [...]\n-- \n2.17.1\n\n"}]}