]> git.phdru.name Git - git-scripts.git/blobdiff - hooks/post-checkout-touch
Set timestamp only on the files known to git
[git-scripts.git] / hooks / post-checkout-touch
index 5bd00a273dba1a064c60e8f4351b14441fd58c12..713395f2fb7eb54db24e2def67e0962b73bc450e 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# post-checkout hook that change timestamps on files to that one of the commit
+# post-checkout hook that changes timestamps on files to that one of the commit
 # if branch was changed
 
 prev_HEAD="$1"
@@ -9,7 +9,7 @@ new_branch="$3"
 
 if [ "$new_branch" = 1 ]; then
    commit_date="`git show --format='%cD' \"$new_HEAD\" | awk '{if (NR==1) print}'`" &&
-   find . \( -name .git -type d -prune \) -o -exec touch --date="$commit_date" '{}' \+
+   touch --date="$commit_date" `git ls-files --cached`
 fi
 
 exit 0