X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=hooks%2Fpost-checkout-touch-all;fp=hooks%2Fpost-checkout-touch-all;h=b91425a4260505325ca8970317ae6b657e3cf5d5;hb=46dd450c24e931946082236088842f48e24993bb;hp=0000000000000000000000000000000000000000;hpb=950d3b3e506d4805900c2f8c0c416986b7fca444;p=git-scripts.git diff --git a/hooks/post-checkout-touch-all b/hooks/post-checkout-touch-all new file mode 100755 index 0000000..b91425a --- /dev/null +++ b/hooks/post-checkout-touch-all @@ -0,0 +1,15 @@ +#!/bin/sh + +# post-checkout hook that changes timestamps on files to that one of the commit +# if branch was changed + +prev_HEAD="$1" +new_HEAD="$2" +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" '{}' \+ +fi + +exit 0