This appears to mainly be a lightweight wrapper of watchman.
https://github.com/git/git/blob/v2.16.0/templates/hooks--fsm...
Edit: well, maybe just fewer comments... ha
Its a watchman wrapper written in rust.
But in that article you linked, there is mentioned that git ships with a sample watchman hook already?!
What watchman is doing is doing inotify-as-a-service for you, in order for any program to use the Linux inotify API it needs to be running constantly so it can keep consuming events from the kernel, and in the case of the use case watchman fulfills, maintain an internal database of how the current state differs from various times in the past.
There's lots of very nasty edge cases you need to deal with. E.g. if you don't consume the kernel events fast enough (or the buffer is too small) new events will be dropped.
You'll get told about this by the kernel, but now the only way to re-build your in-memory representation to match reality is to recursively walk the FS with readdir(), stat() etc, but at the same time consume new inotify events and update your in-memory structures while doing both.
Needless to say this is a lot more complex than just using watchman off the shelf.
It's also pointless to optimize this area, watchman usually returns in 2-3 milliseconds even on huge trees, but because of bugs / misfeatures in the current git-side implementation it can take hundreds of milliseconds until we make sense of all of that. This is because git doesn't really "know" about watchman/inotify, it just uses it as a replacement for walking the FS, but on big repositories other stuff can still be expensive.
To OP: I highly encourage you to submit this to the Git mailing list for comment. I've been involved in this area (helped write the Perl hook) and there's people who'd be interested in having this be e.g. a part of git's contrib/ directory so it can be compiled with git.
https://github.com/facebook/watchman/tree/master/rust/serde_...