public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.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 2/2] path: remove repository argument from worktree_git_path()
Date: Thu, 19 Feb 2026 11:34:21 -0800	[thread overview]
Message-ID: <xmqqqzqg4jeq.fsf@gitster.g> (raw)
In-Reply-To: <db9d519cbda44c46986e127e820b5b7b0ba31206.1771511192.git.phillip.wood@dunelm.org.uk> (Phillip Wood's message of "Thu, 19 Feb 2026 14:26:33 +0000")

Phillip Wood <phillip.wood123@gmail.com> writes:

> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> 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 <phillip.wood@dunelm.org.uk>
> ---
>  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.

      reply	other threads:[~2026-02-19 19:34 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
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 [this message]

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=xmqqqzqg4jeq.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=karthik.188@gmail.com \
    --cc=phillip.wood123@gmail.com \
    --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