post-checkout 753 B

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. #This hook launches after a branch change, or branch checkout. It cannot affect
  3. #the outcome of a git switch or git checkout with the exception that the hook
  4. #exit status becomes the exit status of the antecedent command
  5. #See https://git-scm.com/docs/githooks#_post_checkout
  6. if [[ -L "$0" ]]; then
  7. #If our launched script is a link, grab the root
  8. hookRoot="$(dirname $(readlink --canonicalize "$0"))"
  9. else
  10. #Otherwise use the launched script directory
  11. hookRoot="$(dirname "$0")"
  12. fi
  13. if [[ "$1" == "$2" ]]; then
  14. #Previous HEAD and new HEAD are the same, ignore
  15. exit 0
  16. fi
  17. if [[ "$3" == '1' ]]; then
  18. #A branch checkout will always be flagged as 1, and a file checkout as 0
  19. "${hookRoot}/update_editor.sh" $0
  20. fi