{"thread":{"id":"48917","subject":"Q: Ignore ./foo, but not script/foo","startedAt":"2018-07-19T07:45:19Z","lastAt":"2018-07-19T11:00:09Z","messageCount":6,"participants":["Ulrich Windl","3Ævar Arnfjörð Bjarmason","Timothy Rice","Konstantin Khomoutov","Ævar Arnfjörð Bjarmason"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"353013","messageId":"5B503FF0020000A10002C6B5@gwsmtp1.uni-regensburg.de","threadId":"48917","inReplyTo":null,"subject":"Q: Ignore ./foo, but not script/foo","fromName":"Ulrich Windl","fromEmail":"ulrich.windl@rz.uni-regensburg.de","sentAt":"2018-07-19T07:38:24Z","receivedAt":"2018-07-19T07:45:19Z","isPatch":false,"sender":{"key":"ulrich.windl@rz.uni-regensburg.de","avatar":null},"body":"Hi!\n\nI have a (simple) question I could not answer elegantly from the gitignore(5) manual page:\n\nA project produces a \"foo\" binary in the root directory that I want to ignore (So I put \"foo\" into .gitignore)\nUnfortunately I found out taht I cannot have a \"script/foo\" added while \"foo\" is in .gitignore.\nSo I changed \"foo\" to \"./foo\" in .gitignore. I can could add \"script/foo\", but now \"foo\" is not ignored any more!\n\nIs there as solution other than:?\n--\nfoo\n!script/foo\n!bla/foo\n#etc.\n--\n\nIf \"foo\" is one exception to generally using foo elsewhere, it seems to be counterproductive to have to add exceptions for all the cases that are not exceptions, while \"foo\" is the only exception...\n\nDid I miss something? If so, maybe add it to a future manual page.\n\nRegards,\nUlrich\n\n\n"},{"id":"353014","messageId":"8736wfd579.fsf@evledraar.gmail.com","threadId":"48917","inReplyTo":"5B503FF0020000A10002C6B5@gwsmtp1.uni-regensburg.de","subject":"Re: Q: Ignore ./foo, but not script/foo","fromName":"3Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-07-19T08:01:46Z","receivedAt":"2018-07-19T08:01:50Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, Jul 19 2018, Ulrich Windl wrote:\n\n> Hi!\n>\n> I have a (simple) question I could not answer elegantly from the gitignore(5) manual page:\n>\n> A project produces a \"foo\" binary in the root directory that I want to ignore (So I put \"foo\" into .gitignore)\n> Unfortunately I found out taht I cannot have a \"script/foo\" added while \"foo\" is in .gitignore.\n> So I changed \"foo\" to \"./foo\" in .gitignore. I can could add \"script/foo\", but now \"foo\" is not ignored any more!\n>\n> Is there as solution other than:?\n> --\n> foo\n> !script/foo\n> !bla/foo\n> #etc.\n\nThe solution is to just do:\n\n    echo /foo >.gitignore\n\nThen it'll ignore the top-level /foo, but nothing else. How did you come\nup with this \"./\" syntax? It's not understood by gitignore. From\ngitignore(5):\n\n   A leading slash matches the beginning of the pathname. For example,\n   \"/*.c\" matches \"cat-file.c\" but not \"mozilla-sha1/sha1.c\".\n"},{"id":"353016","messageId":"20180719090656.GA18624@sleipnir","threadId":"48917","inReplyTo":"8736wfd579.fsf@evledraar.gmail.com","subject":"Re: Q: Ignore ./foo, but not script/foo","fromName":"Timothy Rice","fromEmail":"timothy.rice@unimelb.edu.au","sentAt":"2018-07-19T09:06:57Z","receivedAt":"2018-07-19T09:13:22Z","isPatch":false,"sender":{"key":"timothy.rice@unimelb.edu.au","avatar":null},"body":"> How did you come up with this \"./\" syntax?\n\nIt is a Unix thing: \"./\" or just \".\" refers to the current directory.\n\nWhen calling scripts or programs in the current directory from a Unix\ncommand line, it is required to refer to them as, say, \"./foo\" (not just\n\"foo\") -- unless \".\" is in your PATH.\n\nMost people do put \".\" in their PATH for convenience but it is considered a\nlittle unsafe [1].\n\nPersonally, I am surprised that gitignore does not understand this\nnotation. To me, OPs meaning was crystal clear: \"./foo\" should mean to only\nignore the foo in the repository's root directory.\n\n[1] https://superuser.com/questions/156582/why-is-not-in-the-path-by-default\n\n~ Tim\n\n"},{"id":"353018","messageId":"20180719092246.vtwfludt7gmk6gdz@tigra","threadId":"48917","inReplyTo":"20180719090656.GA18624@sleipnir","subject":"Re: Q: Ignore ./foo, but not script/foo","fromName":"Konstantin Khomoutov","fromEmail":"kostix@bswap.ru","sentAt":"2018-07-19T09:22:46Z","receivedAt":"2018-07-19T09:23:09Z","isPatch":false,"sender":{"key":"kostix@bswap.ru","avatar":null},"body":"On Thu, Jul 19, 2018 at 07:06:57PM +1000, Timothy Rice wrote:\n\n[...]\n> Most people do put \".\" in their PATH for convenience\n[...]\n\nIMO this is a gross overstatement: personally, I know of no person using\na Unix-like operation system who does this.\n\n"},{"id":"353019","messageId":"871sbzd13z.fsf@evledraar.gmail.com","threadId":"48917","inReplyTo":"20180719090656.GA18624@sleipnir","subject":"Re: Q: Ignore ./foo, but not script/foo","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-07-19T09:30:08Z","receivedAt":"2018-07-19T09:30:12Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, Jul 19 2018, Timothy Rice wrote:\n\n>> How did you come up with this \"./\" syntax?\n>\n> It is a Unix thing: \"./\" or just \".\" refers to the current directory.\n>\n> When calling scripts or programs in the current directory from a Unix\n> command line, it is required to refer to them as, say, \"./foo\" (not just\n> \"foo\") -- unless \".\" is in your PATH.\n>\n> Most people do put \".\" in their PATH for convenience but it is considered a\n> little unsafe [1].\n>\n> Personally, I am surprised that gitignore does not understand this\n> notation. To me, OPs meaning was crystal clear: \"./foo\" should mean to only\n> ignore the foo in the repository's root directory.\n>\n> [1] https://superuser.com/questions/156582/why-is-not-in-the-path-by-default\n\nTo clarify I was trying to fish for whether we'd accidentally documented\n\"./\" somewhere since OP was making references to the docs.\n"},{"id":"353021","messageId":"5B506F34020000A10002C6C5@gwsmtp1.uni-regensburg.de","threadId":"48917","inReplyTo":"CA+xP2SZJ0VN0Y7SChAx1a8joVMKMU2R9d0je801i=9SuLicF3w@mail.gmail.com","subject":"Antw: Re: Q: Ignore ./foo, but not script/foo","fromName":"Ulrich Windl","fromEmail":"ulrich.windl@rz.uni-regensburg.de","sentAt":"2018-07-19T11:00:04Z","receivedAt":"2018-07-19T11:00:09Z","isPatch":false,"sender":{"key":"ulrich.windl@rz.uni-regensburg.de","avatar":null},"body":">>> Sebastian Staudt <koraktor@gmail.com> schrieb am 19.07.2018 um 09:55 in\nNachricht\n<CA+xP2SZJ0VN0Y7SChAx1a8joVMKMU2R9d0je801i=9SuLicF3w@mail.gmail.com>:\n> Hello Ulrich,\n> \n> if you want to ignore a file in the root of the repository (and only\n> there) this is the correct syntax:\n> \n>     /foo\n\nHi!\n\nThanks, you are perfectly right: It works, and actually, when read carefully enough, the last item in \"PATTERN FORMAT\" explains that.\n\nMaybe the EXAMPLES could have an example for each item (5 cases) described ;-)\n\nRegards,\nUlrich\n\n> \n> Best regards,\n>     Sebastian\n> Am Do., 19. Juli 2018 um 09:45 Uhr schrieb Ulrich Windl\n> <Ulrich.Windl@rz.uni-regensburg.de>:\n>>\n>> Hi!\n>>\n>> I have a (simple) question I could not answer elegantly from the \n> gitignore(5) manual page:\n>>\n>> A project produces a \"foo\" binary in the root directory that I want to \n> ignore (So I put \"foo\" into .gitignore)\n>> Unfortunately I found out taht I cannot have a \"script/foo\" added while \n> \"foo\" is in .gitignore.\n>> So I changed \"foo\" to \"./foo\" in .gitignore. I can could add \"script/foo\", \n> but now \"foo\" is not ignored any more!\n>>\n>> Is there as solution other than:?\n>> --\n>> foo\n>> !script/foo\n>> !bla/foo\n>> #etc.\n>> --\n>>\n>> If \"foo\" is one exception to generally using foo elsewhere, it seems to be \n> counterproductive to have to add exceptions for all the cases that are not \n> exceptions, while \"foo\" is the only exception...\n>>\n>> Did I miss something? If so, maybe add it to a future manual page.\n>>\n>> Regards,\n>> Ulrich\n>>\n>>\n\n\n\n\n"}]}