summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-11-06 10:43:49 +0200
committerLars Wirzenius <liw@liw.fi>2020-11-06 10:44:07 +0200
commite34c3e01d7aac0b23383372ecf469e02f6e7ea08 (patch)
tree8ad61d703276972b001a6b8563fee28bd06490bb
parent7368d166199e2f2e59b86babf14379b9f2513cd3 (diff)
downloadsubplot.liw.fi-e34c3e01d7aac0b23383372ecf469e02f6e7ea08.tar.gz
add script to set mtime from git
-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