]> git.phdru.name Git - git-scripts.git/blobdiff - hooks/post-checkout/set-last-commit-date-all
Rename touch-all -> set-commit-date
[git-scripts.git] / hooks / post-checkout / set-last-commit-date-all
diff --git a/hooks/post-checkout/set-last-commit-date-all b/hooks/post-checkout/set-last-commit-date-all
new file mode 100755 (executable)
index 0000000..e950e4c
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# post-checkout hook that changes timestamps on all files
+# to that one of the last commit (head) if branch was changed
+
+prev_HEAD="$1"
+new_HEAD="$2"
+new_branch="$3"
+
+if [ "$new_branch" = 1 ]; then
+   commit_date="`git show --format='%cD' | head -1`" &&
+   find . \( -name .git -type d -prune \) -o \
+      -exec touch --date="$commit_date" '{}' \+
+fi
+
+exit 0