Git development
 help / color / mirror / Atom feed
From: Jasper Mayone <me@jaspermayone.com>
To: phillip.wood123@gmail.com, git@vger.kernel.org
Cc: gitster@pobox.com, sunshine@sunshineco.com,
	kristofferhaugsbakk@fastmail.com, ben.knoble@gmail.com,
	haraldnordgren@gmail.com, Jasper Mayone <me@jaspermayone.com>
Subject: Re: [PATCH 2/2] ref-filter: name the worktree of a branch being rebased or bisected
Date: Mon,  2 Nov 2026 12:57:22 -0500	[thread overview]
Message-ID: <20261102175722.76770-1-me@jaspermayone.com> (raw)
In-Reply-To: <37d53d40-66b6-46bb-a38d-0d3534ca112a@gmail.com>

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

> Those commands also reject branches that are being updated by a rebase
> via "update-ref" commands. If we're interested in checkouts we don't
> want to list those, but it means that "%(worktree)" will still give
> different results.

Yes, that difference is on purpose. I will say so in the commit message
and the documentation.

> I don't really follow this logic. At the moment neither "git
> for-each-ref", nor "git worktree list" show this - there is no way for
> a script to find out which worktree is working on a given branch. We
> can choose to add it to one or both commands.

You are right, that paragraph is wrong. No command shows it today, and
this patch adds it to %(worktreepath) only. I will rewrite it.

> If we want it to behave like prepare_checked_out_branches() we should
> use that function, rather than copying some of it to a separate file.

Agreed. For v4 I have added a small function to branch.c,

    const char *branch_checked_out_worktree(const char *refname);

which reads the list that prepare_checked_out_branches() builds and
skips the BRANCH_CHECKOUT_KIND_UPDATE_REF entries. ref-filter calls it
and drops its own hashmap, so the patch now removes more code than it
adds in ref-filter.c. t6302, t3203, t3200, t2400 and t2403 pass with it.

> That sounds a bit confusing - "* (no branch, rebasing topic)" already
> tells us what we need to know, why do we need "+ topic" as well?

I agree. In v4 "git branch" will not mark the branch with "+" in the
worktree that is rebasing or bisecting it, since the "*" line already
names it. The "also in the worktree" sentence in git-branch.adoc goes
away with that.

> It is not a new problem, but I think it would be helpful to add
> something like
>
>     As the path may contain a newline, [...]
>
>     Note that if a branch checked out in more than one worktree,
>     `%(worktreepath)` will only show one of those worktrees.

Thanks, I will add that as a separate documentation patch before this
one.

>> +		if (wt->is_bare)
>> +			continue;
>
> This is a change in behavior. We currently print the git_dir of bare
> worktrees. I think you can argue that this change is a bug fix as the
> user asked for the worktree path, but it should be explained in the
> commit message.

Agreed. With a bare repository and a linked worktree, today "git
branch" in the linked worktree shows "+ main" for the bare
repository's HEAD, and %(worktreepath) gives the path of the bare
repository. main is not checked out anywhere, and "git worktree add"
already lets you check it out. I will explain that in the commit
message and add a test for it.

Thanks,
Jasper

  reply	other threads:[~2026-11-02 17:57 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 17:33 [RFC PATCH 0/1] worktree list: add --merged and --no-merged Jasper Mayone
2026-10-21 17:33 ` [RFC PATCH 1/1] " Jasper Mayone
2026-10-23 18:30   ` Junio C Hamano
2026-10-24  6:25     ` Eric Sunshine
2026-10-24 16:53       ` [PATCH v2] worktree list: add --branch to select worktrees by branch Jasper Mayone
2026-10-25 14:47         ` Phillip Wood
2026-10-26 11:02           ` Phillip Wood
2026-10-28  6:02           ` Eric Sunshine
2026-10-28 15:27             ` Junio C Hamano
2026-10-28 11:32         ` Kristoffer Haugsbakk
2026-10-29  4:46           ` Jasper Mayone
2026-10-29  5:01             ` Eric Sunshine
2026-10-29 11:14             ` Phillip Wood
2026-10-29 14:23               ` Ben Knoble
2026-10-29 16:10                 ` Phillip Wood
2026-10-30 14:21         ` [PATCH 0/2] worktree: treat a branch being rebased or bisected as checked out Jasper Mayone
2026-10-30 14:21           ` [PATCH 1/2] worktree remove: refuse a worktree in the middle of a rebase or bisect Jasper Mayone
2026-11-02 14:07             ` Phillip Wood
2026-11-02 17:57               ` Jasper Mayone
2026-10-30 14:21           ` [PATCH 2/2] ref-filter: name the worktree of a branch being rebased or bisected Jasper Mayone
2026-11-02 14:06             ` Phillip Wood
2026-11-02 17:57               ` Jasper Mayone [this message]
2026-10-30 22:55           ` [PATCH 0/2] worktree: treat a branch being rebased or bisected as checked out Junio C Hamano
2026-10-30 23:06             ` Jasper Mayone
2026-11-02 18:29           ` [PATCH v4 0/4] " Jasper Mayone
2026-11-02 18:29             ` [PATCH v4 1/4] worktree remove: refuse a worktree in the middle of an operation Jasper Mayone
2026-11-02 18:29             ` [PATCH v4 2/4] doc: for-each-ref: say how to read %(worktreepath) safely Jasper Mayone
2026-11-02 18:29             ` [PATCH v4 3/4] ref-filter: name the worktree of a branch being rebased or bisected Jasper Mayone
2026-11-02 18:29             ` [PATCH v4 4/4] branch: do not mark the branch the current worktree is rebasing Jasper Mayone
2026-10-21 21:36 ` [RFC PATCH 0/1] worktree list: add --merged and --no-merged Harald Nordgren
2026-10-21 22:12   ` Junio C Hamano
2026-10-22  7:21     ` Harald Nordgren
2026-10-22 17:58   ` Kristoffer Haugsbakk

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=20261102175722.76770-1-me@jaspermayone.com \
    --to=me@jaspermayone.com \
    --cc=ben.knoble@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=haraldnordgren@gmail.com \
    --cc=kristofferhaugsbakk@fastmail.com \
    --cc=phillip.wood123@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