From patchwork Wed Jan 27 08:03:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Silva X-Patchwork-Id: 12049223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60A98C433DB for ; Wed, 27 Jan 2021 08:09:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2CB8E2074D for ; Wed, 27 Jan 2021 08:09:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234746AbhA0IJc (ORCPT ); Wed, 27 Jan 2021 03:09:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234667AbhA0IGy (ORCPT ); Wed, 27 Jan 2021 03:06:54 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 899FEC061793 for ; Wed, 27 Jan 2021 00:04:18 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id f16so719841wmq.5 for ; Wed, 27 Jan 2021 00:04:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XK2rqJHBuejowsAGoy7pZYNLUczglUa9B/6CJKA4KWQ=; b=HVgwZydYObdAmwUH1U9UnavmEdbbJC52P/o/wP24n8QUVwsO34Fg+s1NgcRrLO56FP a7L/+LZbO4l7YzmVRDnrL8DpqvEjcsK9Fc+/dLPpiXJHWpKp2NTfo3eUljONJ0cLrzDd d6z5DxaBcBchFs0vqWYal/P5mZYFB4MeJT4NuAbF1MWKzZF3EQI4TjDsc7eQD0WegnaU Kza2lI/sP0BBtTaWKKk7h/19sYP7SGI+AYQriM9qItktaD2hh0eiwPTT9VXQrxdQWI2J Lypdo7MygUoQOuowg8B9Kbht+uALT4z/XDcwAgDYlhqW34lX+xiCOsD11TLrFdjHViuS 9TRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XK2rqJHBuejowsAGoy7pZYNLUczglUa9B/6CJKA4KWQ=; b=UAkjX+qLd7neNrqZZDwi1T3ksLevt+BiLr3fLTyoI37XZldpKtjgX8EKopbGGBiUcr +Ca36vmb5y6CSBdSJLIA1BNTqhuQKcjRTIOFJCFg9cZIUvr3Yq+FsxXmnKnk+xXt1Aw9 ZNcyCq+oGGisTXM/h0znelFxC0BbvDBFj3mfgcVFPisYvK6FCkoh/QC85RttRmnxckNK fYvJsxxNxLDUf04ENJ9dJWaV+a8DJA4mE0BIFeEE9F2KSNA3f8Fj3iAZE8KOt48V9pBP sHAJYKUsO41zf8oLvznPG1Pc5lOjWoGfwZhv3D6aPpCQ/ygu4nVtkz4vMtoyIMsKAtYu Q/dg== X-Gm-Message-State: AOAM5336EHBSw4560pk3+pLI2x9G2omVA0ZMsPJ/oiXP7AJAxWwJBvWU lstyDaN1QT1q2IgO5byknj+bmzKO+d1apiyc X-Google-Smtp-Source: ABdhPJy8AJzkk3wmMpiONEnEviktnVjG/WS7Fqtt8IchdQETS2dm6g8oJE/HhqtYhbNA8fNJT5ugRw== X-Received: by 2002:a1c:5608:: with SMTP id k8mr2999376wmb.91.1611734656874; Wed, 27 Jan 2021 00:04:16 -0800 (PST) Received: from localhost.localdomain ([79.140.115.116]) by smtp.gmail.com with ESMTPSA id m8sm1850237wrv.37.2021.01.27.00.04.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jan 2021 00:04:16 -0800 (PST) From: Rafael Silva To: git@vger.kernel.org Cc: Eric Sunshine , Phillip Wood , Junio C Hamano , Rafael Silva Subject: [PATCH v4 7/7] worktree: teach `list` verbose mode Date: Wed, 27 Jan 2021 09:03:10 +0100 Message-Id: <20210127080310.89639-8-rafaeloliveira.cs@gmail.com> X-Mailer: git-send-email 2.30.0.395.g7821b4e95a In-Reply-To: <20210127080310.89639-1-rafaeloliveira.cs@gmail.com> References: <20210119212739.77882-1-rafaeloliveira.cs@gmail.com> <20210127080310.89639-1-rafaeloliveira.cs@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org "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" a --verbose mode that outputs 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-no-reason 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 | 14 ++++++++++++-- t/t2402-worktree-list.sh | 31 +++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index 240c3fd76b..f1bb1fa5f5 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