git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Feature request: highlight local worktree in `worktree list`

From
Rubén Justo <rjusto@gmail.com>
Date
Mar 20, 2024, 22:24 UTC
Message-ID
<63dda239-1205-4aae-a3b2-10365147751c@gmail.com>
In-Reply-To
<CAGJzqsmy9RcWJeFLkZjCrrhv_y5q_R3yYUMhcyafY3jOUJFxOg@mail.gmail.com>
On Wed, Mar 20, 2024 at 08:00:00 +0000, Matt Hickford wrote:
Show 11 quoted lines
> Hi. `git branch` lists branches. It highlights the current branch with
> an asterisk and (for me) the colour green. This is handy for quick
> reading.
>
> `git worktree list` lists worktrees. It would be neat to highlight the
> local worktree.
>
> Another idea: `git branch -v` shows the commit subject and
> ahead/behind counts for each branch, eg. "[ahead 1, behind 1] avoid
> RegexReplace". It would be neat for `git worktree list -v` (or
> similar) to show the commit subject and ahead/behind counts.
Both ideas sound good.  And so do what Peff has suggested.

I want to point out that maybe "git branch [--list] -v -v" has gone unnoticed. It does not fully meet the expectations expressed in this thread, but perhaps it can be of some help:

    $ git init -b foo /tmp/main
    Initialized empty Git repository in /tmp/main/.git/
    $ cd /tmp/main
    $ git commit --allow-empty -m test
    [foo (root-commit) 87382f1] test
    $ git worktree add ../wt
    Preparing worktree (new branch 'wt')
    HEAD is now at 87382f1 test
    $ git branch --set-upstream-to=wt
    Branch 'foo' set up to track local branch 'wt'.
    $ cd /tmp/wt
    $ git branch -v -v
    + foo 87382f1 (/tmp/main) [wt] test
    * wt  87382f1 test
    $ git commit --allow-empty -m test_2
    [wt df39c54] test_2
    $ git branch -v -v
    + foo 87382f1 (/tmp/main) [wt: behind 1] test
    * wt  df39c54 test_2

"git branch --list" has a much richer machinery than "git worktree list". Perhaps the display machinery of both commands can converge in some way.

Previous: Matt HickfordNext: Chris Torek
Message 6 of 7 in “Feature request: highlight local worktree in `worktree list`”
  1. Matt HickfordMar 20, 2024
  2. Jeff KingMar 20, 2024
  3. Junio C HamanoMar 20, 2024
  4. Jeff KingMar 20, 2024
  5. Matt HickfordMar 21, 2024
  6. Rubén JustoMar 20, 2024
  7. Chris TorekMar 21, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.