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