Skip to content

fix: remove self-recursive husky hook stubs - #68

Merged
vishu-bh merged 1 commit into
contextforge-org:mainfrom
Altamimi-Dev:fix/husky-recursive-hooks
Aug 21, 2026
Merged

fix: remove self-recursive husky hook stubs#68
vishu-bh merged 1 commit into
contextforge-org:mainfrom
Altamimi-Dev:fix/husky-recursive-hooks

Conversation

@Altamimi-Dev

Copy link
Copy Markdown
Contributor

#49 added .husky/post-checkout, .husky/post-commit and .husky/post-merge, each containing just the path to its own shim (e.g. .husky/_/post-checkout). Husky's shim runs the user hook with sh -e, so that line calls the shim again, which runs the hook again, and so on. Once hooks are installed, every git checkout, commit or merge loops until you kill it. I first hit it when a rebase hung on post-checkout (mentioned in #16 (comment)).

The stubs don't run any commands, and the shims exit cleanly when a user hook file doesn't exist, so deleting them is the whole fix. The real hooks (pre-commit, pre-push) are untouched. If post-checkout/commit/merge automation was intended in #49, real commands can be added back in those files later.

Verified by toggling branches with hooks installed: checkout now completes instantly instead of recursing.

.husky/post-checkout, post-commit and post-merge (added in aac9753)
each contain only the path to their own shim. The shim runs the user
hook with `sh -e`, so that line re-invokes the shim and every
checkout, commit or merge recurses until killed. The stubs carry no
commands, and husky's shims exit cleanly when a user hook file is
absent, so delete them.

Signed-off-by: Ahmad Al Tamimi <altamimi.dev@gmail.com>

@vishu-bh vishu-bh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@vishu-bh
vishu-bh merged commit b5f8b47 into contextforge-org:main Aug 21, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants