All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] worktree add: skip HEAD reads for destination checks
@ 2026-11-28 23:06 Maik Riechert via GitGitGadget
  2026-11-29  5:01 ` Junio C Hamano
  2026-11-29  5:41 ` [PATCH v2] " Maik Riechert via GitGitGadget
  0 siblings, 2 replies; 3+ messages in thread
From: Maik Riechert via GitGitGadget @ 2026-11-28 23:06 UTC (permalink / raw)
  To: git; +Cc: Eric Sunshine, Patrick Steinhardt, Maik Riechert, Maik Riechert

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:

              before     after
files         11.13 ms    6.77 ms
reftable      18.86 ms    7.60 ms

Signed-off-by: Maik Riechert <letmaik@outlook.com>
---
    worktree add: skip HEAD reads for destination checks

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2339%2Fletmaik%2Fworktree-add-path-checks-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2339/letmaik/worktree-add-path-checks-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2339

 builtin/worktree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index 77ecd0f71f..82a93b0adf 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -473,7 +473,7 @@ static int add_worktree(const char *path, const char *refname,
 	struct ref_store *wt_refs;
 	struct repo_config_values *cfg = repo_config_values(the_repository);
 
-	worktrees = get_worktrees(the_repository);
+	worktrees = get_worktrees_without_reading_head(the_repository);
 	check_candidate_path(path, opts->force, worktrees, "add");
 	free_worktrees(worktrees);
 	worktrees = NULL;

base-commit: acba8bf9753134d9bde89f94369f775838a8c5fe
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-29  5:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 23:06 [PATCH] worktree add: skip HEAD reads for destination checks Maik Riechert via GitGitGadget
2026-11-29  5:01 ` Junio C Hamano
2026-11-29  5:41 ` [PATCH v2] " Maik Riechert via GitGitGadget

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.