On Wed, Dec 29, 2021 at 2:15 PM Elijah Newren <newren@xxxxxxxxx> wrote: > > On Wed, Dec 29, 2021 at 12:54 PM Britton Kerin <britton.kerin@xxxxxxxxx> wrote: > > > > I'd like to query if a file e.g. symLinkToDir/foo.o would be ignored > > if it were in a real dir instead (don't ask) but in a general way and > > hopefully without parsing and matching all the .gitignore entries > > myself. Is it possible? > > How would that even work? If there is just one gitignore pattern and it was: > > build/* > > And you tried to ask (making up a new `--patterns` flag): > > git check-ignore --patterns '*/foo.o' You're right that it wouldn't make sense for a pattern but I want to ask about a concrete path. I've got a setup that hashes source trees (some of which are large, and some of which sometimes switch between sym links and identical dirs) and some make tricks to cause it to first consider timestamps then hashes in a link-transparent way before commiting to a rebuild. I want to recycle .gitignore (and ~/.gitignore) etc. to filter out built files out of the hash input so it works right for dirs that build into themselves (as most do). > What should the command return? True? False? It kinda depends on > what that '*' actually is. If it's "build" then it's ignored. If > it's not, then for this example it wouldn't be ignored. So the best > answer we would be able to give is "maybe", which isn't particularly > useful. Also, typical cases will be much more complex than that. So > we can only answer whether specific paths are ignored, not whether The problem is just that check-ignore won't answer for paths it finds are beyond a link, when what I want to know is just whether a given path matches any of the patterns (and doesn't later get excluded etc.) regardless of other git or filesystem state (except source names and contents of course). Britton