{"thread":{"id":"61160","subject":"Feature request: highlight local worktree in `worktree list`","startedAt":"2024-03-20T08:00:18Z","lastAt":"2024-03-21T13:00:35Z","messageCount":7,"participants":["Matt Hickford","Jeff King","Junio C Hamano","Rubén Justo","Chris Torek"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"490998","messageId":"CAGJzqsmy9RcWJeFLkZjCrrhv_y5q_R3yYUMhcyafY3jOUJFxOg@mail.gmail.com","threadId":"61160","inReplyTo":null,"subject":"Feature request: highlight local worktree in `worktree list`","fromName":"Matt Hickford","fromEmail":"matt.hickford@gmail.com","sentAt":"2024-03-20T08:00:00Z","receivedAt":"2024-03-20T08:00:18Z","isPatch":false,"sender":{"key":"matt.hickford@gmail.com","avatar":null},"body":"Hi. `git branch` lists branches. It highlights the current branch with\nan asterisk and (for me) the colour green. This is handy for quick\nreading.\n\n`git worktree list` lists worktrees. It would be neat to highlight the\nlocal worktree.\n\nAnother idea: `git branch -v` shows the commit subject and\nahead/behind counts for each branch, eg. \"[ahead 1, behind 1] avoid\nRegexReplace\". It would be neat for `git worktree list -v` (or\nsimilar) to show the commit subject and ahead/behind counts.\n"},{"id":"491007","messageId":"20240320100232.GB2446185@coredump.intra.peff.net","threadId":"61160","inReplyTo":"CAGJzqsmy9RcWJeFLkZjCrrhv_y5q_R3yYUMhcyafY3jOUJFxOg@mail.gmail.com","subject":"Re: Feature request: highlight local worktree in `worktree list`","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-03-20T10:02:32Z","receivedAt":"2024-03-20T10:02:33Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 20, 2024 at 08:00:00AM +0000, Matt Hickford wrote:\n\n> Hi. `git branch` lists branches. It highlights the current branch with\n> an asterisk and (for me) the colour green. This is handy for quick\n> reading.\n> \n> `git worktree list` lists worktrees. It would be neat to highlight the\n> local worktree.\n> \n> Another idea: `git branch -v` shows the commit subject and\n> ahead/behind counts for each branch, eg. \"[ahead 1, behind 1] avoid\n> RegexReplace\". It would be neat for `git worktree list -v` (or\n> similar) to show the commit subject and ahead/behind counts.\n\nI'm not sure if this is a dumb idea or not, but: what if git-branch\nlearned to display branches associated with worktrees (just like \"-r\"\nlists remote branches, etc).\n\nThen you'd get the all of the display niceties you want, along with\nother features like sorting, limiting by merge, etc. You can even show\nthe worktree paths with a custom format that uses %(worktreepath).\n\nI think the only thing it wouldn't do is show worktrees that are\ndetached from any branch at all. I'm not sure if that's important to\nyour workflow or not.\n\n-Peff\n"},{"id":"491014","messageId":"xmqqedc5hsse.fsf@gitster.g","threadId":"61160","inReplyTo":"20240320100232.GB2446185@coredump.intra.peff.net","subject":"Re: Feature request: highlight local worktree in `worktree list`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-03-20T14:38:57Z","receivedAt":"2024-03-20T14:39:00Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I'm not sure if this is a dumb idea or not, but: what if git-branch\n> learned to display branches associated with worktrees (just like \"-r\"\n> lists remote branches, etc).\n\nA branch usually, but not necessarily, is checked out in at most one\nworktree, so the display may become a bit more cluttered when more\nthan one checks out the same branch, but it is similar to how a commit\npointed at by multiple refs are shown with --decorate, so I do not think\nit is such a huge deal.\n\n> I think the only thing it wouldn't do is show worktrees that are\n> detached from any branch at all. I'm not sure if that's important to\n> your workflow or not.\n\nIf such a mode in \"git branch --list\" were written, I would imagine\nthat the output from such a mode will include detached HEAD from\nother worktrees as well.  Perhaps something like this?\n\n    $ git branch --list --worktrees\n      (HEAD detached from ffa877cd2f, checked out in worktree 'buildtest')\n      jch (checked out in worktree 'integration')\n      maint\n    * master (checked out in the primary worktree)\n      next\n      seen\n      jk/branch-list-with-worktree\n\n"},{"id":"491034","messageId":"20240320203905.GA2966606@coredump.intra.peff.net","threadId":"61160","inReplyTo":"xmqqedc5hsse.fsf@gitster.g","subject":"Re: Feature request: highlight local worktree in `worktree list`","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-03-20T20:39:05Z","receivedAt":"2024-03-20T20:39:07Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 20, 2024 at 07:38:57AM -0700, Junio C Hamano wrote:\n\n> > I think the only thing it wouldn't do is show worktrees that are\n> > detached from any branch at all. I'm not sure if that's important to\n> > your workflow or not.\n> \n> If such a mode in \"git branch --list\" were written, I would imagine\n> that the output from such a mode will include detached HEAD from\n> other worktrees as well.  Perhaps something like this?\n\nGood point. I was thinking it only iterated on refs, but of course we\nalready show a detached HEAD in the main worktree.\n\n-Peff\n"},{"id":"491070","messageId":"63dda239-1205-4aae-a3b2-10365147751c@gmail.com","threadId":"61160","inReplyTo":"CAGJzqsmy9RcWJeFLkZjCrrhv_y5q_R3yYUMhcyafY3jOUJFxOg@mail.gmail.com","subject":"Re: Feature request: highlight local worktree in `worktree list`","fromName":"Rubén Justo","fromEmail":"rjusto@gmail.com","sentAt":"2024-03-20T22:24:08Z","receivedAt":"2024-03-20T22:24:26Z","isPatch":false,"sender":{"key":"rjusto@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5685487?v=4"},"body":"On Wed, Mar 20, 2024 at 08:00:00 +0000, Matt Hickford wrote:\n> Hi. `git branch` lists branches. It highlights the current branch with\n> an asterisk and (for me) the colour green. This is handy for quick\n> reading.\n>\n> `git worktree list` lists worktrees. It would be neat to highlight the\n> local worktree.\n>\n> Another idea: `git branch -v` shows the commit subject and\n> ahead/behind counts for each branch, eg. \"[ahead 1, behind 1] avoid\n> RegexReplace\". It would be neat for `git worktree list -v` (or\n> similar) to show the commit subject and ahead/behind counts.\n\nBoth ideas sound good.  And so do what Peff has suggested.\n\nI want to point out that maybe \"git branch [--list] -v -v\" has gone\nunnoticed.  It does not fully meet the expectations expressed in this\nthread, but perhaps it can be of some help:\n\n    $ git init -b foo /tmp/main\n    Initialized empty Git repository in /tmp/main/.git/\n    $ cd /tmp/main\n    $ git commit --allow-empty -m test\n    [foo (root-commit) 87382f1] test\n    $ git worktree add ../wt\n    Preparing worktree (new branch 'wt')\n    HEAD is now at 87382f1 test\n    $ git branch --set-upstream-to=wt\n    Branch 'foo' set up to track local branch 'wt'.\n    $ cd /tmp/wt\n    $ git branch -v -v\n    + foo 87382f1 (/tmp/main) [wt] test\n    * wt  87382f1 test\n    $ git commit --allow-empty -m test_2\n    [wt df39c54] test_2\n    $ git branch -v -v\n    + foo 87382f1 (/tmp/main) [wt: behind 1] test\n    * wt  df39c54 test_2\n\n\"git branch --list\" has a much richer machinery than \"git worktree list\".\nPerhaps the display machinery of both commands can converge in some way.\n"},{"id":"491085","messageId":"CAPx1Gvf5g3z8E0e6TmwgDc-TVFmTvSBexBGtOwB8+jh-k6G=7g@mail.gmail.com","threadId":"61160","inReplyTo":"63dda239-1205-4aae-a3b2-10365147751c@gmail.com","subject":"Re: Feature request: highlight local worktree in `worktree list`","fromName":"Chris Torek","fromEmail":"chris.torek@gmail.com","sentAt":"2024-03-21T00:53:15Z","receivedAt":"2024-03-21T00:53:28Z","isPatch":false,"sender":{"key":"chris.torek@gmail.com","avatar":"https://avatars.githubusercontent.com/u/16826774?v=4"},"body":"On Wed, Mar 20, 2024 at 3:24 PM Rubén Justo <rjusto@gmail.com> wrote:\n> \"git branch --list\" has a much richer machinery than \"git worktree list\".\n> Perhaps the display machinery of both commands can converge in some way.\n\nI have no concrete suggestions for such, but I will note that there is a\n`git for-each-ref` plumbing command for refs, but no `git for-each-worktree`\nplumbing command for worktrees.  Given the relationship here (each\nworktree has a worktree-specific set of refs), perhaps that's a point\nof leverage, as it were?\n\nChris\n"},{"id":"491128","messageId":"CAGJzqsmKcmd5+FADnE_T6kHTQXEvBo2=L3MexvQiJqj6OgXHiA@mail.gmail.com","threadId":"61160","inReplyTo":"20240320100232.GB2446185@coredump.intra.peff.net","subject":"Re: Feature request: highlight local worktree in `worktree list`","fromName":"Matt Hickford","fromEmail":"matt.hickford@gmail.com","sentAt":"2024-03-21T13:00:00Z","receivedAt":"2024-03-21T13:00:35Z","isPatch":false,"sender":{"key":"matt.hickford@gmail.com","avatar":null},"body":"On Wed, 20 Mar 2024 at 10:02, Jeff King <peff@peff.net> wrote:\n>\n> On Wed, Mar 20, 2024 at 08:00:00AM +0000, Matt Hickford wrote:\n>\n> > Hi. `git branch` lists branches. It highlights the current branch with\n> > an asterisk and (for me) the colour green. This is handy for quick\n> > reading.\n> >\n> > `git worktree list` lists worktrees. It would be neat to highlight the\n> > local worktree.\n> >\n> > Another idea: `git branch -v` shows the commit subject and\n> > ahead/behind counts for each branch, eg. \"[ahead 1, behind 1] avoid\n> > RegexReplace\". It would be neat for `git worktree list -v` (or\n> > similar) to show the commit subject and ahead/behind counts.\n>\n> I'm not sure if this is a dumb idea or not, but: what if git-branch\n> learned to display branches associated with worktrees (just like \"-r\"\n> lists remote branches, etc).\n>\n> Then you'd get the all of the display niceties you want, along with\n> other features like sorting, limiting by merge, etc. You can even show\n> the worktree paths with a custom format that uses %(worktreepath).\n>\n> I think the only thing it wouldn't do is show worktrees that are\n> detached from any branch at all. I'm not sure if that's important to\n> your workflow or not.\n\nI frequently run `git worktree list` to review my work in each tree.\nOr to choose an inactive tree for new work. Example output:\n\nE:/product1  ea601b57e (detached HEAD)\nE:/product2  b255bd1b6 [json]\nE:/product3  0d7623530 [optimise]\nE:/product4  7bf8297c7 (detached HEAD)\nE:/product5  a8f89cabc (detached HEAD)\nE:/product6  89a022651 [xml]\n\nThe more information the better -- highlighting the local workspace,\nref names when HEAD is detached:\n\n  E:/product1  ea601b57e (detached HEAD, main)\n  E:/product2  b255bd1b6 [json]\n  E:/product3  0d7623530 [optimise]\n* E:/product4  7bf8297c7 (detached HEAD)\n  E:/product5  a8f89cabc (detached HEAD, origin/random)\n  E:/product6  89a022651 [xml]\n\nA verbose option with commit subjects and ahead-behind counts:\n\n  E:/product1  ea601b57e (detached HEAD, main)           Articulate splines\n  E:/product2  b255bd1b6 [json]                          [ahead 1]\nCorrect syntax error\n  E:/product3  0d7623530 [optimise]                      Optimise algorithm\n* E:/product4  7bf8297c7 (detached HEAD)                 Reformat doc\n  E:/product5  a8f89cabc (detached HEAD, origin/random)  Seed random generator\n  E:/product6  89a022651 [xml]                           Replace with XML\n"}]}