Fix a minor issue with "git-set-mtimes" on a dirty working tree

This commit is contained in:
Tianon Gravi 2015-07-29 15:17:21 -07:00
parent bd63adf3b7
commit 98c5d8cfe6
1 changed files with 4 additions and 0 deletions

View File

@ -6,6 +6,10 @@ files=( $({ git ls-files | xargs -n1 dirname | sort -u && git ls-files; } | sort
unset IFS
for f in "${files[@]}"; do
if [ ! -e "$f" ]; then
# don't try touching files that don't exist
continue
fi
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"