š fix(sarathi): the hooks-path handler clears an empty value and warns on a failed clear, 0.8.6
Fixes the two gaps Cubic found in sarathi's hooks/worktree-hooks-path.sh on https://github.com/veda-hq/veda/pull/427, and moves sarathi to 0.8.6 for the patch release.
What changes
- An empty scoped value is cleared. The handler tests whether the scoped key is present (the exit status of
git config --worktree --get-all core.hooksPath), not whether its value is non-empty. It says "Cleared an empty worktree-scoped core.hooksPath, under which git ran no hooks; ⦠now applies". - A failed clear is reported. After the unset, whatever its exit status, the handler reads the key again. If it is still there, it prints one line on stdout, which reaches the session's context. That line names the value (or says it is empty) and the absolute path of
config.worktree. The handler still exits 0. On that path the shared value it names comes from--show-scope, skipping the worktree scope, because a plain read would return the scoped value itself. packages/sarathi/README.mddescribes both. sarathi'spackage.jsonandsrc/version.tsmove to 0.8.6, the next legal version after the v0.8.5 tag. https://github.com/veda-hq/veda/pull/432 (slice https://github.com/veda-hq/veda/issues/431) moved the version out ofcli.tsso that this release passes the mutation gate.
What git does with an empty core.hooksPath
Tried on a throwaway repository with git 2.54.0 (Apple Git-157). There was a pre-commit hook in .git/hooks, in the configured folder and at the worktree root, and each run was a git commit --allow-empty:
| Setting | Hooks that ran | git config --get / --get-all |
|---|---|---|
No core.hooksPath | .git/hooks | ā |
Shared custom | the custom folder | exit 0, custom |
Shared hooksPath = (empty) | none | exit 0, empty line |
Worktree-scoped empty over a shared custom | none, not even the root pre-commit | exit 0, empty line |
So an empty scoped line turns off every git hook in that worktree. It also outranks the shared .githooks (--show-scope lists local custom then worktree with an empty value). The old [ -n "$scoped" ] test missed it because $(ā¦) turns the empty line into an empty string.
Out of scope: a bare hooksPath line with no = makes every git command in that worktree fail with "missing value for 'core.hookspath'" (exit 128), --unset-all included. The extensions.worktreeConfig read fails first, so the handler exits 0 without a word. No git call from the handler could read or clear the line.
Tests
packages/sarathi/src/hooks/shell-hooks.test.ts gets three cases:
- An empty scoped value is cleared:
--get-allexits 0 before and 1 after, and the shared.githooksapplies. - A held
config.worktree.lockmakes the unset fail. The warning names the value and the file, the value stays, and the exit status is 0. - The same lock with an empty value: the warning says git runs no hooks there.
All three failed against the old script (empty stdout) and pass now. pnpm --dir packages/sarathi check and pnpm lint are green.
After merge
Tag v0.8.6 on main to release sarathi 0.8.6. A second pull request then moves veda's @veda-hq/sarathi pin to it. That one completes the slice, so this one does not close it.
Slice: #428
š¤ Generated with Claude Code
Summary by cubic
Fixes two gaps in sarathi's worktree-hooks-path.sh: an empty worktree-scoped core.hooksPath is now cleared (previously left in place, under which git runs no hooks at all), and a failed clear now warns with the value and config.worktree path instead of passing in silence. Messages also name an empty shared value as running no hooks rather than git's default, when that is what would apply. The handler still exits 0. Bumps sarathi to 0.8.6.
After merging, tag v0.8.6 and update veda's @veda-hq/sarathi pin in a follow-up PR.