tokensave 7.10.0

Code intelligence tool that builds a semantic knowledge graph from Rust, Go, Java, Scala, TypeScript, Python, C, C++, Kotlin, C#, Swift, and many more codebases
#!/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="$1"
IS_BRANCH_CHECKOUT="$3"

command -v tokensave &>/dev/null || exit 0

if [ "$PREV_HEAD" = "0000000000000000000000000000000000000000" ]; 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).
    (
        tokensave init &>/dev/null || exit 0
        tokensave branch add --if-enabled &>/dev/null
    ) &
elif [ "$IS_BRANCH_CHECKOUT" = "1" ]; 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.
    tokensave branch add --if-enabled &>/dev/null &
fi