From patchwork Sun Jan 17 23:42:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Silva X-Patchwork-Id: 12025931 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,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 363D9C433E0 for ; Sun, 17 Jan 2021 23:46:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 090F9206E3 for ; Sun, 17 Jan 2021 23:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730596AbhAQXqO (ORCPT ); Sun, 17 Jan 2021 18:46:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730812AbhAQXpR (ORCPT ); Sun, 17 Jan 2021 18:45:17 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9298C0613D3 for ; Sun, 17 Jan 2021 15:43:53 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id b2so15603290edm.3 for ; Sun, 17 Jan 2021 15:43:53 -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=SOeYEV1l4UGxmmPE1qm8HksHMQZQ1y7UY8p0OvtGauc=; b=iOver2l97x3KpEAmmadVkE8euwYrRlmQHc8oXKr5VAVH4qyHxTt27qgVEDDMI86IA7 bWFaC0cIhSDhY8SUYS9+NmAXmAA+cwsd3DWW9eWdQWNUQxA6UwG0UKDf2Fg0DNGCXs6l +QAKNRIf2VBoYN+ylveX0IGf7d0qQyQGAdjS1gRiQ6cDURbiybKiW5clhsOs4Bg02T4e T7iSkaoXYX3zjRAuyGiJUjbcAu00s+xv/m/QJCpH3eEEEkJWXCnjdycu8WiI0yzljOD8 xN8eMPl+gTSxtoKZKOOqzRjnYxcwT2z+PnnWfdXIyS6n5oZ5lJ6iBPfudnzCVykFwvTj +Aaw== 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=SOeYEV1l4UGxmmPE1qm8HksHMQZQ1y7UY8p0OvtGauc=; b=BHcX2woVUvL5fdf+rPYfX8c9szfAcL7n+Hecx0umL8xFQpEoQxdtS2jg0YuEH2fb5y f2rzyNZ/bWCJYNAIumdrxMVx3UArgizFUTbzSmhiI4aGqLeEQtWrEtyLvZO0dSQIeMGg hFMEHc0MXslvPLt/mMlq6h9NRlmZ2mSzIEd4zFGfuntfS3ImeDjHiHTaUEMihj1exVRY f9hDcS/5rTmqaBONcdtUQyQu7Q9ZGBVlUfmgXlXLx7QHjzPJK7g4uTShULq+X75dLVN0 1UGRa0/DM/ZSK00QcdsFGrPj2nwTrbnUbn13jNFldlorFk38I7Ay3dMlG+PbQjZg3ZIg l+6g== X-Gm-Message-State: AOAM533CgOwLx7CX5GfxDLEfd58jDi9zgbaCI3uYPUGgSL3xHlHS7/oP wVOz4TCLKLBxo9yaXaKTZZ+54YeOCDI= X-Google-Smtp-Source: ABdhPJyLSWCiCsibk4aTLM7m4vcSa5lGaJxzrfY+Sdk3FAPev6/oqcRsUJgKASHiiEt2UzBu38YP1Q== X-Received: by 2002:aa7:c94a:: with SMTP id h10mr17289118edt.247.1610927032143; Sun, 17 Jan 2021 15:43:52 -0800 (PST) Received: from localhost.localdomain ([79.140.114.246]) by smtp.gmail.com with ESMTPSA id f13sm8639932ejf.42.2021.01.17.15.43.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Jan 2021 15:43:51 -0800 (PST) From: Rafael Silva To: git@vger.kernel.org Cc: Eric Sunshine , Phillip Wood , Rafael Silva Subject: [PATCH v2 6/6] worktree: teach `list` verbose mode Date: Mon, 18 Jan 2021 00:42:44 +0100 Message-Id: <20210117234244.95106-7-rafaeloliveira.cs@gmail.com> X-Mailer: git-send-email 2.30.0.372.gbc7e965391 In-Reply-To: <20210117234244.95106-1-rafaeloliveira.cs@gmail.com> References: <20210104162128.95281-1-rafaeloliveira.cs@gmail.com> <20210117234244.95106-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" 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