From patchwork Sat Aug 27 12:44: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: 12957004 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 1E6F7C0502E for ; Sat, 27 Aug 2022 12:44:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232747AbiH0Mof (ORCPT ); Sat, 27 Aug 2022 08:44:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbiH0Moc (ORCPT ); Sat, 27 Aug 2022 08:44:32 -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 91BCC31374 for ; Sat, 27 Aug 2022 05:44:30 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id bu22so4418603wrb.3 for ; Sat, 27 Aug 2022 05:44:30 -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=Df/T12AzCli8yOajjykg6sBiy1m4TGEc1ErDSIHlQTJphXlCmb37IOP2IJ3xg7hmIi RH84l3qxJHE0Pmd4ny23F7vmjw33ILI10EP4ioxYwTqFQ18FLN4EByIOs0dLaSwG1nyN tpkjxWwcgMoP4od2Kxg+GmsaHi0nVA3ahFSCb6ZH0zh3BOY440ytPowBjnMMTzyZdoiY Q957E7MudMWPiLzaTJvwwYnana4AyRtcMf11w/ouE6v9fn4jhRZwk2PxDgJBy1yu2sJz SzTSwZEWYbj42YMtPt3CtV/TbbgAlkJ5ZxU5IHZi4hPcOUnS1LbncRvmIf6L9aqn2Inm JlVA== 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=iGZw0PP5/S1QqRwLPGiyopJlqp4shikquS/p6rV44KxtiqFpKnx2Xnvd+8S28doJSS JErl2xZQab7nBG1MdKiZ/4FLshFezsnrsyNnsjl9/kH3mnJkeaKNXwtzDt7mXwYAwV+J 1RcealnPI1CyUpzyIuczHiqCGAxHkSPtLIgPrQehp885O9New/AKdwy9DbgI063s2yr8 qZQ9MNpn8edbfSJ9DCAaVwahMRv4qvjZ3CS6086rxCnESVx+lc7nBzs+M5BOsawXTfyQ 9LQIz0zAJE1q78AjiSb27vG/7+PA7XioggUiZ7nUya/jrKzO2vzhbi4Xvfg3jx4ruPvv seBA== X-Gm-Message-State: ACgBeo3Eeww25zlSYpYwbgYuS4LWiUUsHNv5vqgj5wwa4NzeCuy8rj7w Qj01s2H1MrTgUJ8k+Wdp1V9oI3Xk/hA= X-Google-Smtp-Source: AA6agR7DZ6HVRJcv56s5ovsCqhMSoEGSsWRAmBvCihz2jGtjCOmpxYwQDWnK6mTHfrcHKEh30wvxUQ== X-Received: by 2002:a05:6000:1d82:b0:220:5f9b:9a77 with SMTP id bk2-20020a0560001d8200b002205f9b9a77mr2111473wrb.622.1661604268970; Sat, 27 Aug 2022 05:44:28 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l14-20020a05600c4f0e00b003a83d5f3678sm1695180wmq.7.2022.08.27.05.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:28 -0700 (PDT) Message-Id: <05262b6a7d1b20a0d2f2ca2090be284ffb8c679c.1661604264.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:09 +0000 Subject: [PATCH v5 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 Sat Aug 27 12:44: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: 12957007 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 64A6AECAAD2 for ; Sat, 27 Aug 2022 12:44:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232879AbiH0Moj (ORCPT ); Sat, 27 Aug 2022 08:44:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231391AbiH0Moc (ORCPT ); Sat, 27 Aug 2022 08:44:32 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C71003137A for ; Sat, 27 Aug 2022 05:44:31 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id v16so2035795wrm.8 for ; Sat, 27 Aug 2022 05:44: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=4nZ5T9cMdKhWlaoNeMMhrxt/eq5mUn7eiiPvf1i1Ivs=; b=bnrsnPagXcSb+GyUfwG6PItwpgs6SZJt9BrP+y8a7QgtldKys4AYqPhaoHMFg7f4+e kfKJVYbjcV1JHBCawZ5sJf6CLyPoEXOk/q24qo/go6cskT8bjLC/uKgvqpCMyFA+Lffo cQ4nFMurOlJ12Uqc01v5b9aG/ZzDZ/R42RfbjkrNcPYd5o0aTq8lRrOdFHLUozu5dZZl TFYv1D/fkJXDliI65g2wdRoy7rl4ycgF4nTweEbFuUrJs5HzQANFypnD2V/9YCbFyqxM 1/FsNIQfgey8qu9SC+ldcbGIg6xsJYtveVr8vGvaz/qokHvczW7pCrIs8xC9iwzfgfe2 0VXA== 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=yQpvRF5F0n2Z3UcXhCTg1NgdnViTPOXuwE1KVY4rUapL17ZLpmTtS0jbTPba2UJi5g /fmxfCo95E59T+J3NDhmWY6xK3ZUMaNI9lm8ZjyupUwuRDxwjLvFn4DoDcXAaBrM8yZG KG78CoBeudSTbhVZL5/klldIueWqA4Yi3NVbioTYSTfO+3zQsfb/4rd6m5LE9guWvJgW 8TT2kUlDZOhDkC/bmZr93uGvnvn4W/XKl7M3nxAbVIpwA/da7tvz/ammTCEcslJvpc76 IySa9K/JAJpTtJ2ZVpIWcZBuw4Qnru4rBhH0wtyDDHfBPkRH6E5nKdSJsQ1NC5LbUT9j cfsA== X-Gm-Message-State: ACgBeo14MWvUJm8MHWlOi/BNEParh57OD69DoGMD/Qqoa/AnjeCKALPf jxQkBZNHhTTLuou+2VCk+94hx8O5VlQ= X-Google-Smtp-Source: AA6agR6xjNMHoPlRNen16TYuvzDABNW+AoBI0fCAPITTR8FsU4Iry9lnD/kirySeXDk9o/4q15MLcw== X-Received: by 2002:adf:d081:0:b0:225:8625:53e0 with SMTP id y1-20020adfd081000000b00225862553e0mr2079554wrh.542.1661604270196; Sat, 27 Aug 2022 05:44:30 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v20-20020a05600c15d400b003a331c6bffdsm2501773wmf.47.2022.08.27.05.44.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:29 -0700 (PDT) Message-Id: <1e43148864a52ffe05b5075bd0e449c0e056f078.1661604264.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:10 +0000 Subject: [PATCH v5 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 Sat Aug 27 12:44: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: 12957006 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 78AF1C0502A for ; Sat, 27 Aug 2022 12:44:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232907AbiH0Mom (ORCPT ); Sat, 27 Aug 2022 08:44:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232678AbiH0Moe (ORCPT ); Sat, 27 Aug 2022 08:44:34 -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 12F1031370 for ; Sat, 27 Aug 2022 05:44:33 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id k9so4792023wri.0 for ; Sat, 27 Aug 2022 05:44: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=fputxYI2HUfkFVNx9yxXGsgXMgIUSaa9LOnIcfF5Q2c=; b=Fy7NAm+g/Ea5dp/QuWYHpsrgypRuRNA2SeqgNPReO40K40e1Ke89f0rdqXRNWDaqV2 6rDbtYTjc9ueOEeWTG461drngLyS6IY0Jr0IvQ/18jJ1BxlSivuxaM1/slKEDIwD8ftK sAYyue1cebHqOrzcEGIc3WsQ+6LZ9+14N2GXIUz7HWuFXB5OwXUl2pUqcyaY7BNkaY3r QQclxCmpfEYxLI4Ugwhgc5cj3lK+zCHMQ4gcA3OavAqA5+PTfNQAAfX4B1SbNd/aqPdU GkH+dZAkOcdV9eZj8KwhAMp7uHIFezAgctl2c+GLtjHZRpTJa/3k9hJ/1tpWeQbRGLEm kcFg== 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=V0R4XAgn0MKg7cwNrJvdl7+rnTbmzkjTDImjqAvJoA0RSmPUrzmAVKdBfDv2QGJ1r2 yXL+ZcgJx1Qn949pre1ScO/PKKX0cah6oaYEXKZ0QDSjEz+eKuPIg0b5eJUHaSF8aiUr 5bpmqCLi64KaJ7oH53S+6Bn58wyrvkWQ71Se251YkCX/M6QCTlZeoXCdwhmrhuG1UhH4 PMHWCVIgYvgafYG1jy5j1hB1eNhi7iC7VmiRLMrfv/EZamPDLh+GKO24qHLOfpomhKwW 5R/pcLGgV0nei/lpDGVUNMHj0LOerAY/JVxHPPf8EZ1eUg4/IPCWIVrQcapdCQzxP8W9 xXiA== X-Gm-Message-State: ACgBeo3Kruro/qlHxafYAPZUxCvIpajEvDynVXbxqQoB4x5KeRWvpUdD se99MWXvvXYzWoq4KOAH6Jq6xhkaIO8= X-Google-Smtp-Source: AA6agR7f2EN34dJbRsA7IKho5jknjEI7pSy4qpgFuBNEydtOnWX3UnxHbkhVJN/noClxvuDhEpZnEA== X-Received: by 2002:a5d:6245:0:b0:225:3e24:e5b1 with SMTP id m5-20020a5d6245000000b002253e24e5b1mr2161849wrv.698.1661604271336; Sat, 27 Aug 2022 05:44:31 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f28-20020a5d58fc000000b0021e4829d359sm2214403wrd.39.2022.08.27.05.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:30 -0700 (PDT) Message-Id: <1a1649d9d0d5739f76db82fdafae7e88374bc8a6.1661604264.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:11 +0000 Subject: [PATCH v5 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 Sat Aug 27 12:44: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: 12957008 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 04018C0502E for ; Sat, 27 Aug 2022 12:44:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232938AbiH0Moq (ORCPT ); Sat, 27 Aug 2022 08:44:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232793AbiH0Mof (ORCPT ); Sat, 27 Aug 2022 08:44:35 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41B2E31374 for ; Sat, 27 Aug 2022 05:44:34 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id bd26-20020a05600c1f1a00b003a5e82a6474so2119063wmb.4 for ; Sat, 27 Aug 2022 05:44: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=oaO05srWf/I52sc2LqNWTDuaqmQesAxh5GR52Lgsn+E=; b=DfA60Rk6hcHUVT8IqwPDwYzoZlxtLOmtfGu6Q1wogzrzS2MeHhYB27v5kSw1hBsBXa GeZM9uiHQh+LHfCINJEf1iyYLLQynXE2YRenxUbh60uom6Bx+w7zhu/eOYowZ4wbGfA8 7dVXTlh72Qa8DNIh0QlIGlymXDq2Vt61AbcmTyhz9DFQhkqZg/h9Z04buJpEHKtAGmrG hP60aPKSWh/A7AGFzY3vyzog5R1cpUU7xvPUdbnyL5bmw7aU13e7iPEea0Q6fQJ7rWcP 2kKNEyjzRo6ZlEd0KyUVWwzMYImPRgCkfpJFKWC+qMd5c9ynNTxVSRLuuCFo5DGFWjcm eh1Q== 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=QvVhvJjqS0h7qvDrBZ09dAFChWoIiEMlrdofjT7T4z4ktkFRh/2H5FP5Z9mx3VI69t qTOFD1ewyZ6mDeonHO39/nsWJb9hTO781/MDjiR8M7GDzfK0ywUleAVVnKqWjWuLNCML KUZx/S7c806FxzRz7o39vAr2ueUGnG7Dz8tmIn/GzefBsw86QBfTMRxAxPx3Sp68wBtG JS892wfVp+9jOoxRzC6XmBMU41VNJrOU/Vpdf2PVjO0aUM8ibEF/BqYw3H49Ol834+9f ctd9qERQ8lZ3zm0Eu3zWUnJznggGKpetges1fDWhaxLYAbKgqG7hcPNptsnJ6yCeCKJx miiQ== X-Gm-Message-State: ACgBeo2K0fRKmjQrgn4+Z/yH/AFja1HhMQ5DIIIeb95sqvegVev51BpW Vd4x9rk+4JxYOaZJ+ZPNJlgRuxfcNhw= X-Google-Smtp-Source: AA6agR40eMMdY9Y1QuytOxQ/73zo5Z69k4BEf8IFljot6MqlRoN20DipkYoLsMN9hRdA1OqXEMOeVw== X-Received: by 2002:a05:600c:1009:b0:3a5:4512:5f71 with SMTP id c9-20020a05600c100900b003a545125f71mr2309735wmc.134.1661604272507; Sat, 27 Aug 2022 05:44:32 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v15-20020adfe28f000000b002255eebf785sm2200099wri.89.2022.08.27.05.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:31 -0700 (PDT) Message-Id: <9ab30552c6ae6a5d0a85d7a7bbdd10af4a4cf7ec.1661604264.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:12 +0000 Subject: [PATCH v5 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 Sat Aug 27 12:44: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: 12957010 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 ECD44C0502A for ; Sat, 27 Aug 2022 12:44:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232949AbiH0Mos (ORCPT ); Sat, 27 Aug 2022 08:44:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232806AbiH0Moi (ORCPT ); Sat, 27 Aug 2022 08:44:38 -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 867BA31DCB for ; Sat, 27 Aug 2022 05:44:35 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id h5so4752142wru.7 for ; Sat, 27 Aug 2022 05:44: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=NGbWsZD/xP+Yj0+/RaEfg4uoVSXgFgsqty6tXzT97io=; b=kgflxm/REUuSY5nNxK+yh5LYxoU43PFkiQO/w2AtuGq+blpVLaE0QE5H8Zkkq6jWlS 9MppTHok7EI5mIEz1bwO5uKUkr36JrZ2dxprjbhpL6Uax1WdM/4BWSwVf2CaTqBrvanp XTMhdXNpDosHOT7KWXnXHsnasnKhO1i5jy7pj/9YaPnaJfdlyzNDT720s7wHVqf+I7tp drbxmylqPSjZkjje+yHXIxrp/3zpwQ5Yp8c2LiIPxUvwqaxAIzFM+xP7Wp0nh1KDBjOp tLunAa11bfsPCKRM/y4aaiVf+i3SCo8Gd7fIaUlmA9WlE7YLdzE/Xi+vtBp+sY2Zt2jM nslg== 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=gVoyd4ziJIRAHrmkbcpbKVAkiqf1/hCUGGtb4uEZS7ul4AKeEL78X8q41RtB0GH+us 0FXVMs8zjKNY7R0pfTtDJseFr/VcjwIes+wXz0i5E5Tv71fZnVtDsJmaA0pKua8K8aJ5 TJfbDdPcg+BvkWUNuJLFBoAiv55LwcO+2JxNEBb+yIWCwENZP33/QFM39KSKN9yaagzg iWJc2CVMkv46jE3TIvpedxBRGMcI6Z+UnOlzBJt/Jp3/v/m6CqaMIjUJHNJLoASvWz/c ntOARAEXmfyJTy49ZRfDLHgyHic2VGQ5nIze3oiogAiLDXhgbuBWMpIKe7yg8yR5jB4S C4cA== X-Gm-Message-State: ACgBeo2cZNzPTOZrtw8bJwhox4fw+a4JoQrhB1stmvQlWyCzK20Q0/gA 21fW0p8QXUryDCBkftzJIfUBosGk9Ag= X-Google-Smtp-Source: AA6agR7mKovZmxhDujKlf6M5dKicWVkHesyHFZDfaFqcpbAgv1/98zMeq80TEOVJ0D+P4tE3i2m/LQ== X-Received: by 2002:a05:6000:887:b0:21e:24a0:f302 with SMTP id ca7-20020a056000088700b0021e24a0f302mr2029221wrb.466.1661604273671; Sat, 27 Aug 2022 05:44:33 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j5-20020a05600c1c0500b003a2f6367049sm2734801wms.48.2022.08.27.05.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:33 -0700 (PDT) Message-Id: <92b3b116ef8f879192d9deb94d68b73e29d5dcd6.1661604264.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:13 +0000 Subject: [PATCH v5 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 Sat Aug 27 12:44: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: 12957009 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 DC19CECAAD2 for ; Sat, 27 Aug 2022 12:44:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233038AbiH0Mot (ORCPT ); Sat, 27 Aug 2022 08:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232827AbiH0Moi (ORCPT ); Sat, 27 Aug 2022 08:44:38 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE2CA31DFE for ; Sat, 27 Aug 2022 05:44:36 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id h204-20020a1c21d5000000b003a5b467c3abso5728074wmh.5 for ; Sat, 27 Aug 2022 05:44:36 -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=oL6SGJgMzyyg0zWVVEKqXgwxaEh50A6qOwTHDfsuxBRo9K3WK4fLmswZhHqV5nxjMN 9gEMe3LHYUjFf26IPFKtkSQS5x5EuH/g1qHez0+TO4/HnoqjWZ55HjKjLxMemtXOncQ7 eQUORJHCg2Fhnhzz2hlBAdVqkZUOALgOTVUuvyXBGX+PjJpgI0bZ2qQawgME1+c5T9vD VnMhbqD14x1F5sP+wg8g0b7hVpxgDEPCNO07w5o471OZdtI30EmZhJzeUG1ERcPAKn6N 74dF6g7EKUxsmGVh/mXNk2kOlxL5WFjCSGYoutky4oP3wJjICb3OdWQFm7cKd6bBsCWV GUBQ== 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=C9hHqIPpDJqMC88hZ6DpL14UkTQ6EHPbhwTbUfD44oS1PM6cs07FLCbPUPwOD9DtlN ePV3uabfcg9NY5i/kNLsHCDDVEkV7keNZ/Mb69oDXcpOtIACS/BS3W0TfBMtq/ydig8p DB6B0l+JSFpxcJGImbDAZVh9We1c8e4gpiRg/sMeerrFntaNEeo0kz3mBeGXD0v3kfT7 muI2S/dzutq2LP6rrlbx72EhgjZmCh7oOvAQ+fQ9g6iHsnA/vLNc/Fhn1VMbgrS424fJ KAG4Y6PXSRyf63O4MsX8Uw4PFD1ZplfiZr+sPF1Xf7uKSjFFmfDsWs+vsxJz/mNV06qt +C9Q== X-Gm-Message-State: ACgBeo0LTDkhtK5zYEleJmdTC4lVUnwxZEqcouyhW9xbqYu05YKDtWFk bvAGqyDFsmiqOslUTnOhW6jCvbzeZDk= X-Google-Smtp-Source: AA6agR5R/o2KsvgFxqGssv1DE6gQdrYo1w+pQVT35/WivOByYZaLfLkXWaUEmpd/6aHgustBKUPLMA== X-Received: by 2002:a7b:c318:0:b0:3a6:9c49:2b8c with SMTP id k24-20020a7bc318000000b003a69c492b8cmr2190166wmj.34.1661604274960; Sat, 27 Aug 2022 05:44:34 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bh7-20020a05600c3d0700b003a4f1385f0asm2766093wmb.24.2022.08.27.05.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:34 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:14 +0000 Subject: [PATCH v5 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 Sat Aug 27 12:44: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: 12957011 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 95026C0502E for ; Sat, 27 Aug 2022 12:44:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232923AbiH0Mou (ORCPT ); Sat, 27 Aug 2022 08:44:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232887AbiH0Mok (ORCPT ); Sat, 27 Aug 2022 08:44:40 -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 61AD931EC8 for ; Sat, 27 Aug 2022 05:44:38 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id m17-20020a7bce11000000b003a5bedec07bso5752195wmc.0 for ; Sat, 27 Aug 2022 05:44: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=fwrKm+3cHaYRs4PQq7qXa/fxaaT/XzGfHTpmCfdzpRg=; b=PFrRSDJBIEB3xbELzVZ9aBMmDI0HcMlFn7KAX4dgywflIoHXryWtHmkM6+jzOXAlnu quoXjxTy9IqoAwwHDPnLOtZrMsX+bOOtTeZF42bRcxGsr92swfKJ23Qlj4rm/bgVNuot jF6rKlOkayi1LCK3pfSA/Onq8y4gTmY5G/F2l3p0+/LuZ2A3iwJdzqjrXHv8WeFyZ1gE fnk3T6WL6zG8VZHitKzq5j/J3gpeXPjGJkvVfXB5svjFrOvqn4RqIouLDB8Jf6vszGF0 7Nt94fNOdHEbRuGcfzRteTDYp2HeL6oxk/ELDtr47jaasuJo/BcRJw+ZH4igf+K7ff1C GMNQ== 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=fwrKm+3cHaYRs4PQq7qXa/fxaaT/XzGfHTpmCfdzpRg=; b=5x0WEWuf/kpDl2zmqK6SP5EJrydpMMNlpqaTK0hN/AX3OAgC92Rw6YG08hLvT/DpdA OLr7rLEfSucJaIhab/gJKgVE3IsnFOsPqVCdweR1ufM++AABhF0oFUzz58XaOGuql8Rg YnOxYxcBrSDJW7d6MNVMpBUHckVY1gF8TwT/4gcZj5jYZEBGSyazWJQ2fAA0gXIbXOz4 FaNeRy4WK2kS7eRgBQt+OU37XpIc/QSLTROzYQ74zPP7ut771ncZ2fWsCkJFMO0LLmsu /p+LpknoH6HPTaq/59uXHiqUrzY0EWmbL71jYp2wMMVtQxdsky2ZbpmXrWU7dMoFWDvy bXxA== X-Gm-Message-State: ACgBeo1lXFX314X47AOkHIcWJei5e+vSwb7HcvuhrT5FbsMIfSkS7jLU wabmLBWTMdBkJPzOz+6jGgF0M8Qe1os= X-Google-Smtp-Source: AA6agR5RSPT8ySV+M0AzTWQW5pzw9clHSPbRs1KE+rNftZCcbL2eqNnnSE9l74ihZZ3t9g1ccbD+GQ== X-Received: by 2002:a05:600c:a4c:b0:39c:34d0:fd25 with SMTP id c12-20020a05600c0a4c00b0039c34d0fd25mr2261972wmq.172.1661604276421; Sat, 27 Aug 2022 05:44:36 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c16-20020adffb50000000b00226d473ebd6sm665066wrs.86.2022.08.27.05.44.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:35 -0700 (PDT) Message-Id: <5b7a3d58b4f84f72e1ae2196fa67c76b0a6302ad.1661604264.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:15 +0000 Subject: [PATCH v5 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. 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..d797cd1cef8 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) [...]"), + N_("git bisect terms [--term-good | --term-bad]"), + N_("git bisect skip [(|)...]"), + N_("git bisect next"), + N_("git bisect reset []"), + N_("git bisect (visualize|view)"), + N_("git bisect replay "), + N_("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[] = { + N_("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[] = { + N_("git bisect next"), + NULL +}; + +static const char * const bisect_reset_usage[] = { + N_("git bisect reset []"), + NULL +}; + +static const char * const bisect_visualize_usage[] = { + N_("git bisect visualize"), + NULL +}; + +static const char * const bisect_replay_usage[] = { + N_("git bisect replay "), + NULL +}; + +static const char * const bisect_log_usage[] = { + N_("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 Sat Aug 27 12:44: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: 12957012 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 31B55ECAAD2 for ; Sat, 27 Aug 2022 12:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233043AbiH0Mow (ORCPT ); Sat, 27 Aug 2022 08:44:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232915AbiH0Mom (ORCPT ); Sat, 27 Aug 2022 08:44:42 -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 5FB3231EC5 for ; Sat, 27 Aug 2022 05:44:39 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id b5so4757220wrr.5 for ; Sat, 27 Aug 2022 05:44: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=vJ/hCck+XaBNHDW9f2+pkxNta44cpypydrMCRFEptu8=; b=SztfntRn+yOSBqhUw19wzsnN+EzsMIQ3OPwfGQES8Q53GDTnuNtLtevUaJRay/WwBV MrQKOe3XUNSftpg72NGv6kQiLPjQKc5w0stHjxApPACjmdlqE5fcBVx6c0rowsXwV6Xj 5SQFd30pSSOrc8XHp2+cg7DqNmWJqQ1HyldSMjX312SCtuAzabUXMM5gnUSFPZe/9cPY NdAynyr/SoYT7qqH8utoKD4fwmkJPar3HGSjzeUAIGvjlsB2wth74tKF/JsvxSRooMZQ B10ubKOtlBwd6PhcdFbHF24IO0OCqUva6m5trkh1Pov9Oq2KPSet9TpJqzMdNz+k671n shPg== 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=6b4jS69tL6nVYHKIVbep8GEk78d43wfM8yIkm64I42wha8yafnFw8FBhOXKSI8+iqm XLD6XkEt9FKCN7IRM0lp8yhV4r/3TV8/lQxCVU0JRGg4wS95JGnk4CCbkew01pniHI0z wbDCwqkfn2F6RXCxOJDcXz1gPLkXVDR8ZFzRZc9Og/vU3WsAFe4ZC1NxUwZ1uXMOa5dm IAZ6SsUBsbmr6YRJUyy677obpyL66/JZQAgOZQ0LebenOYCxce2VuYrMpfZw5AHdi3pd 4ZulDSFm3HXPb3h4XkrAbo+ytrnXs6/0m0MxqK7J/i0csAoVDZd5sGHuHtc1L2P6l7MM UuLg== X-Gm-Message-State: ACgBeo3zpZ1iE1GVvciLebXIyjsZcI84tW0QQxrlQB+b7Y2fMwdDRg62 AV/Xmp13fo06j8VELAk4sktxGE538Bg= X-Google-Smtp-Source: AA6agR5FfAkDU5l2yQaUb4bvTmnumuex2ChwIYi97s6d62FmQq/2p+cxU/0H0Fmi40bjTTBXS5arqg== X-Received: by 2002:a05:6000:4005:b0:225:8b27:e6d5 with SMTP id cy5-20020a056000400500b002258b27e6d5mr2083602wrb.603.1661604277668; Sat, 27 Aug 2022 05:44:37 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n19-20020a05600c3b9300b003a6091b3a96sm3109863wms.23.2022.08.27.05.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:36 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:16 +0000 Subject: [PATCH v5 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 Sat Aug 27 12:44: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: 12957013 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 ECC5BC0502E for ; Sat, 27 Aug 2022 12:44:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232959AbiH0Mox (ORCPT ); Sat, 27 Aug 2022 08:44:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232936AbiH0Mon (ORCPT ); Sat, 27 Aug 2022 08:44:43 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1716A31EFC for ; Sat, 27 Aug 2022 05:44:41 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id c187-20020a1c35c4000000b003a30d88fe8eso5736055wma.2 for ; Sat, 27 Aug 2022 05:44:40 -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=197lBONP6pItK9QmNDlCg6sPoKXmLwJvk18dpuLL79s=; b=k0Cc9VTBDqtwIm0iOTtb1YePMtxBVWAOI9Q3ZM/K1PhqA4ql1fA1JutXWy2yHJ/+qm a7Ng2D8itAB6FDuFcfQ2aGZ99wuRslSqUagNzfD3LoON+WNG3WY9ZJ25n3vddoqcI2tW UL84q4NB/3g3dHdt8eDethhpupaAv39pdXDEwx1DIekP2UJCI3K+Hjxzry11vOfE3CBl +ZSYkKFTY1bZoajjX3o2624Xs8LmurIjjZNIe7h3CscNvnRBT4D/AcVOVo19ntEixp4K mOFgEgyymTzEXPT/RHxKeZ2pFuBdW1w0GtPHDKtfYgcG0Kwc4pMNDVFuvVVFfUEgU/1U nDWg== 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=197lBONP6pItK9QmNDlCg6sPoKXmLwJvk18dpuLL79s=; b=0fXN1CGzUuIO3waGHB0XMYD3qxU+b1KMJZAl+TvO4gXkz4NkaWBORvJrL8JGE7lDW6 jR92oD7qqwlWrfEyUFmq5Yv9arwpapRBskqVMlbJcP0D3gptS5KGabhbElRKqp4Y8dYI shWI/hBB8nKjzX8YZtpwDTMBarhQaNF3TQs0VRgAoCOOQ5kwMUPJX6qOx2A+YAXe3c6/ K6aWc8EJWeKjLVsoeoPwVdGXcDfpGaOIHm6Vsucnrnqz5CIl2pbKsq0fB1NTNMSgSmRp A6OYuKiISBDXt8hq8yoYNoD8ZUOBC7auJ+899bmh1ouQNsADM6eoqk3oA/As8VjfKqZK qoig== X-Gm-Message-State: ACgBeo3q9qth0KCcw83461qJcdWKXifmJuvlvGQC56KNA0e/aAw3lGjC 7V1VcCpFAYqVQfFTBfnwwoEPrxbbWEk= X-Google-Smtp-Source: AA6agR4reilpFpUvEewGSPd4pYWnq8wVJ3csPWLD6qOM2cUWxx6fkRqpTRKVHeeVrU2NYyZbxz17wQ== X-Received: by 2002:a7b:cd14:0:b0:3a5:c5b3:508 with SMTP id f20-20020a7bcd14000000b003a5c5b30508mr2165213wmj.179.1661604279125; Sat, 27 Aug 2022 05:44:39 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v5-20020a5d59c5000000b002257fd37877sm2369308wry.6.2022.08.27.05.44.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:38 -0700 (PDT) Message-Id: <409492ad830828f2b5f341706ad9ad1c64f66d6e.1661604264.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:17 +0000 Subject: [PATCH v5 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. 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 d797cd1cef8..a00167f1373 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 Sat Aug 27 12:44: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: 12957014 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 7CBC7ECAAD2 for ; Sat, 27 Aug 2022 12:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232065AbiH0Moz (ORCPT ); Sat, 27 Aug 2022 08:44:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232888AbiH0Mos (ORCPT ); Sat, 27 Aug 2022 08:44:48 -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 14E8132058 for ; Sat, 27 Aug 2022 05:44:42 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id e20so4732537wri.13 for ; Sat, 27 Aug 2022 05:44:42 -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=SbKPM9JTUZha4nG2bHynsELou0YoJeQnyy3IQBLS1ek=; b=IlQTgsUHtuNBkbef5r8UVLxXjJkakq1i3rjaRgC8LbQS+zePSmnaWM884mTDMz3fce BcsDikhr7k2GikJtsICPIi2LB1HVHyT+FUItCOVKa+cf78Hxb3N+EkNTeISjyAiZshPN sDUdSG6rg+YN43NKy7FUU6mfyRgEzbHctU/3KWIxyH8iyks2J1k7zVtGGYPtqH8XL1Kl 3UfgkoLDiuicPLxIAfoaZ3gUvEHcHsyKlK/5Bnae6bAwUEPs9heRoGOGiB/eCfRLsKnL StaEQ8sAXrm/iIIyp/h0hzpcAApnN3ikd7rftVDmdO8ckVMhss2F8l41+o7m+4kfeg7c x5MQ== 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=SbKPM9JTUZha4nG2bHynsELou0YoJeQnyy3IQBLS1ek=; b=kKD5xwhztHILbFk9XnILaStDc7xK2UufDW0EtmI7itbWnqQXHP2cBWH4fa8BrfZS2G o4Ti12lwhNugAtgtFbzLMogAK2TL2d+aPRkRxRF8mzsnvyWBaP6GnT7+OABR8Ui+myO7 63R/Hj5k6IKpPr3XEfmJosUCCLNnIya4OVlFTHBMu5gbcYj/9sWSpUG4GJ1/PE/xLqmk VD/++wBpPNpfdqZMyzMLo2arO2cI/usQ9N6yLVrwxPgf5FCkxxrq87yGqieI02Osv5d9 roz245PzGWZTCCqK88YHWvhtbJZbwcVkUGtpmdSnROmmVHK9qVSZtMySYi3AxjdrxwRC iwew== X-Gm-Message-State: ACgBeo0pgtWIFnUS7vBznI9ILVuiffu1N79jEdtSgDx+cgf+ROZpNfjR FVoBsI5h78X0P1rA4NmM1u6bn1/uiPY= X-Google-Smtp-Source: AA6agR5Tsqy2YAdj1pEEmJEniS943GPGA4/OhydeTX/xLfQD9PkRfvaDw2TuAevLujx5Fn3cWvjLkg== X-Received: by 2002:adf:f841:0:b0:225:8b4f:9a5c with SMTP id d1-20020adff841000000b002258b4f9a5cmr2058877wrq.667.1661604280386; Sat, 27 Aug 2022 05:44:40 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v18-20020a1cf712000000b003a5c7a942edsm2614999wmh.28.2022.08.27.05.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:39 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:18 +0000 Subject: [PATCH v5 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 a00167f1373..5cf688c0dac 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 Sat Aug 27 12:44: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: 12957015 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 751BDC0502E for ; Sat, 27 Aug 2022 12:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232888AbiH0Mo5 (ORCPT ); Sat, 27 Aug 2022 08:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233011AbiH0Mot (ORCPT ); Sat, 27 Aug 2022 08:44:49 -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 D277532073 for ; Sat, 27 Aug 2022 05:44:43 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id bq11so4737564wrb.12 for ; Sat, 27 Aug 2022 05:44:43 -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=5RcJoZRTa7C6GfnWGFEECNH5E/ou2jLePAPsBm7pvOI=; b=p0SAzbmT382a5eCHQz55P+swwWIHjLeXitb0VoLkTTQucpdTKX54gVioTZ61vBGFA3 Kc8OAA8RggXWQ9GaNBwvG/vQr0lZR2rpPsjTAGCphyRBYCgcDV7e8Bjypp89XOLWZYki SGbaP1u6FzItFQRoOeGPyruGhhdZg1IDOtM4cqjOAlCyMHZB6zmc61HbBi5aiTzSDEzl 4gy8OK61mC4Yy6w6JLA/ntEQsYAcmuAYGLvInBMFCaVrquIn38afA453O4sKyMm8U7Fh 2vlXF75Dareioxw/fdLJJDsaGurdImawmd2Z7ctqWMl2op3OeeAv4YLrLCUnSxssOCFH DQPQ== 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=5RcJoZRTa7C6GfnWGFEECNH5E/ou2jLePAPsBm7pvOI=; b=hiu/PkUuHx/2LwTOtuzHK6bAp5CrYhTv50V+B9yf1QqcqzWWDzxD+c8eIOTb1XGw9G lk0+GWm9ETaiQ3Hf8js6pR2J59JtdbZrn9K+0qtLGd1LGY6VxAEZBeuwBINWvJ1rhMkj lvGICDnhu2NKmcjOA+NLaQd3voKFgRV48J+8hmzPOmq/9RE2QEL1eCEAq+4e3Um1udU9 JkgCZgOhX1k+7F1F0j52rMDal1SfLafignBbt0TKXThdchltIobqF1UI6aTQextnjouz xooglBrUZj4U4cBZEDGSbqMRlwlsXCg6o64LSatAUfHdtXlAF2fZG1SgUauv5h5MkpLj ySPw== X-Gm-Message-State: ACgBeo2ApZsWpNvS5gLnOoH+j5fvNcG5nyfb7wRfQ7QRWsmEPg0kzGhi m5oC7xjjEuU1QdV9ROnNftta/6OxD7k= X-Google-Smtp-Source: AA6agR6y0nYqvjvQ89mTL3m/idd+H82tgBILC2CpgCuAJSmsLXKCdnwyGtH7GfaXb4Dd6BE5TESozg== X-Received: by 2002:a05:6000:1210:b0:225:5eeb:fdf3 with SMTP id e16-20020a056000121000b002255eebfdf3mr2193312wrx.334.1661604281618; Sat, 27 Aug 2022 05:44:41 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z1-20020a05600c0a0100b003a1980d55c4sm2974824wmp.47.2022.08.27.05.44.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:40 -0700 (PDT) Message-Id: <8a0adfe3867157102e75d53ed928603ad634b904.1661604264.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:19 +0000 Subject: [PATCH v5 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 5cf688c0dac..3f333cfae76 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 Sat Aug 27 12:44:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12957019 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 882A4C0502E for ; Sat, 27 Aug 2022 12:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233150AbiH0MrV (ORCPT ); Sat, 27 Aug 2022 08:47:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233180AbiH0Mo4 (ORCPT ); Sat, 27 Aug 2022 08:44:56 -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 90DB93A5 for ; Sat, 27 Aug 2022 05:44:44 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id j26so2103008wms.0 for ; Sat, 27 Aug 2022 05:44:44 -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=/kwZIue7j8EWKzTdscC6miqTsBYC8i81DbI86N2OYWE=; b=JXsinyWPXwGGLnqNfqWGR97FlGwMLv2MOcCMxOuS4OG4k8VswApb07tIygRDmw1+uM oUThnWBQqZlN3r28nvuZAit5Zxj8l/Ue/R7Jjr4RgcViG80iGE4v4wToyWX+SPyW7l4H Ewdz3aD6UNFRRr/hwoZ59pTp6ZGROi6d3z7DgkSk7vkrH2mny0t2nn9f3gzgZvjxe7v9 qHkLoHyutJCJYyD7jLetizn5a2X84a467hGj8JueIbRcGta3DnQlzh+4Byar6uV6q676 1IOf8oS/w2jGBuu6hS4+7REs/C/q3GzNIpPDMeipyKzSCGTP/xgPzTi2kNKcu94BytNi 5PeA== 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=/kwZIue7j8EWKzTdscC6miqTsBYC8i81DbI86N2OYWE=; b=7UKIvOf42Zqv0AKv0HgqNUlNT7EJSbm/Iu/eJUL6fq/2mhpidf9cozqwGW4XOlJKt4 hFqEuCmFNpb4SOMJ6nyDZWZQya6c+pE8Y7AOFpRN5fidVqoHiP0rnkgRv+qjDLlfrNz3 1vDEHVCcbl8CvEYQ56M41wZ98L6UTZlKjeHmfU6Fm6/Y/JWPmGFJhRZ2RgmZhtZrYKYK ov+iXkg6ZnxCwx8KvxaRhClGBxLDaBtXoSBDYNCmVAL3cGT5OmAlgGyQwUQPcTlFdi5I uuzv3pz6Zsq/71SDE4BFnifchDnDZW/3JRnD8b6KZVvnm8HZ1b4ZfSH7rMGaTCk18dGv FBng== X-Gm-Message-State: ACgBeo1dPkEeeGsSgfU+KsPp/PzwFmPDXZL6lvpNS0FM66NCAW2fCaSt IsH2kKOH5GY6vqS7Ubgy8Z+dfncUfA0= X-Google-Smtp-Source: AA6agR5boSidE+G/JyO0n5+MCjnO8nEdkL5j8cNGKBe8mWNcTq/3LVNreGwSlL8f2tMJDG91ITCdCg== X-Received: by 2002:a05:600c:40d5:b0:3a5:3d9f:6e7f with SMTP id m21-20020a05600c40d500b003a53d9f6e7fmr2244635wmh.21.1661604282667; Sat, 27 Aug 2022 05:44:42 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k35-20020a05600c1ca300b003a5f3de6fddsm2978374wms.25.2022.08.27.05.44.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:42 -0700 (PDT) Message-Id: <189d2b3ba46ce67ece7f8852d3ced4682ce8a645.1661604264.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:20 +0000 Subject: [PATCH v5 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 3f333cfae76..9f78bd45ca5 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 Sat Aug 27 12:44:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12957018 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 28298ECAAD2 for ; Sat, 27 Aug 2022 12:47:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232995AbiH0MrT (ORCPT ); Sat, 27 Aug 2022 08:47:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233187AbiH0Mo4 (ORCPT ); Sat, 27 Aug 2022 08:44:56 -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 D69F2D8 for ; Sat, 27 Aug 2022 05:44:44 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id b5so4757400wrr.5 for ; Sat, 27 Aug 2022 05:44:44 -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=LNl5SVdJoRTLtmYCF1Gl2szB2InWVkGCdpMEEKC38No=; b=cI04kUWMrhczuIOoGZ19hmtnjXxjXqy3gaYE+NhXGlQWP0F6uoZKK0mJn9r6IoBZMR D/zXNZ65uKl6b+muQ85oAcJHNrjg93e1KkdogUbHD+BMcKRsU/GPQERglsvrBtB2AuY7 fIAv8xFMMPAoGRsQjndVtF0uCLRnpQctG4DY6KmARZ33iA1TLwwtqDj8rNV5yb1jhWSb XB5sUeEUbB9vhS+SbaL2Ji0CjoeIsT4IbivOQE5VQoQ95UG1+b6t2obz4P3MnBqZK9Xu lVwwypmEe4Uo8825XyoNRw4PdM+Lh76MkkHJGllX+0orc/zfXTumR4qdc06Xyi01uXUh RJgA== 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=LNl5SVdJoRTLtmYCF1Gl2szB2InWVkGCdpMEEKC38No=; b=TSqZBCMhGWlaVFa+nZ0UThqr5uM7Y5LrYH5RqbkI1NY1l4kHL2iG1j9UKNYK2o+7XQ NJmpylsYKbAMjbKtua8COEXNd3UCIuWYyWmEzWFdnRZZy/hunI6q6TrNp1o4LluEqQoA lhDh2/v4uJZjaqYviGo2OX2lN3GQlIeSpeuZQjQoP4ZdlvrsJ/tbx9v111zp/W4Ct0vg RW8nMjaYQa6UNp5qKzlyII2NGtm1q+ztW0M2oJ3M61wYDurmgo/1MHtJ+mIGi0m8Whn7 3RPeYRRpW5xICx0MyvREt3LKC95Q0Htyer4u+RdRi/x62pmdJO+Y76on+2DnjbetLSkB VevA== X-Gm-Message-State: ACgBeo2dgyqMuxBcfNxlrgc8HB++QMwDvEZC9pZMjgVuWWgiKznXTmmL rjvDVOO0JGYBZ/9InpnGdZffoUy3yNQ= X-Google-Smtp-Source: AA6agR7cUbqgblGIcVJC8VbUViayPVIuSucb2cFLexqDiwE8piix45ZlJVot2CPDw9T9Ac6pbMdnvQ== X-Received: by 2002:adf:f1ca:0:b0:226:cf9d:7c2a with SMTP id z10-20020adff1ca000000b00226cf9d7c2amr2128228wro.392.1661604283953; Sat, 27 Aug 2022 05:44:43 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j34-20020a05600c1c2200b003a682354f63sm2946648wms.11.2022.08.27.05.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:43 -0700 (PDT) Message-Id: <32bf74e3050a6e30e1e3fb1e77ce0d53f9054fd6.1661604264.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:21 +0000 Subject: [PATCH v5 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 9f78bd45ca5..d243a9132e2 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 Sat Aug 27 12:44:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12957017 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 79076ECAAD2 for ; Sat, 27 Aug 2022 12:47:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233680AbiH0Mpj (ORCPT ); Sat, 27 Aug 2022 08:45:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233077AbiH0Moz (ORCPT ); Sat, 27 Aug 2022 08:44:55 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CF67F51 for ; Sat, 27 Aug 2022 05:44:47 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id e13so3848265wrm.1 for ; Sat, 27 Aug 2022 05:44:47 -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=PauC0EwEr5xvcTDJZfV+MsH+SKq8eY9nrWh2OoMP6y0=; b=cHwByHfmPJ3Ly06YCHb1haUQ6u3JPNmVUC1WGLMcZp6Ah2eZ8vIWVrk07kmNRFjdl+ oJod5c250kqJLNH9HedS+EJw01StuegXUu9KuGIJNvCF1XFtlP6BMi+sXYCPDxPhr9BT QFkCiOUK+h00akYQ/vEOV6542o3qekK1dbekJWQWjJBu72JV9C/D5qR5DdwwMHFM5mJt IBrV3g+P9GYt+ovWlZ14+w/+7TKMPtF3n8nO/2ovb8aINRC0Mil9FSdS1yIGZ2QE3Fw6 hiEgsdeR2xpdxwaUD+1rNi/WeqNqNXYW8XCSTWauMfecG2X5WJd1s5QcqnuSoODMEWpM mL2g== 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=PauC0EwEr5xvcTDJZfV+MsH+SKq8eY9nrWh2OoMP6y0=; b=28PVQGI8lsDq9tKpCyZQHNJRBRuPRywz8NoWjBW+bxrR+Jyed1DYnUMGgITwT58NYN 4cLoKenXM9UVRhHhY5AO3IaQuCKXAjmRGtW6e8i0k4Qm2npodHTf0nfxrJxBhnY1zphd dw+r+z/b+5dykfdlqzTtO3GTr3J1WlzTtshbU9CS0yXCR4pmEfPUp3L4VzoAM3aID4uU vPG8Q6INyoz3HDvwqZoscumM9xhoWD6Ao09n2c7tXhiQD4OrL9M5ShyLh1jgYDMpe3jr P0u8SC/DfH26qQXvcurl1Y5tCaB+D9u4L0NMgvNx94FOZaQZwa08NeCvM4eOX/aR9Sf5 v6xw== X-Gm-Message-State: ACgBeo0Lg94dTsTYIO7GS1iZ3WRyV78hqRC0nlYMmC5qdj9KwxWBaOBJ QCGzzyu6dt8g2thHEYoKLXFPgj/xzFE= X-Google-Smtp-Source: AA6agR4o/8W9+WLDEC+wFr3SLT0fKQfSwS4/YFv3SEvSajbx4OPLXUIyQ3aGmYTLDHnG/fq++8mNhQ== X-Received: by 2002:a05:6000:1549:b0:225:64d0:a5c2 with SMTP id 9-20020a056000154900b0022564d0a5c2mr1999365wry.87.1661604285139; Sat, 27 Aug 2022 05:44:45 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id p17-20020a5d6391000000b0022511d35d5bsm2307603wru.12.2022.08.27.05.44.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:44 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:22 +0000 Subject: [PATCH v5 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 d243a9132e2..16f5c92bb9e 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 Sat Aug 27 12:44:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12957016 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 1C2BAC0502A for ; Sat, 27 Aug 2022 12:45:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233077AbiH0Mpp (ORCPT ); Sat, 27 Aug 2022 08:45:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233052AbiH0Moz (ORCPT ); Sat, 27 Aug 2022 08:44:55 -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 34C08DE6 for ; Sat, 27 Aug 2022 05:44:46 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id bq11so4737682wrb.12 for ; Sat, 27 Aug 2022 05:44:46 -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=aGD/ZignE1C0ZhT6sGuJHm3uTUzVHjwimyqlXH6u/GA=; b=Pwst26F4FH1fVh/xz09LY9f2czkB1XL7xvk+QYZ5trSwFBMjDqIvT0j9KxNcGu/54+ 7LbDqHe2ZjULE0PvAehCZxNU3qS+hrLwux4mnMBozaWYC+g9+d1NtbzPHGRaJvsaIXem jEI0F9pJ71kFfuQNChOsaFRnEpkjUXAGSvbPx7Nd5TLYUIQIKQsg/IdYjhAFYbXjYPTA IQwnpVHQLj0pWmzGvgHYQj4UfWQN60zjbM44VKwruFIk3QChcHdXcZIVZnNE5tEfBZ6Y 0Lb+f9d3opH/vMSMV9htOixXyNzeHldXNhpCXbxNs2mei17deEqfUyipISKg1vXx/Vkb IBCA== 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=aGD/ZignE1C0ZhT6sGuJHm3uTUzVHjwimyqlXH6u/GA=; b=ji1AYi7MmH5LaQlD+aQ7vcL9w3jdsixyNCXWCj18Gdcs3S/v0icfN0z35tMkg4g/1W BJN8PgsYXoYTgsvFyy4CN/dv2gGKExuwZVgbXOvlTKUreydRHLLqRF2/5I3LfbkD+Kfk ueXqWQqxJ8pIrOG5dDen7LZnGyvZSEdNpbbWgCfiNAx4Jy/cWiE2Yf84yAWmi6kt9yiM wWUcnCb19cZgqyQCJF4Fui2IaqVntFibfajA+i6wawnte3yh3mEUbp8pDrO6QwPTv+5/ a3dkKsa2XFj0SlWcDYFgJBs+L34nH1Dz7CfJeixBR6JzVGR61CYm59iArpqBf5WXkA8j thpw== X-Gm-Message-State: ACgBeo2/yU+5HzFDmP5WyggIFdkevKwVUWFW7R7qRkOTAi5EptUBkoJi mKsozmKTFlnAvwuD5Y0KhtZugsxbH3w= X-Google-Smtp-Source: AA6agR7rP9LhmanOfPHGImXsBTnarXPx8uNEC/Kg9ibC9bjCHRE5QQ222m/1HfkDgzYx4QA1LXAz2Q== X-Received: by 2002:a5d:6f08:0:b0:225:3bc2:ac94 with SMTP id ay8-20020a5d6f08000000b002253bc2ac94mr1973217wrb.203.1661604286253; Sat, 27 Aug 2022 05:44:46 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o7-20020adfeac7000000b00226332f9275sm2264369wrn.22.2022.08.27.05.44.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:45 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:23 +0000 Subject: [PATCH v5 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 16f5c92bb9e..cfd6b63214a 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 Sat Aug 27 12:44:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12957020 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 A9BCAC0502A for ; Sat, 27 Aug 2022 12:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233184AbiH0MrX (ORCPT ); Sat, 27 Aug 2022 08:47:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233147AbiH0Mo4 (ORCPT ); Sat, 27 Aug 2022 08:44:56 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0FA35FCD for ; Sat, 27 Aug 2022 05:44:49 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id k18-20020a05600c0b5200b003a5dab49d0bso2125826wmr.3 for ; Sat, 27 Aug 2022 05:44:49 -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=X1mB6CZwiDKyGoue96TDBcQbaVB81qRvAfMFpjbGWahyoDxbfD973VxmZO8/pkvNzg L8SPunMPRgLtZqF2nxzdsQIvFAk+dLajlULf4W7Tflrg9BvcqXTvLGe9cml9BTUF2j0m vTy54PjCOJ96WXgfLUh8OV+8roslc06x9NLyyKVTWXaDaOt4jqkGUUQ597lpuViRVZr+ d/1t5P02ku/BR4/ba5u7n3UCj/a7lmHrTqnSMq+IhQ+8vSE9asAFuyihtSy8uRWVnIAM NlXehF6m3vyLJthn9vytSgQE26J5zA0S/WDnw2rmYVpGrYkSWS2FEhWupLUIk7RepcSg beZw== 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=4DBM2wKGhKMdewOD0MNQCITxchvWZ3DbyOk9Jhpf5zzA2BtfYQog0tjzT+OJAZ//wi ZNRsvKdC9x1myoh68amBTQRr4/U+AGnBs5ZxgOBVVjfNCWiMIts6uSPmmPzTC5tf3wNT Ih6itgB3sOuFXAzOrpXwObaFLmZ27PbCu6PcQ4zgvwI7Xoig05kwTd/pFfetbwJS7IM4 uuO6xpAR6IS7BGxocD8zcxjohrZq44nZfe23f6b6F2gUGRMqMC3npPPMJZOHSlf2+JGD 0lXdCImIMtNVmYDVbY+wi2OIxZ4aQB8eOWCZOUBmcwI5twekflqf5rIMALoA6k/oYb6g ioFA== X-Gm-Message-State: ACgBeo3Vemv8rdBd2DjbFghfEMjcReqXXM3n8E2mirwX3jWC0BXT+KO5 +NFMagYhCPk7aHUk/ErUiO7JU6lwVL4= X-Google-Smtp-Source: AA6agR76imPlDCkvaJGmzZv7YJ6FUbvzwqEBH4QIOao+Jsvj9DNjZ1B434oJeVG+cT2ilBog3xkLZw== X-Received: by 2002:a05:600c:2193:b0:3a5:346f:57d0 with SMTP id e19-20020a05600c219300b003a5346f57d0mr2166827wme.124.1661604287553; Sat, 27 Aug 2022 05:44:47 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f16-20020a5d58f0000000b0021e42e7c7dbsm2238190wrd.83.2022.08.27.05.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 05:44:46 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sat, 27 Aug 2022 12:44:24 +0000 Subject: [PATCH v5 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" '