]> git.phdru.name Git - git-scripts.git/commitdiff
Rename post-checkout-touch to post-checkout-touch-all
authorOleg Broytman <phd@phdru.name>
Wed, 6 Aug 2014 21:46:10 +0000 (01:46 +0400)
committerOleg Broytman <phd@phdru.name>
Wed, 6 Aug 2014 21:46:10 +0000 (01:46 +0400)
hooks/post-checkout-touch-all [new file with mode: 0755]

diff --git a/hooks/post-checkout-touch-all b/hooks/post-checkout-touch-all
new file mode 100755 (executable)
index 0000000..b91425a
--- /dev/null
@@ -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