From patchwork Fri Nov 4 13:22:38 2022 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: 13031856 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 579E5C4332F for ; Fri, 4 Nov 2022 13:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230509AbiKDN0O (ORCPT ); Fri, 4 Nov 2022 09:26:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231561AbiKDNZn (ORCPT ); Fri, 4 Nov 2022 09:25:43 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D0252F393 for ; Fri, 4 Nov 2022 06:24:55 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id q9so13369366ejd.0 for ; Fri, 04 Nov 2022 06:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K0inKvNSu7oEulSnLOZrmB64qFmoj4b/1adWmaCU06A=; b=RK3hcex+AVIzOiyGR3W+CVqPc14SVUJBaWi2AhS8VEhoUNjKdKjMhEiJTfQXrK6Qg/ RtBb213DyOx0Nyjjapc8y/TPtwNnQjQeHsFW4NOiOcseAfKJ7Bh8V0ubbM3QfK2j67ZC HCusNsIdQN48Ud9PXcz44vNzlMVPg5MtMQfY0iuhlEHgwaVIoFQjJTmDT1BUPGgIs9X2 ImOLKUI3l3raqFvZDhVoXexa92BWve4kRQw9dX1bxftQyHIgFJeLn6LOp/wYMvUVrUZj 5/tsf9A6DE7zeS3KV71Lc0leCsmuSeTV2NZysLYJ5rMZEyvNOi6+xF5UcmxmTWeEYMMt TxkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K0inKvNSu7oEulSnLOZrmB64qFmoj4b/1adWmaCU06A=; b=ugM0ATyArIwHSG78IgNaMVzEp1piOPh/BhOxvadqT3MERR9C4SxHNrOic7MNVM9UwQ kRYu6xoP7Pt3Y+wmOwQ56nlJM90hG5h4hnMztEITe5ysrPFtDZxbHwFobbcPCl8P7+bo NhbvC0jKAuwiKQrYkEmjjbNCBz5ec+EaXQ1ohXccTXNVHXshcobEi6qNWV7825m83uEm 12g8yqMqr/1lRIeE/bJfP/ex2A60BbI5ipzvwTkHAJw6JDhNbavIgGwx/x8Snqcj61T6 1FgUmvfLFPJ1jfyHuJemEEcgn72E8tDCVHHhzTkvwcvaL/Z68eORfaGeynznp5Auey/+ h1rg== X-Gm-Message-State: ACrzQf1usQtY16LJjtkIHzfm396ikIeXvqmn/pMaYQqFdWnqo2Ag6Us1 I/vQIiEBYMNSiKtjBe4AwGt/NkI09xgGsA== X-Google-Smtp-Source: AMsMyM755A0V16jItWlKTecJYy9hCCgfAeb9r/WdRixFeqgfm0uyg0Y1Tgz7DUqSAibo6GUmSOZCLg== X-Received: by 2002:a17:907:969e:b0:7a6:fe3:6f11 with SMTP id hd30-20020a170907969e00b007a60fe36f11mr34951976ejc.501.1667568293611; Fri, 04 Nov 2022 06:24:53 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 6-20020a170906318600b007ae38d837c5sm652979ejy.174.2022.11.04.06.24.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:24:53 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Taylor Blau , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?THVrw6E=?= =?utf-8?b?xaEgRG9rdG9y?= , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 01/13] bisect tests: test for v2.30.0 "bisect run" regressions Date: Fri, 4 Nov 2022 14:22:38 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1452.g710f45c7951 In-Reply-To: References: <1cb1c033-0525-7e62-8c09-81019bf26060@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add three failing tests which succeed on v2.29.0, but due to the topic merged at [1] (specifically [2]) have been failing since then. We'll address those regressions in subsequent commits. There was also a "regression" where: git bisect run ./missing-script.sh Would count a non-existing script as "good", as the shell would exit with 127. That edge case is a bit too insane to preserve, so let's not add it to these regression tests. 1. 0a4cb1f1f2f (Merge branch 'mr/bisect-in-c-4', 2021-09-23) 2. d1bbbe45df8 (bisect--helper: reimplement `bisect_run` shell function in C, 2021-09-13) Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t6030-bisect-porcelain.sh | 79 +++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 83931d482fb..478e74e1f0f 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -252,6 +252,85 @@ test_expect_success 'bisect skip: with commit both bad and skipped' ' grep $HASH4 my_bisect_log.txt ' +test_bisect_run_args () { + test_when_finished "rm -f run.sh actual" && + >actual && + cat >expect.args && + cat <&6 >expect.out && + cat <&7 >expect.err && + write_script run.sh <<-\EOF && + while test $# != 0 + do + echo "<$1>" && + shift + done >actual.args + EOF + + test_when_finished "git bisect reset" && + git bisect start && + git bisect good $HASH1 && + git bisect bad $HASH4 && + git bisect run ./run.sh $@ >actual.out.raw 2>actual.err && + # Prune just the log output + sed -n \ + -e '/^Author:/d' \ + -e '/^Date:/d' \ + -e '/^$/d' \ + -e '/^commit /d' \ + -e '/^ /d' \ + -e 'p' \ + actual.out && + test_cmp expect.out actual.out && + test_cmp expect.err actual.err && + test_cmp expect.args actual.args +} + +test_expect_failure 'git bisect run: args, stdout and stderr with no arguments' ' + test_bisect_run_args <<-\EOF_ARGS 6<<-EOF_OUT 7<<-\EOF_ERR + EOF_ARGS + running ./run.sh + $HASH4 is the first bad commit + bisect run success + EOF_OUT + EOF_ERR +' + +test_expect_failure 'git bisect run: args, stdout and stderr: "--" argument' ' + test_bisect_run_args -- <<-\EOF_ARGS 6<<-EOF_OUT 7<<-\EOF_ERR + <--> + EOF_ARGS + running ./run.sh -- + $HASH4 is the first bad commit + bisect run success + EOF_OUT + EOF_ERR +' + +test_expect_failure 'git bisect run: args, stdout and stderr: "--log foo --no-log bar" arguments' ' + test_bisect_run_args --log foo --no-log bar <<-\EOF_ARGS 6<<-EOF_OUT 7<<-\EOF_ERR + <--log> + + <--no-log> + + EOF_ARGS + running ./run.sh --log foo --no-log bar + $HASH4 is the first bad commit + bisect run success + EOF_OUT + EOF_ERR +' + +test_expect_failure 'git bisect run: args, stdout and stderr: "--bisect-start" argument' ' + test_bisect_run_args --bisect-start <<-\EOF_ARGS 6<<-EOF_OUT 7<<-\EOF_ERR + <--bisect-start> + EOF_ARGS + running ./run.sh --bisect-start + $HASH4 is the first bad commit + bisect run success + EOF_OUT + EOF_ERR +' + # We want to automatically find the commit that # added "Another" into hello. test_expect_success '"git bisect run" simple case' ' From patchwork Fri Nov 4 13:22:39 2022 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: 13031857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D7CFC4167B for ; Fri, 4 Nov 2022 13:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231648AbiKDN0R (ORCPT ); Fri, 4 Nov 2022 09:26:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231646AbiKDNZo (ORCPT ); Fri, 4 Nov 2022 09:25:44 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 556772D1E5 for ; Fri, 4 Nov 2022 06:24:56 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id y69so7575620ede.5 for ; Fri, 04 Nov 2022 06:24:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M7VX4bKD34xxVKoj6G/KVNG1sJHYoZhR8IFk+CdxIxk=; b=JdZLpgeuM66g3xSCyAQPEJp/uA1mIJm2KMiLGyxPmDUJA3alKBgxUQc6VJ3GaHioHI IPQsdSBG3QUOTowEJ+hyO88/tQ5bRinY1/XeiPh6PLvj+zgs26b9N1j0HEfqr28zhZoN foB8nVkV4UyLSiIM7QzJqKZA+KeHMS7fT2RKfVB4+DIZaIPczEEDXNvRQhMbi8cLYvVJ v0FUvKxPz+JCvV8UC2primf+GSNkDFg5fbgMv7G9/O/jjkxjBtYXdztCQxVHVTvprqta MeqgHPMNMv1OqIf+eT/U26McjV3tCXA8MugsCZr0YShdwzy6ToT9dBCC6B0esdjHx6lJ /HoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M7VX4bKD34xxVKoj6G/KVNG1sJHYoZhR8IFk+CdxIxk=; b=CONh3U31XtEM/ahT7ntvu3vneHezVy4pRt8IgVQ2iVHPeQ6B05FJ1BS6KF918b2Po/ Mdszsog36WCFKhl52xucSyBS/3dxlbYjkWy4D0+IuRHZh7P4OV5DR8KMdbEO1gnKguzJ ujDozjSibHk9V+WmIHt47Pic4/pPqr1kDSpO0lgjFntIdaO4ZL9uOD31DMLlQ+GTFh9Z B8aoEkR+YXS+eG6taS+X++o8eOJglQUqK+yKsWpZPEtCOWZAy99XfdiWKnmCVL70jGiE R/+Lm3XdYX9QsG1YpOadDgQBRU0ctkP4rCONmPVZ+nf4s9MdjfX0IWLZUCZWPRf4ccL4 KJFQ== X-Gm-Message-State: ACrzQf2cwr9blSfeeE7QjMwpWMPl1pBMQHVUOtCpNAi+U34t6qR+hS4x 2OxExDGLAz/N8O+qfQPs+xamhyFZmvQbGg== X-Google-Smtp-Source: AMsMyM71lPumdqrpmgJuczWSHQzfZXnirKfp7yXw1rglzTpgHhuiIMuqJ0fFvsG3IrEO+sN8RxiO8A== X-Received: by 2002:a05:6402:22a5:b0:462:b393:f281 with SMTP id cx5-20020a05640222a500b00462b393f281mr36068265edb.379.1667568294572; Fri, 04 Nov 2022 06:24:54 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 6-20020a170906318600b007ae38d837c5sm652979ejy.174.2022.11.04.06.24.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:24:54 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Taylor Blau , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?THVrw6E=?= =?utf-8?b?xaEgRG9rdG9y?= , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 02/13] bisect: refactor bisect_run() to match CodingGuidelines Date: Fri, 4 Nov 2022 14:22:39 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1452.g710f45c7951 In-Reply-To: References: <1cb1c033-0525-7e62-8c09-81019bf26060@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We didn't add "{}" to all "if/else" branches, and one "error" was mis-indented. Let's fix that first, which makes subsequent commits smaller. In the case of the "if" we can simply early return instead. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/bisect--helper.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 28ef7ec2a48..7dd90da72d3 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1185,13 +1185,12 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) if (bisect_next_check(terms, NULL)) return BISECT_FAILED; - if (argc) - sq_quote_argv(&command, argv); - else { + if (!argc) { error(_("bisect run failed: no command provided.")); return BISECT_FAILED; } + sq_quote_argv(&command, argv); strvec_push(&run_args, command.buf); while (1) { @@ -1265,7 +1264,7 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) res = BISECT_OK; } else if (res) { error(_("bisect run failed: 'git bisect--helper --bisect-state" - " %s' exited with error code %d"), new_state, res); + " %s' exited with error code %d"), new_state, res); } else { continue; } From patchwork Fri Nov 4 13:22:40 2022 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: 13031859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F4E0C43217 for ; Fri, 4 Nov 2022 13:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231607AbiKDN0P (ORCPT ); Fri, 4 Nov 2022 09:26:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231485AbiKDNZp (ORCPT ); Fri, 4 Nov 2022 09:25:45 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB2922F3A5 for ; Fri, 4 Nov 2022 06:24:57 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id q9so13369639ejd.0 for ; Fri, 04 Nov 2022 06:24:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0PDD8EjVnRMIRM9lXuA12DnnRY5iFg8ZCyK7/Aekmso=; b=ZS6fhqbTYuxyLF4HLq4Z4lpvfV+2eqe0HY5Kkj7h5+o5xGlhpGggVfzjmcZQ3GResw 2+al23yp0Nc3qZEhs3YfflgAFwqoTCg29uLuaEVbTA/A0XBPPlcWidc8ePSncp7eX0wj P7CaC35jFgMtZz3I7rkfa3vPgWQa5/NSwB7yfj0h96T3PPXW47YYibuxRZDwX76ZQqcD 3EjU3RIcfJ7G7eFlk3BAEeABU8wC+abziv7YVvWafOXuiK6AGu8Z1hRWV1a4m7fnP1ba 3pwBxqonVsrncJE0AS/FI/6XogPQaSuqbg8BcesFQ7bZDYP0f8TDmhaRm5fXfcKwQeW8 yP7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0PDD8EjVnRMIRM9lXuA12DnnRY5iFg8ZCyK7/Aekmso=; b=wmKSIQOsQmPN/bs8qunWjXj30RVLMGePAh1AUERZtF2et1Cmv5PW/E8/Kc9GmZKSA+ x9K9PMBLB1t0rkn25npYdXzRXD3SAxI0j/30ZOTFrUmRurh/JdruKC212OUyLJx7YoPQ qCRLZe+2T/Cb2aL7nqmBA9xQ2lg+N+26zFJBosLsA/Y8PraTAEq5KOU0Ru5ixk0Intaa h32w7wv+JFyCmoMqVOLpG4uZIQGAfoAaOlFX5+UFk5QSiDZpR1h9WPD+sbj7TDgj4/9P +nIgah4qfixftnLojGRu2lxsnj9izCcstzi/slfzIfDrvIyP/W5h21Vr9E1Vyjo3h2zw k07A== X-Gm-Message-State: ACrzQf0lYeybtFGEuvcku6XvsJ673JrSmQ1XVEonJyZgex0RuIj92Fv/ /j2Fhq6Goa2QQhGWNTzF6D5ElzX4nkYo6w== X-Google-Smtp-Source: AMsMyM7oyfH3MmC5viKHOD0nOaxTZrj5VdRi3Dd6MdRckX/x5C7+vsysYbcHw/4Z4pkN13Qw2MK8Zg== X-Received: by 2002:a17:906:f89a:b0:7ac:2e16:a8d2 with SMTP id lg26-20020a170906f89a00b007ac2e16a8d2mr307370ejb.584.1667568295763; Fri, 04 Nov 2022 06:24:55 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 6-20020a170906318600b007ae38d837c5sm652979ejy.174.2022.11.04.06.24.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:24:55 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Taylor Blau , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?THVrw6E=?= =?utf-8?b?xaEgRG9rdG9y?= , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 03/13] bisect: fix output regressions in v2.30.0 Date: Fri, 4 Nov 2022 14:22:40 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1452.g710f45c7951 In-Reply-To: References: <1cb1c033-0525-7e62-8c09-81019bf26060@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When d1bbbe45df8 (bisect--helper: reimplement `bisect_run` shell function in C, 2021-09-13) reimplemented parts of "git bisect run" in C it changed the output we emitted so that: - The "running ..." line was now quoted - We lost the \n after our output - We started saying "bisect found ..." instead of "bisect run success" Arguably some of this is better now, but as d1bbbe45df8 did not advocate for changing the output, let's revert this for now. It'll be easy to change it back if that's what we'd prefer. This does not change the one remaining use of "command.buf" to emit the quoted argument, as that's new in d1bbbe45df8. Some of these cases were not tested for in the tests added in the preceding commit, I didn't have time to fleshen those out, but a look at f1de981e8b6 will show that the other output being adjusted here is now equivalent to what it was before d1bbbe45df8. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/bisect--helper.c | 8 +++++--- t/t6030-bisect-porcelain.sh | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 7dd90da72d3..ee1509c198a 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1192,6 +1192,8 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) sq_quote_argv(&command, argv); strvec_push(&run_args, command.buf); + strbuf_reset(&command); + strbuf_join_argv(&command, argc, argv, ' '); while (1) { printf(_("running %s\n"), command.buf); @@ -1257,13 +1259,13 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) if (res == BISECT_ONLY_SKIPPED_LEFT) error(_("bisect run cannot continue any more")); else if (res == BISECT_INTERNAL_SUCCESS_MERGE_BASE) { - printf(_("bisect run success")); + puts(_("bisect run success")); res = BISECT_OK; } else if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) { - printf(_("bisect found first bad commit")); + puts(_("bisect run success")); res = BISECT_OK; } else if (res) { - error(_("bisect run failed: 'git bisect--helper --bisect-state" + error(_("bisect run failed: 'bisect-state" " %s' exited with error code %d"), new_state, res); } else { continue; diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 478e74e1f0f..30124b6f059 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -285,7 +285,7 @@ test_bisect_run_args () { test_cmp expect.args actual.args } -test_expect_failure 'git bisect run: args, stdout and stderr with no arguments' ' +test_expect_success 'git bisect run: args, stdout and stderr with no arguments' ' test_bisect_run_args <<-\EOF_ARGS 6<<-EOF_OUT 7<<-\EOF_ERR EOF_ARGS running ./run.sh @@ -295,7 +295,7 @@ test_expect_failure 'git bisect run: args, stdout and stderr with no arguments' EOF_ERR ' -test_expect_failure 'git bisect run: args, stdout and stderr: "--" argument' ' +test_expect_success 'git bisect run: args, stdout and stderr: "--" argument' ' test_bisect_run_args -- <<-\EOF_ARGS 6<<-EOF_OUT 7<<-\EOF_ERR <--> EOF_ARGS From patchwork Fri Nov 4 13:22:41 2022 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: 13031858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85340C43219 for ; Fri, 4 Nov 2022 13:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231861AbiKDN0Q (ORCPT ); Fri, 4 Nov 2022 09:26:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231719AbiKDNZp (ORCPT ); Fri, 4 Nov 2022 09:25:45 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A27D2F01C for ; Fri, 4 Nov 2022 06:24:58 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id ud5so13272402ejc.4 for ; Fri, 04 Nov 2022 06:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G3Z9tE72IOxadGKVWpxWvrVBBsZdn0l7frAptRBkjcA=; b=M115uXgy7KZYHV0q1Hjgi1fVMLqZ2JhdUphjEovZoU+S6IwDR3gTuxR2l+IJGcFLPL Ip6SPPVBQdelKbYdqz1ev4KvYhG4HjqV35QXcDqxWuvC74U9wcJG5EpqBK26y4CVuJfY YCrYMeCTK9K5C5vgg+DY1MmrNLqVyPGu3/IGl+sP/SQo7NqKfKWZWoGMGEa16MGAGZEZ QHBw/ZVw1UhOjK9CAAzwFaCvhk2h2bgWUoavCAszLlbox6ZWLXXIlpiB6PSPgU5b1bEF Ul0NwDbILRPilauPBkQdMG6RcQDtR+r5UWti3I4mGThBNylAUDkr64FzB10z9CrxXRrc YGDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G3Z9tE72IOxadGKVWpxWvrVBBsZdn0l7frAptRBkjcA=; b=2fGCQtky4vh7c/T9Teppo9z6E8x+0JEvDbRVdOg4Ex2vEfJOB95jYcx8yTRLbeu6Hc 1+MwZ0L6jEaUYW4+RGWSgPhQGLjYsj2px3fU3yyu5yFMjsMLZPUuYIPJxT9/n+fELq4t NQDk19X4p77OrZ2+wgOJU9JFiky8y5Z0zQEyxdzoNgK8ZiIiCXDI5oDToPk7T9XIKcKd EFwP48fNPTKrkU9mnRuBbvVzS2PRGGdni9hXkW2ICiWQePrgoRX/iF9VjWjiEVyr/vWI lygA00KfQENcSOz+rgzB7NZNZ/31btul44ahkwfTujnVQQfN8NGTVDm1gMn1aRTg13do +rlA== X-Gm-Message-State: ACrzQf21TX0jooPU/IOcKNxU4pQ/QnD/AKnjjTMABV1kgmRjbPAMOvfn H91jEVj71srU05iLbTP2YVF31LvmTEN0+w== X-Google-Smtp-Source: AMsMyM7+YGuTuleE98+zpfPDXuu92LB/J5fLmK8j+CZyVaSLjAH3uDFBYZNuk2KKE9UHx0tz7ELNPQ== X-Received: by 2002:a17:906:f888:b0:78d:d762:5457 with SMTP id lg8-20020a170906f88800b0078dd7625457mr315827ejb.67.1667568296566; Fri, 04 Nov 2022 06:24:56 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 6-20020a170906318600b007ae38d837c5sm652979ejy.174.2022.11.04.06.24.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:24:56 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Taylor Blau , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?THVrw6E=?= =?utf-8?b?xaEgRG9rdG9y?= , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= , Johannes Schindelin Subject: [PATCH 04/13] bisect run: fix "--log" eating regression in v2.30.0 Date: Fri, 4 Nov 2022 14:22:41 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1452.g710f45c7951 In-Reply-To: References: <1cb1c033-0525-7e62-8c09-81019bf26060@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When d1bbbe45df8 (bisect--helper: reimplement `bisect_run` shell function in C, 2021-09-13) reimplemented parts of "git bisect run" in C we started parsing the command line that we'd pass to "run" with cmd_bisect__helper(). Unfortunately this meant that we started eating "--log" and "--no-log" on the command-line. In the general case the fix for this would be more involved, but luckily we don't support any other option here (well, the other CMDMODE options, but that edge case is too obscure to worry about). As noted in [1] we can simply remove the "--no-log" option. It was added in 0f30233a11f (bisect--helper: `bisect_write` shell function in C, 2019-01-02), but has never been used. Reported-by: Lukáš Doktor Signed-off-by: Johannes Schindelin Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/bisect--helper.c | 4 +--- t/t6030-bisect-porcelain.sh | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index ee1509c198a..eb66ad491cd 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1294,7 +1294,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_VISUALIZE, BISECT_RUN, } cmdmode = 0; - int res = 0, nolog = 0; + int res = 0; struct option options[] = { OPT_CMDMODE(0, "bisect-reset", &cmdmode, N_("reset the bisection state"), BISECT_RESET), @@ -1318,8 +1318,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("visualize the bisection"), BISECT_VISUALIZE), OPT_CMDMODE(0, "bisect-run", &cmdmode, N_("use ... to automatically bisect"), BISECT_RUN), - OPT_BOOL(0, "no-log", &nolog, - N_("no log for BISECT_WRITE")), OPT_END() }; struct bisect_terms terms = { .term_good = NULL, .term_bad = NULL }; diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 30124b6f059..dc83034f036 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -306,7 +306,7 @@ test_expect_success 'git bisect run: args, stdout and stderr: "--" argument' ' EOF_ERR ' -test_expect_failure 'git bisect run: args, stdout and stderr: "--log foo --no-log bar" arguments' ' +test_expect_success 'git bisect run: args, stdout and stderr: "--log foo --no-log bar" arguments' ' test_bisect_run_args --log foo --no-log bar <<-\EOF_ARGS 6<<-EOF_OUT 7<<-\EOF_ERR <--log> From patchwork Fri Nov 4 13:22:42 2022 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: 13031860 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF7F9C433FE for ; Fri, 4 Nov 2022 13:26:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231555AbiKDN0a (ORCPT ); Fri, 4 Nov 2022 09:26:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231721AbiKDNZq (ORCPT ); Fri, 4 Nov 2022 09:25:46 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20EE62F3A1 for ; Fri, 4 Nov 2022 06:24:59 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id y14so13205155ejd.9 for ; Fri, 04 Nov 2022 06:24:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PTmtDciAdxFXUf6tSNOzL8gvFNXZQjh9AhRtCQI5YwQ=; b=iN3KGQVAdHP610yw+s3rtGaRL7rqeRSm5gZCfpqQumP1LFMZF6grvraOFmzE+8Pkke lCwgW+oPlDfyS4VwaAz8T/sEBzDYnA8ega+4TWtAqPYYMP7S4sxStOYf5cC7bFmGnOTb kD/Y/YZwRWOF+i2+ZJ27etBWoRaPI7T70xJVbQrdbNBMtkCybh8VxPEiK0FMPKe+1lxn 9i8K6MGS+gZBWX8UwXedjL8gyI4MTwHpRv/Hug/v64dUE4ecYxDR1JOvORSSFRxBz0mK qkLoO/NhQSqAx3af3zfdL1zp47orOrdELnNjjWY28mD6jxHfTw6uY32iZ/f0N3Y1GtmL 4hLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PTmtDciAdxFXUf6tSNOzL8gvFNXZQjh9AhRtCQI5YwQ=; b=ssSWXbBCVAhfXoz2TJKiCx5H0L7VwIDWUL140rr7+d019g9E8bT8z+I4u9Bg+m4clw BKVk0wPvbox/cod3eB6GmYiCaVJa+nbWnREM2akuS0deBYRTnL1qJgIg6+9861aqFYPn DdutePy3W3kjZP44HFW6YBAo1i8KZSI59R8AUmQMJmJbo34p22O5l+e8Y0IrvX74NXAr f1RcFmb+Y4HbgaW5L9FHqLitD7/2CPPusOXcXdNZvCBcM0ISN5XO2Mg+SKZjXnbZKGZG 2N+KPCt7ujV2dCRL+5w8uAfIasuYbcgETzyXu/NQT+qYSsXaF1WAq2K3bzYaHO0rKQFo vWFQ== X-Gm-Message-State: ACrzQf2usjKpYo0aFX0fGQhHNHENg7mAlO7fmXCNecKX61fFXMv26T7A wBxu2Oe5/pXxZ/a7EyuOMcLWm6/fElALPQ== X-Google-Smtp-Source: AMsMyM7WQiIxLquUdweWSgx6WaU4hpNjCq9YUB6kyNddyiLDCthE0WUIjxcrSuI1MucSRaOh6n+vfw== X-Received: by 2002:a17:906:eeca:b0:730:6880:c398 with SMTP id wu10-20020a170906eeca00b007306880c398mr34915756ejb.706.1667568297579; Fri, 04 Nov 2022 06:24:57 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 6-20020a170906318600b007ae38d837c5sm652979ejy.174.2022.11.04.06.24.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:24:56 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Taylor Blau , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?THVrw6E=?= =?utf-8?b?xaEgRG9rdG9y?= , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 05/13] bisect run: keep some of the post-v2.30.0 output Date: Fri, 4 Nov 2022 14:22:42 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1452.g710f45c7951 In-Reply-To: References: <1cb1c033-0525-7e62-8c09-81019bf26060@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Preceding commits fixed output and behavior regressions in d1bbbe45df8 (bisect--helper: reimplement `bisect_run` shell function in C, 2021-09-13), which did not claim to be changing the output of "git bisect run". But some of the output it emitted was subjectively better, so once we've asserted that we're back on v2.29.0 behavior, let's change some of it back: - We now quote the arguments again, but omit the first " " when printing the "running" line. - Ditto for other cases where we emitted the argument - We say "found first bad commit" again, not just "run success" Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/bisect--helper.c | 6 +++--- t/t6030-bisect-porcelain.sh | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index eb66ad491cd..5c0572d0672 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1192,8 +1192,8 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) sq_quote_argv(&command, argv); strvec_push(&run_args, command.buf); - strbuf_reset(&command); - strbuf_join_argv(&command, argc, argv, ' '); + /* Quoted, but skip initial " " */ + strbuf_ltrim(&command); while (1) { printf(_("running %s\n"), command.buf); @@ -1262,7 +1262,7 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) puts(_("bisect run success")); res = BISECT_OK; } else if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) { - puts(_("bisect run success")); + puts(_("bisect found first bad commit")); res = BISECT_OK; } else if (res) { error(_("bisect run failed: 'bisect-state" diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index dc83034f036..69fad3f94f6 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -288,9 +288,9 @@ test_bisect_run_args () { test_expect_success 'git bisect run: args, stdout and stderr with no arguments' ' test_bisect_run_args <<-\EOF_ARGS 6<<-EOF_OUT 7<<-\EOF_ERR EOF_ARGS - running ./run.sh + running '\''./run.sh'\'' $HASH4 is the first bad commit - bisect run success + bisect found first bad commit EOF_OUT EOF_ERR ' @@ -299,9 +299,9 @@ test_expect_success 'git bisect run: args, stdout and stderr: "--" argument' ' test_bisect_run_args -- <<-\EOF_ARGS 6<<-EOF_OUT 7<<-\EOF_ERR <--> EOF_ARGS - running ./run.sh -- + running '\''./run.sh'\'' '\''--'\'' $HASH4 is the first bad commit - bisect run success + bisect found first bad commit EOF_OUT EOF_ERR ' @@ -313,9 +313,9 @@ test_expect_success 'git bisect run: args, stdout and stderr: "--log foo --no-lo <--no-log> EOF_ARGS - running ./run.sh --log foo --no-log bar + running '\''./run.sh'\'' '\''--log'\'' '\''foo'\'' '\''--no-log'\'' '\''bar'\'' $HASH4 is the first bad commit - bisect run success + bisect found first bad commit EOF_OUT EOF_ERR ' @@ -324,9 +324,9 @@ test_expect_failure 'git bisect run: args, stdout and stderr: "--bisect-start" a test_bisect_run_args --bisect-start <<-\EOF_ARGS 6<<-EOF_OUT 7<<-\EOF_ERR <--bisect-start> EOF_ARGS - running ./run.sh --bisect-start + running '\''./run.sh'\'' '\''--bisect-start'\'' $HASH4 is the first bad commit - bisect run success + bisect found first bad commit EOF_OUT EOF_ERR ' From patchwork Fri Nov 4 13:22:43 2022 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: 13031861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A5A6C433FE for ; Fri, 4 Nov 2022 13:26:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231592AbiKDN0d (ORCPT ); Fri, 4 Nov 2022 09:26:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231735AbiKDNZr (ORCPT ); Fri, 4 Nov 2022 09:25:47 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 721012F3B8 for ; Fri, 4 Nov 2022 06:25:00 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id ud5so13272585ejc.4 for ; Fri, 04 Nov 2022 06:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8gUAFl7bhpV7Eqs4bDpWRpbSNS5chKHHzllU1WVJ9CQ=; b=ATO+1jN8qQvxcoOCjUcMYdAKi6jFM1wND5NO0EtwfVrEO0opd/zSKF7qzArETDiT8r omLYXUGIB5vVlcIvgDxKKpZDoVKNLNBA9aZjm2d0kKs9ry9HTEyyvRKWolW6By214NBK YBDlKQjPpNSVrIOxpJpZXDftWsr5bUQCyZSC/lKb91JPHps0OavD56CJcK4znK2Li+X7 aYpmrM5s31LWrBUIeAlT233KwZxgc/BfTgOPEq5Jy0tQqoV5md9DvlJ4Yb/kczQksgsp fY1r2vEV25UMvH9cPtQ2+GnSkev0e+hi1/VxYOhwx6Umy6XyrejB+i5YtU4ZNG/Eu/Z5 N0dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8gUAFl7bhpV7Eqs4bDpWRpbSNS5chKHHzllU1WVJ9CQ=; b=eoqAK5LwseZiKCUVeWbjHbt+mDUB7/Vq9+Lna7/gmWmLdJAMYM8aIhNf7MPYC8yXwH ksXGLces9cfT0oIXq8bDEqmT8pqtDHThG2I3xsRNu+03R/ORPPfr+o7azpIyNwnaWX/3 yjd5ZQCfNaDlJrYSvPSq3VavcgDgOsmCXDgDF2waITF92BoovG3helBSb4v0XLxSt+w5 ucbugOFijb3zdThwEIviWk2u3RalsCnnHkLRvoLcRmhh4vHc0lhrU9p3XH9/lVRcCBo4 KTAvXudf8vNdqK5ynOSJSUMacqrUGQ/Zk+oqa7b+FVdg+MFe6+jWr4czC/IyK4lzuu2N papw== X-Gm-Message-State: ACrzQf2lnZ+jSZ1noir8bMEopOEhsfr6DxNeG6gw9+c82Hp2T3oQ9lXp ioMpu3foQ0eQZkgVIjGVz67IzzbZ9kUO1Q== X-Google-Smtp-Source: AMsMyM4tbepx5LFkXkRz5UTtt/SlKhgRFSem1qGum5DX+IDikeNsFzpdxRseDfMkBOQ5omK7dkRrHg== X-Received: by 2002:a17:907:7286:b0:7a1:ba0:7d7a with SMTP id dt6-20020a170907728600b007a10ba07d7amr35294961ejc.227.1667568298517; Fri, 04 Nov 2022 06:24:58 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 6-20020a170906318600b007ae38d837c5sm652979ejy.174.2022.11.04.06.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:24:57 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Taylor Blau , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?THVrw6E=?= =?utf-8?b?xaEgRG9rdG9y?= , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 06/13] bisect test: test exit codes on bad usage Date: Fri, 4 Nov 2022 14:22:43 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1452.g710f45c7951 In-Reply-To: References: <1cb1c033-0525-7e62-8c09-81019bf26060@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Address a test blindspot, the "log" command is the odd one out because "git-bisect.sh" ignores any arguments it receives. Let's test both the exit codes we expect, and the stderr and stdout we're emitting. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t6030-bisect-porcelain.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 69fad3f94f6..eace0af637e 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -34,6 +34,36 @@ HASH2= HASH3= HASH4= +test_bisect_usage () { + local code="$1" && + shift && + cat >expect && + test_expect_code $code "$@" >out 2>actual && + test_must_be_empty out && + test_cmp expect actual +} + +test_expect_success 'bisect usage' ' + test_bisect_usage 255 git bisect reset extra1 extra2 <<-\EOF && + error: --bisect-reset requires either no argument or a commit + EOF + test_bisect_usage 255 git bisect terms extra1 extra2 <<-\EOF && + error: --bisect-terms requires 0 or 1 argument + EOF + test_bisect_usage 255 git bisect next extra1 <<-\EOF && + error: --bisect-next requires 0 arguments + EOF + test_bisect_usage 1 git bisect log extra1 <<-\EOF && + error: We are not bisecting. + EOF + test_bisect_usage 255 git bisect replay <<-\EOF && + error: no logfile given + EOF + test_bisect_usage 255 git bisect run <<-\EOF + error: bisect run failed: no command provided. + EOF +' + test_expect_success 'set up basic repo with 1 file (hello) and 4 commits' ' add_line_into_file "1: Hello World" hello && HASH1=$(git rev-parse --verify HEAD) && From patchwork Fri Nov 4 13:22:44 2022 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: 13031862 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F315C4332F for ; Fri, 4 Nov 2022 13:26:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231657AbiKDN0g (ORCPT ); Fri, 4 Nov 2022 09:26:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231772AbiKDNZt (ORCPT ); Fri, 4 Nov 2022 09:25:49 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34AA82F65D for ; Fri, 4 Nov 2022 06:25:01 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id d26so13190271eje.10 for ; Fri, 04 Nov 2022 06:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OkZFJLlIobhwxBHNPNoAYqsmk5sNPFxCsyBx9XMhH7E=; b=HasEB9nitQFlpOe8BJjh8qNdJ0JcMgffWuzJ91+FzBI3gTyRStz5n+YZ05IjXAOqNP gIPzKA6IQryqdeDKXJxaHjBhdzdUTBkAijLkZfrNLRnE5aqrQPm+NxctjqUfrjyE552W 4YWEXAVvfP/KyBeoGEVm7dmhf1XNAsxQuA3ZJiLh28LN6gnU6GjkzxQpT6LZgGIhTuVp z+xd9ftWQpuQSkiUw/Olo4iTRfE2WzjYkPIo1f+zH0Nba1Y5DpJpvHoa14+AsKoD5xKx 5aZWWbz/WbDFy0Me0cfHpYMlrBFLzYYPgvsBM9OUINi5ejpslM755TN5azWtxEGSW1fM gYZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OkZFJLlIobhwxBHNPNoAYqsmk5sNPFxCsyBx9XMhH7E=; b=B6q4OtSbpab+t7n06SkqGaAziFDyb3Mon0BDjHOAukG/FGKzY1EamvgeCiFw6uQwyK bEz5rIIbX0Dr2pEktTI1dtVMyTF4wau8aemC9y59Ib0Qo7M8XIN68VVUZWX5GxM8AsBG hXrTNfQ7+AIteOLcwqfl5Rxcdf+hnJm8eRJUcc0vzmguoFxW7rvAEegwiY7dWt2Z0d9F aRCZKDMR3dt4Lz/uCjKY1/U/oBtaiL84LG+JrxaKXvdp3rN7+j/fW2uJ0ik+gAubMci4 msFwfLLe3XQUSV+N8Bbrl/qwlwspltMocZXtmgFlDN8tntPYG4Du+tszusRlsAhPncZI l9Ig== X-Gm-Message-State: ACrzQf0LSZUDUGYxy6ijFg3bp0q+qXspaQjk1c+JOmei20CXeBzoGTMt dFpV+ALWn19w4aCvSJp3yZuCZT0P9jEVog== X-Google-Smtp-Source: AMsMyM5c/P6vhLmdXQfo41ettM31/JfdSQZyf4/HFLrrotb5c2LOWoJFX2SRrHMzuVX12IjKib94cA== X-Received: by 2002:a17:906:d10d:b0:7ad:b7c2:a2f7 with SMTP id b13-20020a170906d10d00b007adb7c2a2f7mr321350ejz.227.1667568299442; Fri, 04 Nov 2022 06:24:59 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 6-20020a170906318600b007ae38d837c5sm652979ejy.174.2022.11.04.06.24.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:24:58 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Taylor Blau , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?THVrw6E=?= =?utf-8?b?xaEgRG9rdG9y?= , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 07/13] bisect--helper: emit usage for "git bisect" Date: Fri, 4 Nov 2022 14:22:44 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1452.g710f45c7951 In-Reply-To: References: <1cb1c033-0525-7e62-8c09-81019bf26060@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In subsequent commits we'll be removing "git-bisect.sh" in favor of promoting "bisect--helper" to a "bisect" built-in. In doing that we'll first need to have it support "git bisect--helper " rather than "git bisect--helper --", and then finally have its "-h" output claim to be "bisect" rather than "bisect--helper". Instead of suffering that churn let's start claiming to be "git bisect" now. In just a few commits this will be true, and in the meantime emitting the "wrong" usage information from the helper is a small price to pay to avoid the churn. Let's also declare "BUILTIN_*" macros, when we eventually migrate the sub-commands themselves to parse_options() we'll be able to re-use the strings. See 0afd556b2e1 (worktree: define subcommand -h in terms of command -h, 2022-10-13) for a recent example. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/bisect--helper.c | 51 ++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 5c0572d0672..b10ecee64cc 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -20,18 +20,40 @@ static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN") -static const char * const git_bisect_helper_usage[] = { - N_("git bisect--helper --bisect-reset []"), - "git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]", - N_("git bisect--helper --bisect-start [--term-{new,bad}= --term-{old,good}=]" - " [--no-checkout] [--first-parent] [ [...]] [--] [...]"), - "git bisect--helper --bisect-next", - N_("git bisect--helper --bisect-state (bad|new) []"), - N_("git bisect--helper --bisect-state (good|old) [...]"), - N_("git bisect--helper --bisect-replay "), - N_("git bisect--helper --bisect-skip [(|)...]"), - "git bisect--helper --bisect-visualize", - N_("git bisect--helper --bisect-run ..."), +#define BUILTIN_GIT_BISECT_START_USAGE \ + N_("git bisect start [--term-{new,bad}= --term-{old,good}=]" \ + " [--no-checkout] [--first-parent] [ [...]] [--]" \ + " [...]") +#define BUILTIN_GIT_BISECT_STATE_USAGE \ + N_("git bisect (good|bad) [...]") +#define BUILTIN_GIT_BISECT_TERMS_USAGE \ + "git bisect terms [--term-good | --term-bad]" +#define BUILTIN_GIT_BISECT_SKIP_USAGE \ + N_("git bisect skip [(|)...]") +#define BUILTIN_GIT_BISECT_NEXT_USAGE \ + "git bisect next" +#define BUILTIN_GIT_BISECT_RESET_USAGE \ + N_("git bisect reset []") +#define BUILTIN_GIT_BISECT_VISUALIZE_USAGE \ + "git bisect visualize" +#define BUILTIN_GIT_BISECT_REPLAY_USAGE \ + N_("git bisect replay ") +#define BUILTIN_GIT_BISECT_LOG_USAGE \ + "git bisect log" +#define BUILTIN_GIT_BISECT_RUN_USAGE \ + N_("git bisect run ...") + +static const char * const git_bisect_usage[] = { + BUILTIN_GIT_BISECT_START_USAGE, + BUILTIN_GIT_BISECT_STATE_USAGE, + BUILTIN_GIT_BISECT_TERMS_USAGE, + BUILTIN_GIT_BISECT_SKIP_USAGE, + BUILTIN_GIT_BISECT_NEXT_USAGE, + BUILTIN_GIT_BISECT_RESET_USAGE, + BUILTIN_GIT_BISECT_VISUALIZE_USAGE, + BUILTIN_GIT_BISECT_REPLAY_USAGE, + BUILTIN_GIT_BISECT_LOG_USAGE, + BUILTIN_GIT_BISECT_RUN_USAGE, NULL }; @@ -1322,12 +1344,11 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) }; struct bisect_terms terms = { .term_good = NULL, .term_bad = NULL }; - argc = parse_options(argc, argv, prefix, options, - git_bisect_helper_usage, + argc = parse_options(argc, argv, prefix, options, git_bisect_usage, PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_UNKNOWN_OPT); if (!cmdmode) - usage_with_options(git_bisect_helper_usage, options); + usage_with_options(git_bisect_usage, options); switch (cmdmode) { case BISECT_RESET: From patchwork Fri Nov 4 13:22:45 2022 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: 13031864 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37D8EC433FE for ; Fri, 4 Nov 2022 13:26:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231721AbiKDN0l (ORCPT ); Fri, 4 Nov 2022 09:26:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231791AbiKDNZv (ORCPT ); Fri, 4 Nov 2022 09:25:51 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 463402FFCF for ; Fri, 4 Nov 2022 06:25:02 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id n12so13174506eja.11 for ; Fri, 04 Nov 2022 06:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D4geern8MJmnZTElelnN4Ptyy/8ghPefoeqW4bFu5oQ=; b=j8fisUkvS2O6HLov+VASPBosoo0Qee6CuVYWFFxVemBtz8hMhq7O4YR02emRnmgGdY mXCXsFLz+RLoAe8lwYBns+dZRiSl4r9mYZCUB+tHf2kmFXQi+l9lK+YUMmWPSXLkWxig mdayfCE6g8twIqdOyFDQbZUTDAFzwC66H8KNhnlSkK3WliB8YwquewFeQ1hTKanGJLcI 7l/qzFOep5dES8Xc7GVLR2dtMagWu89WEsTBptKshO1YJG3GSqNUTxxZsGWX3uwt2+b4 THXeX1ThEd4g4C0m3WCrPirfFnebRtiqKj2dUSUt1WqEUHNGob9MR8f/vFsqetYKqjPy te/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D4geern8MJmnZTElelnN4Ptyy/8ghPefoeqW4bFu5oQ=; b=REJgDqIsMMvcvfhc6Ex7SwRLvgXgX05R0TEx9XC7NvMD9wvudd5pXcrK0LBvTfexnR mFL0Jz8tEcxfcp8ejq3ZYktVIRmY9EgLp14xaidsSBXE1Op4NLCImixkLcgd9XVv2/JE aXX1ks532AA+JMvqqk26DbrKKLWDV8FwSoFuEzYPQ+zmQEOj4wbvOxyNq+sZQOjmxDCN DyWqv7DdteDmXzxdmbfBZIe9fqKi8oi4YyO0L4NHWIGSx3rfVu7hdpOD5VmIzLbxwZsG Yp3O52OEv/a7RF+KJ9POM7CM7zIRnnEQqYviDYFY6vYB/msiDmdDzrshEeVluVSexKVk /hOw== X-Gm-Message-State: ACrzQf2EB73D8qbJBf4mpezOwsSwDBeNOBMae/AqvnGpOmyF0bruyvg2 shf6UiMuF1V6syQOd57nWiVEa0F/WYUK6w== X-Google-Smtp-Source: AMsMyM4HcJXj1nS5iM36/dYkYbybaH6SRf/6U2bNQF1eB+ljmDjrubnwyWsYYpA9+lS25waQtyCnVQ== X-Received: by 2002:a17:906:fe0b:b0:787:f1d3:2105 with SMTP id wy11-20020a170906fe0b00b00787f1d32105mr34713641ejb.83.1667568300438; Fri, 04 Nov 2022 06:25:00 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 6-20020a170906318600b007ae38d837c5sm652979ejy.174.2022.11.04.06.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:25:00 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Taylor Blau , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?THVrw6E=?= =?utf-8?b?xaEgRG9rdG9y?= , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 08/13] bisect--helper: have all functions take state, argc, argv, prefix Date: Fri, 4 Nov 2022 14:22:45 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1452.g710f45c7951 In-Reply-To: References: <1cb1c033-0525-7e62-8c09-81019bf26060@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In order to use the OPT_SUBCOMMAND() API in a subsequent commit give all of the bisect_*() functions a consistent prototype we'll be able to use. The "prefix" parameter is only used by bisect_next(), bisect_log() doesn't need any of them, etc. The UNUSED attribute helps us to sanity check the current use. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/bisect--helper.c | 70 ++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index b10ecee64cc..32e427fa878 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -223,8 +223,10 @@ static int write_terms(const char *bad, const char *good) return res; } -static int bisect_reset(const char *commit) +static int bisect_reset(struct bisect_terms *terms UNUSED, int argc, const char **argv, + const char *prefix UNUSED) { + const char *commit = argc ? argv[0] : NULL; struct strbuf branch = STRBUF_INIT; if (!commit) { @@ -492,8 +494,10 @@ static int get_terms(struct bisect_terms *terms) return res; } -static int bisect_terms(struct bisect_terms *terms, const char *option) +static int bisect_terms(struct bisect_terms *terms, int argc, const char **argv, + const char *prefix UNUSED) { + const char *option = argc ? argv[0] : NULL; if (get_terms(terms)) return error(_("no terms defined")); @@ -646,7 +650,8 @@ static int bisect_successful(struct bisect_terms *terms) return res; } -static enum bisect_error bisect_next(struct bisect_terms *terms, const char *prefix) +static int bisect_next(struct bisect_terms *terms, int argc UNUSED, + const char **argv UNUSED, const char *prefix) { enum bisect_error res; @@ -676,10 +681,11 @@ static enum bisect_error bisect_auto_next(struct bisect_terms *terms, const char return BISECT_OK; } - return bisect_next(terms, prefix); + return bisect_next(terms, 0, empty_strvec, prefix); } -static enum bisect_error bisect_start(struct bisect_terms *terms, const char **argv, int argc) +static int bisect_start(struct bisect_terms *terms, int argc, + const char **argv, const char *prefix UNUSED) { int no_checkout = 0; int first_parent_only = 0; @@ -907,13 +913,13 @@ static int bisect_autostart(struct bisect_terms *terms) yesno = git_prompt(_("Do you want me to do it for you " "[Y/n]? "), PROMPT_ECHO); res = tolower(*yesno) == 'n' ? - -1 : bisect_start(terms, empty_strvec, 0); + -1 : bisect_start(terms, 0, empty_strvec, NULL); return res; } -static enum bisect_error bisect_state(struct bisect_terms *terms, const char **argv, - int argc) +static int bisect_state(struct bisect_terms *terms, int argc, + const char **argv, const char *prefix UNUSED) { const char *state; int i, verify_expected = 1; @@ -993,7 +999,9 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, const char **a return bisect_auto_next(terms, NULL); } -static enum bisect_error bisect_log(void) +static int bisect_log(struct bisect_terms *terms UNUSED, + int argc UNUSED, const char **argv UNUSED, + const char *prefix UNUSED) { int fd, status; const char* filename = git_path_bisect_log(); @@ -1032,7 +1040,7 @@ static int process_replay_line(struct bisect_terms *terms, struct strbuf *line) struct strvec argv = STRVEC_INIT; int res; sq_dequote_to_strvec(rev, &argv); - res = bisect_start(terms, argv.v, argv.nr); + res = bisect_start(terms, argv.nr, argv.v, NULL); strvec_clear(&argv); return res; } @@ -1045,7 +1053,7 @@ static int process_replay_line(struct bisect_terms *terms, struct strbuf *line) struct strvec argv = STRVEC_INIT; int res; sq_dequote_to_strvec(rev, &argv); - res = bisect_terms(terms, argv.nr == 1 ? argv.v[0] : NULL); + res = bisect_terms(terms, argv.nr, argv.v, NULL); strvec_clear(&argv); return res; } @@ -1054,8 +1062,10 @@ static int process_replay_line(struct bisect_terms *terms, struct strbuf *line) return -1; } -static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *filename) +static int bisect_replay(struct bisect_terms *terms, int argc UNUSED, + const char **argv, const char *prefix UNUSED) { + const char *filename = argv[0]; FILE *fp = NULL; enum bisect_error res = BISECT_OK; struct strbuf line = STRBUF_INIT; @@ -1063,7 +1073,7 @@ static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *f if (is_empty_or_missing_file(filename)) return error(_("cannot read file '%s' for replaying"), filename); - if (bisect_reset(NULL)) + if (bisect_reset(NULL, 0, empty_strvec, NULL)) return BISECT_FAILED; fp = fopen(filename, "r"); @@ -1082,7 +1092,9 @@ static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *f return bisect_auto_next(terms, NULL); } -static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **argv, int argc) +static enum bisect_error bisect_skip(struct bisect_terms *terms, int argc, + const char **argv, + const char *prefix UNUSED) { int i; enum bisect_error res; @@ -1112,13 +1124,14 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **ar strvec_push(&argv_state, argv[i]); } } - res = bisect_state(terms, argv_state.v, argv_state.nr); + res = bisect_state(terms, argv_state.nr, argv_state.v, NULL); strvec_clear(&argv_state); return res; } -static int bisect_visualize(struct bisect_terms *terms, const char **argv, int argc) +static int bisect_visualize(struct bisect_terms *terms, int argc, + const char **argv, const char *prefix UNUSED) { struct strvec args = STRVEC_INIT; int flags = RUN_COMMAND_NO_STDIN, res = 0; @@ -1195,7 +1208,8 @@ static int verify_good(const struct bisect_terms *terms, return rc; } -static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) +static int bisect_run(struct bisect_terms *terms, int argc, + const char **argv, const char *prefix UNUSED) { int res = BISECT_OK; struct strbuf command = STRBUF_INIT; @@ -1269,7 +1283,7 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) saved_stdout = dup(1); dup2(temporary_stdout_fd, 1); - res = bisect_state(terms, &new_state, 1); + res = bisect_state(terms, 1, &new_state, NULL); fflush(stdout); dup2(saved_stdout, 1); @@ -1354,53 +1368,53 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) case BISECT_RESET: if (argc > 1) return error(_("--bisect-reset requires either no argument or a commit")); - res = bisect_reset(argc ? argv[0] : NULL); + res = bisect_reset(&terms, argc, argv, prefix); break; case BISECT_TERMS: if (argc > 1) return error(_("--bisect-terms requires 0 or 1 argument")); - res = bisect_terms(&terms, argc == 1 ? argv[0] : NULL); + res = bisect_terms(&terms, argc, argv, prefix); break; case BISECT_START: set_terms(&terms, "bad", "good"); - res = bisect_start(&terms, argv, argc); + res = bisect_start(&terms, argc, argv, prefix); break; case BISECT_NEXT: if (argc) return error(_("--bisect-next requires 0 arguments")); get_terms(&terms); - res = bisect_next(&terms, prefix); + res = bisect_next(&terms, argc, argv, prefix); break; case BISECT_STATE: set_terms(&terms, "bad", "good"); get_terms(&terms); - res = bisect_state(&terms, argv, argc); + res = bisect_state(&terms, argc, argv, prefix); break; case BISECT_LOG: if (argc) return error(_("--bisect-log requires 0 arguments")); - res = bisect_log(); + res = bisect_log(&terms, argc, argv, prefix); break; case BISECT_REPLAY: if (argc != 1) return error(_("no logfile given")); set_terms(&terms, "bad", "good"); - res = bisect_replay(&terms, argv[0]); + res = bisect_replay(&terms, argc, argv, prefix); break; case BISECT_SKIP: set_terms(&terms, "bad", "good"); get_terms(&terms); - res = bisect_skip(&terms, argv, argc); + res = bisect_skip(&terms, argc, argv, prefix); break; case BISECT_VISUALIZE: get_terms(&terms); - res = bisect_visualize(&terms, argv, argc); + res = bisect_visualize(&terms, argc, argv, prefix); break; case BISECT_RUN: if (!argc) return error(_("bisect run failed: no command provided.")); get_terms(&terms); - res = bisect_run(&terms, argv, argc); + res = bisect_run(&terms, argc, argv, prefix); break; default: BUG("unknown subcommand %d", cmdmode); From patchwork Fri Nov 4 13:22:46 2022 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: 13031863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 402B0C4332F for ; Fri, 4 Nov 2022 13:26:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbiKDN0j (ORCPT ); Fri, 4 Nov 2022 09:26:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231890AbiKDNZx (ORCPT ); Fri, 4 Nov 2022 09:25:53 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A7A52FFD2 for ; Fri, 4 Nov 2022 06:25:03 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id x2so7610576edd.2 for ; Fri, 04 Nov 2022 06:25:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qKusFQLb1DWa/HlXidk0/KiTUv3NQWC6oGAaBfVspaI=; b=ODdwbIt7BrTbmrNmG5RMvUvc8oJxH6o7ufRIYH7FKTrQ9LsR73vUYI3O01UMzLO2pW 2iumeVqelh8LNp5GSHAJQGxuqW8fxS2LPZNHnf299XgdhOl+krxvdQpvbCz6+aUHsGA7 XVpqo+K+Osd112d1L1jkk9mz0b7JUAn7a99vizEOamPXp3GfKRCN+kgmxbV3OC/QR/ry m983ejmCJ5KmfrgRZuv/i2vDCayiuHZ+lNz7nVtf6bzS+w0iPjCsSkoDzsgSNEqjdnkR NXI2tDIymWurnTwarM0rt/ogtD4aJao43fYvT8s+Lf9r+PgLQ8hIxu5Cf+A1zN9ZTmkP jCtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qKusFQLb1DWa/HlXidk0/KiTUv3NQWC6oGAaBfVspaI=; b=mlFR+yFyGtBTA02mSqVEPWpYf7F1W4dQpysjJqA4KlOvQk56NOj1rkuVlxcusDw1o/ 5y7CN8dTROfrzDT4tm28dfmB3IDMXhVmtr4A+6IdHge0jwqVxW14ysplXnF5RiWStIov e4rpsDqQMhNcdDc3nHbo1vvY2J2SCUaW+1meSnE4NMx5vWsotlwDP7Y5xCbvjgGqW04H NgpCfasRg17yiWQ2nDP3PPD3gN09mzGZIKT/UnU2dfY5pLNl3lHkQX1Lp21nB8xbB+PW i98oZdGwtBWarbNWvQPQQG7TC1KGxVG3pfH4Yb/1CgF9qGhQNQZCu8W6sKft/JLDvaAb IcPw== X-Gm-Message-State: ACrzQf2vYPM5ewEZ6Z3bRdjRTbhx4eGGdqvtAuFbjebazmqHdCyL7Iyz FrTqF4rQJXjmxMYIs2NRROqczyAaCKGXWQ== X-Google-Smtp-Source: AMsMyM5XwuB/UDdwpP4Q03MRm8lgV3lIQZEMFPfxSiN5vQtOP437OQELVnR7yYFPxDNblb6XOsTkpw== X-Received: by 2002:a05:6402:187:b0:464:163b:36b8 with SMTP id r7-20020a056402018700b00464163b36b8mr12298279edv.213.1667568301279; Fri, 04 Nov 2022 06:25:01 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 6-20020a170906318600b007ae38d837c5sm652979ejy.174.2022.11.04.06.25.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:25:00 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Taylor Blau , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?THVrw6E=?= =?utf-8?b?xaEgRG9rdG9y?= , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 09/13] parse-options API: don't restrict OPT_SUBCOMMAND() to one *_fn type Date: Fri, 4 Nov 2022 14:22:46 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1452.g710f45c7951 In-Reply-To: References: <1cb1c033-0525-7e62-8c09-81019bf26060@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When the OPT_SUBCOMMAND() API was implemented in [1] it did so by adding a new "subcommand_fn" member to "struct option", rather than allowing the user of the API to pick the type of the function. An advantage of mandating that "parse_opt_subcommand_fn" must be used is that we'll get type checking for the function we're passing in, a disadvantage is that we can't convert e.g. "builtin/bisect--helper.c" easily to it, as its callbacks need their own argument. Let's generalize this interface, while leaving in place a small hack to give the existing API users their type safety. We assign to "typecheck_subcommand_fn", but don't subsequently use it for anything. Instead we use the "defval" and "value" members. A subsequent commit will add a OPT_SUBCOMMAND() variant where the "callback" isn't our default "parse_options_pick_subcommand" (and that caller won't be able to use the type checking). 1. fa83cc834da (parse-options: add support for parsing subcommands, 2022-08-19) Signed-off-by: Ævar Arnfjörð Bjarmason --- parse-options.c | 9 ++++++--- parse-options.h | 25 +++++++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/parse-options.c b/parse-options.c index a1ec932f0f9..1d9e46c9dc7 100644 --- a/parse-options.c +++ b/parse-options.c @@ -427,7 +427,8 @@ static enum parse_opt_result parse_subcommand(const char *arg, for (; options->type != OPTION_END; options++) if (options->type == OPTION_SUBCOMMAND && !strcmp(options->long_name, arg)) { - *(parse_opt_subcommand_fn **)options->value = options->subcommand_fn; + if (options->callback(options, arg, 0)) + BUG("OPT_SUBCOMMAND callback returning non-zero"); return PARSE_OPT_SUBCOMMAND; } @@ -506,8 +507,10 @@ static void parse_options_check(const struct option *opts) "That case is not supported yet."); break; case OPTION_SUBCOMMAND: - if (!opts->value || !opts->subcommand_fn) - optbug(opts, "OPTION_SUBCOMMAND needs a value and a subcommand function"); + if (!opts->value || !opts->callback) + optbug(opts, "OPTION_SUBCOMMAND needs a value and a callback function"); + if (opts->ll_callback) + optbug(opts, "OPTION_SUBCOMMAND uses callback, not ll_callback"); if (!subcommand_value) subcommand_value = opts->value; else if (subcommand_value != opts->value) diff --git a/parse-options.h b/parse-options.h index b6ef86e0d15..61e3016c3fc 100644 --- a/parse-options.h +++ b/parse-options.h @@ -128,19 +128,24 @@ typedef int parse_opt_subcommand_fn(int argc, const char **argv, * the option takes optional argument. * * `callback`:: - * pointer to the callback to use for OPTION_CALLBACK + * pointer to the callback to use for OPTION_CALLBACK and OPTION_SUBCOMMAND. * * `defval`:: * default value to fill (*->value) with for PARSE_OPT_OPTARG. * OPTION_{BIT,SET_INT} store the {mask,integer} to put in the value when met. + * OPTION_SUBCOMMAND stores the pointer the function selected for + * the subcommand. + * * CALLBACKS can use it like they want. * * `ll_callback`:: * pointer to the callback to use for OPTION_LOWLEVEL_CALLBACK * * `subcommand_fn`:: - * pointer to a function to use for OPTION_SUBCOMMAND. - * It will be put in value when the subcommand is given on the command line. + * pointer to the callback used with OPT_SUBCOMMAND() and + * OPT_SUBCOMMAND_F(). Internally we store the same value in + * `defval`. This is only here to give the OPT_SUBCOMMAND{,_F}() + * common case type safety. */ struct option { enum parse_opt_type type; @@ -217,12 +222,24 @@ struct option { #define OPT_ALIAS(s, l, source_long_name) \ { OPTION_ALIAS, (s), (l), (source_long_name) } +static inline int parse_options_pick_subcommand_cb(const struct option *option, + const char *arg UNUSED, + int unset UNUSED) +{ + parse_opt_subcommand_fn *fn = (parse_opt_subcommand_fn *)option->defval; + *(parse_opt_subcommand_fn **)option->value = fn; + return 0; +} + #define OPT_SUBCOMMAND_F(l, v, fn, f) { \ .type = OPTION_SUBCOMMAND, \ .long_name = (l), \ .value = (v), \ .flags = (f), \ - .subcommand_fn = (fn) } + .defval = (intptr_t)(fn), \ + .subcommand_fn = (fn), \ + .callback = parse_options_pick_subcommand_cb, \ +} #define OPT_SUBCOMMAND(l, v, fn) OPT_SUBCOMMAND_F((l), (v), (fn), 0) /* From patchwork Fri Nov 4 13:22:47 2022 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: 13031865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CFAAC433FE for ; Fri, 4 Nov 2022 13:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231735AbiKDN0r (ORCPT ); Fri, 4 Nov 2022 09:26:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231966AbiKDNZx (ORCPT ); Fri, 4 Nov 2022 09:25:53 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 510382F3AC for ; Fri, 4 Nov 2022 06:25:04 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id i21so7554555edj.10 for ; Fri, 04 Nov 2022 06:25:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7w7gzaaZ3CrVbdB+BTzfRFNRbX4dE8SOAaAWOA3cbF0=; b=e2XYLiL0g9+LhKXviwDGGkZy5U8ZNegcBRsom6+1hW8gwaHub/jSxIzLgfA0v/ouOK pAE5AjbF1DNNE7HTiS4TSpju9+C1KG4yALHiXzIqZubWswEOgvfs++KwN6sUsMQ2gD7o NTVHd4fFs0KwyTlgDy4UADvnQNz5J8qWNRhHSbYCPMmdWhk6V7QAmFb2MBwnih9lp8ph d4eHsDZJKVldLcSYqiGPFO7TEjG2qfJ+XCh6XaQWgzkiFT9Mbot2wBUu6iXzELX8e9pq mFxIJhUVSxcKbc8l9iQAkoOWllPOobs/0AyKfp5wWbsXqoir8mNTui7N8MukUwE7NpFI Hnjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7w7gzaaZ3CrVbdB+BTzfRFNRbX4dE8SOAaAWOA3cbF0=; b=ahQDCbu3aqPJSqHQxl//Kl6fTlvadgQfTmCaMsinZfBHER1jkiPNtx1ez0h5hwgXrN TWZZa9Ko904UaaIgXqWy/lBxHFp1Cp41gAALIrzeHnx7aDc2bHG433q5Pw8ETbnavKhX 7rnFVE4OXeB7V3dh5xRcN1/RT2VLDqpd50uTyNcN8A6W+adSY/A82kz5NprK+nT0UCJ0 tzGwnuNSW5Fst/1Lt3JYRzoXKt/HeqY9L0D8znznV12Umnj11mJIuYS/5Y1L9tyhZdpX wRrCyyj+oH6DS6VOpklRxWa8hcE+NB7wNywXiZZSsE5uZDGEEs+MGt/kbV8kvBsnUcVg c0Zg== X-Gm-Message-State: ACrzQf22KeJ96GmteN171xzKOVrXtHeivCOUyNETWiNMS2CX67kVry7G CxxEORxA0e8MqBsbmZ137Y8bvUFpIOf/fg== X-Google-Smtp-Source: AMsMyM75u5uKltqCwYtfxuDv6qVPH4doLGx/GlIIl3VmsSeyqqnqIqYVEtaOpyW7GdpsMOJZnB4dvg== X-Received: by 2002:aa7:c14b:0:b0:461:c47d:48cf with SMTP id r11-20020aa7c14b000000b00461c47d48cfmr34794816edp.83.1667568302432; Fri, 04 Nov 2022 06:25:02 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 6-20020a170906318600b007ae38d837c5sm652979ejy.174.2022.11.04.06.25.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:25:01 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Taylor Blau , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?THVrw6E=?= =?utf-8?b?xaEgRG9rdG9y?= , Johannes Schindelin , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 10/13] bisect--helper: remove dead --bisect-{next-check,autostart} code Date: Fri, 4 Nov 2022 14:22:47 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1452.g710f45c7951 In-Reply-To: References: <1cb1c033-0525-7e62-8c09-81019bf26060@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin In 911aba14205 (bisect--helper: retire `--bisect-next-check` subcommand, 2021-09-13), we removed the usage string and the implementation, but not actually the option. Since b0f6494f70f (bisect--helper: retire `--bisect-autostart` subcommand, 2020-10-15), the `--bisect-autostart` option is no more. But we kept the `enum` value of the command mode around. Let's drop it, too. Signed-off-by: Johannes Schindelin Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/bisect--helper.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 32e427fa878..e13c60d54b2 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1318,10 +1318,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { BISECT_RESET = 1, - BISECT_NEXT_CHECK, BISECT_TERMS, BISECT_START, - BISECT_AUTOSTART, BISECT_NEXT, BISECT_STATE, BISECT_LOG, @@ -1334,8 +1332,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) struct option options[] = { OPT_CMDMODE(0, "bisect-reset", &cmdmode, N_("reset the bisection state"), BISECT_RESET), - OPT_CMDMODE(0, "bisect-next-check", &cmdmode, - N_("check whether bad or good terms exist"), BISECT_NEXT_CHECK), OPT_CMDMODE(0, "bisect-terms", &cmdmode, N_("print out the bisect terms"), BISECT_TERMS), OPT_CMDMODE(0, "bisect-start", &cmdmode, From patchwork Fri Nov 4 13:22:48 2022 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: 13031866 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C15AC4332F for ; Fri, 4 Nov 2022 13:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231725AbiKDN0o (ORCPT ); Fri, 4 Nov 2022 09:26:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232043AbiKDNZy (ORCPT ); Fri, 4 Nov 2022 09:25:54 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EDA02F666 for ; Fri, 4 Nov 2022 06:25:05 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id r14so7591617edc.7 for ; Fri, 04 Nov 2022 06:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2tRUPQq5fXbEJ35r/Wk5OSA1xNtpfP5gm1R7gCHwtXE=; b=GA8OHgJb72vHG87QmGbjXrDXzagIMMHqsWM+7EuvJWb155wSCVur1+IMSPUxpnnRxa CW0S67Y5WlALwrmSDR6hMl8jvEwG0NPesSmHJGmxebzphoiyHXjbsdBblAFqWR1lQNWr skytF0N83QLcWhQQrqJhldcHY2Vb1XKy9owvqi41dobznPSolQ2TqtL47MYk7Hc8Vb0x kTqvbzzCu8kaTYRsqKnTO2IsexYD03VvLznQHL7ubXLsDYL0WUEHSZqcgbENp3YFNaPG RQuirhdngVG/Pe7UGg10X22LhKpGHzkk2gEKiB7wkFboxHtih0UUJlunhUs+jonaJQkF M4Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2tRUPQq5fXbEJ35r/Wk5OSA1xNtpfP5gm1R7gCHwtXE=; b=7Ti23va2ojI9r9ia88i6qf6ACTokAtfXe/Kn2CXeZXqP7vB7Vx6cLLeA7Jln3WGnCz qWMbcKQ2/UDkMid26tC5ykY/Am6HKHsF2AfFEBo2wbg7B6rLr1YVSpoNFu3iOM1wktSr JUWoxs3XDbpv/ctoSXDJfb4eMD3ocqr+zMOqZdXUa0R8PDvWiZVxpt2PJyr9H4o33re0 Jq0vdDENPZSrFqpSj37Iw17vzaAuP2sWMyUXvvevxuDzDzo2BmHhB7au7aixLMfYOzbn jUAx7QWHYbr78kewAQRTM1okW5D9wsStUgZsgB4fOuGeHMf9E586A/U+dQzTHwj3Fln6 c1eg== X-Gm-Message-State: ACrzQf3R4FOS34L6gGvm3lG+sP5Zl90DaUAbgX+TK1tXMsGZa7cVdZDs rZlhS+bRcisNl6NPd5GCcAV1orVFAgKl4A== X-Google-Smtp-Source: AMsMyM6bF1RIGycjeJuN+6y2dfAjhMf5XnUjOq/EW8UO73Uz9us46C47WvWaITQben5ouyGCbLLNTQ== X-Received: by 2002:aa7:da0a:0:b0:461:135e:7298 with SMTP id r10-20020aa7da0a000000b00461135e7298mr35385210eds.242.1667568303346; Fri, 04 Nov 2022 06:25:03 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 6-20020a170906318600b007ae38d837c5sm652979ejy.174.2022.11.04.06.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:25:02 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Taylor Blau , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?THVrw6E=?= =?utf-8?b?xaEgRG9rdG9y?= , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 11/13] bisect--helper: convert to OPT_SUBCOMMAND_CB() Date: Fri, 4 Nov 2022 14:22:48 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1452.g710f45c7951 In-Reply-To: References: <1cb1c033-0525-7e62-8c09-81019bf26060@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Have the "bisect--helper" take arguments like "log" instead of "--log" by using a new OPT_SUBCOMMAND_CB() variant of OPT_SUBCOMMAND(). As discussed in a preceding commit this allows for using OPT_SUBCOMMAND() with custom function signatures. It would be nice to also convert all of the callbacks to use parse_options(), [1] does. But due to using the new OPT_SUBCOMMAND_CB() here we can punt on that for now. Note that we're intentionally leaving the errors which mention "--bisect-terms", as opposed to "terms". We've been showing that bad usage information to users for a while now, and don't need to further enlarge this change now by changing all of "--bisect-" to "" (which also occurs outside of this context). This finally fixes the last obscure regression in "git bisect run" in v2.30.0. We'd previously addressed it eating the "--log" and "--no-log" options, but d1bbbe45df8 (bisect--helper: reimplement `bisect_run` shell function in C, 2021-09-13) also had us conflate the internal-only "--bisect-*" options with user arguments. 1. https://lore.kernel.org/git/e97e187bbec93b47f35e3dd42b4831f1c1d8658d.1661885419.git.gitgitgadget@gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/bisect--helper.c | 110 ++++++++++++++---------------------- git-bisect.sh | 20 +++---- parse-options.h | 8 ++- t/t6030-bisect-porcelain.sh | 2 +- 4 files changed, 59 insertions(+), 81 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index e13c60d54b2..b62d3f4d418 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1314,107 +1314,79 @@ static int bisect_run(struct bisect_terms *terms, int argc, return res; } +typedef int bisect_fn(struct bisect_terms *terms, int argc, const char **argv, + const char *prefix); + +static int pick_subcommand_cb(const struct option *option, + const char *arg UNUSED, int unset UNUSED) +{ + bisect_fn *fn = (bisect_fn *)option->defval; + *(bisect_fn **)option->value = fn; + return 0; +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { - enum { - BISECT_RESET = 1, - BISECT_TERMS, - BISECT_START, - BISECT_NEXT, - BISECT_STATE, - BISECT_LOG, - BISECT_REPLAY, - BISECT_SKIP, - BISECT_VISUALIZE, - BISECT_RUN, - } cmdmode = 0; + bisect_fn *fn = NULL; int res = 0; +#define OPT_BISECT_SUBCMD(l, v, fn) \ + OPT_SUBCOMMAND_CB((l), (v), (fn), pick_subcommand_cb) struct option options[] = { - OPT_CMDMODE(0, "bisect-reset", &cmdmode, - N_("reset the bisection state"), BISECT_RESET), - OPT_CMDMODE(0, "bisect-terms", &cmdmode, - N_("print out the bisect terms"), BISECT_TERMS), - OPT_CMDMODE(0, "bisect-start", &cmdmode, - N_("start the bisect session"), BISECT_START), - OPT_CMDMODE(0, "bisect-next", &cmdmode, - N_("find the next bisection commit"), BISECT_NEXT), - OPT_CMDMODE(0, "bisect-state", &cmdmode, - N_("mark the state of ref (or refs)"), BISECT_STATE), - OPT_CMDMODE(0, "bisect-log", &cmdmode, - N_("list the bisection steps so far"), BISECT_LOG), - OPT_CMDMODE(0, "bisect-replay", &cmdmode, - N_("replay the bisection process from the given file"), BISECT_REPLAY), - OPT_CMDMODE(0, "bisect-skip", &cmdmode, - N_("skip some commits for checkout"), BISECT_SKIP), - OPT_CMDMODE(0, "bisect-visualize", &cmdmode, - N_("visualize the bisection"), BISECT_VISUALIZE), - OPT_CMDMODE(0, "bisect-run", &cmdmode, - N_("use ... to automatically bisect"), BISECT_RUN), + OPT_BISECT_SUBCMD("reset", &fn, bisect_reset), + OPT_BISECT_SUBCMD("terms", &fn, bisect_terms), + OPT_BISECT_SUBCMD("start", &fn, bisect_start), + OPT_BISECT_SUBCMD("next", &fn, bisect_next), + OPT_BISECT_SUBCMD("state", &fn, bisect_state), + OPT_BISECT_SUBCMD("log", &fn, bisect_log), + OPT_BISECT_SUBCMD("replay", &fn, bisect_replay), + OPT_BISECT_SUBCMD("skip", &fn, bisect_skip), + OPT_BISECT_SUBCMD("visualize", &fn, bisect_visualize), + OPT_BISECT_SUBCMD("run", &fn, bisect_run), OPT_END() }; +#undef OPT_BISECT_SUBCMD struct bisect_terms terms = { .term_good = NULL, .term_bad = NULL }; argc = parse_options(argc, argv, prefix, options, git_bisect_usage, - PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_UNKNOWN_OPT); + 0); - if (!cmdmode) - usage_with_options(git_bisect_usage, options); + argc--; + argv++; - switch (cmdmode) { - case BISECT_RESET: + if (fn == bisect_reset) { if (argc > 1) return error(_("--bisect-reset requires either no argument or a commit")); - res = bisect_reset(&terms, argc, argv, prefix); - break; - case BISECT_TERMS: + } else if (fn == bisect_terms) { if (argc > 1) return error(_("--bisect-terms requires 0 or 1 argument")); - res = bisect_terms(&terms, argc, argv, prefix); - break; - case BISECT_START: + } else if (fn == bisect_start) { set_terms(&terms, "bad", "good"); - res = bisect_start(&terms, argc, argv, prefix); - break; - case BISECT_NEXT: + } else if (fn == bisect_next) { + get_terms(&terms); if (argc) return error(_("--bisect-next requires 0 arguments")); - get_terms(&terms); - res = bisect_next(&terms, argc, argv, prefix); - break; - case BISECT_STATE: + } else if (fn == bisect_state) { set_terms(&terms, "bad", "good"); get_terms(&terms); - res = bisect_state(&terms, argc, argv, prefix); - break; - case BISECT_LOG: + } else if (fn == bisect_log) { if (argc) return error(_("--bisect-log requires 0 arguments")); - res = bisect_log(&terms, argc, argv, prefix); - break; - case BISECT_REPLAY: + } else if (fn == bisect_replay) { if (argc != 1) return error(_("no logfile given")); set_terms(&terms, "bad", "good"); - res = bisect_replay(&terms, argc, argv, prefix); - break; - case BISECT_SKIP: + } else if (fn == bisect_skip) { set_terms(&terms, "bad", "good"); get_terms(&terms); - res = bisect_skip(&terms, argc, argv, prefix); - break; - case BISECT_VISUALIZE: + } else if (fn == bisect_visualize) { get_terms(&terms); - res = bisect_visualize(&terms, argc, argv, prefix); - break; - case BISECT_RUN: + } else if (fn == bisect_run) { if (!argc) return error(_("bisect run failed: no command provided.")); get_terms(&terms); - res = bisect_run(&terms, argc, argv, prefix); - break; - default: - BUG("unknown subcommand %d", cmdmode); } + + res = fn(&terms, argc, argv, prefix); free_terms(&terms); /* diff --git a/git-bisect.sh b/git-bisect.sh index 405cf76f2a3..e19847eba0d 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -58,26 +58,26 @@ case "$#" in help) git bisect -h ;; start) - git bisect--helper --bisect-start "$@" ;; + git bisect--helper start "$@" ;; bad|good|new|old|"$TERM_BAD"|"$TERM_GOOD") - git bisect--helper --bisect-state "$cmd" "$@" ;; + git bisect--helper state "$cmd" "$@" ;; skip) - git bisect--helper --bisect-skip "$@" || exit;; + git bisect--helper skip "$@" || exit;; next) # Not sure we want "next" at the UI level anymore. - git bisect--helper --bisect-next "$@" || exit ;; + git bisect--helper next "$@" || exit ;; visualize|view) - git bisect--helper --bisect-visualize "$@" || exit;; + git bisect--helper visualize "$@" || exit;; reset) - git bisect--helper --bisect-reset "$@" ;; + git bisect--helper reset "$@" ;; replay) - git bisect--helper --bisect-replay "$@" || exit;; + git bisect--helper replay "$@" || exit;; log) - git bisect--helper --bisect-log || exit ;; + git bisect--helper log || exit ;; run) - git bisect--helper --bisect-run "$@" || exit;; + git bisect--helper run "$@" || exit;; terms) - git bisect--helper --bisect-terms "$@" || exit;; + git bisect--helper terms "$@" || exit;; *) usage ;; esac diff --git a/parse-options.h b/parse-options.h index 61e3016c3fc..4e32b557174 100644 --- a/parse-options.h +++ b/parse-options.h @@ -237,10 +237,16 @@ static inline int parse_options_pick_subcommand_cb(const struct option *option, .value = (v), \ .flags = (f), \ .defval = (intptr_t)(fn), \ - .subcommand_fn = (fn), \ .callback = parse_options_pick_subcommand_cb, \ } #define OPT_SUBCOMMAND(l, v, fn) OPT_SUBCOMMAND_F((l), (v), (fn), 0) +#define OPT_SUBCOMMAND_CB(l, v, fn, cb) { \ + .type = OPTION_SUBCOMMAND, \ + .long_name = (l), \ + .value = (v), \ + .defval = (intptr_t)(fn), \ + .callback = (cb), \ +} /* * parse_options() will filter out the processed options and leave the diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index eace0af637e..de47c87a6ff 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -350,7 +350,7 @@ test_expect_success 'git bisect run: args, stdout and stderr: "--log foo --no-lo EOF_ERR ' -test_expect_failure 'git bisect run: args, stdout and stderr: "--bisect-start" argument' ' +test_expect_success 'git bisect run: args, stdout and stderr: "--bisect-start" argument' ' test_bisect_run_args --bisect-start <<-\EOF_ARGS 6<<-EOF_OUT 7<<-\EOF_ERR <--bisect-start> EOF_ARGS From patchwork Fri Nov 4 13:22:49 2022 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: 13031867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D848C43219 for ; Fri, 4 Nov 2022 13:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231766AbiKDN0s (ORCPT ); Fri, 4 Nov 2022 09:26:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbiKDNZ6 (ORCPT ); Fri, 4 Nov 2022 09:25:58 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F7CE2F650 for ; Fri, 4 Nov 2022 06:25:05 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id i21so7554669edj.10 for ; Fri, 04 Nov 2022 06:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OFiQ1B/BRrFmQP4PSVNSTKt0/dSAUUl0tWnwjTzPlkA=; b=dHE+1d6wKhGKIUkdFqrttR2bjB17sovHkEfwW3BlpgWCwbqCGYOiKA76ZEUqSyTmPb 7eI586DyOEA4UAGFGyZFwO3xeWrqlIO3wZ+2FWHEu+owS3hw0kGeoAFhFHDPXjtTdoQV RD1DEqfJarea+YzBe9kNPEcNWgW+R+67SZ1tzuS7nTRFs3YCeowiqnaG3z8MT0Oqwvjf dE7z4wXVuwW98IH7wLUfnbyRGn8UKmc6zxpVb4DPC4bD7sovQDKNB6ZQlJeyJYvKsoPW kOyexUlh8DQOivpULKXOUngflPHE9L7d4mVp+uynK5nb5ebCz+iQBFEvZQmrY7f54/vJ mFlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OFiQ1B/BRrFmQP4PSVNSTKt0/dSAUUl0tWnwjTzPlkA=; b=4O/crHVFnWcoBhRpTV/Ta7dA9Pg0afq0NWXRNXpzRvygkHKvIZszhB14wUsAbVr6jN XS7ydKWCEqcQSCuPceiFQlS59MOJNt8wDrSLXNqCYiNb0+6USnGvl3cogctjta9QGv+G UKRPRkPnAyVMxQVbNyAcBdapM+Cypg69QyMykwqqw/G+pim5wlJHmoFitcH74kAhVJY7 +kj4zoLGbr1p6YoOokxq+mRI6ixnPHKjRjZdmCGype2UGF79wQ0B+rLPe2tQC9QzYljK AL5OLNy+qJAt6qj8pJU/vhNk1AQx13hcItvB8PbJRxs+hh1DjxH5jgbMLvaNqknsBw/L CzCg== X-Gm-Message-State: ACrzQf0+ydUpHRnwB1PWN9xTIEQ8T06tW46wJ7CNl7M2BwZH9EhaIjz3 GKHye3J8V5MSYIHopyYqf4VCzQ5eLI7MdQ== X-Google-Smtp-Source: AMsMyM4K9e0myizxc5qQQkCSmMipUoIWIoWnfa/SucpKIv7MmtVfNscuDqlbUbiA0lrp5OOXcCVmCQ== X-Received: by 2002:a05:6402:51a:b0:461:970e:2adc with SMTP id m26-20020a056402051a00b00461970e2adcmr35375247edv.44.1667568304146; Fri, 04 Nov 2022 06:25:04 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 6-20020a170906318600b007ae38d837c5sm652979ejy.174.2022.11.04.06.25.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:25:03 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Taylor Blau , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?THVrw6E=?= =?utf-8?b?xaEgRG9rdG9y?= , Johannes Schindelin , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 12/13] bisect--helper: make `state` optional Date: Fri, 4 Nov 2022 14:22:49 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1452.g710f45c7951 In-Reply-To: References: <1cb1c033-0525-7e62-8c09-81019bf26060@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin In preparation for making `git bisect` a real built-in, let's prepare the `bisect--helper` built-in to handle `git bisect--helper good` and `git bisect--helper bad`, i.e. do not require the `state` subcommand to be passed explicitly. Signed-off-by: Johannes Schindelin Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/bisect--helper.c | 21 ++++++++++++++++++--- git-bisect.sh | 17 +---------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index b62d3f4d418..c92197b0ea5 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1348,10 +1348,12 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) struct bisect_terms terms = { .term_good = NULL, .term_bad = NULL }; argc = parse_options(argc, argv, prefix, options, git_bisect_usage, - 0); + PARSE_OPT_SUBCOMMAND_OPTIONAL); - argc--; - argv++; + if (fn) { + argc--; + argv++; + } if (fn == bisect_reset) { if (argc > 1) @@ -1386,6 +1388,19 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) get_terms(&terms); } + if (!fn) { + if (!argc) + usage_msg_opt(_("need a command"), git_bisect_usage, + options); + + set_terms(&terms, "bad", "good"); + get_terms(&terms); + if (check_and_set_terms(&terms, argv[0])) + usage_msg_optf(_("unknown command: '%s'"), + git_bisect_usage, options, argv[0]); + fn = bisect_state; + } + res = fn(&terms, argc, argv, prefix); free_terms(&terms); diff --git a/git-bisect.sh b/git-bisect.sh index e19847eba0d..c6e12f60f83 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -34,33 +34,18 @@ Please use "git help bisect" to get the full man page.' OPTIONS_SPEC= . git-sh-setup -TERM_BAD=bad -TERM_GOOD=good - -get_terms () { - if test -s "$GIT_DIR/BISECT_TERMS" - then - { - read TERM_BAD - read TERM_GOOD - } <"$GIT_DIR/BISECT_TERMS" - fi -} case "$#" in 0) usage ;; *) cmd="$1" - get_terms shift case "$cmd" in help) git bisect -h ;; start) git bisect--helper start "$@" ;; - bad|good|new|old|"$TERM_BAD"|"$TERM_GOOD") - git bisect--helper state "$cmd" "$@" ;; skip) git bisect--helper skip "$@" || exit;; next) @@ -79,6 +64,6 @@ case "$#" in terms) git bisect--helper terms "$@" || exit;; *) - usage ;; + git bisect--helper "$cmd" "$@" ;; esac esac From patchwork Fri Nov 4 13:22:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13031868 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75240C43217 for ; Fri, 4 Nov 2022 13:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231790AbiKDN0u (ORCPT ); Fri, 4 Nov 2022 09:26:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231364AbiKDN0B (ORCPT ); Fri, 4 Nov 2022 09:26:01 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 238882FFD4 for ; Fri, 4 Nov 2022 06:25:07 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id v17so7578580edc.8 for ; Fri, 04 Nov 2022 06:25:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LBdzku4GFWxQbPQypBERtBhAwYhsuMn/S4bKV0ZkDWs=; b=BZPnCpS54MTUhiyQnU/jxyI2D6bJ2BMYwot0F40gUOfMk/eRjPPoOslunY3P9nYct7 B7nK5qXOfccSmawWYOuDCn4QccqKNmb6ejbZ3ODS/4/SbV/LUbhkjsq68+oPetIc65Z0 sdpEpjB1QuKU9oHVFHKi25b41kk8JXm3VlJ4Px3oY6GMcrJQi5Iir5shN1i2s2avoab2 VkovPaPFVGEOFMJiBMp4RyFQR3J85vd+lleX/pp8mdTThs2R42Qpl9mUOQlLilztWeaH ncdadtydQRj4wcym+VBEItLgNqeb6Mm3FxJlcP1E/K345MVKf12n5uTJjV/5EWPhWzUS vtog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LBdzku4GFWxQbPQypBERtBhAwYhsuMn/S4bKV0ZkDWs=; b=sxtlwqTjmjiMojiQNYDSzLbw+0UE29n70VZIHpRq86cFCUYcju6XaPV38TAlgxjXri YlkGlIWAk0gpU4te7D6RSGOlL+3oUYu0iq7z/5HMBkuGkIdc2N/DOIO9rFHrHwhii4I/ X3lErw/7I9LDhocpCBymHugZzlXBKMAiKlDbKtX4l0IQFtW8VSdB6L6l40d8lBnAl1UN PFKFmx4otIsLkS/HTiZaxViy+laXMfqj3PbsR7NTYQR7FRbfea+RUmvMakOfU0ujK51b sAutt2VUMW5Y48XtGjq4tDacypoSOkSrR5gZeypM+wQkczo55CBokL4t6PGzmEF7yAXd Fwpg== X-Gm-Message-State: ACrzQf3DQ84doXW+HvCWkIbYFMsZOUC6X5czLjMGcqXy1oudTEZ/lc0L 6argEqLLa+5EQNfHJHl4UiQIvlEZdOLfSg== X-Google-Smtp-Source: AMsMyM6cNrqLCSouHHono9MA+nchOrjNPIsFWLlZuwSrn3caflxi8U5QldrVvHOpCOggI4De4/WbrA== X-Received: by 2002:aa7:dd57:0:b0:453:2d35:70bb with SMTP id o23-20020aa7dd57000000b004532d3570bbmr36112939edw.26.1667568305190; Fri, 04 Nov 2022 06:25:05 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 6-20020a170906318600b007ae38d837c5sm652979ejy.174.2022.11.04.06.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:25:04 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Taylor Blau , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?THVrw6E=?= =?utf-8?b?xaEgRG9rdG9y?= , Johannes Schindelin , Johannes Schindelin Subject: [PATCH 13/13] Turn `git bisect` into a full built-in Date: Fri, 4 Nov 2022 14:22:50 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1452.g710f45c7951 In-Reply-To: References: <1cb1c033-0525-7e62-8c09-81019bf26060@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin Now that the shell script hands off to the `bisect--helper` to do _anything_ (except to show the help), it is but a tiny step to let the helper implement the actual `git bisect` command instead. This retires `git-bisect.sh`, concluding a multi-year journey that many hands helped with, in particular Pranit Bauna, Tanushree Tumane and Miriam Rubio. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- Makefile | 3 +- builtin.h | 2 +- builtin/{bisect--helper.c => bisect.c} | 5 +- git-bisect.sh | 69 -------------------------- git.c | 2 +- 5 files changed, 4 insertions(+), 77 deletions(-) rename builtin/{bisect--helper.c => bisect.c} (99%) delete mode 100755 git-bisect.sh diff --git a/Makefile b/Makefile index 4927379184c..78785c6b843 100644 --- a/Makefile +++ b/Makefile @@ -627,7 +627,6 @@ THIRD_PARTY_SOURCES = # interactive shell sessions without exporting it. unexport CDPATH -SCRIPT_SH += git-bisect.sh SCRIPT_SH += git-difftool--helper.sh SCRIPT_SH += git-filter-branch.sh SCRIPT_SH += git-merge-octopus.sh @@ -1137,7 +1136,7 @@ BUILTIN_OBJS += builtin/am.o BUILTIN_OBJS += builtin/annotate.o BUILTIN_OBJS += builtin/apply.o BUILTIN_OBJS += builtin/archive.o -BUILTIN_OBJS += builtin/bisect--helper.o +BUILTIN_OBJS += builtin/bisect.o BUILTIN_OBJS += builtin/blame.o BUILTIN_OBJS += builtin/branch.o BUILTIN_OBJS += builtin/bugreport.o diff --git a/builtin.h b/builtin.h index 8901a34d6bf..aa955466b4e 100644 --- a/builtin.h +++ b/builtin.h @@ -116,7 +116,7 @@ int cmd_am(int argc, const char **argv, const char *prefix); int cmd_annotate(int argc, const char **argv, const char *prefix); int cmd_apply(int argc, const char **argv, const char *prefix); int cmd_archive(int argc, const char **argv, const char *prefix); -int cmd_bisect__helper(int argc, const char **argv, const char *prefix); +int cmd_bisect(int argc, const char **argv, const char *prefix); int cmd_blame(int argc, const char **argv, const char *prefix); int cmd_branch(int argc, const char **argv, const char *prefix); int cmd_bugreport(int argc, const char **argv, const char *prefix); diff --git a/builtin/bisect--helper.c b/builtin/bisect.c similarity index 99% rename from builtin/bisect--helper.c rename to builtin/bisect.c index c92197b0ea5..9d66da2148b 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect.c @@ -1325,7 +1325,7 @@ static int pick_subcommand_cb(const struct option *option, return 0; } -int cmd_bisect__helper(int argc, const char **argv, const char *prefix) +int cmd_bisect(int argc, const char **argv, const char *prefix) { bisect_fn *fn = NULL; int res = 0; @@ -1370,9 +1370,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) } else if (fn == bisect_state) { set_terms(&terms, "bad", "good"); get_terms(&terms); - } else if (fn == bisect_log) { - if (argc) - return error(_("--bisect-log requires 0 arguments")); } else if (fn == bisect_replay) { if (argc != 1) return error(_("no logfile given")); diff --git a/git-bisect.sh b/git-bisect.sh deleted file mode 100755 index c6e12f60f83..00000000000 --- a/git-bisect.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh - -USAGE='[help|start|bad|good|new|old|terms|skip|next|reset|visualize|view|replay|log|run]' -LONG_USAGE='git bisect help - print this long help message. -git bisect start [--term-{new,bad}= --term-{old,good}=] - [--no-checkout] [--first-parent] [ [...]] [--] [...] - reset bisect state and start bisection. -git bisect (bad|new) [] - mark a known-bad revision/ - a revision after change in a given property. -git bisect (good|old) [...] - mark ... known-good revisions/ - revisions before change in a given property. -git bisect terms [--term-good | --term-bad] - show the terms used for old and new commits (default: bad, good) -git bisect skip [(|)...] - mark ... untestable revisions. -git bisect next - find next bisection to test and check it out. -git bisect reset [] - finish bisection search and go back to commit. -git bisect (visualize|view) - show bisect status in gitk. -git bisect replay - replay bisection log. -git bisect log - show bisect log. -git bisect run ... - use ... to automatically bisect. - -Please use "git help bisect" to get the full man page.' - -OPTIONS_SPEC= -. git-sh-setup - - -case "$#" in -0) - usage ;; -*) - cmd="$1" - shift - case "$cmd" in - help) - git bisect -h ;; - start) - git bisect--helper start "$@" ;; - skip) - git bisect--helper skip "$@" || exit;; - next) - # Not sure we want "next" at the UI level anymore. - git bisect--helper next "$@" || exit ;; - visualize|view) - git bisect--helper visualize "$@" || exit;; - reset) - git bisect--helper reset "$@" ;; - replay) - git bisect--helper replay "$@" || exit;; - log) - git bisect--helper log || exit ;; - run) - git bisect--helper run "$@" || exit;; - terms) - git bisect--helper terms "$@" || exit;; - *) - git bisect--helper "$cmd" "$@" ;; - esac -esac diff --git a/git.c b/git.c index ee7758dcb0e..f18a5750313 100644 --- a/git.c +++ b/git.c @@ -492,7 +492,7 @@ static struct cmd_struct commands[] = { { "annotate", cmd_annotate, RUN_SETUP }, { "apply", cmd_apply, RUN_SETUP_GENTLY }, { "archive", cmd_archive, RUN_SETUP_GENTLY }, - { "bisect--helper", cmd_bisect__helper, RUN_SETUP }, + { "bisect", cmd_bisect, RUN_SETUP }, { "blame", cmd_blame, RUN_SETUP }, { "branch", cmd_branch, RUN_SETUP | DELAY_PAGER_CONFIG }, { "bugreport", cmd_bugreport, RUN_SETUP_GENTLY },