Hash cache
Is your feature request related to a problem? Please describe.
With frequent Git (or similar) operations, treefmt often needs to reformat all files, even though almost none changed, since the timestamps got updated, therefore invalidating the cache.
Describe the solution you'd like
A cache of hashes that are known to be formatted. So when it would format a file, it first checks if its hash is in the cache. If yes, no action necessary. If no, format it and add the new hash to the cache.
Describe alternatives you've considered
Additional context
The reason we didn't go for the hashes is because opening and reading all the files to compute them can make the no-op version pretty slow. But maybe we can combine it and only check the hashes when the timestamps change.
Yeah, as @zimbatm mentioned, we've been toying with this for a while. We're open to suggestions.
I've played around with probabilistic hashing to try to lighten the overhead, and there have been some experiments that try to lean on Git more to determine what has changed. Nothing has borne fruit as of yet, but I'd like to find some time and have another crack at it.
Nixpkgs is the perfect playground for testing new ideas.