Is there a way to determine the new git sha of a file (or ideally of a tree), BEFORE committing the changes?
Background:
I'm trying to automatically change a string in one file in my repo to a unique value, every time any files in another directory of the repo are changed.
I was thinking that an easy way to do this would be to write a git hook that just uses the sha of the subdirectory tree as the unique string. This seems like it would be straightforward to do as a post-commit hook with git ls-tree, but that would require an extra dummy commit to commit the string each time, generating extra noise.
So far I've determined that this might be possible by running git hash-object, but I'd have to write a mildly complex script to recursively build up the hashes of the files in the directory in order to eventually compute the hash of the directory (tree). I'm wondering if there is a simpler option.