]> git.phdru.name Git - git-scripts.git/blob - hooks/post-checkout-touch
5bd00a273dba1a064c60e8f4351b14441fd58c12
[git-scripts.git] / hooks / post-checkout-touch
1 #!/bin/sh
2
3 # post-checkout hook that change timestamps on files to that one of the commit
4 # if branch was changed
5
6 prev_HEAD="$1"
7 new_HEAD="$2"
8 new_branch="$3"
9
10 if [ "$new_branch" = 1 ]; then
11    commit_date="`git show --format='%cD' \"$new_HEAD\" | awk '{if (NR==1) print}'`" &&
12    find . \( -name .git -type d -prune \) -o -exec touch --date="$commit_date" '{}' \+
13 fi
14
15 exit 0