{"thread":{"id":"51031","subject":"[PATCH] make slash rules more readable","startedAt":"2019-05-04T10:19:15Z","lastAt":"2019-05-08T01:42:29Z","messageCount":4,"participants":["Dr. Adam Nielsen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"374898","messageId":"20190504101905.7522-1-admin@in-ici.net","threadId":"51031","inReplyTo":null,"subject":"[PATCH] make slash rules more readable","fromName":"Dr. Adam Nielsen","fromEmail":"admin@in-ici.net","sentAt":"2019-05-04T10:19:05Z","receivedAt":"2019-05-04T10:19:15Z","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\nMake all paragraphs valid, even if they are not read\nin strict order. Make paragraph better understandable\nfor pattern without slash. Add paragraph for pattern \nwith slash. Be precise whenever a trailing slashes\nwould make a difference. Add some examples.\n\nSigned-off-by: Dr. Adam Nielsen <admin@in-ici.net>\n\n---\n Documentation/gitignore.txt | 37 ++++++++++++++++++++++++-------------\n 1 file changed, 24 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt\nindex b5bc9dbff0..3a6fb9117c 100644\n--- a/Documentation/gitignore.txt\n+++ b/Documentation/gitignore.txt\n@@ -89,24 +89,35 @@ 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+ - 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+ - If the pattern contains no slash \"`/`\" (except an optional trailing slash),\n+   the pattern is matched against all files and folders (recursively)\n+   from the location of the `.gitignore` file.\n+   For example, `frotz/` matches `frotz` and `a/frotz` that\n+   is a directory (relative from the `.gitignore` file). \n+\n+ - A pattern that contains a non-trailing slash is matched relative to the \n+   location of the `.gitignore` file.\n+   For example, `doc/frotz/` matches `doc/frotz` directory, but not \n+   `a/doc/frotz` (relative from the `.gitignore` file). \n+   Note that the pattern `doc/frotz` and `/doc/frotz`  \n+   have the same effect in any `.gitignore` file, while `/bar` and `bar` \n+   have not the same effect (`/bar` will not match `foo/bar`).\n+\n+ - An asterisk \"`*`\" matches anything except a slash.  A\n+   pattern \"foo/*\", for example, matches \"foo/test.json\" (a\n+   regular file), \"foo/bar\" (a diretory), but it does not match\n+   \"foo/bar/hello.c\" (a regular file), as the asterisk in the\n+   patter does not match \"bar/hello.c\" which has a slash in it.\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  - A leading slash matches the beginning of the pathname.\n    For example, \"/{asterisk}.c\" matches \"cat-file.c\" but not\n-- \n2.17.1\n\n"},{"id":"375007","messageId":"xmqqlfzilgrm.fsf@gitster-ct.c.googlers.com","threadId":"51031","inReplyTo":"20190504101905.7522-1-admin@in-ici.net","subject":"Re: [PATCH] make slash rules more readable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-05-07T10:07:25Z","receivedAt":"2019-05-07T10:07:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Dr. Adam Nielsen\" <admin@in-ici.net> writes:\n\n> gitignore.txt: make slash-rules more readable\n>\n> Make all paragraphs valid, even if they are not read\n> in strict order. Make paragraph better understandable\n> for pattern without slash. Add paragraph for pattern \n> with slash. Be precise whenever a trailing slashes\n> would make a difference. Add some examples.\n>\n> Signed-off-by: Dr. Adam Nielsen <admin@in-ici.net>\n>\n\nHave you run \"git diff --check\" before committing the change?  It\nseems that many updated lines end in trailing spaces.\n"},{"id":"375009","messageId":"6549e684-ac91-4a66-afa0-73c0e8c658f8@in-ici.net","threadId":"51031","inReplyTo":"xmqqlfzilgrm.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] make slash rules more readable","fromName":"Dr. Adam Nielsen","fromEmail":"admin@in-ici.net","sentAt":"2019-05-07T10:23:02Z","receivedAt":"2019-05-07T10:23:08Z","isPatch":true,"sender":{"key":"admin@in-ici.net","avatar":"https://avatars.githubusercontent.com/u/1765602?v=4"},"body":"\n\nOn 07.05.19 12:07, Junio C Hamano wrote:\n> \"Dr. Adam Nielsen\" <admin@in-ici.net> writes:\n> \n>> gitignore.txt: make slash-rules more readable\n>>\n>> Make all paragraphs valid, even if they are not read\n>> in strict order. Make paragraph better understandable\n>> for pattern without slash. Add paragraph for pattern\n>> with slash. Be precise whenever a trailing slashes\n>> would make a difference. Add some examples.\n>>\n>> Signed-off-by: Dr. Adam Nielsen <admin@in-ici.net>\n>>\n> \n> Have you run \"git diff --check\" before committing the change?  It\n> seems that many updated lines end in trailing spaces.\n> \n\nUh, I forgot that. I will send a clean version in a moment.\n\n"},{"id":"375082","messageId":"xmqqlfzhk9he.fsf@gitster-ct.c.googlers.com","threadId":"51031","inReplyTo":"6549e684-ac91-4a66-afa0-73c0e8c658f8@in-ici.net","subject":"Re: [PATCH] make slash rules more readable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-05-08T01:42:21Z","receivedAt":"2019-05-08T01:42:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Dr. Adam Nielsen\" <admin@in-ici.net> writes:\n\n> On 07.05.19 12:07, Junio C Hamano wrote:\n>> \"Dr. Adam Nielsen\" <admin@in-ici.net> writes:\n>>\n>>> gitignore.txt: make slash-rules more readable\n>>>\n>>> Make all paragraphs valid, even if they are not read\n>>> in strict order. Make paragraph better understandable\n>>> for pattern without slash. Add paragraph for pattern\n>>> with slash. Be precise whenever a trailing slashes\n>>> would make a difference. Add some examples.\n>>>\n>>> Signed-off-by: Dr. Adam Nielsen <admin@in-ici.net>\n>>>\n>>\n>> Have you run \"git diff --check\" before committing the change?  It\n>> seems that many updated lines end in trailing spaces.\n>>\n>\n> Uh, I forgot that. I will send a clean version in a moment.\n\nIt's OK; \"git am --whitespace=fix\" can rescue a gotcha like this.\n"}]}