summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-11-06 10:36:41 +0200
committerLars Wirzenius <liw@liw.fi>2020-11-06 10:36:41 +0200
commitf39aad2069aff0688d610bb64e2464764eef95ae (patch)
tree60579f9bde9b4b1af52520010017c6db3de4e61b
parentb3e06b45f58c7d34cf4f285fb23548f5e380fb31 (diff)
downloadnoir.liw.fi-master.tar.gz
add script to set mtime from gitHEADmaster
-rwxr-xr-xgit-mtime.sh11
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