From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org,
Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>,
Eric Sunshine <sunshine@sunshineco.com>,
Karthik Nayak <karthik.188@gmail.com>
Subject: Re: [PATCH v2 1/2] wt-status: avoid passing NULL worktree
Date: Wed, 25 Feb 2026 16:39:05 +0000 [thread overview]
Message-ID: <8397f971-39dd-4a18-b520-3157ae15324f@gmail.com> (raw)
In-Reply-To: <xmqq4inc4ghg.fsf@gitster.g>
On 19/02/2026 20:37, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> In other words, the function is_current_worktree(wt) may not take a
>> repository and always compute things relative to the_repository, but
>> once we wean ourselves off of the_repository, we would/should have
>> repo_is_current_worktree(repo, wt), making is_current_worktree(wt) a
>> thin wrapper for repo_is_current_worktree(the_repository, wt)?
>
> Eh, in light of 2/2 of this series, since wt knows which repository
> it belongs to, what I wrote above does not make much sense.
> Allowing callers to give repo that is different from wt->repo to
> that function is a potential foot-gun. In other words, isn't
> is_current_worktree(wt) using the_worktree and not wt->repo a bug
> already, I have to wonder?
I wonder that too. You, Karthik and me all initially assumed that the
current worktree would be defined by wt->repo->worktree matching
wt->path (the code actually compares the git_dir of the worktree and the
repository to accommodate bare repositories but the same principle
applies). The use of "the_repository" in is_current_wortree() comes from
replacing get_git_dir() with repo_get_git_dir() in 246deeac951
(environment: make `get_git_dir()` accept a repository, 2024-09-12). In
get_worktree_git_dir() it comes from replacing git_common_path() with
repo_common_path() in 07242c2a5af (path: drop `git_common_path()` in
favor of `repo_common_path()`, 2025-02-07). I suspect the replacements
were mechanical and not much thought went into considering whether, in a
world where there can be more than one repository per process, they
should use the local repository instance instead of "the_repository".
The current situation seems counter intuitive and I don't see what the
benefit is in defining the current worktree to be per-process rather
than per-struct-repository instance.
This series isn't in next yet - shall I re-roll with an extra
preparatory patch changing is_current_worktree() and
git_worktree_git_dir() to use wt->repo, or are you happy to have that as
a separate follow up on top of these patches?
Thanks
Phillip
next prev parent reply other threads:[~2026-02-25 16:39 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-13 11:59 [RFC][PATCH 0/2] worktree: change representation and usage of primary worktree Shreyansh Paliwal
2026-02-13 11:59 ` [RFC][PATCH 1/2] worktree: represent the primary worktree with '/' instead of NULL Shreyansh Paliwal
2026-02-13 21:35 ` Junio C Hamano
2026-02-14 9:54 ` Shreyansh Paliwal
2026-02-13 11:59 ` [RFC][PATCH 2/2] worktree: stop passing NULL as primary worktree Shreyansh Paliwal
2026-02-13 22:29 ` Junio C Hamano
2026-02-14 9:59 ` Shreyansh Paliwal
2026-02-14 14:30 ` Phillip Wood
2026-02-14 15:34 ` Junio C Hamano
2026-02-15 8:56 ` Shreyansh Paliwal
2026-02-16 16:18 ` Phillip Wood
2026-02-17 5:21 ` Junio C Hamano
2026-02-17 10:09 ` Shreyansh Paliwal
2026-02-16 16:18 ` [PATCH 0/2] worktree_git_path(): remove repository argument Phillip Wood
2026-02-16 16:18 ` [PATCH 1/2] wt-status: avoid passing NULL worktree Phillip Wood
2026-02-17 9:23 ` Phillip Wood
2026-02-17 10:18 ` Shreyansh Paliwal
2026-02-17 15:20 ` Phillip Wood
2026-02-17 16:38 ` Shreyansh Paliwal
2026-02-17 18:29 ` Junio C Hamano
2026-02-17 17:46 ` Karthik Nayak
2026-02-18 14:19 ` Phillip Wood
2026-02-17 18:47 ` Junio C Hamano
2026-02-18 14:18 ` Phillip Wood
2026-02-16 16:18 ` [PATCH 2/2] path: remove repository argument from worktree_git_path() Phillip Wood
2026-02-17 17:48 ` Karthik Nayak
2026-02-17 10:12 ` [PATCH 0/2] worktree_git_path(): remove repository argument Shreyansh Paliwal
2026-02-17 15:22 ` Phillip Wood
2026-02-17 16:45 ` Shreyansh Paliwal
2026-02-19 14:26 ` [PATCH v2 " Phillip Wood
2026-02-19 14:26 ` [PATCH v2 1/2] wt-status: avoid passing NULL worktree Phillip Wood
2026-02-19 19:30 ` Junio C Hamano
2026-02-19 20:37 ` Junio C Hamano
2026-02-25 16:39 ` Phillip Wood [this message]
2026-02-25 17:11 ` Junio C Hamano
2026-02-26 16:09 ` Phillip Wood
2026-02-26 16:15 ` Junio C Hamano
2026-02-19 14:26 ` [PATCH v2 2/2] path: remove repository argument from worktree_git_path() Phillip Wood
2026-02-19 19:34 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8397f971-39dd-4a18-b520-3157ae15324f@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=karthik.188@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=shreyanshpaliwalcmsmn@gmail.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox