bashbrew/git-set-mtimes

13 lines
323 B
Bash
Executable File

#!/bin/bash
set -e
IFS=$'\n'
files=( $({ git ls-files | xargs dirname | sort -u && git ls-files; } | sort -r) )
unset IFS
for f in "${files[@]}"; do
stamp="$(git --no-pager log -1 --format='format:%ai' -- "$f")"
touchFormat="$(date --date="$stamp" +'%Y%m%d%H%M.%S')"
touch --no-dereference -t "$touchFormat" "$f"
done