From: Junio C Hamano Date: Thu, 19 Feb 2026 19:34:21 GMT Subject: Re: [PATCH v2 2/2] path: remove repository argument from worktree_git_path() Message-ID: In-Reply-To: Phillip Wood writes: > From: Phillip Wood > > worktree_git_path() takes a struct repository and a struct worktree > which also contains a struct repository. The repository argument > was added by a973f60dc7c (path: stop relying on `the_repository` in > `worktree_git_path()`, 2024-08-13) and exists because the worktree > argument is optional. Having two ways of passing a repository is > a potential foot-gun as if the the worktree argument is present the > repository argument must match the worktree's repository member. Since > the last commit there are no callers that pass a NULL worktree so lets > remove the repository argument. This removes the potential confusion > and lets us delete a number of uses of "the_repository". > > worktree_git_path() has the following callers: > > - builtin/worktree.c:validate_no_submodules() which is called from > check_clean_worktree() and move_worktree(), both of which supply > a non-NULL worktree. > > - builtin/fsck.c:cmd_fsck() which loops over all worktrees. > > - revision.c:add_index_objects_to_pending() which loops over all > worktrees. > > - worktree.c:worktree_lock_reason() which dereferences wt before > calling worktree_git_path(). > > - wt-status.c:wt_status_check_bisect() and wt_status_check_rebase() > which are always called with a non-NULL worktree after the last > commit. > > - wt-status.c:git_branch() which is only called by > wt_status_check_bisect() and wt_status_check_rebase(). > > Signed-off-by: Phillip Wood > --- > builtin/fsck.c | 2 +- > builtin/worktree.c | 4 ++-- > path.c | 9 ++++----- > path.h | 8 +++----- > revision.c | 2 +- > worktree.c | 2 +- > wt-status.c | 14 +++++++------- > 7 files changed, 19 insertions(+), 22 deletions(-) Thank you for working on this clean-up. Very well reasoned.