X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-checkout.sh;h=89939206732849e968fabaf9128597c87f18f5c7;hb=2729cadca22dce2b5bb994581c45a6a71daf7998;hp=e00b697fef66adecaade1b9f6e7b7600f822e251;hpb=e2b1accc59ab5d682d71fd801ebe959c3e871488;p=git.git diff --git a/git-checkout.sh b/git-checkout.sh index e00b697fe..899392067 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -137,6 +137,13 @@ Did you intend to checkout '$@' which can not be resolved as commit?" git ls-files --error-unmatch -- "$@" >/dev/null || exit git ls-files -- "$@" | git checkout-index -f -u --stdin + + # Run a post-checkout hook -- the HEAD does not change so the + # current HEAD is passed in for both args + if test -x "$GIT_DIR"/hooks/post-checkout; then + "$GIT_DIR"/hooks/post-checkout $old $old 0 + fi + exit $? else # Make sure we did not fall back on $arg^{tree} codepath @@ -259,7 +266,8 @@ if [ "$?" -eq 0 ]; then fi if test -n "$branch" then - GIT_DIR="$GIT_DIR" git symbolic-ref -m "checkout: moving to $branch" HEAD "refs/heads/$branch" + old_branch_name=`expr "z$oldbranch" : 'zrefs/heads/\(.*\)'` + GIT_DIR="$GIT_DIR" git symbolic-ref -m "checkout: moving from $old_branch_name to $branch" HEAD "refs/heads/$branch" if test -n "$quiet" then true # nothing @@ -283,3 +291,8 @@ if [ "$?" -eq 0 ]; then else exit 1 fi + +# Run a post-checkout hook +if test -x "$GIT_DIR"/hooks/post-checkout; then + "$GIT_DIR"/hooks/post-checkout $old $new 1 +fi