{"thread":{"id":"46101","subject":"Wrong gitattributes documentation?","startedAt":"2017-06-02T17:19:32Z","lastAt":"2017-06-03T01:20:47Z","messageCount":4,"participants":["Rene Pasing","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"321411","messageId":"e7734a23-12b2-8f62-ab5c-c856d59e3010@pasing.net","threadId":"46101","inReplyTo":null,"subject":"Wrong gitattributes documentation?","fromName":"Rene Pasing","fromEmail":"rene@pasing.net","sentAt":"2017-06-02T17:12:36Z","receivedAt":"2017-06-02T17:19:32Z","isPatch":false,"sender":{"key":"rene@pasing.net","avatar":null},"body":"Hi all,\n\nI have noticed a strange behaviour when using git-lfs.\n\nIf I understood correctly, git-lfs adds patterns to .gitattributes, for \nwhich git then calls lfs for any matches with this pattern.\n\nThe problem is, the documentation[1] says: \"The rules how the pattern \nmatches paths are the same as in .gitignore files; see gitignore[5].\", \nso when I have a pattern like '/images/', it should match on all \nfiles+folders under /images, even the directory itself, right? Or when \nI'd use '/images/*', it should match on all files+folders under /images, \nright?\n\nThis does not seem to be the case. Nothing is done by lfs when using \n'/images/', and when using '/images/*', it only takes into account files \nwhich are directly in /images (so it doesnt take into account \nsubdirectories).\n\nThe only solution to this (until now) is to use '/images/**/*', which \nseems to do exactly what I want (lfs gets executed for all files+folders \nunder /images).\n\nIs this expected behaviour? If yes, then the documentation of \ngitattributes seems incorrect to me. If not, can this be considered as a \nbug?\n\nI found several complaints about this to git-lfs (or other projects \nrelying on gitattributes), e.g. [2], but I didn't find anything about \nthis regarding gitattributes itself.\n\nThanks for answers\nRegards\nRene\n\nPS: $ git --version\ngit version 2.1.4\n\n[1] = https://git-scm.com/docs/gitattributes\n[2] = https://github.com/git-lfs/git-lfs/issues/2068\n"},{"id":"321463","messageId":"xmqq8tlax7lm.fsf@gitster.mtv.corp.google.com","threadId":"46101","inReplyTo":"e7734a23-12b2-8f62-ab5c-c856d59e3010@pasing.net","subject":"Re: Wrong gitattributes documentation?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-03T00:01:09Z","receivedAt":"2017-06-03T00:01:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Rene Pasing <rene@pasing.net> writes:\n\n> The problem is, the documentation[1] says: \"The rules how the pattern\n> matches paths are the same as in .gitignore files; see gitignore[5].\",\n> so when I have a pattern like '/images/', it should match on all\n> files+folders under /images, even the directory itself, right?\n>\n> Or when\n> I'd use '/images/*', it should match on all files+folders under\n> /images, right?\n\nMy reading of \"PATTERN FORMAT\" section in \"git help ignore\" says it\nshouldn't.\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 suitable\n   for consumption by fnmatch(3) with the FNM_PATHNAME flag:\n   wildcards in the pattern will not match a / in the pathname.\n   For example, \"Documentation/{asterisk}.html\" matches\n   \"Documentation/git.html\" but not \"Documentation/ppc/ppc.html\"\n   or \"tools/perf/Documentation/perf.html\".\n\nYour \"/images/*\" is the \"Otherwise\" case, isn't it?\n"},{"id":"321470","messageId":"3b119d82-3d40-c48f-14b5-3348879aabc8@pasing.net","threadId":"46101","inReplyTo":"xmqq8tlax7lm.fsf@gitster.mtv.corp.google.com","subject":"Re: Wrong gitattributes documentation?","fromName":"Rene Pasing","fromEmail":"rene@pasing.net","sentAt":"2017-06-03T01:10:14Z","receivedAt":"2017-06-03T01:10:25Z","isPatch":false,"sender":{"key":"rene@pasing.net","avatar":null},"body":"On 06/03/2017 02:01 AM, Junio C Hamano wrote:\n> Your \"/images/*\" is the \"Otherwise\" case, isn't it?\n\nYes, true. I forgot to mention in my first mail that I also tried\n'/images/', which had the same (=none) effect as '/images/*', sorry\nabout the confusion.\n\n\n"},{"id":"321471","messageId":"2dc4c436-0886-ec05-7a4f-e051bbfbc49f@pasing.net","threadId":"46101","inReplyTo":"xmqq8tlax7lm.fsf@gitster.mtv.corp.google.com","subject":"Re: Wrong gitattributes documentation?","fromName":"Rene Pasing","fromEmail":"rene@pasing.net","sentAt":"2017-06-03T01:20:38Z","receivedAt":"2017-06-03T01:20:47Z","isPatch":false,"sender":{"key":"rene@pasing.net","avatar":null},"body":"On 06/03/2017 02:01 AM, Junio C Hamano wrote:\n> Your \"/images/*\" is the \"Otherwise\" case, isn't it?\n\nOk, sorry, didn't read your answer thoroughly enough the first time.\n\nThe problem is, when I have an entry in .gitignore like this:\n/images\n\nThen git will ignore that whole directory (and all of its subfolders\netc.). Git will just ignore everything in the tree starting with that\npathname.\n\nBut when I use the same pattern ('/images') in .gitattributes I would\nexpect (due to the documentation) that git-lfs will be called for all\nfiles+subfolders+subfolderfiles and even the folder itself (this is what\nI understand from 'The rules how the pattern matches paths are the same\nas in .gitignore files').\n\nThis does not seem to be the case!\n\nSorry again for the confusion.\n\n"}]}