diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-11-06 10:40:54 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-11-06 10:40:54 +0200 |
commit | a398fc58c0b308daf419eec07a30d0954bb0fac4 (patch) | |
tree | a7d151ed5a6347a13bab4054b2cc650b4172b4f1 /git-mtime.sh | |
parent | 24a6e312e91c1562662df480071721ad2807f21e (diff) | |
download | obnam.org-a398fc58c0b308daf419eec07a30d0954bb0fac4.tar.gz |
add script to set mtime from git
Diffstat (limited to 'git-mtime.sh')
-rwxr-xr-x | git-mtime.sh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/git-mtime.sh b/git-mtime.sh new file mode 100755 index 0000000..84c9299 --- /dev/null +++ b/git-mtime.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# From https://stackoverflow.com/questions/2458042/restore-a-files-modification-time-in-git + +set -euo pipefail + +rev=HEAD +for f in $(git ls-tree -r -t --full-name --name-only "$rev") +do + echo "setting mtime for $f" + touch -d "$(git log --pretty=format:%cI -1 "$rev" -- "$f")" "$f"; +done |