From patchwork Tue Jan 19 21:27:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Silva X-Patchwork-Id: 12030857 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.8 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,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 03A8BC433DB for ; Tue, 19 Jan 2021 21:29:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C410822D71 for ; Tue, 19 Jan 2021 21:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729292AbhASV33 (ORCPT ); Tue, 19 Jan 2021 16:29:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729166AbhASV3K (ORCPT ); Tue, 19 Jan 2021 16:29:10 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53802C061798 for ; Tue, 19 Jan 2021 13:28:23 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id a9so17683904wrt.5 for ; Tue, 19 Jan 2021 13:28:23 -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=/2PrOHyTI6gxfTo8gpNiD6wTjUB3W3eT/kuLDYeiwMA=; b=uQP/zfSeqxE8CH68CnL8m4XYlYoml7DMYpWzzRFzRplPQYgzGAg8k1w3Yql5s4QMnW EwBmeUBG3XH1wKq+vrxJ3Aa6ySTv4WRgaHjEU8XROccHA4Bn1OsmOad1QX7dN0Zyj18s vx3/easHib6fWCCFsKOOBt262nGUj00jadrXimIBxq62FhRngIvpIblpwqNoJ6t/hLSq wZAqtA2daXhEfOCNKZERCBOiLll9bdrn6/YX5jdYuqvAlPDuwI3DsuVy4SYFyXvcOhvZ QaPa326OUA/auxrq8uFiwd3T+2SJfxBeULfXcm3+D5rm/AO0OA7j4thpcQMtVJHo626a zzZQ== 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=/2PrOHyTI6gxfTo8gpNiD6wTjUB3W3eT/kuLDYeiwMA=; b=l1BjMsTStUFRpK5MyLzsOo+JRN9i88zyYVeharJXZUAm60dh1nqbbOakgGg9vz4BPq GCYp7Owf8F8/aak73eTNBefGpVJ74SgF7ZhiuYTbYtumEHZq3hroHA9sL1WMtWBJ72+2 gtBysrmkIrlvjFN7YNpmoeKoQWyXJZeASrJEFY6AbwIypcK1Zq0/4Nh1ebbrdUKPQtZh 5jN3aJQCR+9FMeAN6h16LbVky3K9xvbimlHpvm/S8gmfroklwPplg3QrtnqLfQnwxpeq y9FghwH4X+8vuB0l8SqfYzvel0TV2TSi1aWrw30E7yfzJ8TiL6jnTYc0SlSbdSUvpIQT AHCQ== X-Gm-Message-State: AOAM531fNQ3bUecrcCx7M/J9zIuXmn7LEAT/nbtXCF7P9AFYkR6R/jft WzURkK5WlHMjL5OKdaS2HS51LTRhbEI= X-Google-Smtp-Source: ABdhPJwyukofulQeVlDhDIFXp4I43WdqqAcDmcCISQnNHbBTmVpf9/mrTt8Oilu/ZIqUGJtwvxDgzA== X-Received: by 2002:a5d:6a05:: with SMTP id m5mr6066653wru.96.1611091701788; Tue, 19 Jan 2021 13:28:21 -0800 (PST) Received: from localhost.localdomain ([212.86.35.161]) by smtp.gmail.com with ESMTPSA id r2sm39448819wrn.83.2021.01.19.13.28.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jan 2021 13:28:21 -0800 (PST) From: Rafael Silva To: git@vger.kernel.org Cc: Eric Sunshine , Phillip Wood , Rafael Silva Subject: [PATCH v3 7/7] worktree: teach `list` verbose mode Date: Tue, 19 Jan 2021 22:27:39 +0100 Message-Id: <20210119212739.77882-8-rafaeloliveira.cs@gmail.com> X-Mailer: git-send-email 2.30.0.421.g32f838e276 In-Reply-To: <20210119212739.77882-1-rafaeloliveira.cs@gmail.com> References: <20210117234244.95106-1-rafaeloliveira.cs@gmail.com> <20210119212739.77882-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 | 30 ++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index e0dd291e30..27f79ce638 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