{"thread":{"id":"27202","subject":"git sparse checkout exclusions not working?","startedAt":"2011-04-27T16:35:07Z","lastAt":"2011-04-30T10:06:58Z","messageCount":3,"participants":["skillzero@gmail.com","Nguyen Thai Ngoc Duy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"166525","messageId":"BANLkTinPg_jaxiF8yFtnf4BrT4fx-BQ=+A@mail.gmail.com","threadId":"27202","inReplyTo":null,"subject":"git sparse checkout exclusions not working?","fromName":"","fromEmail":"skillzero@gmail.com","sentAt":"2011-04-27T16:35:07Z","receivedAt":"2011-04-27T16:35:07Z","isPatch":false,"sender":{"key":"skillzero@gmail.com","avatar":null},"body":"It seems like ! patterns in the sparse-checkout file don't exclude\nindividual files in a directory. Here's what I did:\n\ngit init\nmkdir test1\necho \"test1\" test1/file1.txt\necho \"test2\" test1/file2.txt\necho \"test3\" test1/file3.txt\nmkdir test2\necho \"test2\" test2/file1.txt\necho \"test2\" test2/file2.txt\necho \"test2\" test2/file3.txt\ngit add .\ngit commit -m \"test\"\ngit config core.sparseCheckout true\n\necho 'test1/' > .git/info/sparse-checkout\necho '!test1/file2.txt' >> .git/info/sparse-checkout\ngit checkout master --\n\nThe end result is like this:\n\ntest1\ntest1/file1.txt\ntest1/file2.txt\ntest1/file3.txt\n\nThe \"test1\" directory was included, but \"test1/file2.txt\" wasn't\nexcluded even though I added a ! pattern for it. The test2 directory\nwas correctly excluded so that makes me think sparse was working in\ngeneral, but just not respecting the ! pattern in this case.\n\nIs this a bug or am I doing something wrong?\n"},{"id":"166731","messageId":"BANLkTi=m4hcs7pVgn0rkQktmZaqK_ORxaA@mail.gmail.com","threadId":"27202","inReplyTo":"BANLkTinPg_jaxiF8yFtnf4BrT4fx-BQ=+A@mail.gmail.com","subject":"Re: git sparse checkout exclusions not working?","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-04-29T12:10:26Z","receivedAt":"2011-04-29T12:10:26Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Apr 27, 2011 at 11:35 PM,  <skillzero@gmail.com> wrote:\n> It seems like ! patterns in the sparse-checkout file don't exclude\n> individual files in a directory. Here's what I did:\n>\n> ...\n>\n> The \"test1\" directory was included, but \"test1/file2.txt\" wasn't\n> excluded even though I added a ! pattern for it. The test2 directory\n> was correctly excluded so that makes me think sparse was working in\n> general, but just not respecting the ! pattern in this case.\n>\n> Is this a bug or am I doing something wrong?\n\nI can reproduce it too. It looks like a regression from\nwhole-directory matching. If a directory is matched, all files inside\nare considered \"in\". Let's see if I can come up with something this\nweekend.\n-- \nDuy\n"},{"id":"166799","messageId":"BANLkTikU_Qjs9jo2MmPdbwVNBj1V9vJJSw@mail.gmail.com","threadId":"27202","inReplyTo":"BANLkTi=m4hcs7pVgn0rkQktmZaqK_ORxaA@mail.gmail.com","subject":"Re: git sparse checkout exclusions not working?","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-04-30T10:06:58Z","receivedAt":"2011-04-30T10:06:58Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Apr 29, 2011 at 7:10 PM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:\n> On Wed, Apr 27, 2011 at 11:35 PM,  <skillzero@gmail.com> wrote:\n>> It seems like ! patterns in the sparse-checkout file don't exclude\n>> individual files in a directory. Here's what I did:\n>>\n>> ...\n>>\n>> The \"test1\" directory was included, but \"test1/file2.txt\" wasn't\n>> excluded even though I added a ! pattern for it. The test2 directory\n>> was correctly excluded so that makes me think sparse was working in\n>> general, but just not respecting the ! pattern in this case.\n>>\n>> Is this a bug or am I doing something wrong?\n>\n> I can reproduce it too. It looks like a regression from\n> whole-directory matching. If a directory is matched, all files inside\n> are considered \"in\". Let's see if I can come up with something this\n> weekend.\n\nsparse checkout rules are not the only ones falling for this trap.\n.gitignore has the same problem:\n\npclouds@do /tmp/z $ cat .gitignore\nt\n!t/1\npclouds@do /tmp/z $ ls t\n1  2  3\npclouds@do /tmp/z $ git init\nInitialized empty Git repository in /tmp/z/.git/\npclouds@do /tmp/z $ ~/w/git/git add .\npclouds@do /tmp/z $ git ls-files\n.gitignore\n\nI wonder if we can convert struct exclude to struct pathspec and solve\nthe problem all at the same place. Granted .gitignore's '*' is\ndifferent from pathspec's '*' (ie. FNM_PATHNAME vs no flag to\nfnmatch), but struct pathspec can be taught to do it both ways and the\npathspec magic can expose FNM_PATHNAME to users too.\n-- \nDuy\n"}]}