| Thanks for sharing, I love stuff like this. I get frustrated at mtimes being munged. MacOS finder is terrible about this. If anyone is interested, I wrote a more generalized tool for storing metadata called storetouch[1] which takes a snapshot of file's mtimes, and stores them in a nicely formatted file for convenient restoration. You can run it's output by itself with bash, or easily parse it's output. I found that the commit or author date's did not always make sense to represent the true age of a file. Especially for non-source-code documents. For example, a repo of scanned documents. Or a git-annex repo of podcasts going back 20 years. Instead, I treat the commit date as the commit date, and I have a versioned sidecar that stores the actual original mtimes of the files. It can also handle all valid POSIX filenames (a surprising amount of utilities don't, including tools like git-restore-mtime, last time I checked).
If you're already using a tool like git-annex or datalad though, they have the ability to store metadata for each file as well. I would also suggest checking out git-store-meta[2] which was the original inspiration. It stores more than just mtime, but it is more closely tied to git. [1]: https://github.com/unqueued/storetouch [2]: https://github.com/danny0838/git-store-meta |