{"thread":{"id":"57162","subject":"something like git-check-ignore but considering only patterns?","startedAt":"2021-12-28T23:41:40Z","lastAt":"2022-01-02T08:12:19Z","messageCount":3,"participants":["Britton Kerin","Elijah Newren"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"445151","messageId":"CAC4O8c-2sxHyAjtd4jZQcjzX4d9+19AUx-h13nttjwP=pd1Ukw@mail.gmail.com","threadId":"57162","inReplyTo":null,"subject":"something like git-check-ignore but considering only patterns?","fromName":"Britton Kerin","fromEmail":"britton.kerin@gmail.com","sentAt":"2021-12-28T23:41:24Z","receivedAt":"2021-12-28T23:41:40Z","isPatch":false,"sender":{"key":"britton.kerin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7434164?v=4"},"body":"I'd like to query if a file e.g. symLinkToDir/foo.o would be ignored\nif it were in a real dir instead (don't ask) but in a general way and\nhopefully without parsing and matching all the .gitignore entries\nmyself.  Is it possible?\n\nThanks,\nBritton\n"},{"id":"445202","messageId":"CABPp-BEQdpO5=j_f2MjgZjhudNZgKhDgV31M_Cy6Agx_U=KweQ@mail.gmail.com","threadId":"57162","inReplyTo":"CAC4O8c-2sxHyAjtd4jZQcjzX4d9+19AUx-h13nttjwP=pd1Ukw@mail.gmail.com","subject":"Re: something like git-check-ignore but considering only patterns?","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2021-12-29T23:15:31Z","receivedAt":"2021-12-29T23:15:50Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Wed, Dec 29, 2021 at 12:54 PM Britton Kerin <britton.kerin@gmail.com> wrote:\n>\n> I'd like to query if a file e.g. symLinkToDir/foo.o would be ignored\n> if it were in a real dir instead (don't ask) but in a general way and\n> hopefully without parsing and matching all the .gitignore entries\n> myself.  Is it possible?\n\nHow would that even work?  If there is just one gitignore pattern and it was:\n\n    build/*\n\nAnd you tried to ask (making up a new `--patterns` flag):\n\n    git check-ignore --patterns '*/foo.o'\n\nWhat should the command return?  True?  False?  It kinda depends on\nwhat that '*' actually is.  If it's \"build\" then it's ignored.  If\nit's not, then for this example it wouldn't be ignored.  So the best\nanswer we would be able to give is \"maybe\", which isn't particularly\nuseful.  Also, typical cases will be much more complex than that.  So\nwe can only answer whether specific paths are ignored, not whether\nvarious globs would be.\n"},{"id":"445324","messageId":"CAC4O8c95QEnV2=KueE0AOE4Dg+Jh58M2iYiVv=-655667AX85Q@mail.gmail.com","threadId":"57162","inReplyTo":"CABPp-BEQdpO5=j_f2MjgZjhudNZgKhDgV31M_Cy6Agx_U=KweQ@mail.gmail.com","subject":"Re: something like git-check-ignore but considering only patterns?","fromName":"Britton Kerin","fromEmail":"britton.kerin@gmail.com","sentAt":"2022-01-02T08:12:02Z","receivedAt":"2022-01-02T08:12:19Z","isPatch":false,"sender":{"key":"britton.kerin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7434164?v=4"},"body":"On Wed, Dec 29, 2021 at 2:15 PM Elijah Newren <newren@gmail.com> wrote:\n>\n> On Wed, Dec 29, 2021 at 12:54 PM Britton Kerin <britton.kerin@gmail.com> wrote:\n> >\n> > I'd like to query if a file e.g. symLinkToDir/foo.o would be ignored\n> > if it were in a real dir instead (don't ask) but in a general way and\n> > hopefully without parsing and matching all the .gitignore entries\n> > myself.  Is it possible?\n>\n> How would that even work?  If there is just one gitignore pattern and it was:\n>\n>     build/*\n>\n> And you tried to ask (making up a new `--patterns` flag):\n>\n>     git check-ignore --patterns '*/foo.o'\n\nYou're right that it wouldn't make sense for a pattern but I want to\nask about a concrete path.  I've got a setup that hashes source trees\n(some of which are large, and some of which sometimes switch between\nsym links and identical dirs) and some make tricks to cause it to\nfirst consider timestamps then hashes in a link-transparent way before\ncommiting to a rebuild.  I want to recycle .gitignore (and\n~/.gitignore) etc. to filter out built files out of the hash input so\nit works right for dirs that build into themselves (as most do).\n\n> What should the command return?  True?  False?  It kinda depends on\n> what that '*' actually is.  If it's \"build\" then it's ignored.  If\n> it's not, then for this example it wouldn't be ignored.  So the best\n> answer we would be able to give is \"maybe\", which isn't particularly\n> useful.  Also, typical cases will be much more complex than that.  So\n> we can only answer whether specific paths are ignored, not whether\n\nThe problem is just that check-ignore won't answer for paths it finds\nare beyond a link, when what I want to know is just whether a given\npath matches any of the patterns (and doesn't later get excluded etc.)\nregardless of other git or filesystem state (except source names and\ncontents of course).\n\nBritton\n"}]}