post-merge.git-hook 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh
  2. # This is post-merge git hook script to check for changes in:
  3. # * git hook scripts
  4. # * helper scripts for using git efficiently.
  5. # If any changes are detected, a diff of them is printed.
  6. #
  7. # To install this script, copy it to .git/hooks/post-merge in local copy of
  8. # tor git repo and make sure it has permission to execute.
  9. git_toplevel=$(git rev-parse --show-toplevel)
  10. check_for_diffs() {
  11. installed="$git_toplevel/.git/hooks/$1"
  12. latest="$git_toplevel/scripts/maint/$1.git-hook"
  13. if [ -e "$installed" ]
  14. then
  15. if ! cmp "$installed" "$latest" >/dev/null 2>&1
  16. then
  17. echo "ATTENTION: $1 hook has changed:"
  18. echo "==============================="
  19. diff "$installed" "$latest"
  20. fi
  21. fi
  22. }
  23. check_for_script_update() {
  24. fullpath="$git_toplevel/scripts/maint/$1"
  25. git diff ORIG_HEAD HEAD --exit-code -- "$fullpath"
  26. }
  27. check_for_diffs "pre-push"
  28. check_for_diffs "pre-commit"
  29. check_for_diffs "post-merge"
  30. check_for_script_update "git-merge-forward.sh"
  31. check_for_script_update "git-pull-all.sh"
  32. check_for_script_update "git-push-all.sh"