{"thread":{"id":"50206","subject":"Gitignore documentation","startedAt":"2019-01-12T20:16:22Z","lastAt":"2019-01-15T09:27:40Z","messageCount":5,"participants":["Maris Razvan","Junio C Hamano","Jonathan Nieder","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"366624","messageId":"CALZbgSQti+t2dA4nm+DCDGxQjsvNJy3UDdqAya16v+Mv5O4Xdw@mail.gmail.com","threadId":"50206","inReplyTo":null,"subject":"Gitignore documentation","fromName":"Maris Razvan","fromEmail":"razvan.alex.maris@gmail.com","sentAt":"2019-01-12T20:16:07Z","receivedAt":"2019-01-12T20:16:22Z","isPatch":false,"sender":{"key":"razvan.alex.maris@gmail.com","avatar":null},"body":"Hello,\n\nI was reading the gitignore documentation\n(https://git-scm.com/docs/gitignore), especially the following\nparagraph:\n\n         \"If the pattern does not contain a slash /, Git treats it as\na shell glob pattern and checks for a match against the pathname\nrelative to the location of the .gitignore file (relative to the\ntoplevel of the work tree if not from a .gitignore file).\"\n\nFrom that paragraph I understand that if I have the following\ndirectory structure:\n\n        .gitignore\n        a\n            f\n\n(the root of the repository contains the file .gitignore and the\nfolder a, while the file f is inside folder a)\nwhere the file .gitignore contains only the pattern f, when file \"f\"\nis tested whether it should be ignored or not, the pattern f in\n.gitignore is matched against the \"pathname relative to the location\nof the .gitignore file\" (which is a/f). Because \"f\" (the pattern) does\nnot match \"a/f\" (the pathname relative to the location of .gitignore),\nthe file \"f\" should not be ignored. However, if I test this scenario,\ngit ignores the file (this behaviour is consistent with the examples\nfrom the rest of the documentation and other explanations on the\ninternet).\n\nI looked at the history of the \"Documentation/gitignore.txt\" file on\nthe github repository and I saw that initially the paragraph looked\nlike this:\n\n        \"If the pattern does not contain a slash '/', git treats it as\na shell glob pattern and checks for a match against the pathname\nwithout leading directories.\"\n\nThis old version of the paragraph is consistent with git's current behaviour.\n\nThen I saw the following commit\nhttps://github.com/git/git/commit/81c13fde379c46cad6b6e4a03ed7ee4f686c030f#diff-7fea460d44f92f185e7add8aa5620305,\nwhich changed that paragraph to the current version.\nHowever, I cannot see how the two wordings (the original one and the\ncurrent one) are the same.\n\nI would really appreciate if someone could explain how to read the\ncurrent version of the paragraph such that it is consistent with git's\nbehaviour.\n\n\n\nThank you,\nRazvan Maris\n"},{"id":"366670","messageId":"xmqqzhs3uldb.fsf@gitster-ct.c.googlers.com","threadId":"50206","inReplyTo":"CALZbgSQti+t2dA4nm+DCDGxQjsvNJy3UDdqAya16v+Mv5O4Xdw@mail.gmail.com","subject":"Re: Gitignore documentation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-01-14T18:47:44Z","receivedAt":"2019-01-14T18:47:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Maris Razvan <razvan.alex.maris@gmail.com> writes:\n\n> I was reading the gitignore documentation\n> (https://git-scm.com/docs/gitignore), especially the following\n> paragraph:\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 pathname\n> relative to the location of the .gitignore file (relative to the\n> toplevel of the work tree if not from a .gitignore file).\"\n>\n> From that paragraph I understand that if I have the following\n> directory structure:\n>\n>         .gitignore\n>         a\n>             f\n>\n> (the root of the repository contains the file .gitignore and the\n> folder a, while the file f is inside folder a)\n> where the file .gitignore contains only the pattern f, when file \"f\"\n> is tested whether it should be ignored or not, the pattern f in\n> .gitignore is matched against the \"pathname relative to the location\n> of the .gitignore file\" (which is a/f). Because \"f\" (the pattern) does\n> not match \"a/f\" (the pathname relative to the location of .gitignore),\n> the file \"f\" should not be ignored. However, if I test this scenario,\n> git ignores the file (this behaviour is consistent with the examples\n> from the rest of the documentation and other explanations on the\n> internet).\n>\n> I looked at the history of the \"Documentation/gitignore.txt\" file on\n> the github repository and I saw that initially the paragraph looked\n> like this:\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 pathname\n> without leading directories.\"\n>\n> This old version of the paragraph is consistent with git's current behaviour.\n>\n> Then I saw the following commit\n> https://github.com/git/git/commit/81c13fde379c46cad6b6e4a03ed7ee4f686c030f#diff-7fea460d44f92f185e7add8aa5620305,\n> which changed that paragraph to the current version.\n> However, I cannot see how the two wordings (the original one and the\n> current one) are the same.\n\nThanks.\n\nJonathan, after re-reading 81c13fde (\"gitignore.5: Clarify matching\nrules\", 2010-03-05), I do not recall why we thought this part of the\nchange was a good idea, either.  Patterns with slash is anchored at\none directory, and that directory is the one that has per-directory\n.gitignore file.  Patterns without slash (including a pattern that\nends with but otherwise has no other slash) are supposed to match at\nevery level below the directory that the pattern is defined in.\n\n\n\n\n\n\n\n\n Documentation/gitignore.txt | 4 +---\n 1 file changed, 1 insertion(+), 3 deletions(-)\n\ndiff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt\nindex 1c94f08ff4..bf1182169e 100644\n--- a/Documentation/gitignore.txt\n+++ b/Documentation/gitignore.txt\n@@ -98,9 +98,7 @@ PATTERN FORMAT\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+   pathname without leading directories.\n \n  - Otherwise, Git treats the pattern as a shell glob: \"`*`\" matches\n    anything except \"`/`\", \"`?`\" matches any one character except \"`/`\"\n"},{"id":"366678","messageId":"20190114213852.GD162110@google.com","threadId":"50206","inReplyTo":"xmqqzhs3uldb.fsf@gitster-ct.c.googlers.com","subject":"Re: Gitignore documentation","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2019-01-14T21:38:52Z","receivedAt":"2019-01-14T21:38:57Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nJunio C Hamano wrote:\n\n>                                  Patterns with slash is anchored at\n> one directory, and that directory is the one that has per-directory\n> .gitignore file.  Patterns without slash (including a pattern that\n> ends with but otherwise has no other slash) are supposed to match at\n> every level below the directory that the pattern is defined in.\n\nI had a sense of deja vu, and found\nhttps://public-inbox.org/git/20111107080926.GC30486@elie.hsd1.il.comcast.net/\n\nAny idea what happened there?  Would it be useful for me to rebase\nand revive that series?\n\nThanks,\nJonathan\n"},{"id":"366680","messageId":"xmqqsgxuuctp.fsf@gitster-ct.c.googlers.com","threadId":"50206","inReplyTo":"20190114213852.GD162110@google.com","subject":"Re: Gitignore documentation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-01-14T21:52:18Z","receivedAt":"2019-01-14T21:52:23Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> https://public-inbox.org/git/20111107080926.GC30486@elie.hsd1.il.comcast.net/\n>\n> Any idea what happened there?  Would it be useful for me to rebase\n> and revive that series?\n\nNo idea what happend there.\n\nAnyway, I quickly read them over and found nothing questionable,\nexcept perhaps the moving of \"slash is dropped for the purpose of\nthe remaining rules\" in 1/4 were probably not a great idea (IOW, I\nfound that it leaves a stronger impression to the readers to say it\nupfront in the paragraph), but I do not think it is a show-stopper.\n\nReviving the topic would indeed be a good idea.\n\nThanks.\n\n\n\n"},{"id":"366704","messageId":"CACsJy8BdsXYMy6S-8xmCtPzg6wWXb_AJLyfhCG1f6jxPu0LJDQ@mail.gmail.com","threadId":"50206","inReplyTo":"20190114213852.GD162110@google.com","subject":"Re: Gitignore documentation","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2019-01-15T09:27:10Z","receivedAt":"2019-01-15T09:27:40Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Jan 15, 2019 at 4:38 AM Jonathan Nieder <jrnieder@gmail.com> wrote:\n>\n> Hi,\n>\n> Junio C Hamano wrote:\n>\n> >                                  Patterns with slash is anchored at\n> > one directory, and that directory is the one that has per-directory\n> > .gitignore file.  Patterns without slash (including a pattern that\n> > ends with but otherwise has no other slash) are supposed to match at\n> > every level below the directory that the pattern is defined in.\n>\n> I had a sense of deja vu, and found\n> https://public-inbox.org/git/20111107080926.GC30486@elie.hsd1.il.comcast.net/\n>\n> Any idea what happened there?  Would it be useful for me to rebase\n> and revive that series?\n\nI don't remember what happened either. But yeah it's always good to\nimprove this text.\n-- \nDuy\n"}]}