add mtime-to-git script to pull more correct mtimes out of git
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 16 Apr 2010 16:21:44 +0000 (12:21 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 16 Apr 2010 16:23:28 +0000 (12:23 -0400)
mtime-to-git [new file with mode: 0755]

diff --git a/mtime-to-git b/mtime-to-git
new file mode 100755 (executable)
index 0000000..9875af5
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Sets mtimes of all files in the tree their last change date
+# based on git's log. Useful to avoid too new dates after a
+# fresh checkout, which lead to ikiwiki unnecessarily rebuilding
+# basewiki files on upgrade.
+if [ -d .git ]; then
+       for file in $(git ls-files); do
+               date="$(git log -1 --date=rfc "$file" | grep ^Date: | sed -e 's/Date://')"
+               if [ -n "$date" ]; then
+                       echo "$date $file"
+                       touch -d"$date" $file
+               fi
+       done
+fi