summaryrefslogtreecommitdiff
path: root/mtime-to-git
blob: 9875af5d75215e422053d483607cd6b29023c66b (plain)
  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