{"thread":{"id":"26850","subject":"`*' gitignores and nested ignores","startedAt":"2011-03-24T10:10:00Z","lastAt":"2011-03-25T09:37:10Z","messageCount":3,"participants":["Eli Barzilay","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"164224","messageId":"19851.6264.179471.935771@winooski.ccs.neu.edu","threadId":"26850","inReplyTo":null,"subject":"`*' gitignores and nested ignores","fromName":"Eli Barzilay","fromEmail":"eli@barzilay.org","sentAt":"2011-03-24T10:10:00Z","receivedAt":"2011-03-24T10:10:00Z","isPatch":false,"sender":{"key":"eli@barzilay.org","avatar":"https://avatars.githubusercontent.com/u/185905?v=4"},"body":"According to the man page, a .gitignore file that is deeper has higher\nprecedence, and a `!' line overrides lower precedence ignores.  I\ntried that, and it works in cases like the last \"vmlinux*\" example.\n\nBut it doesn't work if the lower precedence directory has a \"*\"\npattern.  If the last example from the man page is changed to:\n\n               $ cat .gitignore\n               *\n               $ ls arch/foo/kernel/vm*\n               arch/foo/kernel/vmlinux.lds.S\n               $ echo ´!/vmlinux*´ >arch/foo/kernel/.gitignore\n\nthen -- IIUC -- the second ignore should work the same, but it\ndoesn't.  This also happens if the first pattern is \"/*\".\n\nIs this a bug?\n\n\nBTW, my use case is to track random stuff in a directory that has lots\nof junk.  I wanted to do this by having a toplevel \"/*\" ignore and add\nfiles explicitly when I want to.  But there are some directories that\nshould be tracked, and I was trying to achieve this effect by adding a\n\"!/*\" pattern in them.  Is there a more convenient (or saner) way of\ndoing this?\n\n-- \n          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:\n                    http://barzilay.org/                   Maze is Life!\n"},{"id":"164276","messageId":"4D8C4FCF.5060900@viscovery.net","threadId":"26850","inReplyTo":"19851.6264.179471.935771@winooski.ccs.neu.edu","subject":"Re: `*' gitignores and nested ignores","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-03-25T08:18:23Z","receivedAt":"2011-03-25T08:18:23Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 3/24/2011 11:10, schrieb Eli Barzilay:\n> According to the man page, a .gitignore file that is deeper has higher\n> precedence, and a `!' line overrides lower precedence ignores.  I\n> tried that, and it works in cases like the last \"vmlinux*\" example.\n> \n> But it doesn't work if the lower precedence directory has a \"*\"\n> pattern.  If the last example from the man page is changed to:\n> \n>                $ cat .gitignore\n>                *\n>                $ ls arch/foo/kernel/vm*\n>                arch/foo/kernel/vmlinux.lds.S\n>                $ echo ´!/vmlinux*´ >arch/foo/kernel/.gitignore\n> \n> then -- IIUC -- the second ignore should work the same, but it\n> doesn't.  This also happens if the first pattern is \"/*\".\n> \n> Is this a bug?\n\nThis has been discussed before, and IMNSHO, this is not a bug:\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/157190\n\n-- Hannes\n"},{"id":"164284","messageId":"19852.25158.340116.57859@winooski.ccs.neu.edu","threadId":"26850","inReplyTo":"4D8C4FCF.5060900@viscovery.net","subject":"Re: `*' gitignores and nested ignores","fromName":"Eli Barzilay","fromEmail":"eli@barzilay.org","sentAt":"2011-03-25T09:37:10Z","receivedAt":"2011-03-25T09:37:10Z","isPatch":false,"sender":{"key":"eli@barzilay.org","avatar":"https://avatars.githubusercontent.com/u/185905?v=4"},"body":"An hour ago, Johannes Sixt wrote:\n> Am 3/24/2011 11:10, schrieb Eli Barzilay:\n> > According to the man page, a .gitignore file that is deeper has\n> > higher precedence, and a `!' line overrides lower precedence\n> > ignores.  I tried that, and it works in cases like the last\n> > \"vmlinux*\" example.\n> > \n> > But it doesn't work if the lower precedence directory has a \"*\"\n> > pattern.  [...]\n> > \n> > Is this a bug?\n> \n> This has been discussed before, and IMNSHO, this is not a bug:\n> \n> http://thread.gmane.org/gmane.comp.version-control.git/157190\n\nTo reply to what you wrote there:\n\n> You should update your expectations to match what you got.\n\nThat kind of an answer is a thick hint that something is not\ndocumented right.  As things stand, I don't see anything in the man\npage that describes the actual algorithm that is used.  I also found a\nsimilar weirdness now -- the man page says\n\n  within one level of precedence, the last matching pattern decides\n  the outcome\n\nbut this is not true for nested files in this case:\n\n  *\n  !foo\n\nSo some description of what's going on is needed.  Perhaps it's\nexactly what Seth's suggested patch describes.\n\n\nIn any case, it seems possible to do something that works more as\nexpected.  As suggested in that thread -- scanning only directories\nthat have committed files would not make things slow, since the files\nneed to be checked anyway.  This is not even hard to describe in a man\npage.  It seems like some arbitrariness that buys performance, but its\nless so than the current situation.\n\nThere's also the option of scanning only .gitignore files that are\nchecked in, but that will probably be too confusing when the files are\ncreated and/or modified.\n\nYet another alternative is to say that an ignored .gitignore file is\nignored, and making this:\n\n  /*\n  !.gitignore\n\nan idiom for doing the slow thing in case you really want it.\n\n-- \n          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:\n                    http://barzilay.org/                   Maze is Life!\n"}]}