#!/bin/bash
# Git post-checkout hook that keeps a tokensave index in step with git.
#
# Install globally:
# git config --global core.hooksPath ~/.git-hooks
# cp scripts/post-checkout ~/.git-hooks/post-checkout
# chmod +x ~/.git-hooks/post-checkout
#
# Install per-repo:
# cp scripts/post-checkout .git/hooks/post-checkout
# chmod +x .git/hooks/post-checkout
PREV_HEAD=""
IS_BRANCH_CHECKOUT=""
||
if [; then
# A fresh clone, or a new `git worktree add`. git reports both with the
# all-zeros previous HEAD, and both are also branch checkouts that can land
# on a non-default branch (`git clone -b`, `git worktree add -b`). Index
# first, then track the branch: sequentially, because `branch add` copies
# the index `init` creates, and in one background job, because two
# independent jobs would race (#391).
(
||
) &
elif [; then
# An ordinary branch checkout: track the branch, don't re-index. A no-op
# when the branch is already tracked or is the default branch.
&
fi