From: Rafael Silva Date: Sun, 17 Jan 2021 23:42:44 GMT Subject: [PATCH v2 6/6] worktree: teach `list` verbose mode Message-ID: <20210117234244.95106-7-rafaeloliveira.cs@gmail.com> In-Reply-To: <20210117234244.95106-1-rafaeloliveira.cs@gmail.com> "git worktree list" annotates each worktree according to its state such as "prunable" or "locked", however it is not immediately obvious why these worktrees are being annotated. For prunable worktrees a reason is available that is returned by should_prune_worktree() and for locked worktrees a reason might be available provided by the user via `lock` command. Let's teach "git worktree list" to output the reason why the worktrees are being annotated. The reason is a text that can take virtually any size and appending the text on the default columned format will make it difficult to extend the command with other annotations and not fit nicely on the screen. In order to address this shortcoming the annotation is then moved to the next line indented followed by the reason, if the reason is not available the annotation stays on the same line as the worktree itself. The output of "git worktree list" with verbose becomes like so: $ git worktree list --verbose ... /path/to/locked acb124 [branch-a] locked /path/to/locked-with-reason acc125 [branch-b] locked: worktree with a locked reason /path/to/prunable-reason ace127 [branch-d] prunable: gitdir file points to non-existent location ... Helped-by: Eric Sunshine Signed-off-by: Rafael Silva --- Documentation/git-worktree.txt | 20 ++++++++++++++++++++ builtin/worktree.c | 11 +++++++++-- t/t2402-worktree-list.sh | 27 +++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index 3d8c14dbdf..d34bf121f3 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -232,6 +232,8 @@ This can also be set up as the default behaviour by using the -v:: --verbose:: With `prune`, report all removals. ++ +With `list`, output additional information about worktrees (see below). --expire