From patchwork Thu Jun 17 10:53:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12327433 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 59171C48BE5 for ; Thu, 17 Jun 2021 10:53:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37B5C613C1 for ; Thu, 17 Jun 2021 10:53:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231926AbhFQKzy (ORCPT ); Thu, 17 Jun 2021 06:55:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbhFQKzv (ORCPT ); Thu, 17 Jun 2021 06:55:51 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3122DC06175F for ; Thu, 17 Jun 2021 03:53:43 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id c5so6225392wrq.9 for ; Thu, 17 Jun 2021 03:53:43 -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=6MDo3zv4nqdbgXSYHHI4fYxg5rx+MAOAz0ylsRiiUM8=; b=P37SdoeGU82KPAUILtRd+UfUVSdo2fdJFGA6UQz5929qAxMStyAy1hnTnOd7Tz76dR PatwHsvrwXxERL+X9JaRp585bflyQln4+mi6ZDW8WbUkkjY/kkk/EMkn1dzncvX/A3ca g/ytalkZlP6p8IGFoRW5S6WH/DoCpnmOydIkQ4Sc0ZZ8vVL0FsX3312bdWnNCjuAo4B2 CQ3HZivCSLDKv1L/j6MiwTb33So9aIdwp523wiMH/OVNfDISivBo74Jr5CXN3T+k4bCH ARPdclktVlKS4cEUJQ/PKYHpG1y8TAdg7bf340RtzVnezsYt7kXPJbORYzpFnH9MdDxt FxGw== 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=6MDo3zv4nqdbgXSYHHI4fYxg5rx+MAOAz0ylsRiiUM8=; b=CPfieFtxX1PnOJ2JTIQ+Kd1zp8KyFlWF8yfDB86MVjQeJH/wIdXmTFjiVKyEAGA5fs kOni2UXKbfTyXMcJ5bhzN6JaSVU+obVHjGJZZXHeVfXZMpO0KRyfUNSXaUaINYJKNlLJ gQTKvLJa1sIrnAqo2LB+Z+kOnx3A+M8In1pGPGpasA0kG9J7UfhXdBdRr1J/A+lbyauz NrNzG73bVSW0CISVx68K0B/AcpuipOTP/bEOa3h1/zYhVVpDvXANBGcgCn9vVYuo3n4O fh+nmZy7w/KXXUMT7z5h6NzQjYjSQuEscFbBqqszfAotFoh0eVOPhv5y/YwMLNtHSb28 xs2A== X-Gm-Message-State: AOAM532Ls0Bw24ag5Y3sjC5IIiTS8Er0KSzBLFqK3MJHMAph43+nd1+M c4537gYxz//rN4aI9Ho2SJ7YP4lpy5PaKw== X-Google-Smtp-Source: ABdhPJzAGS9/DNOgB03pCfy+S/TKOnDFhH6yAhYgBt3/T7bFo7Zj2VeqsOAwyvkztFeSwEnf9PD78Q== X-Received: by 2002:adf:e948:: with SMTP id m8mr4923166wrn.205.1623927221400; Thu, 17 Jun 2021 03:53:41 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 61sm5409586wrp.4.2021.06.17.03.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 03:53:40 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Michael J Gruber , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v2 1/4] show-branch tests: rename the one "show-branch" test file Date: Thu, 17 Jun 2021 12:53:35 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.571.gdba276db2c In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Rename the only *show-branch* test file to indicate that more tests belong it in than just the one-off octopus test it now contains. The test was initially added in ce567d1867a (Add test to show that show-branch misses out the 8th column, 2008-07-23) and 11ee57bc4c4 (sort_in_topological_order(): avoid setting a commit flag, 2008-07-23). Those two add almost the same content, one with a test_expect_success and the other a test_expect_failure (a bug being tested for was fixed on one of the branches). Signed-off-by: Ævar Arnfjörð Bjarmason --- t/{t3202-show-branch-octopus.sh => t3202-show-branch.sh} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename t/{t3202-show-branch-octopus.sh => t3202-show-branch.sh} (95%) diff --git a/t/t3202-show-branch-octopus.sh b/t/t3202-show-branch.sh similarity index 95% rename from t/t3202-show-branch-octopus.sh rename to t/t3202-show-branch.sh index 5cb0126cfe..8cfbbf79c1 100755 --- a/t/t3202-show-branch-octopus.sh +++ b/t/t3202-show-branch.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='test show-branch with more than 8 heads' +test_description='test show-branch' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME From patchwork Thu Jun 17 10:53:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12327435 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 4BFA7C49361 for ; Thu, 17 Jun 2021 10:53:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 319AB613DB for ; Thu, 17 Jun 2021 10:53:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231984AbhFQKzz (ORCPT ); Thu, 17 Jun 2021 06:55:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230393AbhFQKzv (ORCPT ); Thu, 17 Jun 2021 06:55:51 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E44BC061760 for ; Thu, 17 Jun 2021 03:53:44 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id l7-20020a05600c1d07b02901b0e2ebd6deso3421574wms.1 for ; Thu, 17 Jun 2021 03:53:43 -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=Qa+8BrREZ5p34Qum5gowxCQYlOXGRE6v3YY/LmwYUqk=; b=nFnSLWvd39E/8Vo8WYElMBgFzporc2OlyYGr0losINlgCjuH2V2ZbgFfVrSG61GSX/ KWlx9+ue6IBt5ZOFlueQ0AjmoW0aXwK2WqzI2jeikBrQKuHTeWe5GYFMf98Q41wEH28+ HSpoJ/rMh1q3ZTKvX1QRphvyeiQrqmunha7SBM9qJUUZWLJL3VtNqeqxPV84c7iwXjGw ceGfLSaphypdIDBpb2TDExSNM8BHTi/hGPOdqAPq1JpN0lHpmjgDU341IBbOVEfypPkr gx+6N5G18NRPTgHcNnQ4aUm3W4HSaUGF3hdgpFqcq91ARcHz/sB0jQK7R9RQZ2CxQ7pi paZg== 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=Qa+8BrREZ5p34Qum5gowxCQYlOXGRE6v3YY/LmwYUqk=; b=TWJDuzZKPnwIjM0HP4f1+LJjK/8Xen+2YDbeveU+jq6bG/8DdHyoa8azydY806Rt3k Wxz3YJ3/o65voZ/UrR6/IBKhORUw5IQ5LWX0R2sFHry59YjpKO4W5mXJKLmGqBpY/Obc GU6fSvAEyOXEldiL1hN9/4+xDLtATw+z20pCDjufqTP/HN6T7L1H/LVKxuhZkDEsokmd 2xDFO2K1ag2V4EOYXPW/oN1Z6HqD/7k/wtcrB08crMhtz02aP1LTaJ469tIRbG2sDaBG ks0YFtcL2gu/4QJLndVL4FmXqbv+zVbSChVoUPd6S+VufFKHG5hwwteQOFny3hAofyKw CebA== X-Gm-Message-State: AOAM531XGvcV/Zr0JjYzdMGZ/2evsMLgfV5u3M/cDulvNUpFrqlapuu3 LTPtQLomyV87646Ofgy9X7LUi0b7HueTLA== X-Google-Smtp-Source: ABdhPJwnvccRpkjHgoBDksfIIIIvUrMa30sWf8/II8YNndY+KE8lcikPWkUJCvpHEE/30DqlDlI31A== X-Received: by 2002:a05:600c:1546:: with SMTP id f6mr4416761wmg.47.1623927222406; Thu, 17 Jun 2021 03:53:42 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 61sm5409586wrp.4.2021.06.17.03.53.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 03:53:41 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Michael J Gruber , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v2 2/4] show-branch tests: modernize test code Date: Thu, 17 Jun 2021 12:53:36 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.571.gdba276db2c In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Modernize test code added in ce567d1867a (Add test to show that show-branch misses out the 8th column, 2008-07-23) and 11ee57bc4c4 (sort_in_topological_order(): avoid setting a commit flag, 2008-07-23) to use test helpers. I'm renaming "out" to "actual" for consistency with other tests, and introducing a "branches.sorted" file in the setup, to make it clear that it's important that the list be sorted in this particular way. The "show-branch" output is indented with spaces, which would cause complaints under "git show --check" with an indented here-doc block. Let's prefix the lines with "> " to work around that, and to make it clear that the leading whitespace is important. We can also get rid of the hardcoding of "main" added here in 334afbc76fb (tests: mark tests relying on the current default for `init.defaultBranch`, 2020-11-18). For this test we're setting up an "initial" commit anyway, and now that we've moved over to test_commit we can reference that instead. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3202-show-branch.sh | 92 ++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 52 deletions(-) diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh index 8cfbbf79c1..7b06048905 100755 --- a/t/t3202-show-branch.sh +++ b/t/t3202-show-branch.sh @@ -2,69 +2,57 @@ test_description='test show-branch' -GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main -export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME - . ./test-lib.sh -numbers="1 2 3 4 5 6 7 8 9 10" - test_expect_success 'setup' ' - - > file && - git add file && - test_tick && - git commit -m initial && - - for i in $numbers + test_commit initial && + for i in $(test_seq 1 10) do - git checkout -b branch$i main && - > file$i && - git add file$i && - test_tick && - git commit -m branch$i || return 1 - done - + git checkout -b branch$i initial && + test_commit --no-tag branch$i + done && + git for-each-ref \ + --sort=version:refname \ + --format="%(refname:strip=2)" \ + "refs/heads/branch*" >branches.sorted && + sed "s/^> //" >expect <<-\EOF + > ! [branch1] branch1 + > ! [branch2] branch2 + > ! [branch3] branch3 + > ! [branch4] branch4 + > ! [branch5] branch5 + > ! [branch6] branch6 + > ! [branch7] branch7 + > ! [branch8] branch8 + > ! [branch9] branch9 + > * [branch10] branch10 + > ---------- + > * [branch10] branch10 + > + [branch9] branch9 + > + [branch8] branch8 + > + [branch7] branch7 + > + [branch6] branch6 + > + [branch5] branch5 + > + [branch4] branch4 + > + [branch3] branch3 + > + [branch2] branch2 + > + [branch1] branch1 + > +++++++++* [branch10^] initial + EOF ' -cat > expect << EOF -! [branch1] branch1 - ! [branch2] branch2 - ! [branch3] branch3 - ! [branch4] branch4 - ! [branch5] branch5 - ! [branch6] branch6 - ! [branch7] branch7 - ! [branch8] branch8 - ! [branch9] branch9 - * [branch10] branch10 ----------- - * [branch10] branch10 - + [branch9] branch9 - + [branch8] branch8 - + [branch7] branch7 - + [branch6] branch6 - + [branch5] branch5 - + [branch4] branch4 - + [branch3] branch3 - + [branch2] branch2 -+ [branch1] branch1 -+++++++++* [branch10^] initial -EOF - test_expect_success 'show-branch with more than 8 branches' ' - - git show-branch $(for i in $numbers; do echo branch$i; done) > out && - test_cmp expect out - + git show-branch $(cat branches.sorted) >actual && + test_cmp expect actual ' test_expect_success 'show-branch with showbranch.default' ' - for i in $numbers; do - git config --add showbranch.default branch$i + for branch in $(cat branches.sorted) + do + test_config showbranch.default $branch --add done && - git show-branch >out && - test_cmp expect out + git show-branch >actual && + test_cmp expect actual ' test_done From patchwork Thu Jun 17 10:53:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12327439 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 9E6D6C48BE5 for ; Thu, 17 Jun 2021 10:53:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 805E4613CA for ; Thu, 17 Jun 2021 10:53:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232090AbhFQKz6 (ORCPT ); Thu, 17 Jun 2021 06:55:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231903AbhFQKzx (ORCPT ); Thu, 17 Jun 2021 06:55:53 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDCC0C061574 for ; Thu, 17 Jun 2021 03:53:44 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id n23so3142219wms.2 for ; Thu, 17 Jun 2021 03:53:44 -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=QJmx2dtKJhz5xJ/KMDdnCv2VD0UIKcQn4RnB/rSWwyo=; b=VyYZV4MKOoSxToJZkZdcvUehJzekpx1tOHJ4qmtIiLDkMjQldqqhSAqizdLvtIHTBY 4R/dGeMQomRCVG40D6VhmA+1jVxIytsabAE33ndBTOlJXANs0SEWowx8g2wm8ct/MII2 H+cg4psXO+SZBFUnsktO4kCLUatpuk6TdmgsExFkQYXdEIi8wl7Eg1NGM0sJhLfmB5Tj 5Cy5j5tVO7xOAUiyZaDq33rQm7mINe7jKmYDK6Az9KqfMK/ZMtzJAlhBnyR2y/aXsxuu Y+J9Jxm8rP8t37Zc+42Oq8DVWU9LVkxRhjG+4zpb+1rteWWea+BD6aBhkgNhp2Do/K7i X9iQ== 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=QJmx2dtKJhz5xJ/KMDdnCv2VD0UIKcQn4RnB/rSWwyo=; b=psml7d4kx4YIasBCcXGS+c/OxrbvoCpO1i8N4+zIyfFaosHjCqOmWQ3sCPhlsvo1Wo fXM63wsADoLxwli+rFfa+sAOS0BzV8kde+e6kFdfCg4nkglFb9/QSn2WDrFbZTSIHJC+ bUJyoDLPFM9c3NG+8dsOHYACHd/POFY6bAKXeZkZb1LXHnvLA+MClCyAwjeonHuVtcbG hFubPF+D4W93QBdOtyeXS/CGQvuhluep1fg60tZlUpTtir00Rbd8SBpWwCfHjklRz5qH T7pAsjC3qYt/HHS3l/WiP9EyFK4WHZlf5KSrHPfI1FcHLsNUjvivyIbIWclWyyTjMT5+ 3v8w== X-Gm-Message-State: AOAM530XDyr4jlVsh7rL7ml9/zt5FsanWTRp8EnDQjR3kYLvlXpxj0vz HbPgj8TDcgVd68uSTEw0oMOWxGjiJnOq7w== X-Google-Smtp-Source: ABdhPJy4bJ2xLyyxmt76gRja/gitw/PYMb/jYe/hfzkzO9YVkOprp6vT/k40RYgh1XLSAz+NUFGfyQ== X-Received: by 2002:a05:600c:218c:: with SMTP id e12mr4372888wme.92.1623927223128; Thu, 17 Jun 2021 03:53:43 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 61sm5409586wrp.4.2021.06.17.03.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 03:53:42 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Michael J Gruber , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v2 3/4] show-branch: don't for space characters Date: Thu, 17 Jun 2021 12:53:37 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.571.gdba276db2c In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the colored output introduced in ab07ba2a24 (show-branch: color the commit status signs, 2009-04-22) to not color and reset each individual space character we use for padding. The intent is to color just the "!", "+" etc. characters. This makes the output easier to test, so let's do that now. The test would be much more verbose without a color/reset for each space character. Since the coloring cycles through colors we previously had a "rainbow of space characters". In theory this breaks things for anyone who's relying on the exact colored output of show-branch, in practice I'd think anyone parsing it isn't actively turning on the colored output. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/show-branch.c | 9 ++++++--- t/t3202-show-branch.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/builtin/show-branch.c b/builtin/show-branch.c index d6d2dabeca..d77ce7aeb3 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -939,9 +939,12 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) mark = '*'; else mark = '+'; - printf("%s%c%s", - get_color_code(i), - mark, get_color_reset_code()); + if (mark == ' ') + putchar(mark); + else + printf("%s%c%s", + get_color_code(i), + mark, get_color_reset_code()); } putchar(' '); } diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh index 7b06048905..54025f0337 100755 --- a/t/t3202-show-branch.sh +++ b/t/t3202-show-branch.sh @@ -55,4 +55,34 @@ test_expect_success 'show-branch with showbranch.default' ' test_cmp expect actual ' +test_expect_success 'show-branch --color output' ' + sed "s/^> //" >expect <<-\EOF && + > ! [branch1] branch1 + > ! [branch2] branch2 + > ! [branch3] branch3 + > ! [branch4] branch4 + > ! [branch5] branch5 + > ! [branch6] branch6 + > ! [branch7] branch7 + > ! [branch8] branch8 + > ! [branch9] branch9 + > * [branch10] branch10 + > ---------- + > * [branch10] branch10 + > + [branch9] branch9 + > + [branch8] branch8 + > + [branch7] branch7 + > + [branch6] branch6 + > + [branch5] branch5 + > + [branch4] branch4 + > + [branch3] branch3 + > + [branch2] branch2 + > + [branch1] branch1 + > +++++++++* [branch10^] initial + EOF + git show-branch --color=always $(cat branches.sorted) >actual.raw && + test_decode_color actual && + test_cmp expect actual +' + test_done From patchwork Thu Jun 17 10:53:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12327437 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 85ECEC2B9F4 for ; Thu, 17 Jun 2021 10:53:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 624E7613DB for ; Thu, 17 Jun 2021 10:53:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232011AbhFQKz4 (ORCPT ); Thu, 17 Jun 2021 06:55:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231974AbhFQKzx (ORCPT ); Thu, 17 Jun 2021 06:55:53 -0400 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 A3E49C06175F for ; Thu, 17 Jun 2021 03:53:45 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id n35-20020a05600c3ba3b02901cdecb6bda8so6043940wms.5 for ; Thu, 17 Jun 2021 03:53:45 -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=q2A4/oeL2pfoaqZ7Ry2AnIimZBQldGusUZuKSGvKRyg=; b=ZDeobTYrcPUSORUwhHACdhKxB8JCt5W7cVZhUg7YyH8PuB6mOWn89MS7dEkfYl/HQI alPht/FdYwS+iZ+q8fMQMf8+IcbKi9KZjO3hLksTm2u72UxTwr07x9eP5OgrQBWvzcfI f8T2j1FkWBchuuqNDBrGlLxERJ0tUEmXujUc6LV+nmE/Hu6R6tIEJTGPR6EBXz7U1Q8M DZ411NWN+T0wAOzIxiyS2q9SXl6y5gE4gsZliDj7/1Si2c01CAiWvN775fL7Ri+xE7nI W+TYNTE9q0yaAzdOe9wYHLeuCtWm+G7YtRqLPNAnUU5+w+b/DLyR+uZqWnrKXfejWDSu j0/Q== 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=q2A4/oeL2pfoaqZ7Ry2AnIimZBQldGusUZuKSGvKRyg=; b=bK7coJDyM4i8yFZpZVIglyWruibcrtc2T08U0VaenX5jek2wrrKExEVhnYG5FGc3MI FAEH2gzUFchybAY/DDST0cvP5z9auC/wRfnIDjFc6Fh8rKJZ61/5hl0FuI5bQsw0GRir iRiczaor66JRBAh+B8Ddq84mstTGuVVUQz0GTB23zDnZqgAVLIMdsT+sWCnsmldX0fzP URW9Tfg9su4FCEjFy4SiXP1kC/tVh9GYNlhOhk5pZEoL98MOC2ZMgOwBXamUNBTZkbhr cDIaunbseMZSy5qSIRiNk8N0lpvGU1mAlTJoSWnQuQ4A/RG2cOFn/m7VbVzf0NArZOqs Fltw== X-Gm-Message-State: AOAM532tJJci4hg23VSaiRGiqiV2B67ARQvr4dh4+MhvYpEhrBAHI/mS nbK1txdD0/gkyJqpcYVTblJeYC5A4H7sRA== X-Google-Smtp-Source: ABdhPJy8JDS6GSRo0XwgXqVez6bBqoowRisUqNp6IIli24wvCTAbzyA25Cg0fxbGn2cW/U9cSuQN7A== X-Received: by 2002:a7b:c453:: with SMTP id l19mr4388312wmi.154.1623927224024; Thu, 17 Jun 2021 03:53:44 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 61sm5409586wrp.4.2021.06.17.03.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 03:53:43 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Michael J Gruber , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v2 4/4] show-branch tests: add missing tests Date: Thu, 17 Jun 2021 12:53:38 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.571.gdba276db2c In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add missing tests for --remotes, --list and --merge-base. These are not exhaustive, but better than the nothing we have now. There were some tests for this command added in f76412ed6db ([PATCH] Add 'git show-branch'., 2005-08-21) has never been properly tested, namely for the --all option in t6432-merge-recursive-space-options.sh, and some of --merge-base and --independent in t6010-merge-base.sh. This fixes a few more blind spots, but there's still a lot of behavior that's not tested for. These new tests show the odd (and possibly unintentional) behavior of --merge-base with one argument, and how its output is the same as "git merge-base" with N bases in this particular case. See the test added in f621a8454d1 (git-merge-base/git-show-branch --merge-base: Documentation and test, 2009-08-05) for a case where the two aren't the same. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3202-show-branch.sh | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh index 54025f0337..ad9902a06b 100755 --- a/t/t3202-show-branch.sh +++ b/t/t3202-show-branch.sh @@ -85,4 +85,65 @@ test_expect_success 'show-branch --color output' ' test_cmp expect actual ' +test_expect_success 'show branch --remotes' ' + cat >expect.err <<-\EOF && + No revs to be shown. + EOF + git show-branch -r 2>actual.err >actual.out && + test_cmp expect.err actual.err && + test_must_be_empty actual.out +' + +test_expect_success 'setup show branch --list' ' + sed "s/^> //" >expect <<-\EOF + > [branch1] branch1 + > [branch2] branch2 + > [branch3] branch3 + > [branch4] branch4 + > [branch5] branch5 + > [branch6] branch6 + > [branch7] branch7 + > [branch8] branch8 + > [branch9] branch9 + > * [branch10] branch10 + EOF +' + +test_expect_success 'show branch --list' ' + git show-branch --list $(cat branches.sorted) >actual && + test_cmp expect actual +' + +test_expect_success 'show branch --list has no --color output' ' + git show-branch --color=always --list $(cat branches.sorted) >actual && + test_cmp expect actual +' + +test_expect_success 'show branch --merge-base with one argument' ' + for branch in $(cat branches.sorted) + do + git rev-parse $branch >expect && + git show-branch --merge-base $branch >actual && + test_cmp expect actual + done +' + +test_expect_success 'show branch --merge-base with two arguments' ' + for branch in $(cat branches.sorted) + do + git rev-parse initial >expect && + git show-branch --merge-base initial $branch >actual && + test_cmp expect actual + done +' + +test_expect_success 'show branch --merge-base with N arguments' ' + git rev-parse initial >expect && + git show-branch --merge-base $(cat branches.sorted) >actual && + test_cmp expect actual && + + git merge-base $(cat branches.sorted) >actual && + test_cmp expect actual +' + test_done