{"thread":{"id":"53295","subject":"proposal for improving gitignore syntax","startedAt":"2020-04-23T08:05:13Z","lastAt":"2020-04-23T08:05:13Z","messageCount":1,"participants":["Timothee Cour"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"395997","messageId":"CANri+Ey2o-P+3S9iu1xj5YQooqBxo5Lvom0HdiQDAkSVTRv86A@mail.gmail.com","threadId":"53295","inReplyTo":null,"subject":"proposal for improving gitignore syntax","fromName":"Timothee Cour","fromEmail":"thelastmammoth@gmail.com","sentAt":"2020-04-23T08:04:42Z","receivedAt":"2020-04-23T08:05:13Z","isPatch":false,"sender":{"key":"thelastmammoth@gmail.com","avatar":null},"body":"I'm facing a common problem with gitignore, see\nhttps://stackoverflow.com/questions/61381438/how-to-gitignore-extension-less-files-without-breaking-a-global-gitignore\nIt doesn't seem to be possible to gitignore extension-less files (eg\nposix binaries) without negative side effects, eg:\n```\n*\n!/**/\n!*.*\n```\nIt's more complicated than it should and also doesn't work well, as it\nwill render a global gitignore useless.\n\nThis is just one of the problems with gitignore.\n\nSuch a common task should have an easy solution, and I'm wondering\nwhether gitignore can be improved to make this easy/possible.\n\nHere's a concrete proposal. If 1st line contains `#\ngitignore-syntax:v2`, it uses a new syntax, otherwise it uses existing\nsyntax, to ensure backward compatibility.\nWith the new syntax, strings enclosed inside parenthesis, eg (\\w+)\ndenote regular expressions matching a single path component, with ^$\nimplied for each path component to match the entire component.\n\nRegular expressions are forbidden to span across path components.\n(\\w+\\.(md|txt))\nExamples:\n```\n# gitignore-syntax:v2\n# the line above enables the new syntax for this file\n\n# this gitignores all extension-less files anywhere (:\n([^.]+)\n# this un-ignores files called README\n!README\n\n# this will gitignore for example /abc/foo.md\n/*/((foo|bar)\\.md)\n\n# this will gitignore directories (bc trailing /) like ab/cd/foo/123/\n**/(\\w+)/(\\d+)/\n```\n\nold tools like grep support regex so I'm assuming git could too, but\nif for some reason that can't work (why?), some simplified version\ncould be supported to at least enable common cases without a full\nblown regex engine, for example */([^.]+)\n"}]}