From patchwork Sat Mar 16 01:38:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nickolai Belakovski X-Patchwork-Id: 10855675 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 640B11669 for ; Sat, 16 Mar 2019 01:38:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C6C72ABA8 for ; Sat, 16 Mar 2019 01:38:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40C2C2AC31; Sat, 16 Mar 2019 01:38:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6037F2ABA8 for ; Sat, 16 Mar 2019 01:38:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726736AbfCPBic (ORCPT ); Fri, 15 Mar 2019 21:38:32 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:43315 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726649AbfCPBic (ORCPT ); Fri, 15 Mar 2019 21:38:32 -0400 Received: by mail-pf1-f195.google.com with SMTP id c8so838960pfd.10 for ; Fri, 15 Mar 2019 18:38:32 -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; bh=I+pmuiRF1vn0PNUriOKb1kA/CI3kf5evv0H1tYz1MWo=; b=pg0gKyeCXElz1idcCUxTmu9DfZCeM2Zi/hbviKo4ECyxeB2mgUATdN1uXpNoUwET+4 QSwqWYg8a1Mt5bbVb2joxCVd9sPyrVHpxHVg1IhWs/hFf9tiOkcPaoIBp9hs6s7M2I8K iCkmf6Z2MqDGX7/I1QQS13D9yvHjZkVlZ/MF+DnMO/8QCab7DIijhyNr7YJ3PzXSPTyC orRb0pdZoVSUcPQlkXZag/55tmzituIBdpH36Gkc4NLOJ+IZ+RacO93TlLVsSbsmmuv2 hWSwvJSg6kBRYbHD+rZJft56gRr1IhFNiiP0m9u4fBy8VZxtpg1iPpiSEtIAaysjtSPu Io9w== 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; bh=I+pmuiRF1vn0PNUriOKb1kA/CI3kf5evv0H1tYz1MWo=; b=Ql6uZUMTQOVw6NniD0wcOD4jvDkZMR4rtBP4mGz9wRSzShDp5svLn3HjlS4PjM0+Au obVQNbvf5+se53Paw3ryqH/fBG0IHyctTwnjFyI9l302vrIBhh/xiuPSSKJmj2oOUDU0 KKzLVc+iKditVMa69ab83qXpGX6484EOBqXSvsvTaiTDjARO3RaX4r2P7UAqVklWLnBr hChsjWfQZ2hQwa86oZMMR2N6R/51JUP4wdDIC0rmjHSGcVAxlwsPo5d1WwVortshkYkp XkvriR1DLdqFqzy9GrSh2qYQ63uLk3g5yBirT8ODqSuM3UQrGplWdxw4xmZKxYaLl1RW H29g== X-Gm-Message-State: APjAAAWp29qkbok+86Md54R8iuOT3h2sc5uAaq326prV0kQX8BH88jkT cxwJ20F2YYPTrKsCtAXHpzYnxEtT X-Google-Smtp-Source: APXvYqwq5I7rjXnZj23fgNABWmUDV2D96qtxGKEm6aQmhGYhBcP8vmIfTTklO98vHRTC8sn4RlAu2Q== X-Received: by 2002:a65:6241:: with SMTP id q1mr6410962pgv.340.1552700311564; Fri, 15 Mar 2019 18:38:31 -0700 (PDT) Received: from localhost.localdomain (173-8-128-22-SFBA.hfc.comcastbusiness.net. [173.8.128.22]) by smtp.gmail.com with ESMTPSA id b138sm5817623pfb.48.2019.03.15.18.38.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Mar 2019 18:38:30 -0700 (PDT) From: nbelakovski@gmail.com To: git@vger.kernel.org Cc: peff@peff.net, gitster@pobox.com, rafa.almas@gmail.com, avarab@gmail.com, Nickolai Belakovski Subject: [PATCH v9 3/3] branch: add worktree info on verbose output Date: Fri, 15 Mar 2019 18:38:07 -0700 Message-Id: <20190316013807.38756-4-nbelakovski@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20190316013807.38756-1-nbelakovski@gmail.com> References: <20190316013807.38756-1-nbelakovski@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nickolai Belakovski To display worktree path for refs checked out in a linked worktree Signed-off-by: Nickolai Belakovski --- Documentation/git-branch.txt | 6 ++++-- builtin/branch.c | 4 ++++ t/t3203-branch-output.sh | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 7d18dffc4b..d11d00583a 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -172,8 +172,10 @@ This option is only applicable in non-verbose mode. When in list mode, show sha1 and commit subject line for each head, along with relationship to upstream branch (if any). If given twice, print - the name of the upstream branch, as well (see also `git remote - show `). + the path of the linked worktree (if any) and the name of the upstream + branch, as well (see also `git remote show `). Note that the + current worktree's HEAD will not have its path printed (it will always + be your current directory). -q:: --quiet:: diff --git a/builtin/branch.c b/builtin/branch.c index 350b039063..3d1872babc 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -367,9 +367,13 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r strbuf_addf(&local, " %s ", obname.buf); if (filter->verbose > 1) + { + strbuf_addf(&local, "%%(if:notequals=*)%%(HEAD)%%(then)%%(if)%%(worktreepath)%%(then)(%s%%(worktreepath)%s) %%(end)%%(end)", + branch_get_color(BRANCH_COLOR_WORKTREE), branch_get_color(BRANCH_COLOR_RESET)); strbuf_addf(&local, "%%(if)%%(upstream)%%(then)[%s%%(upstream:short)%s%%(if)%%(upstream:track)" "%%(then): %%(upstream:track,nobracket)%%(end)] %%(end)%%(contents:subject)", branch_get_color(BRANCH_COLOR_UPSTREAM), branch_get_color(BRANCH_COLOR_RESET)); + } else strbuf_addf(&local, "%%(if)%%(upstream:track)%%(then)%%(upstream:track) %%(end)%%(contents:subject)"); diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh index ceb74e0826..e5dc23e225 100755 --- a/t/t3203-branch-output.sh +++ b/t/t3203-branch-output.sh @@ -328,4 +328,23 @@ test_expect_success '--color overrides auto-color' ' test_cmp expect.color actual ' +test_expect_success 'verbose output lists worktree path' ' + one=$(git rev-parse --short HEAD) && + two=$(git rev-parse --short master) && + cat >expect <<-EOF && + * (HEAD detached from fromtag) $one one + ambiguous $one one + branch-one $two two + + branch-two $one ($(pwd)/worktree_dir) one + master $two two + ref-to-branch $two two + ref-to-remote $two two + EOF + git worktree add worktree_dir branch-two && + git branch -vv >actual && + rm -r worktree_dir && + git worktree prune && + test_cmp expect actual +' + test_done