#!/usr/bin/env bash
# Refresh the codegraph index after a merge changed many files at once.
#
# A merge invalidates the index wholesale even when the commit count is small,
# so this hook always triggers a rebuild rather than relying on the lazy check.
set -uo pipefail

root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"

if [ -x "$root/tools/codegraph-sync.sh" ]; then
    "$root/tools/codegraph-sync.sh"
else
    echo "post-merge: tools/codegraph-sync.sh missing or not executable; skipping index" >&2
fi

exit 0
