From: Junio C Hamano Date: Sun, 29 Nov 2026 05:01:01 GMT Subject: Re: [PATCH] worktree add: skip HEAD reads for destination checks Message-ID: In-Reply-To: "Maik Riechert via GitGitGadget" writes: > From: Maik Riechert > > add_worktree() calls get_worktrees() to check whether the destination > matches a registered worktree. This also resolves HEAD for the > enumerated worktrees, although check_candidate_path() only needs their > paths, IDs and lock state. > > Use get_worktrees_without_reading_head() for the destination check to > avoid these unnecessary lookups. > > Detached git worktree add --no-checkout with 200 existing linked > worktrees. Median of seven runs per version, with warm caches: This is a very minor nit, but the above reads like a note fragment without a verb. Something like "Measured with 'git worktree add --detach --no-checkout' on a repository with 200 existing linked worktrees (median of seven runs per version, warm caches)" might read a bit more smoothly. > before after > files 11.13 ms 6.77 ms > reftable 18.86 ms 7.60 ms Nice to see that avoiding extra work yields a simple, straightforward, and expected payoff ;-)