X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;ds=sidebyside;f=hooks%2Fpost-checkout%2Fset-last-commit-date-changed;fp=hooks%2Fpost-checkout%2Fset-last-commit-date-changed;h=4074707e4d5bc84e5dd7f00921a71c959e1b4b95;hb=682002cec47ddc2bacdb64c636d5df581a1029b4;hp=0000000000000000000000000000000000000000;hpb=2472c56c2f8b2e58b669546889664fbfa0555a80;p=git-scripts.git diff --git a/hooks/post-checkout/set-last-commit-date-changed b/hooks/post-checkout/set-last-commit-date-changed new file mode 100755 index 0000000..4074707 --- /dev/null +++ b/hooks/post-checkout/set-last-commit-date-changed @@ -0,0 +1,15 @@ +#!/bin/sh + +# post-checkout hook that changes timestamps on changed 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`" && + touch --date="$commit_date" `git diff --name-only HEAD~` +fi + +exit 0