add mtime-to-git script to pull more correct mtimes out of git
[ikiwiki] / mtime-to-git
1 #!/bin/sh
2 # Sets mtimes of all files in the tree their last change date
3 # based on git's log. Useful to avoid too new dates after a
4 # fresh checkout, which lead to ikiwiki unnecessarily rebuilding
5 # basewiki files on upgrade.
6 if [ -d .git ]; then
7         for file in $(git ls-files); do
8                 date="$(git log -1 --date=rfc "$file" | grep ^Date: | sed -e 's/Date://')"
9                 if [ -n "$date" ]; then
10                         echo "$date $file"
11                         touch -d"$date" $file
12                 fi
13         done
14 fi