From patchwork Mon Sep 28 15:49:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Silva X-Patchwork-Id: 11804013 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B78DB618 for ; Mon, 28 Sep 2020 15:50:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D31D2158C for ; Mon, 28 Sep 2020 15:50:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Wsp3fsca" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726617AbgI1PuV (ORCPT ); Mon, 28 Sep 2020 11:50:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726325AbgI1PuV (ORCPT ); Mon, 28 Sep 2020 11:50:21 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09E3AC061755 for ; Mon, 28 Sep 2020 08:50:21 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id w2so1647142wmi.1 for ; Mon, 28 Sep 2020 08:50:20 -0700 (PDT) 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=WUwQmzqlCtrhqQdmNZH1Yw3BTgVnQ/zChDc3yyYLR2w=; b=Wsp3fscaoOF7ALQIhG9Bk7AQNAQKWFe2yx2yQNUYi6qvmJa3N4wFlBgeZ71JolDc08 32GPAC4zgbG6Yx94oMiSM0yWM4r7+D6xoI5z1uJNjuvLRKsirzJ7QU+whSekuOL+QFmb PPB19CdJW3XFUo0Q7ZiSOIbLn1A2G9Q3/0y0JPF0AObNAjXXnyVdgYsntlqS40PTWNRp oizZiJTkt71uxirwX0+/LWd7n0Z8Q8kQZs0RWTGVWjpbq47dEDOqiVwlcL9Tg0SBJ5iP EC45uKug5KRGY/Grh0QfgbxiXNmGkDEDVe3K0NHpjjC81OiTzb6p36P5fc4u4PdM36YM FgSg== 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=WUwQmzqlCtrhqQdmNZH1Yw3BTgVnQ/zChDc3yyYLR2w=; b=SBf3bFiqv4V77Oe0U12I3FEk9dnex1VaTzYxi+UuTCrCVR/mBcxY9SQY4aCvpywssS dDb39696kreRFKhaM+2p4o7q6qzeVA75HOtygmmKGrR0KYCjMtzJLEN4AMVrOi/ulKPX aUmsLx45mt9GryQq1Mj+HDTGLCkNmWmNrtUHqWkVubBRJYb+KD8B9ac3EsNXxqMBfF8Q 4RWM5GVIEYK932myML/Tj4vgsFapdaKnDOT4WZjnLEvgVuD9WdjgaemNBeA/VZQvvG2R NsoTSZiTXXxyITD3oL7RTLBCzzpmd4PB2Nb1S2KmQuLbuaUd425fZT2EWDWchK2YKrjh 0miw== X-Gm-Message-State: AOAM533jDVLq+RWCrXViShcSAyUPobm5okJ/MmIOdLmdZk+zHFYvHILL deZEcV1o0NPldLPt4GkA65p6D2oBeRM= X-Google-Smtp-Source: ABdhPJyOcHYCSmZtmtdqQLRF/rZCX/OlX1k6dL8Y8UtTCEBIw6vyy19Ga8Em9gqyCEWRdVWGuDIjSA== X-Received: by 2002:a1c:5458:: with SMTP id p24mr589874wmi.160.1601308219449; Mon, 28 Sep 2020 08:50:19 -0700 (PDT) Received: from contrib-buster.auto1.local ([79.140.115.160]) by smtp.gmail.com with ESMTPSA id o15sm1717067wmh.29.2020.09.28.08.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 08:50:18 -0700 (PDT) From: Rafael Silva To: git@vger.kernel.org Cc: Rafael Silva Subject: [RFC PATCH 1/2] worktree: teach `list` to mark locked worktree Date: Mon, 28 Sep 2020 15:49:52 +0000 Message-Id: <20200928154953.30396-2-rafaeloliveira.cs@gmail.com> X-Mailer: git-send-email 2.28.0.856.g4762557030 In-Reply-To: <20200928154953.30396-1-rafaeloliveira.cs@gmail.com> References: <20200928154953.30396-1-rafaeloliveira.cs@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The output of `worktree list` command is extended to mark a locked worktree with `(locked)` text. This is used to communicate to the user that a linked worktree is locked instead of learning only when attempting to remove it. This is the output of the worktree list with locked marker: $ git worktree list /repo/to/main abc123 [master] /path/to/unlocked-worktree1 456def [brancha] /path/to/locked-worktree 123abc (detached HEAD) (locked) Signed-off-by: Rafael Silva --- Documentation/git-worktree.txt | 5 +++-- builtin/worktree.c | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index 32e8440cde..a3781dd664 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -96,8 +96,9 @@ list:: List details of each working tree. The main working tree is listed first, followed by each of the linked working trees. The output details include -whether the working tree is bare, the revision currently checked out, and the -branch currently checked out (or "detached HEAD" if none). +whether the working tree is bare, the revision currently checked out, the +branch currently checked out (or "detached HEAD" if none), and whether +the worktree is locked. lock:: diff --git a/builtin/worktree.c b/builtin/worktree.c index 99abaeec6c..8ad2cdd2f9 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -676,8 +676,12 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len) } else strbuf_addstr(&sb, "(error)"); } - printf("%s\n", sb.buf); + if (!is_main_worktree(wt) && + worktree_lock_reason(wt)) + strbuf_addstr(&sb, " (locked)"); + + printf("%s\n", sb.buf); strbuf_release(&sb); }