git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] worktree add: skip HEAD reads for destination checks

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 29, 2026, 05:01 UTC
Message-ID
<xmqqzeusp6ya.fsf@gitster.g>
In-Reply-To
<pull.2339.git.1795907202117.gitgitgadget@gmail.com>
"Maik Riechert via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 12 quoted lines
> From: Maik Riechert <letmaik@outlook.com>
>
> 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 ;-)

Previous: Maik Riechert via GitGitGadgetNext: Maik Riechert via GitGitGadget
Message 2 of 3 in “worktree add: skip HEAD reads for destination checks”
  1. worktree add: skip HEAD reads for destination checksMaik Riechert via GitGitGadget, Nov 28, 2026
  2. Junio C HamanoNov 29, 2026
  3. worktree add: skip HEAD reads for destination checksMaik Riechert via GitGitGadget, Nov 29, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.