From patchwork Tue Aug 30 18:50:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959691 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 A158CECAAD8 for ; Tue, 30 Aug 2022 18:50:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbiH3Su3 (ORCPT ); Tue, 30 Aug 2022 14:50:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbiH3SuZ (ORCPT ); Tue, 30 Aug 2022 14:50:25 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EB1117AA2 for ; Tue, 30 Aug 2022 11:50:24 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id k9so15450595wri.0 for ; Tue, 30 Aug 2022 11:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=mUxdgs/oj7+z9X3ltpWKwdv75dd+R2a119akogQaQkk=; b=GSm9XFO2N5BaxVzf5R8x24opKKvkv08yKnZxAJOhpHFKvESNqmL5eCOSva0yIhdOUg jHWT5wVng6qAGVIn1WInvIKcTqUD0ymwqGLQjDBI00kAKG01AF22my+eoWo8jRZ8MhWs SiPopZCRrOTdibihItp/imr8QdN8QRxisW517a1UdFtsCB5JC952P1L56tATos3ODAQJ jRwL2qHPIAOaO6KpdXR90VbVJidZUm3hVxSrymWJXgp/+FXSmb+ObTd3R+h7Tnpd/ykg TH1E+9qxItd7eZrcCxns29iIEL4iY/rG0to4+pHFUmnDzmkhuXu4HAlAmOj3WLuc/w7m 0WvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=mUxdgs/oj7+z9X3ltpWKwdv75dd+R2a119akogQaQkk=; b=I8ZG6Tay0kLTJmTclXFX9JfExD0rHbv8aJnZ5yXPDqcflXGM8AjQbg9y0HvMjE/HEW ekfWhfxq9U7HOCNqJ3m5OmxrALZbSrfbesnRPatszToC5nYvzIfyDCCbrJv2zOeIwCS6 qwijY9BkNLJ6jv6JPbYmDTqg3GgW7+5o73Pev+LyOl/KZXCFA6Wx1Xusdpybtvn2ZZXE lXXs4OnckpDAbNAsnqVkEQF8uly7W62SsjaH/wOIxj3TFXvHah3rIwdCwDohhaL5zaqO OVwrJvGYySsWGaKnEU84eaTZLz9x0O3hSCHDVC7dE95gkHj8+xnlr3+ptG8JhdZxPCH+ eIFQ== X-Gm-Message-State: ACgBeo3/wK4EindyFwhRAt6r9nqz0TSQJ36ROPUmCiPXUD+DcWiK3Uz+ 0IbEAejup94Lx4DeaT45MMLsMVYBz94= X-Google-Smtp-Source: AA6agR7XtP2A/fg/xq4bXWWJDEx5gms9Jx5UQiy4/7ppTDhH7+Iw++/pe0a7p5PBJHctZ/YYOBGpyw== X-Received: by 2002:adf:9cca:0:b0:226:dfa0:3fb7 with SMTP id h10-20020adf9cca000000b00226dfa03fb7mr4451050wre.412.1661885422832; Tue, 30 Aug 2022 11:50:22 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n1-20020a05600c4f8100b003a5c064717csm14574929wmq.22.2022.08.30.11.50.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:22 -0700 (PDT) Message-Id: <05262b6a7d1b20a0d2f2ca2090be284ffb8c679c.1661885419.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:04 +0000 Subject: [PATCH v6 01/16] bisect--helper: retire the --no-log option Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin Turns out we actually never used it, anyway... Signed-off-by: Johannes Schindelin --- builtin/bisect--helper.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 7097750fc6b..2cc69e1eee5 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1292,7 +1292,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), @@ -1316,8 +1316,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 }; From patchwork Tue Aug 30 18:50:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959692 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 3A650ECAAA1 for ; Tue, 30 Aug 2022 18:50:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231624AbiH3Sud (ORCPT ); Tue, 30 Aug 2022 14:50:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230257AbiH3Su0 (ORCPT ); Tue, 30 Aug 2022 14:50:26 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A0F9205DE for ; Tue, 30 Aug 2022 11:50:25 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id j26so6251749wms.0 for ; Tue, 30 Aug 2022 11:50:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=4nZ5T9cMdKhWlaoNeMMhrxt/eq5mUn7eiiPvf1i1Ivs=; b=AYl1ALr0ckoySIn+RmQIGD0Aavi+ZNjdo//xpkMXXElAxd4B7PgJkc0MvhIRxbDeGs epyxTWpO1W5vpsJntHNostHSA51aSdOAE0Drz1OUBILJt35Vs4YIvtKyxKA47hDqKEJ8 qQO8kI3IiIMiQ3ynb+HAVpgFuHaEqaD6kk+8POnFNVAaQ+E/UDW9k6gJdIT3jBUR5+zk BnXzR64oCdooSclE0duOGdADl+L0DuVn+vFO6ycLV8/k8q07QyBmOdiNvsbfm1KjCvJa zQnzyo/k2uSuDr+FPy5zLRnpFL1pbYUOwP5OWICI9nlNCg+/ChdkRyyfqtkwJEx2MNxg fnTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=4nZ5T9cMdKhWlaoNeMMhrxt/eq5mUn7eiiPvf1i1Ivs=; b=AZibJWN51So/1+kx6sD8NbqaI8hV3U2kEMdTCUL+nc8h9dcROIUvP0QHJ7UeKSga9v oWSapUMvcfaRpWxRAmMwpMUzBt4ZU32h3HRMOTbM70UpWogQfhyc9BKaRqe7ZJ6Y6kXC e657xL8z6mVj+U6f54BaXyQmFWupT6kMqxE3pC1VlEcS23/Fs6bXUV7K6/jWZLsV59ui DO3QwU4L3/0M48W5Jeagc+9Y/Dm9bdWxaOD6Y/uWhPo9q/URdy4/hass6YT5p3phZWa8 maeRmmUJmaB4IAd1sXYBdUsfi5jMhfWFzGAdXajdoQGaKNGHZN5LpjdwGqtKjWhMAmhW Vi2Q== X-Gm-Message-State: ACgBeo1wZ9Pgskki3v1MdbPs6UIA59Ep+tZpJS3oIAsSGApH+nRYam+5 hEgOJyoYecRHQKxwbwcKO4/QvPOmIaw= X-Google-Smtp-Source: AA6agR4tI8IpFdHMeKO2CQ9j+wY2hcec2imf1usfGhv3eyqlGUTK5asd3S+2jSYMTH2HAck/XD6uSw== X-Received: by 2002:a1c:7c08:0:b0:3a6:2569:4986 with SMTP id x8-20020a1c7c08000000b003a625694986mr10608626wmc.117.1661885423687; Tue, 30 Aug 2022 11:50:23 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d18-20020adff2d2000000b0022542581800sm12012667wrp.45.2022.08.30.11.50.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:23 -0700 (PDT) Message-Id: <1e43148864a52ffe05b5075bd0e449c0e056f078.1661885419.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:05 +0000 Subject: [PATCH v6 02/16] bisect--helper: really retire --bisect-next-check Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin 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. Signed-off-by: Johannes Schindelin --- builtin/bisect--helper.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 2cc69e1eee5..bdf7ce18d7a 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1280,7 +1280,6 @@ 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, @@ -1296,8 +1295,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 Tue Aug 30 18:50:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959693 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 94338ECAAA1 for ; Tue, 30 Aug 2022 18:50:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231517AbiH3Sue (ORCPT ); Tue, 30 Aug 2022 14:50:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231437AbiH3Su1 (ORCPT ); Tue, 30 Aug 2022 14:50:27 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DE5D17AA2 for ; Tue, 30 Aug 2022 11:50:26 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id e13so14496899wrm.1 for ; Tue, 30 Aug 2022 11:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=fputxYI2HUfkFVNx9yxXGsgXMgIUSaa9LOnIcfF5Q2c=; b=MqlEfxUm6rx3NyT12Fb9IkeAZ4zMBSbJqqh3aBjJ1b24/nI7wyoiRgvS/M02xeWOA4 eQXFHtshgy/PMVCDIX0ErFHD74DFFFPXWWDqh1NJ6NX/W3MuYNDZWTQPGKHH/hRMYvEf iQpKZ66CMfetSiXDpLeXL+hro0kmWQygDgCfe4FHPRouikEIp+S+E3O3g+X5S5ZtOvip 8rFvHqAA5GejvlanNrYYt/Z84XVEc57L+p922ct+hnKXstDOk/gsmz3v/5JwLz9nO1aj RBY5YYlN1CyL9S3YvUcp3V1dXp+GlkKqYdlVkfHyFzsNWpMbadRaHGgaYPanviTO/i90 TmjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=fputxYI2HUfkFVNx9yxXGsgXMgIUSaa9LOnIcfF5Q2c=; b=F0rp128ysSDIkG+uOQqsaUKHWlxUp+sLi4+tp+RSMaCBkponF6yEYMNqmJ9iaoivIh KHBpvIZPJ0A6/EqQehgbcLlUs39fGoTr42JH4Ji4dFiTsPd0av+f4yWNPo59ngB0Fbhw ZYdSpQTMCVFf7bbKM0K2eSbuk8A1jJoM/AINf5zWAgNAqFQSXtj1EU4F+ttH49gMSNOo NpPVOn/YCDF5HhGSf9XJyPFH6SvnrJeHjm/JRgfcSjfzdAAZBN2uTh535K4j5h4OJBiH 790yx7Ku8dlPpnFaUk39g3HMlRD8lumH5GDMeD9DmNQk9cHRdQwVYP307M5kCX0Y2cuY /c8w== X-Gm-Message-State: ACgBeo19i1GZ3+6gDybATuHtHgUbvCVST2Amay+qw8AhNHPmxgHEzJu0 UnzLPUm2iD31tBxAHog/aa36iW8eDGI= X-Google-Smtp-Source: AA6agR5V35CRL62/4WFWbIrE8lOV3Ou2yBDawy49mr2GMTNOPBpIINz+2LLjoGv3yIKRww6pL+ZIVQ== X-Received: by 2002:a5d:47ac:0:b0:226:df12:412f with SMTP id 12-20020a5d47ac000000b00226df12412fmr4978997wrb.675.1661885424633; Tue, 30 Aug 2022 11:50:24 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id cc18-20020a5d5c12000000b002253604bbefsm4936802wrb.75.2022.08.30.11.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:24 -0700 (PDT) Message-Id: <1a1649d9d0d5739f76db82fdafae7e88374bc8a6.1661885419.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:06 +0000 Subject: [PATCH v6 03/16] bisect--helper: really retire `--bisect-autostart` Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin 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 --- builtin/bisect--helper.c | 1 - 1 file changed, 1 deletion(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index bdf7ce18d7a..aa94c25ec73 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1282,7 +1282,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_RESET = 1, BISECT_TERMS, BISECT_START, - BISECT_AUTOSTART, BISECT_NEXT, BISECT_STATE, BISECT_LOG, From patchwork Tue Aug 30 18:50:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959694 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 6FE7BECAAA1 for ; Tue, 30 Aug 2022 18:50:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231526AbiH3Sui (ORCPT ); Tue, 30 Aug 2022 14:50:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229735AbiH3Su2 (ORCPT ); Tue, 30 Aug 2022 14:50:28 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 505963DBD7 for ; Tue, 30 Aug 2022 11:50:27 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id j26so6251789wms.0 for ; Tue, 30 Aug 2022 11:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=oaO05srWf/I52sc2LqNWTDuaqmQesAxh5GR52Lgsn+E=; b=RZ1Rw0BRPSCUPudP4g9b2zMksAntN9lsq9LjTnb6dUBqMS7u0BR31j/vo6K1Xlt0aJ XdFKdOQv5lXhEAxlaFZmOGwOuHUtRm/7JfhrrfwOui/lq5VSFWtiB0oZq2P7Aman1QUu q1kVU6Ct1Ib9NVIAYLO8/RCo6Y1MZQdpVZW1SJOR7uiR1NhjE3rOf2OuiD6s+gsh9KpB EPBYLyBWW+BCGUwe02qQNrnWILFn2y4s1E5DO0Tkh1lEj3dl+g7ZuXqcL2euMSPmgsh+ cXX8XaxCEnz/Na1meHZm9LpKFPj8BiOaDZ/ynw2sN3V7Z4YwheFQlWKJiCrnUYzfvog8 NBhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=oaO05srWf/I52sc2LqNWTDuaqmQesAxh5GR52Lgsn+E=; b=wwPwjVZCJpKyMCSKGQjQrpzC97G6oOiH8vt6RlaozLfqmOzbeAPJ9EPbZZXEOeTlP5 A7VSzhT+QCLSQhpJP9Yx29R663RXP5UBxQf4/GER2m5lpVdnQfOgsMWmhoY1tPq1SVO5 e5SgjoQpQIw645PvaV/HkYyGkn+Soj199JFFU4+cS7BewXKvn6r3/Jw6if7NZAuKmCNI x8hYEe64qyW0AqY7PnL6HeGEwU8LqRKsBhtPBkrc4x3vTpyS76SfNIdUpQwhIu6SM2ra Qp9hykx4akL5VE0KUUI5a+RAvkmTow9gp4UT3fAwGC/OAG4WixOpiRI/za6O3LLJVL65 3uZg== X-Gm-Message-State: ACgBeo0MUck0Cz9AF2SoCq7FUuXZaOJ3mVwUBOtddIRo7rKx4C6vVlFA c4z95ef0q9xkHW1vwGjgbAuXRNxfCLM= X-Google-Smtp-Source: AA6agR4qu3D3iFwWzx9XsK3S/C5uB3xrEK/4Sqht6YS7CimobI76Ezvp2WlFOdFfyymrT4rLvpoMFg== X-Received: by 2002:a05:600c:350:b0:3a5:3473:1c23 with SMTP id u16-20020a05600c035000b003a534731c23mr10811097wmd.9.1661885425647; Tue, 30 Aug 2022 11:50:25 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o8-20020a05600c4fc800b003a62400724bsm15750620wmq.0.2022.08.30.11.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:25 -0700 (PDT) Message-Id: <9ab30552c6ae6a5d0a85d7a7bbdd10af4a4cf7ec.1661885419.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:07 +0000 Subject: [PATCH v6 04/16] bisect--helper: simplify exit code computation Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin We _already_ have a function to determine whether a given `enum bisect_error` value is non-zero but still _actually_ indicates success. Let's use it instead of duplicating the logic. Signed-off-by: Johannes Schindelin --- builtin/bisect--helper.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index aa94c25ec73..2f9c7f54f3f 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1380,12 +1380,5 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) } free_terms(&terms); - /* - * Handle early success - * From check_merge_bases > check_good_are_ancestors_of_bad > bisect_next_all - */ - if ((res == BISECT_INTERNAL_SUCCESS_MERGE_BASE) || (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND)) - res = BISECT_OK; - - return -res; + return is_bisect_success(res) ? 0 : -res; } From patchwork Tue Aug 30 18:50:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959696 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 B8797ECAAA1 for ; Tue, 30 Aug 2022 18:50:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231636AbiH3Suw (ORCPT ); Tue, 30 Aug 2022 14:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231615AbiH3Sub (ORCPT ); Tue, 30 Aug 2022 14:50:31 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 965533DBE4 for ; Tue, 30 Aug 2022 11:50:28 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id s23so6234607wmj.4 for ; Tue, 30 Aug 2022 11:50:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=NGbWsZD/xP+Yj0+/RaEfg4uoVSXgFgsqty6tXzT97io=; b=LThm1gi6j8IvrrWXNWb1y9JHuX7ab9etrWHpBqpwmxfbk4fjAptQkbBFMDh26o/jA6 z7LFTcdJXJfAf+aFHhMSmTJa40ISa3sWwVVa6ljAylxyrVjzRdVXC+e3wx7Np6jz2iH1 1G61s3f5PO5+20v1WP7FtZL5SD1wHLF7771vDjHE1iaR+Ml+gIokGwH/DmLgkwZJ70ux 5R7GZbHTQBLUQ/8EGOFxZ5TqNGWqRigAZNksOIVEZV88FmTJ1sGPiEr2txaIvcV/BRcG Sy2yZcnwy+zXNXB98NuWMWtieFf8wX/DYrRhPG5ejP/sJZFCcQJnzbIr2sxkhFb8VTCN AI6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=NGbWsZD/xP+Yj0+/RaEfg4uoVSXgFgsqty6tXzT97io=; b=Jos2anlu5vTKc8SQ4UAaZiEmiVt+QHT6hgeOhz4JBEeAYf5HgsZiRkyuvo8d9tvjvr JyXYt3/HAprdeS5aCouvb2XAgmK08BVFMLbuwKRspM9OM5TKh1DqEFF5of0MOqZyNOr1 kcEC+R5cBtuKxkAaCb+q8pf5Os14uk36qhV6AbYPTyiY9EoL2rCuX73kCyQVAAIaCz4x dJaoSsjxRXro/0tst/2nKGDVHPMx4OexWo0n3mWhtZiSLbwr6pKjpqJyrCwo1Lf6UFm0 bjsWFeX3jHGoprtKJK+ZPn8zRHWoKIY8I5ej7xdBWPeP1dpwOD0/albIZVbLMCdhTTQJ b/qg== X-Gm-Message-State: ACgBeo2f1Rsq1NdvfTCYI4xVZ4JwomZQL55z6njIeEaLA0G23YDqaftH 8D/cP2lMSejYYvGWi97hAgzv9D1C8ig= X-Google-Smtp-Source: AA6agR59ukLywEel/rc3Hp5Wy+LZvJAovk8AJaU/4igLnz7iDtN/Hw1qECWsPE3dqSeyfVCbMnnTvg== X-Received: by 2002:a05:600c:3b05:b0:3a8:4c81:54df with SMTP id m5-20020a05600c3b0500b003a84c8154dfmr3933350wms.129.1661885426651; Tue, 30 Aug 2022 11:50:26 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l7-20020a05600c1d0700b003a317ee3036sm14669618wms.2.2022.08.30.11.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:26 -0700 (PDT) Message-Id: <92b3b116ef8f879192d9deb94d68b73e29d5dcd6.1661885419.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:08 +0000 Subject: [PATCH v6 05/16] bisect--helper: make `terms` an explicit singleton Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin We tried very hard to keep code in `builtin/bisect--helper.c` in as libifyable a state as possible. However, we are about to migrate this built-in to the `OPT_SUBCOMMAND()` API, which does not allow for passing any context (e.g. via a `void *data` parameters as they are used in the config API). Therefore, we _have_ to move the `terms` variable outside of `cmd_bisect__helper()` and explicitly make it a singleton (as it currently is, anyway). Let's just make things consistent and stop passing around pointers to that singleton; Use it directly instead. Signed-off-by: Johannes Schindelin --- builtin/bisect--helper.c | 262 +++++++++++++++++++-------------------- 1 file changed, 128 insertions(+), 134 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 2f9c7f54f3f..7f4e8e707c1 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -40,30 +40,30 @@ struct add_bisect_ref_data { unsigned int object_flags; }; -struct bisect_terms { +static struct bisect_terms { char *term_good; char *term_bad; -}; +} terms; -static void free_terms(struct bisect_terms *terms) +static void free_terms(void) { - FREE_AND_NULL(terms->term_good); - FREE_AND_NULL(terms->term_bad); + FREE_AND_NULL(terms.term_good); + FREE_AND_NULL(terms.term_bad); } -static void set_terms(struct bisect_terms *terms, const char *bad, +static void set_terms(const char *bad, const char *good) { - free((void *)terms->term_good); - terms->term_good = xstrdup(good); - free((void *)terms->term_bad); - terms->term_bad = xstrdup(bad); + free((void *)terms.term_good); + terms.term_good = xstrdup(good); + free((void *)terms.term_bad); + terms.term_bad = xstrdup(bad); } static const char vocab_bad[] = "bad|new"; static const char vocab_good[] = "good|old"; -static int bisect_autostart(struct bisect_terms *terms); +static int bisect_autostart(void); /* * Check whether the string `term` belongs to the set of strings @@ -254,8 +254,7 @@ static void log_commit(FILE *fp, char *fmt, const char *state, free(label); } -static int bisect_write(const char *state, const char *rev, - const struct bisect_terms *terms, int nolog) +static int bisect_write(const char *state, const char *rev, int nolog) { struct strbuf tag = STRBUF_INIT; struct object_id oid; @@ -263,9 +262,9 @@ static int bisect_write(const char *state, const char *rev, FILE *fp = NULL; int res = 0; - if (!strcmp(state, terms->term_bad)) { + if (!strcmp(state, terms.term_bad)) { strbuf_addf(&tag, "refs/bisect/%s", state); - } else if (one_of(state, terms->term_good, "skip", NULL)) { + } else if (one_of(state, terms.term_good, "skip", NULL)) { strbuf_addf(&tag, "refs/bisect/%s-%s", state, rev); } else { res = error(_("Bad bisect_write argument: %s"), state); @@ -302,27 +301,27 @@ finish: return res; } -static int check_and_set_terms(struct bisect_terms *terms, const char *cmd) +static int check_and_set_terms(const char *cmd) { int has_term_file = !is_empty_or_missing_file(git_path_bisect_terms()); if (one_of(cmd, "skip", "start", "terms", NULL)) return 0; - if (has_term_file && strcmp(cmd, terms->term_bad) && - strcmp(cmd, terms->term_good)) + if (has_term_file && strcmp(cmd, terms.term_bad) && + strcmp(cmd, terms.term_good)) return error(_("Invalid command: you're currently in a " - "%s/%s bisect"), terms->term_bad, - terms->term_good); + "%s/%s bisect"), terms.term_bad, + terms.term_good); if (!has_term_file) { if (one_of(cmd, "bad", "good", NULL)) { - set_terms(terms, "bad", "good"); - return write_terms(terms->term_bad, terms->term_good); + set_terms("bad", "good"); + return write_terms(terms.term_bad, terms.term_good); } if (one_of(cmd, "new", "old", NULL)) { - set_terms(terms, "new", "old"); - return write_terms(terms->term_bad, terms->term_good); + set_terms("new", "old"); + return write_terms(terms.term_bad, terms.term_good); } } @@ -346,8 +345,7 @@ static const char need_bisect_start_warning[] = "You then need to give me at least one %s and %s revision.\n" "You can use \"git bisect %s\" and \"git bisect %s\" for that."); -static int decide_next(const struct bisect_terms *terms, - const char *current_term, int missing_good, +static int decide_next(const char *current_term, int missing_good, int missing_bad) { if (!missing_good && !missing_bad) @@ -356,13 +354,13 @@ static int decide_next(const struct bisect_terms *terms, return -1; if (missing_good && !missing_bad && - !strcmp(current_term, terms->term_good)) { + !strcmp(current_term, terms.term_good)) { char *yesno; /* * have bad (or new) but not good (or old). We could bisect * although this is less optimum. */ - warning(_("bisecting only with a %s commit"), terms->term_bad); + warning(_("bisecting only with a %s commit"), terms.term_bad); if (!isatty(0)) return 0; /* @@ -384,11 +382,10 @@ static int decide_next(const struct bisect_terms *terms, vocab_good, vocab_bad, vocab_good, vocab_bad); } -static void bisect_status(struct bisect_state *state, - const struct bisect_terms *terms) +static void bisect_status(struct bisect_state *state) { - char *bad_ref = xstrfmt("refs/bisect/%s", terms->term_bad); - char *good_glob = xstrfmt("%s-*", terms->term_good); + char *bad_ref = xstrfmt("refs/bisect/%s", terms.term_bad); + char *good_glob = xstrfmt("%s-*", terms.term_good); if (ref_exists(bad_ref)) state->nr_bad = 1; @@ -416,11 +413,11 @@ static void bisect_log_printf(const char *fmt, ...) strbuf_release(&buf); } -static void bisect_print_status(const struct bisect_terms *terms) +static void bisect_print_status(void) { struct bisect_state state = { 0 }; - bisect_status(&state, terms); + bisect_status(&state); /* If we had both, we'd already be started, and shouldn't get here. */ if (state.nr_good && state.nr_bad) @@ -436,15 +433,14 @@ static void bisect_print_status(const struct bisect_terms *terms) bisect_log_printf(_("status: waiting for good commit(s), bad commit known\n")); } -static int bisect_next_check(const struct bisect_terms *terms, - const char *current_term) +static int bisect_next_check(const char *current_term) { struct bisect_state state = { 0 }; - bisect_status(&state, terms); - return decide_next(terms, current_term, !state.nr_good, !state.nr_bad); + bisect_status(&state); + return decide_next(current_term, !state.nr_good, !state.nr_bad); } -static int get_terms(struct bisect_terms *terms) +static int get_terms(void) { struct strbuf str = STRBUF_INIT; FILE *fp = NULL; @@ -456,11 +452,11 @@ static int get_terms(struct bisect_terms *terms) goto finish; } - free_terms(terms); + free_terms(); strbuf_getline_lf(&str, fp); - terms->term_bad = strbuf_detach(&str, NULL); + terms.term_bad = strbuf_detach(&str, NULL); strbuf_getline_lf(&str, fp); - terms->term_good = strbuf_detach(&str, NULL); + terms.term_good = strbuf_detach(&str, NULL); finish: if (fp) @@ -469,21 +465,21 @@ finish: return res; } -static int bisect_terms(struct bisect_terms *terms, const char *option) +static int bisect_terms(const char *option) { - if (get_terms(terms)) + if (get_terms()) return error(_("no terms defined")); if (!option) { printf(_("Your current terms are %s for the old state\n" "and %s for the new state.\n"), - terms->term_good, terms->term_bad); + terms.term_good, terms.term_bad); return 0; } if (one_of(option, "--term-good", "--term-old", NULL)) - printf("%s\n", terms->term_good); + printf("%s\n", terms.term_good); else if (one_of(option, "--term-bad", "--term-new", NULL)) - printf("%s\n", terms->term_bad); + printf("%s\n", terms.term_bad); else return error(_("invalid argument %s for 'git bisect terms'.\n" "Supported options are: " @@ -527,18 +523,18 @@ static int add_bisect_ref(const char *refname, const struct object_id *oid, return 0; } -static int prepare_revs(struct bisect_terms *terms, struct rev_info *revs) +static int prepare_revs(struct rev_info *revs) { int res = 0; struct add_bisect_ref_data cb = { revs }; - char *good = xstrfmt("%s-*", terms->term_good); + char *good = xstrfmt("%s-*", terms.term_good); /* - * We cannot use terms->term_bad directly in + * We cannot use terms.term_bad directly in * for_each_glob_ref_in() and we have to append a '*' to it, * otherwise for_each_glob_ref_in() will append '/' and '*'. */ - char *bad = xstrfmt("%s*", terms->term_bad); + char *bad = xstrfmt("%s*", terms.term_bad); /* * It is important to reset the flags used by revision walks @@ -559,7 +555,7 @@ static int prepare_revs(struct bisect_terms *terms, struct rev_info *revs) return res; } -static int bisect_skipped_commits(struct bisect_terms *terms) +static int bisect_skipped_commits(void) { int res; FILE *fp = NULL; @@ -568,7 +564,7 @@ static int bisect_skipped_commits(struct bisect_terms *terms) struct pretty_print_context pp = {0}; struct strbuf commit_name = STRBUF_INIT; - res = prepare_revs(terms, &revs); + res = prepare_revs(&revs); if (res) return res; @@ -585,7 +581,7 @@ static int bisect_skipped_commits(struct bisect_terms *terms) format_commit_message(commit, "%s", &commit_name, &pp); fprintf(fp, "# possible first %s commit: [%s] %s\n", - terms->term_bad, oid_to_hex(&commit->object.oid), + terms.term_bad, oid_to_hex(&commit->object.oid), commit_name.buf); } @@ -601,13 +597,13 @@ static int bisect_skipped_commits(struct bisect_terms *terms) return 0; } -static int bisect_successful(struct bisect_terms *terms) +static int bisect_successful(void) { struct object_id oid; struct commit *commit; struct pretty_print_context pp = {0}; struct strbuf commit_name = STRBUF_INIT; - char *bad_ref = xstrfmt("refs/bisect/%s",terms->term_bad); + char *bad_ref = xstrfmt("refs/bisect/%s",terms.term_bad); int res; read_ref(bad_ref, &oid); @@ -615,7 +611,7 @@ static int bisect_successful(struct bisect_terms *terms) format_commit_message(commit, "%s", &commit_name, &pp); res = append_to_file(git_path_bisect_log(), "# first %s commit: [%s] %s\n", - terms->term_bad, oid_to_hex(&commit->object.oid), + terms.term_bad, oid_to_hex(&commit->object.oid), commit_name.buf); strbuf_release(&commit_name); @@ -623,40 +619,40 @@ static int bisect_successful(struct bisect_terms *terms) return res; } -static enum bisect_error bisect_next(struct bisect_terms *terms, const char *prefix) +static enum bisect_error bisect_next(const char *prefix) { enum bisect_error res; - if (bisect_autostart(terms)) + if (bisect_autostart()) return BISECT_FAILED; - if (bisect_next_check(terms, terms->term_good)) + if (bisect_next_check(terms.term_good)) return BISECT_FAILED; /* Perform all bisection computation */ res = bisect_next_all(the_repository, prefix); if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) { - res = bisect_successful(terms); + res = bisect_successful(); return res ? res : BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND; } else if (res == BISECT_ONLY_SKIPPED_LEFT) { - res = bisect_skipped_commits(terms); + res = bisect_skipped_commits(); return res ? res : BISECT_ONLY_SKIPPED_LEFT; } return res; } -static enum bisect_error bisect_auto_next(struct bisect_terms *terms, const char *prefix) +static enum bisect_error bisect_auto_next(const char *prefix) { - if (bisect_next_check(terms, NULL)) { - bisect_print_status(terms); + if (bisect_next_check(NULL)) { + bisect_print_status(); return BISECT_OK; } - return bisect_next(terms, prefix); + return bisect_next(prefix); } -static enum bisect_error bisect_start(struct bisect_terms *terms, const char **argv, int argc) +static enum bisect_error bisect_start(const char **argv, int argc) { int no_checkout = 0; int first_parent_only = 0; @@ -698,26 +694,26 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a if (argc <= i) return error(_("'' is not a valid term")); must_write_terms = 1; - free((void *) terms->term_good); - terms->term_good = xstrdup(argv[i]); + free((void *) terms.term_good); + terms.term_good = xstrdup(argv[i]); } else if (skip_prefix(arg, "--term-good=", &arg) || skip_prefix(arg, "--term-old=", &arg)) { must_write_terms = 1; - free((void *) terms->term_good); - terms->term_good = xstrdup(arg); + free((void *) terms.term_good); + terms.term_good = xstrdup(arg); } else if (!strcmp(arg, "--term-bad") || !strcmp(arg, "--term-new")) { i++; if (argc <= i) return error(_("'' is not a valid term")); must_write_terms = 1; - free((void *) terms->term_bad); - terms->term_bad = xstrdup(argv[i]); + free((void *) terms.term_bad); + terms.term_bad = xstrdup(argv[i]); } else if (skip_prefix(arg, "--term-bad=", &arg) || skip_prefix(arg, "--term-new=", &arg)) { must_write_terms = 1; - free((void *) terms->term_bad); - terms->term_bad = xstrdup(arg); + free((void *) terms.term_bad); + terms.term_bad = xstrdup(arg); } else if (starts_with(arg, "--")) { return error(_("unrecognized option: '%s'"), arg); } else if (!get_oidf(&oid, "%s^{commit}", arg)) { @@ -741,10 +737,10 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a must_write_terms = 1; for (i = 0; i < revs.nr; i++) { if (bad_seen) { - string_list_append(&states, terms->term_good); + string_list_append(&states, terms.term_good); } else { bad_seen = 1; - string_list_append(&states, terms->term_bad); + string_list_append(&states, terms.term_bad); } } @@ -829,13 +825,13 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a for (i = 0; i < states.nr; i++) if (bisect_write(states.items[i].string, - revs.items[i].string, terms, 1)) { + revs.items[i].string, 1)) { res = BISECT_FAILED; goto finish; } - if (must_write_terms && write_terms(terms->term_bad, - terms->term_good)) { + if (must_write_terms && write_terms(terms.term_bad, + terms.term_good)) { res = BISECT_FAILED; goto finish; } @@ -852,7 +848,7 @@ finish: if (res) return res; - res = bisect_auto_next(terms, NULL); + res = bisect_auto_next(NULL); if (!is_bisect_success(res)) bisect_clean_state(); return res; @@ -863,7 +859,7 @@ static inline int file_is_not_empty(const char *path) return !is_empty_or_missing_file(path); } -static int bisect_autostart(struct bisect_terms *terms) +static int bisect_autostart(void) { int res; const char *yesno; @@ -885,12 +881,12 @@ 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(empty_strvec, 0); return res; } -static enum bisect_error bisect_state(struct bisect_terms *terms, const char **argv, +static enum bisect_error bisect_state(const char **argv, int argc) { const char *state; @@ -902,18 +898,18 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, const char **a if (!argc) return error(_("Please call `--bisect-state` with at least one argument")); - if (bisect_autostart(terms)) + if (bisect_autostart()) return BISECT_FAILED; state = argv[0]; - if (check_and_set_terms(terms, state) || - !one_of(state, terms->term_good, terms->term_bad, "skip", NULL)) + if (check_and_set_terms(state) || + !one_of(state, terms.term_good, terms.term_bad, "skip", NULL)) return BISECT_FAILED; argv++; argc--; - if (argc > 1 && !strcmp(state, terms->term_bad)) - return error(_("'git bisect %s' can take only one argument."), terms->term_bad); + if (argc > 1 && !strcmp(state, terms.term_bad)) + return error(_("'git bisect %s' can take only one argument."), terms.term_bad); if (argc == 0) { const char *head = "BISECT_HEAD"; @@ -956,7 +952,7 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, const char **a strbuf_release(&buf); for (i = 0; i < revs.nr; i++) { - if (bisect_write(state, oid_to_hex(&revs.oid[i]), terms, 0)) { + if (bisect_write(state, oid_to_hex(&revs.oid[i]), 0)) { oid_array_clear(&revs); return BISECT_FAILED; } @@ -968,7 +964,7 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, const char **a } oid_array_clear(&revs); - return bisect_auto_next(terms, NULL); + return bisect_auto_next(NULL); } static enum bisect_error bisect_log(void) @@ -988,7 +984,7 @@ static enum bisect_error bisect_log(void) return status ? BISECT_FAILED : BISECT_OK; } -static int process_replay_line(struct bisect_terms *terms, struct strbuf *line) +static int process_replay_line(struct strbuf *line) { const char *p = line->buf + strspn(line->buf, " \t"); char *word_end, *rev; @@ -1002,28 +998,28 @@ static int process_replay_line(struct bisect_terms *terms, struct strbuf *line) rev = word_end + strspn(word_end, " \t"); *word_end = '\0'; /* NUL-terminate the word */ - get_terms(terms); - if (check_and_set_terms(terms, p)) + get_terms(); + if (check_and_set_terms(p)) return -1; if (!strcmp(p, "start")) { struct strvec argv = STRVEC_INIT; int res; sq_dequote_to_strvec(rev, &argv); - res = bisect_start(terms, argv.v, argv.nr); + res = bisect_start(argv.v, argv.nr); strvec_clear(&argv); return res; } - if (one_of(p, terms->term_good, - terms->term_bad, "skip", NULL)) - return bisect_write(p, rev, terms, 0); + if (one_of(p, terms.term_good, + terms.term_bad, "skip", NULL)) + return bisect_write(p, rev, 0); if (!strcmp(p, "terms")) { 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(argv.nr == 1 ? argv.v[0] : NULL); strvec_clear(&argv); return res; } @@ -1032,7 +1028,7 @@ 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 enum bisect_error bisect_replay(const char *filename) { FILE *fp = NULL; enum bisect_error res = BISECT_OK; @@ -1049,7 +1045,7 @@ static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *f return BISECT_FAILED; while ((strbuf_getline(&line, fp) != EOF) && !res) - res = process_replay_line(terms, &line); + res = process_replay_line(&line); strbuf_release(&line); fclose(fp); @@ -1057,10 +1053,10 @@ static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *f if (res) return BISECT_FAILED; - return bisect_auto_next(terms, NULL); + return bisect_auto_next(NULL); } -static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **argv, int argc) +static enum bisect_error bisect_skip(const char **argv, int argc) { int i; enum bisect_error res; @@ -1090,19 +1086,19 @@ 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(argv_state.v, argv_state.nr); strvec_clear(&argv_state); return res; } -static int bisect_visualize(struct bisect_terms *terms, const char **argv, int argc) +static int bisect_visualize(const char **argv, int argc) { struct strvec args = STRVEC_INIT; int flags = RUN_COMMAND_NO_STDIN, res = 0; struct strbuf sb = STRBUF_INIT; - if (bisect_next_check(terms, NULL) != 0) + if (bisect_next_check(NULL) != 0) return BISECT_FAILED; if (!argc) { @@ -1141,14 +1137,13 @@ static int get_first_good(const char *refname, const struct object_id *oid, return 1; } -static int verify_good(const struct bisect_terms *terms, - const char **quoted_argv) +static int verify_good(const char **quoted_argv) { int rc; enum bisect_error res; struct object_id good_rev; struct object_id current_rev; - char *good_glob = xstrfmt("%s-*", terms->term_good); + char *good_glob = xstrfmt("%s-*", terms.term_good); int no_checkout = ref_exists("BISECT_HEAD"); for_each_glob_ref_in(get_first_good, good_glob, "refs/bisect/", @@ -1172,7 +1167,7 @@ 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(const char **argv, int argc) { int res = BISECT_OK; struct strbuf command = STRBUF_INIT; @@ -1181,7 +1176,7 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) int temporary_stdout_fd, saved_stdout; int is_first_run = 1; - if (bisect_next_check(terms, NULL)) + if (bisect_next_check(NULL)) return BISECT_FAILED; if (argc) @@ -1205,7 +1200,7 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) * missing or non-executable script. */ if (is_first_run && (res == 126 || res == 127)) { - int rc = verify_good(terms, run_args.v); + int rc = verify_good(run_args.v); is_first_run = 0; if (rc < 0) { error(_("unable to verify '%s' on good" @@ -1230,9 +1225,9 @@ static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) if (res == 125) new_state = "skip"; else if (!res) - new_state = terms->term_good; + new_state = terms.term_good; else - new_state = terms->term_bad; + new_state = terms.term_bad; temporary_stdout_fd = open(git_path_bisect_run(), O_CREAT | O_WRONLY | O_TRUNC, 0666); @@ -1245,7 +1240,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(&new_state, 1); fflush(stdout); dup2(saved_stdout, 1); @@ -1314,7 +1309,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("use ... to automatically bisect"), BISECT_RUN), OPT_END() }; - struct bisect_terms terms = { .term_good = NULL, .term_bad = NULL }; argc = parse_options(argc, argv, prefix, options, git_bisect_helper_usage, @@ -1332,22 +1326,22 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) 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(argc == 1 ? argv[0] : NULL); break; case BISECT_START: - set_terms(&terms, "bad", "good"); - res = bisect_start(&terms, argv, argc); + set_terms("bad", "good"); + res = bisect_start(argv, argc); break; case BISECT_NEXT: if (argc) return error(_("--bisect-next requires 0 arguments")); - get_terms(&terms); - res = bisect_next(&terms, prefix); + get_terms(); + res = bisect_next(prefix); break; case BISECT_STATE: - set_terms(&terms, "bad", "good"); - get_terms(&terms); - res = bisect_state(&terms, argv, argc); + set_terms("bad", "good"); + get_terms(); + res = bisect_state(argv, argc); break; case BISECT_LOG: if (argc) @@ -1357,28 +1351,28 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) case BISECT_REPLAY: if (argc != 1) return error(_("no logfile given")); - set_terms(&terms, "bad", "good"); - res = bisect_replay(&terms, argv[0]); + set_terms("bad", "good"); + res = bisect_replay(argv[0]); break; case BISECT_SKIP: - set_terms(&terms, "bad", "good"); - get_terms(&terms); - res = bisect_skip(&terms, argv, argc); + set_terms("bad", "good"); + get_terms(); + res = bisect_skip(argv, argc); break; case BISECT_VISUALIZE: - get_terms(&terms); - res = bisect_visualize(&terms, argv, argc); + get_terms(); + res = bisect_visualize(argv, argc); break; case BISECT_RUN: if (!argc) return error(_("bisect run failed: no command provided.")); - get_terms(&terms); - res = bisect_run(&terms, argv, argc); + get_terms(); + res = bisect_run(argv, argc); break; default: BUG("unknown subcommand %d", cmdmode); } - free_terms(&terms); + free_terms(); return is_bisect_success(res) ? 0 : -res; } From patchwork Tue Aug 30 18:50:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959695 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 EF223ECAAA1 for ; Tue, 30 Aug 2022 18:50:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229800AbiH3Sul (ORCPT ); Tue, 30 Aug 2022 14:50:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231605AbiH3Sub (ORCPT ); Tue, 30 Aug 2022 14:50:31 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EA17419BE for ; Tue, 30 Aug 2022 11:50:29 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id v7-20020a1cac07000000b003a6062a4f81so10458511wme.1 for ; Tue, 30 Aug 2022 11:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=QDn+yI7bY8uprlyldCcjwOx6A/q3dhJY0o3eVQm211g=; b=Zb1DKgTWoUScEZURrCPdvABV6pLasVBEERPetiP/OnE8qwCqWeFRLMBA33xjUbu+2l 8xXSKP4MjpToqAabjG7Q0shTH61CBnPR4ALRteAa6Vmts+kxuwD8nHfnSpgd4TInhgax 09C6J/MufEmAGUpmlyZ8+mYNS08n23xxurj8s3AyjDB8UMNRWGi4dfaqHVhaAuzTVkds uf+rzjM7sNDsbVAsmPOVqhKYp4kiPixgDV208Sfg5jRpumCWEULNVUrJ6JLr4+dqgne3 iJeZM2Go3qWQFIV38KF14y5XvmhfV6egaPyL0/b7+1f9TL6r5oll6rDRLM1Lbu6I3S/I /iew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=QDn+yI7bY8uprlyldCcjwOx6A/q3dhJY0o3eVQm211g=; b=MYOHOZUA6ojoyYrinMbnNCDhVsGBgZ1Vc2ESrBXvegW+qemJwS5tEIz8S+UFYp7Jxn fzK+Y+v0iD9Sg4/OExYUvwGiamKuRFQCgSTlRPVZh1DlEtDqeq/qnNbtr1/BM/JoS6D1 W3/4/vY9xxmhXroUs9nUT/Gp/OYaNVIAZ6G43BOESr61pCy2IdavhtXGxGjyu0fwn5mg mfH6nZzT3eYgeb6hhec5Kzhp5X0CzdLLpEZ+lpkIIYuux+KfyV9OQDW+bD2BPwX/hgTI qKFMO9iE11DkARj2TrmsTTYmBbnX0ztZL7QD7TcxVDr4ufFOFjn8sCSlP/1H7atbzUbp I4HA== X-Gm-Message-State: ACgBeo32y/wfMla6KHCjJ1OAjc3uDFjNEXGVCb2cKpL2bI2NSkK1UZho 51OBXF/A2bOyK90KZ4++fwzUY53szBM= X-Google-Smtp-Source: AA6agR5gG7aCZT3H3LKUsd5i1Cb54hgiysq2GxpZOUD3lFZrm6LI8QRy5iARwroZIjOC1BYRHKbBTQ== X-Received: by 2002:a05:600c:1c16:b0:3a6:b11:79be with SMTP id j22-20020a05600c1c1600b003a60b1179bemr10262550wms.203.1661885427858; Tue, 30 Aug 2022 11:50:27 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id p17-20020a5d6391000000b0022511d35d5bsm10601861wru.12.2022.08.30.11.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:27 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:09 +0000 Subject: [PATCH v6 06/16] bisect--helper: make the order consistently `argc, argv` Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin In C, the natural order is for `argc` to come before `argv` by virtue of the `main()` function declaring the parameters in precisely that order. It is confusing & distracting, then, when readers familiar with the C language read code where that order is switched around. Let's just change the order and avoid that type of developer friction. Signed-off-by: Johannes Schindelin --- builtin/bisect--helper.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 7f4e8e707c1..0d7cc20f9c9 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -652,7 +652,7 @@ static enum bisect_error bisect_auto_next(const char *prefix) return bisect_next(prefix); } -static enum bisect_error bisect_start(const char **argv, int argc) +static enum bisect_error bisect_start(int argc, const char **argv) { int no_checkout = 0; int first_parent_only = 0; @@ -881,13 +881,12 @@ static int bisect_autostart(void) yesno = git_prompt(_("Do you want me to do it for you " "[Y/n]? "), PROMPT_ECHO); res = tolower(*yesno) == 'n' ? - -1 : bisect_start(empty_strvec, 0); + -1 : bisect_start(0, empty_strvec); return res; } -static enum bisect_error bisect_state(const char **argv, - int argc) +static enum bisect_error bisect_state(int argc, const char **argv) { const char *state; int i, verify_expected = 1; @@ -1006,7 +1005,7 @@ static int process_replay_line(struct strbuf *line) struct strvec argv = STRVEC_INIT; int res; sq_dequote_to_strvec(rev, &argv); - res = bisect_start(argv.v, argv.nr); + res = bisect_start(argv.nr, argv.v); strvec_clear(&argv); return res; } @@ -1056,7 +1055,7 @@ static enum bisect_error bisect_replay(const char *filename) return bisect_auto_next(NULL); } -static enum bisect_error bisect_skip(const char **argv, int argc) +static enum bisect_error bisect_skip(int argc, const char **argv) { int i; enum bisect_error res; @@ -1086,13 +1085,13 @@ static enum bisect_error bisect_skip(const char **argv, int argc) strvec_push(&argv_state, argv[i]); } } - res = bisect_state(argv_state.v, argv_state.nr); + res = bisect_state(argv_state.nr, argv_state.v); strvec_clear(&argv_state); return res; } -static int bisect_visualize(const char **argv, int argc) +static int bisect_visualize(int argc, const char **argv) { struct strvec args = STRVEC_INIT; int flags = RUN_COMMAND_NO_STDIN, res = 0; @@ -1167,7 +1166,7 @@ static int verify_good(const char **quoted_argv) return rc; } -static int bisect_run(const char **argv, int argc) +static int bisect_run(int argc, const char **argv) { int res = BISECT_OK; struct strbuf command = STRBUF_INIT; @@ -1240,7 +1239,7 @@ static int bisect_run(const char **argv, int argc) saved_stdout = dup(1); dup2(temporary_stdout_fd, 1); - res = bisect_state(&new_state, 1); + res = bisect_state(1, &new_state); fflush(stdout); dup2(saved_stdout, 1); @@ -1330,7 +1329,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) break; case BISECT_START: set_terms("bad", "good"); - res = bisect_start(argv, argc); + res = bisect_start(argc, argv); break; case BISECT_NEXT: if (argc) @@ -1341,7 +1340,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) case BISECT_STATE: set_terms("bad", "good"); get_terms(); - res = bisect_state(argv, argc); + res = bisect_state(argc, argv); break; case BISECT_LOG: if (argc) @@ -1357,17 +1356,17 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) case BISECT_SKIP: set_terms("bad", "good"); get_terms(); - res = bisect_skip(argv, argc); + res = bisect_skip(argc, argv); break; case BISECT_VISUALIZE: get_terms(); - res = bisect_visualize(argv, argc); + res = bisect_visualize(argc, argv); break; case BISECT_RUN: if (!argc) return error(_("bisect run failed: no command provided.")); get_terms(); - res = bisect_run(argv, argc); + res = bisect_run(argc, argv); break; default: BUG("unknown subcommand %d", cmdmode); From patchwork Tue Aug 30 18:50:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959697 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 71B9BECAAD5 for ; Tue, 30 Aug 2022 18:50:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231673AbiH3Su4 (ORCPT ); Tue, 30 Aug 2022 14:50:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230257AbiH3Sue (ORCPT ); Tue, 30 Aug 2022 14:50:34 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDB56422EF for ; Tue, 30 Aug 2022 11:50:29 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id k9so15450952wri.0 for ; Tue, 30 Aug 2022 11:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=ub6wLdNKCxd3Sa3lNOs19ADffiW6UMuJjsfs+kwUSHQ=; b=RYeVGFdryGmx+BD20EWO9JqgMfJxOAHFfE0izExdOQt6S8luUQg/9RLzblA5bW6OXK VP2D/7f69ITsBctcH2lTur2fLVfyfEY+6SFuMehYOQWgip/n4hgST0h9Yc0+MWeCc4AA 1VWZFYK/aqykuVug2XPJIRY1+ZYU4PVnwDdcrGOhZ+26AzhBChB/4nB41LEHhtR9Hwyl y2Yqh8AMiUYGNI3R6uVrEfGsDGBlX3dzmvxsEF61i37aH3g+vOtftYuKL+YljzfJL+NX aKfBF28c54qHIgiFtD/Zs2Xh4pIxBukJuZPsMU8sSm+EznjUXHmw9ZcdhlrlJYvmUK70 DADw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=ub6wLdNKCxd3Sa3lNOs19ADffiW6UMuJjsfs+kwUSHQ=; b=VS5ck/ZBIt+uHfSntyeCldz/QRkWUFz7Kjqnm3Cks9SBldtecrLEP3tmGqYQFpkkBj uHHxTqZVqpUkYjsjly/rlmEEqZ+8zeaIv5Bqb/xFJSMWfuEQRpOWwsE8zeew1ORmK4Hr bnGuAMwql08IE+a7iUzvwV5NihJ9vsjS1LTj5AqClvOcKCB0WS/p1i3ZJ+0rdkDKa/Hd xGnbKK2CFA7SWFDwRRdJo2V1jxE07L6NBy1h4VI5Ook9calPeubW2E6zNAVZV4egpqZI M27XqEm5PzkStSReBvBICpUMGUYb/+DsgEK6ZF7l8xFJ+NW0Hw6d8H9jLLXknJjnFLML J5qA== X-Gm-Message-State: ACgBeo3wC/wAwTGuV/qHUIe6+YTFbZpBhmupBYCAZ0avsrYey761eT3q wSZdrS8hxMiQomIKR6rS3K66b1pvbN8= X-Google-Smtp-Source: AA6agR5Nl3RNNgMAUqOzNYhQItKKfU14bxmgrgAmmJ+PH9vJpTeo9f/nbuKhIqUw2uijvktkboLKOw== X-Received: by 2002:a05:6000:1f99:b0:226:ded3:3a38 with SMTP id bw25-20020a0560001f9900b00226ded33a38mr4844438wrb.340.1661885428884; Tue, 30 Aug 2022 11:50:28 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id b16-20020a05600c4e1000b003a5ad7f6de2sm13234764wmq.15.2022.08.30.11.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:28 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:10 +0000 Subject: [PATCH v6 07/16] bisect--helper: migrate to OPT_SUBCOMMAND() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin We just introduced a new way to process subcommands, and the `bisect--helper` learns about it in preparation for replacing the `git-bisect.sh` script altogether. As a consequence, the usage strings are copied over from the scripted version of the `git bisect` command. To avoid regressing on 959d670d1a4 (i18n: remove from i18n strings that do not hold translatable parts, 2022-01-31), we specifically do not enclose usage strings in `N_(...)` that do not contain any translatable parts. Note that a couple of `bisect_*()` functions are not converted into `cmd_bisect_*()` functions directly, as they have callers other than the `OPT_SUBCOMMAND()` one (and the original functions did not expect a subcommand name to be passed as `argv[0]`, unlike the convention for the `cmd_*()` functions. In those cases, we introduce wrapper functions `cmd_*()` that also call the original function. Signed-off-by: Johannes Schindelin --- builtin/bisect--helper.c | 462 +++++++++++++++++++++++---------------- git-bisect.sh | 20 +- 2 files changed, 288 insertions(+), 194 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 0d7cc20f9c9..56d900c3d3c 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -20,18 +20,71 @@ 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 ..."), +static const char * const bisect_usage[] = { + N_("git bisect start [--term-{new,bad}= --term-{old,good}=]" + " [--no-checkout] [--first-parent] [ [...]] [--]" + " [...]"), + N_("git bisect (bad|new) []"), + N_("git bisect (good|old) [...]"), + "git bisect terms [--term-good | --term-bad]", + N_("git bisect skip [(|)...]"), + "git bisect next", + N_("git bisect reset []"), + "git bisect (visualize|view)", + N_("git bisect replay "), + "git bisect log", + N_("git bisect run ..."), + NULL +}; + +static const char * const bisect_start_usage[] = { + N_("git bisect start [--term-{new,bad}= --term-{old,good}=]" + " [--no-checkout] [--first-parent] [ [...]] [--]" + " [...]"), + NULL +}; +static const char * const bisect_state_usage[] = { + N_("git bisect (good|bad) [...]"), + NULL +}; + +static const char * const bisect_terms_usage[] = { + "git bisect terms [--term-good | --term-bad]", + NULL +}; + +static const char * const bisect_skip_usage[] = { + N_("git bisect skip [(|)...]"), + NULL +}; + +static const char * const bisect_next_usage[] = { + "git bisect next", + NULL +}; + +static const char * const bisect_reset_usage[] = { + N_("git bisect reset []"), + NULL +}; + +static const char * const bisect_visualize_usage[] = { + "git bisect visualize", + NULL +}; + +static const char * const bisect_replay_usage[] = { + N_("git bisect replay "), + NULL +}; + +static const char * const bisect_log_usage[] = { + "git bisect log", + NULL +}; + +static const char * const bisect_run_usage[] = { + N_("git bisect run ..."), NULL }; @@ -63,7 +116,7 @@ static void set_terms(const char *bad, static const char vocab_bad[] = "bad|new"; static const char vocab_good[] = "good|old"; -static int bisect_autostart(void); +static int bisect_autostart(const char *prefix); /* * Check whether the string `term` belongs to the set of strings @@ -238,6 +291,21 @@ static int bisect_reset(const char *commit) return bisect_clean_state(); } +static int cmd_bisect_reset(int argc, const char **argv, const char *prefix) +{ + struct option options[] = { + OPT_END() + }; + argc = parse_options(argc, argv, prefix, options, + bisect_reset_usage, PARSE_OPT_STOP_AT_NON_OPTION); + + if (argc > 1) + usage_msg_opt(_("requires either no argument or a commit"), + bisect_reset_usage, options); + + return bisect_reset(argc == 1 ? argv[0] : NULL); +} + static void log_commit(FILE *fp, char *fmt, const char *state, struct commit *commit) { @@ -465,26 +533,41 @@ finish: return res; } -static int bisect_terms(const char *option) +static int cmd_bisect_terms(int argc, const char **argv, const char *prefix) { + int mode = -1; + struct option options[] = { + OPT_SET_INT(0, "term-good", &mode, + N_("show term for good/old"), 1), + OPT_SET_INT(0, "term-old", &mode, + N_("show term for good/old"), 1), + OPT_SET_INT(0, "term-bad", &mode, + N_("show term for bad/new"), 0), + OPT_SET_INT(0, "term-new", &mode, + N_("show term for bad/new"), 0), + OPT_END() + }; + + argc = parse_options(argc, argv, prefix, options, + bisect_terms_usage, PARSE_OPT_STOP_AT_NON_OPTION); + + if (argc > 1) + usage_msg_opt(_("terms: requires 0 or 1 argument"), + bisect_terms_usage, options); + if (get_terms()) return error(_("no terms defined")); - if (!option) { + if (mode < 0) { printf(_("Your current terms are %s for the old state\n" "and %s for the new state.\n"), terms.term_good, terms.term_bad); return 0; } - if (one_of(option, "--term-good", "--term-old", NULL)) + if (mode == 1) printf("%s\n", terms.term_good); - else if (one_of(option, "--term-bad", "--term-new", NULL)) - printf("%s\n", terms.term_bad); else - return error(_("invalid argument %s for 'git bisect terms'.\n" - "Supported options are: " - "--term-good|--term-old and " - "--term-bad|--term-new."), option); + printf("%s\n", terms.term_bad); return 0; } @@ -623,7 +706,7 @@ static enum bisect_error bisect_next(const char *prefix) { enum bisect_error res; - if (bisect_autostart()) + if (bisect_autostart(prefix)) return BISECT_FAILED; if (bisect_next_check(terms.term_good)) @@ -642,6 +725,24 @@ static enum bisect_error bisect_next(const char *prefix) return res; } +static int cmd_bisect_next(int argc, const char **argv, const char *prefix) +{ + struct option options[] = { + OPT_END() + }; + + get_terms(); + argc = parse_options(argc, argv, prefix, options, + bisect_next_usage, + PARSE_OPT_STOP_AT_NON_OPTION); + + if (argc > 0) + usage_msg_opt(_("requires 0 argument"), + bisect_next_usage, options); + + return bisect_next(prefix); +} + static enum bisect_error bisect_auto_next(const char *prefix) { if (bisect_next_check(NULL)) { @@ -652,8 +753,9 @@ static enum bisect_error bisect_auto_next(const char *prefix) return bisect_next(prefix); } -static enum bisect_error bisect_start(int argc, const char **argv) +static int cmd_bisect_start(int argc, const char **argv, const char *prefix) { + struct strvec orig_argv = STRVEC_INIT; int no_checkout = 0; int first_parent_only = 0; int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0; @@ -665,66 +767,64 @@ static enum bisect_error bisect_start(int argc, const char **argv) struct strbuf bisect_names = STRBUF_INIT; struct object_id head_oid; struct object_id oid; - const char *head; + const char *head, *term_good = NULL, *term_bad = NULL; + struct option options[] = { + OPT_BOOL(0, "no-checkout", &no_checkout, + N_("do not update worktree")), + OPT_BOOL(0, "first-parent", &first_parent_only, + N_("follow only first parent of merge commits")), + OPT_STRING(0, "term-good", &term_good, N_("term"), + N_("use this term instead of 'good'")), + OPT_STRING(0, "term-bad", &term_bad, N_("term"), + N_("use this term instead of 'bad'")), + OPT_STRING(0, "term-old", &term_good, N_("term"), + N_("use this term instead of 'good'")), + OPT_STRING(0, "term-new", &term_bad, N_("term"), + N_("use this term instead of 'bad'")), + OPT_END() + }; + + set_terms("bad", "good"); if (is_bare_repository()) no_checkout = 1; - /* - * Check for one bad and then some good revisions - */ - for (i = 0; i < argc; i++) { + strvec_pushv(&orig_argv, argv); /* save the command-line for logging */ + argc = parse_options(argc, argv, prefix, options, bisect_start_usage, + PARSE_OPT_KEEP_DASHDASH); + + if (term_good) { + free(terms.term_good); + terms.term_good = xstrdup(term_good); + must_write_terms = 1; + } + + if (term_bad) { + free(terms.term_bad); + terms.term_bad = xstrdup(term_bad); + must_write_terms = 1; + } + + for (i = 0; i < argc; i++) if (!strcmp(argv[i], "--")) { has_double_dash = 1; break; } - } - for (i = 0; i < argc; i++) { - const char *arg = argv[i]; - if (!strcmp(argv[i], "--")) { - break; - } else if (!strcmp(arg, "--no-checkout")) { - no_checkout = 1; - } else if (!strcmp(arg, "--first-parent")) { - first_parent_only = 1; - } else if (!strcmp(arg, "--term-good") || - !strcmp(arg, "--term-old")) { - i++; - if (argc <= i) - return error(_("'' is not a valid term")); - must_write_terms = 1; - free((void *) terms.term_good); - terms.term_good = xstrdup(argv[i]); - } else if (skip_prefix(arg, "--term-good=", &arg) || - skip_prefix(arg, "--term-old=", &arg)) { - must_write_terms = 1; - free((void *) terms.term_good); - terms.term_good = xstrdup(arg); - } else if (!strcmp(arg, "--term-bad") || - !strcmp(arg, "--term-new")) { - i++; - if (argc <= i) - return error(_("'' is not a valid term")); - must_write_terms = 1; - free((void *) terms.term_bad); - terms.term_bad = xstrdup(argv[i]); - } else if (skip_prefix(arg, "--term-bad=", &arg) || - skip_prefix(arg, "--term-new=", &arg)) { - must_write_terms = 1; - free((void *) terms.term_bad); - terms.term_bad = xstrdup(arg); - } else if (starts_with(arg, "--")) { - return error(_("unrecognized option: '%s'"), arg); - } else if (!get_oidf(&oid, "%s^{commit}", arg)) { + /* + * Check for one bad and then some good revisions + */ + + for (i = 0; i < argc && strcmp(argv[i], "--"); i++) + if (!get_oidf(&oid, "%s^{commit}", argv[i])) { string_list_append(&revs, oid_to_hex(&oid)); } else if (has_double_dash) { die(_("'%s' does not appear to be a valid " - "revision"), arg); + "revision"), argv[i]); } else { break; } - } + pathspec_pos = i; /* @@ -836,11 +936,13 @@ static enum bisect_error bisect_start(int argc, const char **argv) goto finish; } - res = bisect_append_log_quoted(argv); + res = bisect_append_log_quoted(orig_argv.v + 1); if (res) res = BISECT_FAILED; finish: + strvec_clear(&orig_argv); + string_list_clear(&revs, 0); string_list_clear(&states, 0); strbuf_release(&start_head); @@ -848,7 +950,7 @@ finish: if (res) return res; - res = bisect_auto_next(NULL); + res = bisect_auto_next(prefix); if (!is_bisect_success(res)) bisect_clean_state(); return res; @@ -859,7 +961,7 @@ static inline int file_is_not_empty(const char *path) return !is_empty_or_missing_file(path); } -static int bisect_autostart(void) +static int bisect_autostart(const char *prefix) { int res; const char *yesno; @@ -881,12 +983,13 @@ static int bisect_autostart(void) yesno = git_prompt(_("Do you want me to do it for you " "[Y/n]? "), PROMPT_ECHO); res = tolower(*yesno) == 'n' ? - -1 : bisect_start(0, empty_strvec); + -1 : cmd_bisect_start(1, &yesno, prefix); return res; } -static enum bisect_error bisect_state(int argc, const char **argv) +static enum bisect_error bisect_state(int argc, const char **argv, + const char *prefix) { const char *state; int i, verify_expected = 1; @@ -894,10 +997,8 @@ static enum bisect_error bisect_state(int argc, const char **argv) struct strbuf buf = STRBUF_INIT; struct oid_array revs = OID_ARRAY_INIT; - if (!argc) - return error(_("Please call `--bisect-state` with at least one argument")); - if (bisect_autostart()) + if (bisect_autostart(prefix)) return BISECT_FAILED; state = argv[0]; @@ -966,11 +1067,41 @@ static enum bisect_error bisect_state(int argc, const char **argv) return bisect_auto_next(NULL); } -static enum bisect_error bisect_log(void) +static int cmd_bisect_state(int argc, const char **argv, + const char *prefix) { + struct option options[] = { + OPT_END() + }; + + set_terms("bad", "good"); + get_terms(); + + argc = parse_options(argc, argv, prefix, options, + bisect_state_usage, PARSE_OPT_STOP_AT_NON_OPTION); + + if (!argc) + usage_msg_opt(_("need at least one argument"), + bisect_state_usage, options); + + return bisect_state(argc, argv, prefix); +} + +static int cmd_bisect_log(int argc, const char **argv, const char *prefix) +{ + struct option options[] = { + OPT_END() + }; int fd, status; const char* filename = git_path_bisect_log(); + argc = parse_options(argc, argv, prefix, options, + bisect_log_usage, PARSE_OPT_STOP_AT_NON_OPTION); + + if (argc > 0) + usage_msg_opt(_("require 0 argument"), bisect_log_usage, + options); + if (is_empty_or_missing_file(filename)) return error(_("We are not bisecting.")); @@ -983,7 +1114,7 @@ static enum bisect_error bisect_log(void) return status ? BISECT_FAILED : BISECT_OK; } -static int process_replay_line(struct strbuf *line) +static int process_replay_line(struct strbuf *line, const char *prefix) { const char *p = line->buf + strspn(line->buf, " \t"); char *word_end, *rev; @@ -1004,8 +1135,10 @@ static int process_replay_line(struct strbuf *line) if (!strcmp(p, "start")) { struct strvec argv = STRVEC_INIT; int res; + + strvec_push(&argv, p); sq_dequote_to_strvec(rev, &argv); - res = bisect_start(argv.nr, argv.v); + res = cmd_bisect_start(argv.nr, argv.v, prefix); strvec_clear(&argv); return res; } @@ -1017,8 +1150,11 @@ static int process_replay_line(struct strbuf *line) if (!strcmp(p, "terms")) { struct strvec argv = STRVEC_INIT; int res; + + strvec_push(&argv, p); sq_dequote_to_strvec(rev, &argv); - res = bisect_terms(argv.nr == 1 ? argv.v[0] : NULL); + res = cmd_bisect_terms(argv.nr, argv.v, NULL); + strvec_clear(&argv); return res; } @@ -1027,12 +1163,25 @@ static int process_replay_line(struct strbuf *line) return -1; } -static enum bisect_error bisect_replay(const char *filename) +static int cmd_bisect_replay(int argc, const char **argv, const char *prefix) { + struct option options[] = { + OPT_END() + }; + const char *filename; FILE *fp = NULL; enum bisect_error res = BISECT_OK; struct strbuf line = STRBUF_INIT; + set_terms("bad", "good"); + argc = parse_options(argc, argv, prefix, options, + bisect_reset_usage, PARSE_OPT_STOP_AT_NON_OPTION); + + if (argc != 1) + usage_msg_opt(_("no logfile given"), bisect_replay_usage, + options); + + filename = argv[0]; if (is_empty_or_missing_file(filename)) return error(_("cannot read file '%s' for replaying"), filename); @@ -1044,7 +1193,7 @@ static enum bisect_error bisect_replay(const char *filename) return BISECT_FAILED; while ((strbuf_getline(&line, fp) != EOF) && !res) - res = process_replay_line(&line); + res = process_replay_line(&line, prefix); strbuf_release(&line); fclose(fp); @@ -1055,12 +1204,20 @@ static enum bisect_error bisect_replay(const char *filename) return bisect_auto_next(NULL); } -static enum bisect_error bisect_skip(int argc, const char **argv) +static int cmd_bisect_skip(int argc, const char **argv, const char *prefix) { + struct option options[] = { + OPT_END() + }; int i; enum bisect_error res; struct strvec argv_state = STRVEC_INIT; + set_terms("bad", "good"); + get_terms(); + argc = parse_options(argc, argv, prefix, options, + bisect_skip_usage, PARSE_OPT_STOP_AT_NON_OPTION); + strvec_push(&argv_state, "skip"); for (i = 0; i < argc; i++) { @@ -1085,18 +1242,28 @@ static enum bisect_error bisect_skip(int argc, const char **argv) strvec_push(&argv_state, argv[i]); } } - res = bisect_state(argv_state.nr, argv_state.v); + res = bisect_state(argv_state.nr, argv_state.v, prefix); strvec_clear(&argv_state); return res; } -static int bisect_visualize(int argc, const char **argv) +static int cmd_bisect_visualize(int argc, const char **argv, const char *prefix) { + struct option options[] = { + OPT_END() + }; struct strvec args = STRVEC_INIT; int flags = RUN_COMMAND_NO_STDIN, res = 0; struct strbuf sb = STRBUF_INIT; + set_terms("bad", "good"); + get_terms(); + argc = parse_options(argc, argv, prefix, options, + bisect_visualize_usage, + PARSE_OPT_KEEP_DASHDASH | + PARSE_OPT_KEEP_UNKNOWN_OPT); + if (bisect_next_check(NULL) != 0) return BISECT_FAILED; @@ -1166,8 +1333,11 @@ static int verify_good(const char **quoted_argv) return rc; } -static int bisect_run(int argc, const char **argv) +static int cmd_bisect_run(int argc, const char **argv, const char *prefix) { + struct option options[] = { + OPT_END() + }; int res = BISECT_OK; struct strbuf command = STRBUF_INIT; struct strvec run_args = STRVEC_INIT; @@ -1175,15 +1345,18 @@ static int bisect_run(int argc, const char **argv) int temporary_stdout_fd, saved_stdout; int is_first_run = 1; + get_terms(); + argc = parse_options(argc, argv, prefix, options, + bisect_run_usage, PARSE_OPT_STOP_AT_NON_OPTION); + if (bisect_next_check(NULL)) return BISECT_FAILED; if (argc) sq_quote_argv(&command, argv); - else { - error(_("bisect run failed: no command provided.")); - return BISECT_FAILED; - } + else + usage_msg_opt(_("bisect run failed: no command provided."), + bisect_run_usage, options); strvec_push(&run_args, command.buf); @@ -1239,7 +1412,7 @@ static int bisect_run(int argc, const char **argv) saved_stdout = dup(1); dup2(temporary_stdout_fd, 1); - res = bisect_state(1, &new_state); + res = bisect_state(1, &new_state, prefix); fflush(stdout); dup2(saved_stdout, 1); @@ -1272,105 +1445,26 @@ static int bisect_run(int argc, const char **argv) 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; + parse_opt_subcommand_fn *fn = NULL; int res = 0; 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_SUBCOMMAND("reset", &fn, cmd_bisect_reset), + OPT_SUBCOMMAND("terms", &fn, cmd_bisect_terms), + OPT_SUBCOMMAND("start", &fn, cmd_bisect_start), + OPT_SUBCOMMAND("next", &fn, cmd_bisect_next), + OPT_SUBCOMMAND("state", &fn, cmd_bisect_state), + OPT_SUBCOMMAND("log", &fn, cmd_bisect_log), + OPT_SUBCOMMAND("replay", &fn, cmd_bisect_replay), + OPT_SUBCOMMAND("skip", &fn, cmd_bisect_skip), + OPT_SUBCOMMAND("visualize", &fn, cmd_bisect_visualize), + OPT_SUBCOMMAND("run", &fn, cmd_bisect_run), OPT_END() }; argc = parse_options(argc, argv, prefix, options, - git_bisect_helper_usage, - PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_UNKNOWN_OPT); - - if (!cmdmode) - usage_with_options(git_bisect_helper_usage, options); + bisect_usage, 0); - switch (cmdmode) { - case BISECT_RESET: - if (argc > 1) - return error(_("--bisect-reset requires either no argument or a commit")); - res = bisect_reset(argc ? argv[0] : NULL); - break; - case BISECT_TERMS: - if (argc > 1) - return error(_("--bisect-terms requires 0 or 1 argument")); - res = bisect_terms(argc == 1 ? argv[0] : NULL); - break; - case BISECT_START: - set_terms("bad", "good"); - res = bisect_start(argc, argv); - break; - case BISECT_NEXT: - if (argc) - return error(_("--bisect-next requires 0 arguments")); - get_terms(); - res = bisect_next(prefix); - break; - case BISECT_STATE: - set_terms("bad", "good"); - get_terms(); - res = bisect_state(argc, argv); - break; - case BISECT_LOG: - if (argc) - return error(_("--bisect-log requires 0 arguments")); - res = bisect_log(); - break; - case BISECT_REPLAY: - if (argc != 1) - return error(_("no logfile given")); - set_terms("bad", "good"); - res = bisect_replay(argv[0]); - break; - case BISECT_SKIP: - set_terms("bad", "good"); - get_terms(); - res = bisect_skip(argc, argv); - break; - case BISECT_VISUALIZE: - get_terms(); - res = bisect_visualize(argc, argv); - break; - case BISECT_RUN: - if (!argc) - return error(_("bisect run failed: no command provided.")); - get_terms(); - res = bisect_run(argc, argv); - break; - default: - BUG("unknown subcommand %d", cmdmode); - } + res = fn(argc, argv, prefix); free_terms(); return is_bisect_success(res) ? 0 : -res; 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 From patchwork Tue Aug 30 18:50:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959698 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 9208EECAAA1 for ; Tue, 30 Aug 2022 18:51:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230093AbiH3Su7 (ORCPT ); Tue, 30 Aug 2022 14:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231485AbiH3Sue (ORCPT ); Tue, 30 Aug 2022 14:50:34 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3001C45F43 for ; Tue, 30 Aug 2022 11:50:31 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id m16so15382318wru.9 for ; Tue, 30 Aug 2022 11:50:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=vJ/hCck+XaBNHDW9f2+pkxNta44cpypydrMCRFEptu8=; b=GxYPbP4vOOVYZCDqm6EcsZ26hCBJJtYJ1ruPXR0r2fub0nrpvFT81DzPkFSuM8t/wr QPZWc5r/ssjOOPIfbfmb0FT0vKye7c7OkZ5CkikjL975vqlQw5iyNfh2ZmXtdSCheBHi Wr0rX6kZQ2iiXPqktvWIZRN+ZdnGpNDNn0lYzCgfFgzlo4g8EF1q8rOmznE/N0L9L+rY RT4B5p5dG8y41FRL4Yh4FS6FbeKaM3BLTZ3w0HnyHypo2wrMc/VMg3eNYkvZm3Ba5Gp8 r3+Kg4hDbTPxXFwSLO5sPUt503rMwJJJxPg/q/djwMZvxb4qjREm9YDCXlnma2LYpP3Y VXig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=vJ/hCck+XaBNHDW9f2+pkxNta44cpypydrMCRFEptu8=; b=6dmrDd0IxOwjVE1zgchN75tEeqvKkrEJ1C9bJ2MijYxi0TIPHOVl/DSoMt5sdDrIfx YACiSop3ckcrWoXfO8JulBerjMwmXh5+MkHH+kj7tZKIujfANh6WtxbtboKk4WEE8Io8 lECXHIQVe74TgrPGrhfXeg0mDLvgLLxBYr9/G5rqM3Pb+Q6Dw/sC+a4KoFBMDu4sFBa/ TS3e8gIL9Bt2bU/XKkIPLMU4KAQb7o04c0mO/zGyOWPm5hOcpd+f5D3NhEqQYgtj6XQq kry85lvBDz6TsZOmRh1McNwk3fFmBJ6a5lofdGRiTtWjXEZfexeEWmk2xsa1ByR0BN1L 2m7Q== X-Gm-Message-State: ACgBeo3LR+3/uarAVvOEytOsXQNTpyv6CmrXbq8E/DRws3cXXZlZFXs6 oLaRYn0ijUhGYI7LpQCr2qT1F8qDciE= X-Google-Smtp-Source: AA6agR7keGNgmkTpLYYKSoxCUYu7HievzJCWmIkIMA41xyouoMLQdUzZMMcLkWsL1D/ZtjzUD6jmDg== X-Received: by 2002:a05:6000:1e1e:b0:226:e5c9:4b08 with SMTP id bj30-20020a0560001e1e00b00226e5c94b08mr2303985wrb.648.1661885430142; Tue, 30 Aug 2022 11:50:30 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l14-20020adfe58e000000b0022377df817fsm10149727wrm.58.2022.08.30.11.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:29 -0700 (PDT) Message-Id: <30c87f2e92eacd315cf2ade6d704cdb03ef17a84.1661885419.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:11 +0000 Subject: [PATCH v6 08/16] bisect: verify that a bogus option won't try to start a bisection Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin We do not want `git bisect --bogus-option` to start a bisection. To verify that, we look for the tell-tale error message `You need to start by "git bisect start"` and fail if it was found. Signed-off-by: Johannes Schindelin --- t/t6030-bisect-porcelain.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 83931d482fb..6d6e72276ae 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -900,6 +900,16 @@ test_expect_success 'bisect start with one term1 and term2' ' git bisect reset ' +test_expect_success 'bogus command does not start bisect' ' + git bisect reset && + test_must_fail git bisect --bisect-terms 1 2 2>out && + ! grep "You need to start" out && + test_must_fail git bisect --bisect-terms 2>out && + ! grep "You need to start" out && + grep "git bisect.*visualize" out && + git bisect reset +' + test_expect_success 'bisect replay with term1 and term2' ' git bisect replay log_to_replay.txt >bisect_result && grep "$HASH2 is the first term1 commit" bisect_result && From patchwork Tue Aug 30 18:50:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959699 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 B1208ECAAD5 for ; Tue, 30 Aug 2022 18:51:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231640AbiH3SvD (ORCPT ); Tue, 30 Aug 2022 14:51:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229607AbiH3Suu (ORCPT ); Tue, 30 Aug 2022 14:50:50 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD8784330A for ; Tue, 30 Aug 2022 11:50:33 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id k6-20020a05600c1c8600b003a54ecc62f6so6678514wms.5 for ; Tue, 30 Aug 2022 11:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=feDvPsKx77Bi4ul4KWxYeI7P3pgcGlJwNEU0p2xe7Zs=; b=Z+UNhmys5XeT89PWnv82QCk61n9f+A54uKsT8vfVvJmWlnI8BbCkfkzkj+Q+SFsrDK yj5ewlD8Y9lHRygi3/nYJ0fmpV8gtlqvg4q7XpBF9wHZcqGkdfd0vjzSsiceMt4KI7S1 TbjZsyedgO1jvpTHSy6n6o+KDJGZSXi8veoU3XHCgPiLGZYPGWXzqbiy2hYRLuCMDjxh rC5C7y3o0v5ASqR9wNEtMIRzr8Nc1nfUmZ7AJeEnwey8AqZJUXNykkWAT0VbpOjUY6KE Yu7/Kh8+Xp6QaAUxtcFcHO2K4J9FyrucF5ZDOoz9sZuXzEpp4XsVoluuTIsADN2afmoy UOlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=feDvPsKx77Bi4ul4KWxYeI7P3pgcGlJwNEU0p2xe7Zs=; b=1LIaT8lNJJrwfmEvSvep1ID70iNsiPq8olrPGgqf93BABqqTu4cCVhrXgwZQ/UwWzm 6lt7jTlzCUEP2/mANQkKmFDDR4R0cuykDLgB2XSJaVNqZUxiAiHtm6cLvK2V29+gfnem o0ChPv5Iwp2JgocMvVomQTaXHSrFGA8GkMK6DfZECq+9THiBHxlfsS11DEdoL/3+p6Tr /i2FMqTbGiBK0waLAzonBFj2umW7vqQy7iRWLeGXXiFLVLyq0BVePvA18bhKbdEs5BRv 7bA+N+b9m0CgoYSUfII+hsqmLt56JGwocsIkYf1vERLGEip8UewongF4kNlfGWs6ZVnt VPSQ== X-Gm-Message-State: ACgBeo2H4k7b+BQ7WYxZCxo8UKPX1P1wZ8p7WFZ6YOZroFvecibza+dq blAmLGR9160nVa9G9AskwXzdoF6tpZU= X-Google-Smtp-Source: AA6agR6E/n91S3I1yPn6y5fGdCN60P9iDQN+bnhsyN0cJUv4nmHY60xaw0QxGoQxBi0CaEUTXiuiMw== X-Received: by 2002:a1c:7414:0:b0:3a5:fd9e:e629 with SMTP id p20-20020a1c7414000000b003a5fd9ee629mr10839097wmc.194.1661885432041; Tue, 30 Aug 2022 11:50:32 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id e14-20020adfef0e000000b0021d6924b777sm5669888wro.115.2022.08.30.11.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:31 -0700 (PDT) Message-Id: <4696652b99ce05bece8e3abd10620aa4e4bba7c5.1661885419.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:12 +0000 Subject: [PATCH v6 09/16] bisect run: fix the error message Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin In d1bbbe45df8 (bisect--helper: reimplement `bisect_run` shell function in C, 2021-09-13), we ported the `bisect run` subcommand to C, including the part that prints out an error message when the implicit `git bisect bad` or `git bisect good` failed. However, the error message was supposed to print out whether the state was "good" or "bad", but used a bogus (because non-populated) `args` variable for it. This was fixed in 80c2e9657f2 (bisect--helper: report actual bisect_state() argument on error, 2022-01-18), but the error message still talks about `bisect--helper`, which is an implementation detail that should not concern end users. Fix that, and add a regression test to ensure that the intended form of the error message. Helped-by: Elijah Newren Signed-off-by: Johannes Schindelin --- builtin/bisect--helper.c | 2 +- t/t6030-bisect-porcelain.sh | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 56d900c3d3c..ba4aa8059cb 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1430,7 +1430,7 @@ static int cmd_bisect_run(int argc, const char **argv, const char *prefix) printf(_("bisect found first bad commit")); res = BISECT_OK; } else if (res) { - error(_("bisect run failed: 'git bisect--helper --bisect-state" + error(_("bisect run failed: 'git bisect" " %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 6d6e72276ae..7a76f204083 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -1063,4 +1063,14 @@ test_expect_success 'bisect state output with bad commit' ' grep -F "waiting for good commit(s), bad commit known" output ' +test_expect_success 'verify correct error message' ' + git bisect reset && + git bisect start $HASH4 $HASH1 && + write_script test_script.sh <<-\EOF && + rm .git/BISECT* + EOF + test_must_fail git bisect run ./test_script.sh 2>error && + grep "git bisect good.*exited with error code" error +' + test_done From patchwork Tue Aug 30 18:50:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959700 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 0AD70ECAAA1 for ; Tue, 30 Aug 2022 18:51:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231388AbiH3SvG (ORCPT ); Tue, 30 Aug 2022 14:51:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231605AbiH3Suv (ORCPT ); Tue, 30 Aug 2022 14:50:51 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 440C04456C for ; Tue, 30 Aug 2022 11:50:35 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id v16so12678359wrm.8 for ; Tue, 30 Aug 2022 11:50:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=IZck1ZBApIc5FUkGzxG4wqWxnF4VcxRIyu7p+2Y8DMM=; b=Ia2c6PwnpJPPG9KdbbVmTE/IHauajmIlDIMocfge5cpQEy+XbRlXijW5ODMUOnrQ2J gEo+kqymNDb+qI/C3/RG4MfnV00LdM0lw5AJwLGcybvOIbT2ubHk0U0r763L3impUkJw GZkQTPkSAmej9PADK6TRWvWHAiO/V7o61a6SDxiz5Smui+nzCxXKPrhjEKU9G4yEQOMo BIJt9B/tf2pEn9A9pl7JIQ13eXFIYDFKsKEAabVSEjiECOEdw+h2nUD/H+tsxv4yGNrE lDXvNBFIAat9zFknZcxLC7bpq6InnW9tIPZOTpQmn9acxjlqq2uxcCwK8JUTnaRPg5HS fQkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=IZck1ZBApIc5FUkGzxG4wqWxnF4VcxRIyu7p+2Y8DMM=; b=hIaGFgR+VezHTzj7B4s06B1qa/Ja2eWjYUYtvIISmtfhp7VAhmtmYV/pwuUH19y4bZ vpH9u1YAHb6KtrQb4mN2vL1yxOBpOBVcDYvipKj5LSEXpyH8bqQzl5cEULO3fjP9ZIAH 19+YwysYLpdn6oTM335dG5uE/2wvtKWFyeDWVPYcSLEnv+4eYFHSiYDiZfyvTRjEwK8o g9d05ILxpQgYSeCMd3Lr120stbCErJDtaFbkmrJgoQEe3f1RMllDK5kN/5IRPgpAZfBg wTw5anlaem49Jo7Gklsv3zmNDo5tKzVONAgreSsZKjKwkwA42kNxJdkjeR+4WS7BTk6j SSmQ== X-Gm-Message-State: ACgBeo28BOTQKDzzya3DIo12BBkE7U+UShOtgIR9pYsaJ5b5MfDyxUJ3 UJt+Js8Dxkq5ytYQcjyy/4ACqBidX+M= X-Google-Smtp-Source: AA6agR5x8/dEY1sqRBHFYMBvPnS06Ywh9pRfAh4rnnCuHgS1PZHh3zlwIRm66+77BAkrbZzW60lpEQ== X-Received: by 2002:a5d:698e:0:b0:225:72d1:94c with SMTP id g14-20020a5d698e000000b0022572d1094cmr9448856wru.381.1661885433164; Tue, 30 Aug 2022 11:50:33 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v20-20020a05600c15d400b003a331c6bffdsm12076474wmf.47.2022.08.30.11.50.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:32 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:13 +0000 Subject: [PATCH v6 10/16] bisect: avoid double-quoting when printing the failed command Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin We already quote the command via `sq_quote_argv()`, no need to enclose the result in an extraneous pair of single-quotes. Pointed out by Elijah Newren. Signed-off-by: Johannes Schindelin --- builtin/bisect--helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index ba4aa8059cb..05fe619c47c 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1390,7 +1390,7 @@ static int cmd_bisect_run(int argc, const char **argv, const char *prefix) if (res < 0 || 128 <= res) { error(_("bisect run failed: exit code %d from" - " '%s' is < 0 or >= 128"), res, command.buf); + " %s is < 0 or >= 128"), res, command.buf); break; } From patchwork Tue Aug 30 18:50:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959701 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 93DE0ECAAD8 for ; Tue, 30 Aug 2022 18:51:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231615AbiH3SvJ (ORCPT ); Tue, 30 Aug 2022 14:51:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231635AbiH3Suv (ORCPT ); Tue, 30 Aug 2022 14:50:51 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61C634BA6C for ; Tue, 30 Aug 2022 11:50:36 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id b16so7783307wru.7 for ; Tue, 30 Aug 2022 11:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=DT36J2AiUWjj01U72IlyGg7tjGHbNeTie3KA+xZ3VDU=; b=epez/TThT9Ci7y9rrxa5ZW3/j51uVhXvvUJhIhwukkGlLmbJ0/A5CFHRw2HBoAPm95 0F8XR30jYLuzd0ePGAfZwHU3wPtVNqWHTTHks8H7CYR1bC8nvMl6v66Y6uWCSQUqvizR fsTG9vBaOVTl6OZLQ2XkkNF+nEB9TIZ/oz5Pz/X4ncp1E5H/5hmCVmREXpGkq8b1CqG8 jLhdp4K1Ta+ND8wX7hU8rxNI8/cltJFublEjary75a1DPHGjU1VU5AOkPKLgFUDUAekJ bILcKB8BAHQOxBirEz4w2AbpkjEmHJrVQvaBHYUsiCzDTInHzZ99FYuYRIsbClT/zFNw ABpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=DT36J2AiUWjj01U72IlyGg7tjGHbNeTie3KA+xZ3VDU=; b=r6PzRj8SJ3pAMIiz3NCX3Fcm04pGQerFTQp4XynlC1XcRUioViEGOzcQ+NDEOM1PVW qQXNtUDv/RaHG/FTSAWwcAZa5gp3X76F5dALV063BEppeLrb+FUrk83o5Lt4LFoPBWdB UfQ3wWaPW7UaqHU/i98J/Op310ZuMqylMBDk7VBporAgJWsODzWsGMkWox9kzPyZ9QSC 8CNDJS8IoqBWB3PrHDPCXsQhdpMqMr5p8nUKpaddFy7ePl5mbCA1f4NvE5muXs3LpgWR SVcmNz7/uaX8aLMqVBvCWVUB3hTkxBPjAYp2dMKnHIFSQ4DfvNPmN2SSHdw1RB1vSaGc EwxA== X-Gm-Message-State: ACgBeo1lVLem3ZrmhDnJ7dT22c2dBKcrvrOd+HX5c0KvcBvgJYX9ZGhP KVcnHiKl5G9nwDzwit0DvhAGPMG90S0= X-Google-Smtp-Source: AA6agR4kcZ97xDPhKAXahZ+pUDpSiyW7uTrQOPaTbc50lQwS+NBIptqaU6myhgpjAAJbRwhwRegwzg== X-Received: by 2002:adf:d0c9:0:b0:225:8c08:288d with SMTP id z9-20020adfd0c9000000b002258c08288dmr9933902wrh.213.1661885434238; Tue, 30 Aug 2022 11:50:34 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c18-20020adffb52000000b00225239d9265sm10456554wrs.74.2022.08.30.11.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:33 -0700 (PDT) Message-Id: <3376b4508671491ff5c3e770ad3cd17203208bac.1661885419.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:14 +0000 Subject: [PATCH v6 11/16] bisect--helper: calling `bisect_state()` without an argument is a bug Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin The `bisect_state()` function is now a purely internal function and must be called with a valid state, everything else is a bug. Signed-off-by: Johannes Schindelin --- builtin/bisect--helper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 05fe619c47c..ac3b2e5b61c 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -997,6 +997,8 @@ static enum bisect_error bisect_state(int argc, const char **argv, struct strbuf buf = STRBUF_INIT; struct oid_array revs = OID_ARRAY_INIT; + if (!argc) + BUG("bisect_state() called without argument"); if (bisect_autostart(prefix)) return BISECT_FAILED; From patchwork Tue Aug 30 18:50:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959702 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 75069ECAAA1 for ; Tue, 30 Aug 2022 18:51:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231709AbiH3SvL (ORCPT ); Tue, 30 Aug 2022 14:51:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231205AbiH3Suv (ORCPT ); Tue, 30 Aug 2022 14:50:51 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BFD04C61D for ; Tue, 30 Aug 2022 11:50:37 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id bu22so15070802wrb.3 for ; Tue, 30 Aug 2022 11:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=NoYvMA/epqY3ghH1gKytvRGrE08JXJ83K6Pyb8wiZSw=; b=YaJTvEcI6+puKdvaY8a3wSwXTAaebPuPXfZDLIMLXT16uAEQy31BT7Kc7z6an0IKXz FM5mBRYQ8jW0mxPByTFga50tbdukKKYq+YVNQsnMhw0galSYj0WK9GZH3CYfKf6NbYcr Tpduwlrws3YvQQRG7/LtQoPx7+dsC90ogHdn/p7XmesTVoVy1EOvhQne39bE4iMk4VeH Jir9HYx0QyfQQ0OX6W1lJUUv/uqHlHGPK195OZZm44JgV25+MGkIfegHd+BpTeNeXghg VnpF1lZoNWOQInDOSjIj/XPnl6Nhaeol9A5u/74wkOZN+26NpLa8JEv1el7E82R+5sb7 P7aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=NoYvMA/epqY3ghH1gKytvRGrE08JXJ83K6Pyb8wiZSw=; b=4iBKAFQSePt6DmmY6Yg95fbE/c0voX/lKXO130YwMloLV05VxEIfVGkEM8fNxiUUGc RxSG/UewaG9pAHRN9yYppabtRCBdj5mpHqwGmJzT8JcsSHjNr26x8Ulv6P75JiwPDj+i gicE9D+sjVLetjs5B3krMfBJ67xYGjJuHmB2FqPOTn0p5xm91znGk15JBlFvdm6XMopR QgD92A3gw58aBNWfnnQADp+eHsHevLO50BSA/T4efdOpTADIK4+izl5bFOwKiiGq6/3k 6rcohknvK4C3gyudAdNR1werOUgTD9aIb6wQLnTbbYzxtAyCUZu31TzfFR325iKUIJw3 m4Aw== X-Gm-Message-State: ACgBeo227FAvLJVdHRMUG6NV8xHNrgqWLp4XaIWgpt70zWmjVml5XIKf LIQIU6IIO2XEIyTXd+WgxZ7TH2oE/hQ= X-Google-Smtp-Source: AA6agR5YDR1dDK2zpE6IXbCnyRslj9SgaXgTJEld+6kb1Yw+lmIDZ02tZ055NyUynZCM1yF4FdMxjw== X-Received: by 2002:a05:6000:795:b0:226:e8d9:828c with SMTP id bu21-20020a056000079500b00226e8d9828cmr726389wrb.464.1661885435276; Tue, 30 Aug 2022 11:50:35 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v18-20020a1cf712000000b003a5c7a942edsm12547648wmh.28.2022.08.30.11.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:34 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:15 +0000 Subject: [PATCH v6 12/16] bisect--helper: make `state` optional Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin 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 --- builtin/bisect--helper.c | 22 +++++++++++++++++++++- git-bisect.sh | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index ac3b2e5b61c..61e819e4efc 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1447,6 +1447,7 @@ static int cmd_bisect_run(int argc, const char **argv, const char *prefix) int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { + struct strvec args = STRVEC_INIT; parse_opt_subcommand_fn *fn = NULL; int res = 0; struct option options[] = { @@ -1464,10 +1465,29 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) }; argc = parse_options(argc, argv, prefix, options, - bisect_usage, 0); + bisect_usage, PARSE_OPT_SUBCOMMAND_OPTIONAL); + + if (!fn) { + if (!argc) + usage_msg_opt(_("need a command"), bisect_usage, + options); + + set_terms("bad", "good"); + get_terms(); + if (check_and_set_terms(argv[0])) + usage_msg_optf(_("unknown command: '%s'"), bisect_usage, + options, argv[0]); + + strvec_push(&args, "state"); + strvec_pushv(&args, argv); + argc = args.nr; + argv = args.v; + fn = cmd_bisect_state; + } res = fn(argc, argv, prefix); free_terms(); + strvec_clear(&args); return is_bisect_success(res) ? 0 : -res; } diff --git a/git-bisect.sh b/git-bisect.sh index e19847eba0d..f4df8709d84 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -60,7 +60,7 @@ case "$#" in start) git bisect--helper start "$@" ;; bad|good|new|old|"$TERM_BAD"|"$TERM_GOOD") - git bisect--helper state "$cmd" "$@" ;; + git bisect--helper "$cmd" "$@" ;; skip) git bisect--helper skip "$@" || exit;; next) From patchwork Tue Aug 30 18:50:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959703 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 64790ECAAA1 for ; Tue, 30 Aug 2022 18:51:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231766AbiH3SvZ (ORCPT ); Tue, 30 Aug 2022 14:51:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231650AbiH3Sux (ORCPT ); Tue, 30 Aug 2022 14:50:53 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A7994DB68 for ; Tue, 30 Aug 2022 11:50:38 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id n17-20020a05600c501100b003a84bf9b68bso1733596wmr.3 for ; Tue, 30 Aug 2022 11:50:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=Ivc0GYFwon7YWFjfTUcP59rgkrO1VN2FSeDMK/I4SJo=; b=HuC7LkP1zxJ3J3mRkfpggG04zNlzRaSZns1GVkU6kxRViA/x/KnJch4RjtXNg6j/EM 2mm+2hBd8E4z50Y9JQYhyb2H//JjqcoV7CqNVX5P5irF9oLMEvJ36tPescX8edMtQoNW g+2mvcMcZiJkcamtO7iYr1akK+tYDvLZE1R/l6YUeirGUY2CyHqGZ0T4UpcCH0a0RKYb P/sO/u+v0dodEHLPBhMou07YUx0Ld+mIN8HRdJLcP11CJZMyjtxtYHF/6/VApJ043l0N JNs1KjMPQ9dFBOckAh0lDICyRdJ6HLGIRkZZHlMnhpD7we2HCWeij9E6MeG3IZZAB/Hs oWUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=Ivc0GYFwon7YWFjfTUcP59rgkrO1VN2FSeDMK/I4SJo=; b=Cs6Kg4i+rvelU+1DuWlxv7vgNwgBVm+OBMj2D3lyb/9JSuBpo5c2/i8nIOD9sA5lRR gxeDIg7Yp9kcdSYN1eN5dVEARAFS3TsExBCsRbmT6QxDAJkd470QZhcY/ctPRayiMcIs htqKxb2N/eZLccBJuksQ/XUbbqLK5bJO2Wo35wYJrOIjUjpkoUuXyxdtYi+Z16NxZ3aO gILPi+NQ0pBKFBh8+AWSpRb6C7TFfKimnDF2bmujMN95K2JNp6wIhu9eoPDATGny9xzo mMqX5SZVllkJOynGJzudHxiqZwwPHJFQsQctPL/shoJIAOPtR9FLS9In1TjagKvKJEv8 F0ng== X-Gm-Message-State: ACgBeo1QP2gk76oihDseDXJWMHuy2pF9MOv1RRQUlQgGI+rvLDjD3/m2 7Hd3zihcWSqDU5/8pXtXUA/hervIqY8= X-Google-Smtp-Source: AA6agR4B9S24AGJiE1BbDb6cYNnaOw72ibrNCI5XnxnHN/Tj8Ou5LoG+xp0JoT1vloKWW8lY5ZpoaQ== X-Received: by 2002:a05:600c:4ece:b0:3a6:28:bc59 with SMTP id g14-20020a05600c4ece00b003a60028bc59mr10529316wmq.154.1661885436235; Tue, 30 Aug 2022 11:50:36 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bd22-20020a05600c1f1600b003a8436e2a94sm9188636wmb.16.2022.08.30.11.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:35 -0700 (PDT) Message-Id: <3f052580c95ff5a570374d17391de1592aa34047.1661885419.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:16 +0000 Subject: [PATCH v6 13/16] bisect: move even the command-line parsing to `bisect--helper` Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin On our journey to a fully built-in `git bisect`, this is the last step. Signed-off-by: Johannes Schindelin --- builtin/bisect--helper.c | 1 - git-bisect.sh | 49 +--------------------------------------- 2 files changed, 1 insertion(+), 49 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 61e819e4efc..6bcf16d9f62 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1455,7 +1455,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) OPT_SUBCOMMAND("terms", &fn, cmd_bisect_terms), OPT_SUBCOMMAND("start", &fn, cmd_bisect_start), OPT_SUBCOMMAND("next", &fn, cmd_bisect_next), - OPT_SUBCOMMAND("state", &fn, cmd_bisect_state), OPT_SUBCOMMAND("log", &fn, cmd_bisect_log), OPT_SUBCOMMAND("replay", &fn, cmd_bisect_replay), OPT_SUBCOMMAND("skip", &fn, cmd_bisect_skip), diff --git a/git-bisect.sh b/git-bisect.sh index f4df8709d84..028d39cd9ce 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -34,51 +34,4 @@ 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 "$cmd" "$@" ;; - 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;; - *) - usage ;; - esac -esac +exec git bisect--helper "$@" From patchwork Tue Aug 30 18:50:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959704 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 15301ECAAA1 for ; Tue, 30 Aug 2022 18:51:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231779AbiH3Sv1 (ORCPT ); Tue, 30 Aug 2022 14:51:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231670AbiH3Suy (ORCPT ); Tue, 30 Aug 2022 14:50:54 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F89251A24 for ; Tue, 30 Aug 2022 11:50:39 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id bd26-20020a05600c1f1a00b003a5e82a6474so6672604wmb.4 for ; Tue, 30 Aug 2022 11:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=vqO9uA64WmS1e8PpcJEol1MDKRUQ2ilSXo64PEbap9U=; b=IgCW63f4E1BTqVh0AisrabAiHCGnvbI4UuIaVd5qWq98vNPFWERduhCzIsiZWqf50V u6dvqDZI9P/z637ZbYlW2S5V2++sICkZ3gnqakp+HXXxuUwejRP7sgX64OulscyrVCLE PHLpBjzIXBG/oYphqQP1KwRNJFKUT3Y6RAus0TzsDoIOX0pYPZVepfeE4/FSGMHW0zsb ITaKHUxpGcHdxiOEpreDLtHX/KX7xRd68b7CB6fcCOyNzq/oYBxiXr6qfbS+DTDbiOY4 mnL+kSoPK0QJPoEF3AbHUqVC1XpUY0vQ/rHd4wdZTen2V3A4Bym2t5QHhrTzNX4CrKHS M+/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=vqO9uA64WmS1e8PpcJEol1MDKRUQ2ilSXo64PEbap9U=; b=wPVKB0cAikwQSqvBJT6NGaajyFxpUk84DJIWzvi7RClCToG//FJa1HXk4e5XnytB7K W9vhfBuBuZFoph3LWwWkrHteU4ibs4fRyuS0D4eo2bNPbTADnicyEnheVn6Yb4jv4o5S HEgcOK0Orsx2yNlfnwLz9BFt+ldEN+lnk1fawxRxzRUjiPU4awGkZiNphMDK0kJ7c32w wZBqP8vKDHkXIgpRhekWPT1+bPgwtaxBjSe5cNt+alBXSoUo652QxJySy76/FqP/5M+7 1awSUpkeAvlrb8agD0xTJevhDBsqJzrNkll082FUbLiDTDXSWdveYsMVi8zZ1jjS95Gz cKrQ== X-Gm-Message-State: ACgBeo1ayZNxYd43w/X+e2JDm6hgLUpqJuSvSXMKuFSskERnIWFRo4lj xs5xCHqRTXSqzGqRH11Wd51R1lkXDA0= X-Google-Smtp-Source: AA6agR5naobIVnBHsHMVEWC8wX0ox9a9qiCiP9RgvnS0b8fM35Xtz7/L7j9LPmLjVohf7PQJvbb6EQ== X-Received: by 2002:a05:600c:1497:b0:3a5:f608:d765 with SMTP id c23-20020a05600c149700b003a5f608d765mr10176746wmh.19.1661885437204; Tue, 30 Aug 2022 11:50:37 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bg20-20020a05600c3c9400b003a60edc3a44sm14288840wmb.5.2022.08.30.11.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:36 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:17 +0000 Subject: [PATCH v6 14/16] Turn `git bisect` into a full built-in Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin 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 --- Makefile | 3 +-- builtin.h | 2 +- builtin/{bisect--helper.c => bisect.c} | 2 +- git-bisect.sh | 37 -------------------------- git.c | 2 +- 5 files changed, 4 insertions(+), 42 deletions(-) rename builtin/{bisect--helper.c => bisect.c} (99%) delete mode 100755 git-bisect.sh diff --git a/Makefile b/Makefile index 1624471badc..4a79b2ba2fe 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 @@ -1127,7 +1126,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 40e9ecc8485..b9470f8ab4f 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 6bcf16d9f62..46b65c91738 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect.c @@ -1445,7 +1445,7 @@ static int cmd_bisect_run(int argc, const char **argv, const char *prefix) return res; } -int cmd_bisect__helper(int argc, const char **argv, const char *prefix) +int cmd_bisect(int argc, const char **argv, const char *prefix) { struct strvec args = STRVEC_INIT; parse_opt_subcommand_fn *fn = NULL; diff --git a/git-bisect.sh b/git-bisect.sh deleted file mode 100755 index 028d39cd9ce..00000000000 --- a/git-bisect.sh +++ /dev/null @@ -1,37 +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 - -exec git bisect--helper "$@" diff --git a/git.c b/git.c index f52a9554103..9c11727e29d 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 }, From patchwork Tue Aug 30 18:50:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959705 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 6EA98ECAAA1 for ; Tue, 30 Aug 2022 18:51:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229773AbiH3Svb (ORCPT ); Tue, 30 Aug 2022 14:51:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231668AbiH3Suy (ORCPT ); Tue, 30 Aug 2022 14:50:54 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 545CA52828 for ; Tue, 30 Aug 2022 11:50:41 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id bu22so15070973wrb.3 for ; Tue, 30 Aug 2022 11:50:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=hsJ3WIRvkFCFc2sMpRSLvnIrzJJH4+C7f78sk3taGXM=; b=aUElGv+zLbDwRXcFKQ77W/vrokOBhKzYBnntcxSBtF3TUob7ClodkjMjtqkksXJdaM blHoxgYpHG7yIKJstQXhMG2Mpnm+LTaSSTRqlebo4b9gCDKnVvKH3OGEuBk/HXjHCnpx J+xwKi+GgOvSPPdaXtZcvBWwebmL5CNumjltUaiX1CXKw14R4DRXAs0o+8jPBndB0Hnt xVzqVXLTX/3Qm12fO8TfFDtT9TgMdx3/YpePc4Ba3kGmZ1sVS1QwEvfkIs+OD6/7ZP3r IsDRlS2r70vsbfvPrVk96K5Vhdk7the8aCD0+IDmIqI6GI6zhC2kekM5ZJdPwuTDzc+L 7nVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=hsJ3WIRvkFCFc2sMpRSLvnIrzJJH4+C7f78sk3taGXM=; b=Z24obHJNQiRDo/iuE/LROmPV39Pz/G+kNaCqlSEXufCKlmpj6Gl+XPUS+3hXXeQJlS jJ8DTdnG1IH7muF/ISgr3xRlJjF37rnW/YRDucC9crajLWoAQwoiFUYFUlHm3tyjF4sE 3jSEbRBXRP9maNHVCY5QdoRHgjsrhqrIYNAaYHZOaUqIaANz2JlaVusTnuxJyh+0fydi 9KIe94I7MwC3Gz17rQxYlG3xvPA5Mngv3gLhLwnadr0PxK/QsPz1Z9f/gBmZQ8DEzePC 8+fSJ2twOVpMdrCde4wBJkFxnIHX/vlvscqgHO/kILJ8ysjeA43jBcYiMZdWfZjpPr7t CvxQ== X-Gm-Message-State: ACgBeo1/7fz2G8fO9s3w+iTJKuxXS5p+TjPNruDU5NHzXPmgn3sfUdqw cR0FpzhPacsaDb37eFwFbGOg0P23AJ8= X-Google-Smtp-Source: AA6agR7CQP8odHMyZhCKXKK8IA3ACf6YPEGsFCFbNU7m8BoXN7JZD2DSiHydE6eCWj78DjDBNgNUrg== X-Received: by 2002:a5d:64a9:0:b0:225:66ef:be9d with SMTP id m9-20020a5d64a9000000b0022566efbe9dmr9789393wrp.604.1661885438421; Tue, 30 Aug 2022 11:50:38 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k35-20020a05600c1ca300b003a5f3de6fddsm14464496wms.25.2022.08.30.11.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:37 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:18 +0000 Subject: [PATCH v6 15/16] bisect: remove Cogito-related code Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin Once upon a time, there was this idea that Git would not actually be a single coherent program, but rather a set of low-level programs that users cobble together via shell scripts, or develop high-level user interfaces for Git, or both. Cogito was such a high-level user interface, incidentally implemented via shell scripts that cobble together Git calls. It did turn out relatively quickly that Git would much rather provide a useful high-level user interface itself. As of April 19th, 2007, Cogito was therefore discontinued (see https://lore.kernel.org/git/20070419124648.GL4489@pasky.or.cz/). Nevertheless, for almost 15 years after that announcement, Git carried special code in `git bisect` to accommodate Cogito. Since it is beyond doubt that there are no more Cogito users, let's remove the last remnant of Cogito-accommodating code. Signed-off-by: Johannes Schindelin --- builtin/bisect.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/builtin/bisect.c b/builtin/bisect.c index 46b65c91738..a8deabf9eb1 100644 --- a/builtin/bisect.c +++ b/builtin/bisect.c @@ -15,7 +15,6 @@ static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV") static GIT_PATH_FUNC(git_path_bisect_ancestors_ok, "BISECT_ANCESTORS_OK") static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START") static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG") -static GIT_PATH_FUNC(git_path_head_name, "head-name") 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") @@ -880,13 +879,6 @@ static int cmd_bisect_start(int argc, const char **argv, const char *prefix) strbuf_addstr(&start_head, oid_to_hex(&head_oid)); } else if (!get_oid(head, &head_oid) && skip_prefix(head, "refs/heads/", &head)) { - /* - * This error message should only be triggered by - * cogito usage, and cogito users should understand - * it relates to cg-seek. - */ - if (!is_empty_or_missing_file(git_path_head_name())) - return error(_("won't bisect on cg-seek'ed tree")); strbuf_addstr(&start_head, head); } else { return error(_("bad HEAD - strange symbolic ref")); From patchwork Tue Aug 30 18:50:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12959706 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 D612FECAAA1 for ; Tue, 30 Aug 2022 18:51:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231259AbiH3Svf (ORCPT ); Tue, 30 Aug 2022 14:51:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230450AbiH3Suy (ORCPT ); Tue, 30 Aug 2022 14:50:54 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 334DA52FE4 for ; Tue, 30 Aug 2022 11:50:41 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id bd26-20020a05600c1f1a00b003a5e82a6474so6672650wmb.4 for ; Tue, 30 Aug 2022 11:50:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc; bh=2Kg7YV2cLc0sPso95VWf/nMyuinQpxkpBHDw1baPYHk=; b=DSHFG8MxgmzC7Zh9R5uBfteCuidvC6GdcxLQDDdqxwsaYVkt5z7zFqZ3qPtg2Tk9jH dCbGqnzjBXEq69li0hbjeqYZxvzZ59htviLWFEMOgyuecyYqlrYg69SmkopibO3A/YeI LkxecApK9AN5RmNdQ6mYPQpITV71QPu0/yI/Ii/D6ILryhZaFP3QDSfVq5o/CgaFmBXl 6pXmyVOMMBPBEoun1m6f6cnuIWfAKfbe+YbHV+7u2d02dZKpFwu5yI/BHZDVGUG0Rqie wmhBiaP1eUcjyosuXcu9Uc6sLiogfQLlNE5C7518xdc7oiqThMsSdfFFglpfoX8muebr 7Aeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc; bh=2Kg7YV2cLc0sPso95VWf/nMyuinQpxkpBHDw1baPYHk=; b=LfMn2s7Ep7HHcDQhhuiuaR6HYO3hGKajmxeOq5nLi6TdW+j0/t/9mq0jJLojdqt0oD HiArta0iVD2vAs8W33cwaMeFpELDg3240q/CTFuH4UBS5fjJiKONriEglHf0MHNe8ooa ymHt5JRPvdxcBEx9wPGYQ1LLYE7Yc11/Y8hu4b8qdNfO968Zq/wsr2Ehqdr/Pnei75mb v4nbizr4xFPjjBmLSL8Gag5kFOWqHFLxDYhG/a0YvmKYcMS5I3Di+2hHYH6YbY+i+g3/ Ejlcaf7CdUKw2SsTL+TDFok+y8qLkIKQaead0d2cqzM98Q1+SmoGdEkif/yqtsZujfGy hhFQ== X-Gm-Message-State: ACgBeo3w9VUBVYykeywg3Rjfox9hM5mERmWWAKY9OGae97ga7z0GVSHf +85MYf66jIv3iAop6ON0ByyH9oPX/8g= X-Google-Smtp-Source: AA6agR51wXfJ34fuOWPk6g07jC601Hc+9UaZU5EWxLxWMR2zji3MZ9I9hQy4DG7Wdv5VfD5JzbZU7A== X-Received: by 2002:a1c:3842:0:b0:3a6:8c16:e239 with SMTP id f63-20020a1c3842000000b003a68c16e239mr10750776wma.80.1661885439447; Tue, 30 Aug 2022 11:50:39 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q3-20020adff943000000b0021efc75914esm10424244wrr.79.2022.08.30.11.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 11:50:38 -0700 (PDT) Message-Id: <4f93692e071cf316fd391344b5dbbc995c162232.1661885419.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Aug 2022 18:50:19 +0000 Subject: [PATCH v6 16/16] bisect: no longer try to clean up left-over `.git/head-name` files Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Junio C Hamano , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin As per the code comment, the `.git/head-name` files were cleaned up for backwards-compatibility: an old version of `git bisect` could have left them behind. Now, just how old would such a version be? As of 0f497e75f05 (Eliminate confusing "won't bisect on seeked tree" failure, 2008-02-23), `git bisect` does not write that file anymore. Which corresponds to Git v1.5.4.4. Even if the likelihood is non-nil that there might still be users out there who use such an old version to start a bisection, but then decide to continue bisecting with a current Git version, it is highly improbable. So let's remove that code, at long last. Signed-off-by: Johannes Schindelin --- bisect.c | 3 --- t/t6030-bisect-porcelain.sh | 1 - 2 files changed, 4 deletions(-) diff --git a/bisect.c b/bisect.c index b63669cc9d7..00bd4ba581c 100644 --- a/bisect.c +++ b/bisect.c @@ -474,7 +474,6 @@ static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START") static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG") static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS") static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") -static GIT_PATH_FUNC(git_path_head_name, "head-name") static void read_bisect_paths(struct strvec *array) { @@ -1181,8 +1180,6 @@ int bisect_clean_state(void) unlink_or_warn(git_path_bisect_run()); unlink_or_warn(git_path_bisect_terms()); unlink_or_warn(git_path_bisect_first_parent()); - /* Cleanup head-name if it got left by an old version of git-bisect */ - unlink_or_warn(git_path_head_name()); /* * Cleanup BISECT_START last to support the --no-checkout option * introduced in the commit 4796e823a. diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 7a76f204083..1d9cbf229e2 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -1000,7 +1000,6 @@ test_expect_success 'git bisect reset cleans bisection state properly' ' test_path_is_missing ".git/BISECT_LOG" && test_path_is_missing ".git/BISECT_RUN" && test_path_is_missing ".git/BISECT_TERMS" && - test_path_is_missing ".git/head-name" && test_path_is_missing ".git/BISECT_HEAD" && test_path_is_missing ".git/BISECT_START" '