Re: [PATCH v2 0/4] worktree: add lifecycle hooks
- From
Domen Kožar <domen@cachix.org>
- Date
- Sep 7, 2026, 19:34 UTC
- Message-ID
- <8fda00ab-a7ac-4ccb-95bb-9d2e28163bb7@mtasv.net>
- In-Reply-To
- <de83b791-92ae-41a1-8ecf-5abce7893998@app.fastmail.com>
Hi Kristoffer,
Thanks for the suggestion. An ownership ID could help tools avoid interfering with each other's worktrees.
The case I'm trying to support has two separate participants: an IDE or agent creates and removes worktrees, while devenv provisions and cleans up the development environment associated with each one.
devenv doesn't own those worktrees or control the commands that create them. It needs to observe their lifecycle regardless of which tool invokes Git. Even if the creator supplies an ownership ID, how would devenv learn that a worktree was added or removed?
Requiring the creator to explicitly notify devenv would bring back the per-tool integration requirement that motivates the hook. The same applies to worktrees created or removed directly by the user.
Pruning is another useful case: Git knows which administrative entries it actually removes, including entries whose directories are already gone. A hook could report each removal directly to interested tooling.
Would ownership IDs and lifecycle notifications serve complementary purposes here?
Thanks, Domen