From patchwork Fri Aug 28 12:46:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11742693 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4806714E5 for ; Fri, 28 Aug 2020 12:47:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D2BC2086A for ; Fri, 28 Aug 2020 12:47:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bq5gX1aZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729448AbgH1Mr2 (ORCPT ); Fri, 28 Aug 2020 08:47:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729306AbgH1MrN (ORCPT ); Fri, 28 Aug 2020 08:47:13 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DE87C06121B for ; Fri, 28 Aug 2020 05:47:12 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id o21so798796wmc.0 for ; Fri, 28 Aug 2020 05:47:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=InUKzhmVJZsVoLdzQXNZrn9VeJlbgKIHXnzWsess1dk=; b=bq5gX1aZIqiARS+9uY4clBH90vyZNP0/Wg3Dy8Ib+3v+pX/adoxPOYLnYysBDnGQ6d GkKtrjMryQMX4NdoQ9Ab/QBS4A7w7zL3Se0mj3Ww6p25SFvP8dMzYkeQv+TwR39NxgAh 8elHn/q2PAwgnZu4taXaCo6ThZ8wIVDBxT6DLSucUNnP5CBkUQGGrJTEBgLtiraKffPZ 8xJQnvv/hfQoGusnsS1RalM9lNwC9nrwfHjhzeTnGt8viHcxGqyPaRciTvt/EwPM1F+M dhfM2LcK1Bm0GDLRVOMMMrcQz0/LWf6q8GlWPkc395fJyK/GznBa4VSZuU7Yh97FhRbP 2w9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=InUKzhmVJZsVoLdzQXNZrn9VeJlbgKIHXnzWsess1dk=; b=BZ2V4jA7Oh2EQC2YZDxJq2jfDbR9PYyQmI8avtW0Aut0vv3YJj6isoDC7FoSoCiaie BGJo5QY7ek8Qc9W1GcM07n6GGuHzGN7y/XOvsKtC4RbrCwlBiMNxQh3AVtXDOfQLXtwf KFp8bIcLAudO8BrntQNeM7l736EhvtVlYcfGxQ/XkWrbpFgVR4Q2WT0JZiU9BtkH+dG1 R8JFIt8FxRBtHd6vKAHbl8oSF8SsGYM5OTeF1eFQW6ZbwV1WlhOFw1zOA/LwAmyKD/lW iZPsqtSc5mdyGcgxDKtIudH7VR+IIULYdDY+JsD/kNDuktSkB85NbFCDzQJpv6MiPSiZ yiOQ== X-Gm-Message-State: AOAM531VOa/8TjF37bxwEPd3ko4lx8l5oLD5m4PLVBKBkbviIx314BwG BPCA3NwEHO3WyFml/2cRD/5lf0BV8Rs= X-Google-Smtp-Source: ABdhPJznaSB39p8NGAP7fzZb4ZfJ3RipbvHMQHQ5ien/GKULeplJ15UxFcQBJgqaQh8nc6CyEXhSyQ== X-Received: by 2002:a1c:c20a:: with SMTP id s10mr1451508wmf.55.1598618831051; Fri, 28 Aug 2020 05:47:11 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id o66sm2176878wmb.27.2020.08.28.05.47.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 05:47:10 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Miriam Rubio , Christian Couder , Johannes Schindelin Subject: [PATCH v6 01/13] bisect--helper: BUG() in cmd_*() on invalid subcommand Date: Fri, 28 Aug 2020 14:46:05 +0200 Message-Id: <20200828124617.60618-2-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200828124617.60618-1-mirucam@gmail.com> References: <20200828124617.60618-1-mirucam@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In cmd_bisect__helper() function, if an invalid or no subcommand is passed there is a BUG. BUG() out instead of returning an error. Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Miriam Rubio --- 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 cdda279b23..f464e95792 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -720,7 +720,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) res = bisect_start(&terms, argv, argc); break; default: - return error("BUG: unknown subcommand '%d'", cmdmode); + BUG("unknown subcommand %d", cmdmode); } free_terms(&terms); From patchwork Fri Aug 28 12:46:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11742695 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16A9414E5 for ; Fri, 28 Aug 2020 12:47:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F33BF2087D for ; Fri, 28 Aug 2020 12:47:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XaCJpAOH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729449AbgH1Mra (ORCPT ); Fri, 28 Aug 2020 08:47:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729369AbgH1MrS (ORCPT ); Fri, 28 Aug 2020 08:47:18 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD082C061232 for ; Fri, 28 Aug 2020 05:47:13 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id s13so808802wmh.4 for ; Fri, 28 Aug 2020 05:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ofxh5lrQ413krwngWYtfxJNA/uVroqEq6PSX1rEY46s=; b=XaCJpAOHm/IrC9JQPEhOpNe5ryb+v7poVMsoeQ4lC/6dfd1GTxvJH43QETqodlsIVb epliPR6jRWAfrJMu8wSgg8nRk5BmYbViuC9jTwpaCD+GQaR9ZReHz/AinsXMOFsaoQR/ 0NdmKCQVkDbSEgTaqRtd/xbX8+tGUXQc9aKhem7jmLPdXwYXEr5r3iwQSEk99zAGvdVl dW8a/TQj+oSPfqdgVp+qWOJlkSlek51tVQelcBf1td5qa6ETcRYReKyRrfUNxjXX7PL/ /taYKmsIFuG6A8B7KbuotY0CvbSfTX/gFMcoAGskc0Q/4+ehy7d2zqZ576IjVBuyhQE1 uPcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ofxh5lrQ413krwngWYtfxJNA/uVroqEq6PSX1rEY46s=; b=i0zdZWrJGSmnC9+o6OPsiRavHNZR0afdxqUPnjPR/g/Cwdl28LHhlMXfKQMS9KHJKs 9Jf2jZobD6LSvTTt32JZwQ0RUtZR1GFxoY1gB/OkWEd6ZV7/vVTYxX6P9zgyUI1Y2jMs HH9P6CIkIhi5LcZACgxnUfAAMyiCTqlFZNZQ8NsrLVXxRQaHsRGYUUXmekL07u3+wxzs C+fiBeM/Rx2gUormHfa0nQkAns1CZFtnqTa1gpeEAKoniZbw3iq/bwmobUF54byCZhZN vXO8xnspIDlZllyKbOZayDnej9Gpp4Cw5nilCC3KnW3iCWOG6iPld4NJaCjHi3gt1jjW DLmw== X-Gm-Message-State: AOAM530QABlHcAzKAc7FJ5EYlwpYqgJ4sxb0xm5yz0epeMxio78e1YOa AsMAsiztRyCu5vFtDSRYpriHxsPvswQ= X-Google-Smtp-Source: ABdhPJwCa1fFbl//BfzXIxyP6fbghMVJZZ06nREn0nNVga/J1uV1CfrzwfQD/A9oEtJEuQtsD9JuFw== X-Received: by 2002:a1c:23c8:: with SMTP id j191mr1406430wmj.64.1598618832236; Fri, 28 Aug 2020 05:47:12 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id o66sm2176878wmb.27.2020.08.28.05.47.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 05:47:11 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Miriam Rubio , Christian Couder , Junio C Hamano Subject: [PATCH v6 02/13] bisect--helper: use '-res' in 'cmd_bisect__helper' return Date: Fri, 28 Aug 2020 14:46:06 +0200 Message-Id: <20200828124617.60618-3-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200828124617.60618-1-mirucam@gmail.com> References: <20200828124617.60618-1-mirucam@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Following 'enum bisect_error' vocabulary, return variable 'res' is always non-positive. Let's use '-res' instead of 'abs(res)' to make the code clearer. Mentored-by: Christian Couder Helped-by: Junio C Hamano Signed-off-by: Miriam Rubio --- 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 f464e95792..b7345be3a5 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -731,5 +731,5 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) if (res == BISECT_INTERNAL_SUCCESS_MERGE_BASE) res = BISECT_OK; - return abs(res); + return -res; } From patchwork Fri Aug 28 12:46:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11742697 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA2C614E5 for ; Fri, 28 Aug 2020 12:47:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C147820872 for ; Fri, 28 Aug 2020 12:47:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EkVQRKEI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729457AbgH1Mrg (ORCPT ); Fri, 28 Aug 2020 08:47:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729388AbgH1MrS (ORCPT ); Fri, 28 Aug 2020 08:47:18 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED1B6C061233 for ; Fri, 28 Aug 2020 05:47:14 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id w2so818624wmi.1 for ; Fri, 28 Aug 2020 05:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6SFHZnVCeS0qHqgRhbltpkrDBqLd+6jSYWAfeJlUWPM=; b=EkVQRKEINIdkD+odhYKpo3s9bFedhs9VwPHhUkbwUs9Ub6ucE+IYi14InxchEpN0Pq zCPJLrCKEecraOLEX6hopXFCPM7cBTceoYaG1tNZXtVdpFGtB0BVNWbgDhVdCUiza1AL hLKpdpYhTq6yooRYNr4esCM8Ye/oQTnhXebHvu/S45YmIsHb1DUz5C62XWrHhxMSNzck AITHVF3sh9RoJR1OJ5Fuzt5Z0Q0/eekUSz4t47yjTiymSVo28t+s5jhaKb3BigVucC/p 3Bhqu8O5E8xvibSqePr9UL6D6sMMMoEVK03L55jJoBbTO0I79V4jT+wvYNAU5g9LEAzP zrJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6SFHZnVCeS0qHqgRhbltpkrDBqLd+6jSYWAfeJlUWPM=; b=OzoDi4DzAbUkuKY8oGqN53l/gKPDHd9lnMj7OfZykUwHYfD0DHHeT7suCmSf5qx+gM HF6Qznt3SS5kiLd6DOj9hAKsTk9OWHAXcdLK+wQxXd9lkcRrNBfjdVIzzOGP0PcyprT2 IRtVbo6AqP/+md4y99F2SHWzCJShz983MavXRKOoEAMn4rKOiWRWh0XPAVmq9/9IIqZw OIGzcNhINEBuyW2yKee/RDy2bNFo6LNUomA1nmqu5H5C1kqwDfmJI/XAX5mq0OcJ5Ho9 wsbtV3thzdpS2bWcEmEYC/NqH8K1fal99Z4xKx6C29fNMRZ5Np5opVCy2pBObYX4yyHY pACw== X-Gm-Message-State: AOAM533/6d0BsbQ0ZBvC8RDYK+dpWMJVe8afZtb+2TosHl27+ZZ/nCry P8GOhe4SIKuvF235pWkuPEbUi5/EHIM= X-Google-Smtp-Source: ABdhPJx9EtR+WIouFCVoKkuPMIuRfKORcIjRHk/sZhH740f2j2A8Ivjk0yclzdvd+EO3Jy7okiqtQg== X-Received: by 2002:a05:600c:228e:: with SMTP id 14mr1533487wmf.17.1598618833372; Fri, 28 Aug 2020 05:47:13 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id o66sm2176878wmb.27.2020.08.28.05.47.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 05:47:12 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Miriam Rubio , Christian Couder , Johannes Schindelin Subject: [PATCH v6 03/13] bisect--helper: introduce new `write_in_file()` function Date: Fri, 28 Aug 2020 14:46:07 +0200 Message-Id: <20200828124617.60618-4-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200828124617.60618-1-mirucam@gmail.com> References: <20200828124617.60618-1-mirucam@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Let's refactor code adding a new `write_in_file()` function that opens a file for writing a message and closes it and a wrapper for writing mode. This helper will be used in later steps and makes the code simpler and easier to understand. Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Miriam Rubio --- builtin/bisect--helper.c | 43 +++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index b7345be3a5..bae09ce65d 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -74,6 +74,40 @@ static int one_of(const char *term, ...) return res; } +static int write_in_file(const char *path, const char *mode, const char *format, va_list args) +{ + FILE *fp = NULL; + int res = 0; + + if (strcmp(mode, "w")) + BUG("write-in-file does not support '%s' mode", mode); + fp = fopen(path, mode); + if (!fp) + return error_errno(_("cannot open file '%s' in mode '%s'"), path, mode); + res = vfprintf(fp, format, args); + + if (res < 0) { + int saved_errno = errno; + fclose(fp); + errno = saved_errno; + return error_errno(_("could not write to file '%s'"), path); + } + + return fclose(fp); +} + +static int write_to_file(const char *path, const char *format, ...) +{ + int res; + va_list args; + + va_start(args, format); + res = write_in_file(path, "w", format, args); + va_end(args); + + return res; +} + static int check_term_format(const char *term, const char *orig_term) { int res; @@ -104,7 +138,6 @@ static int check_term_format(const char *term, const char *orig_term) static int write_terms(const char *bad, const char *good) { - FILE *fp = NULL; int res; if (!strcmp(bad, good)) @@ -113,13 +146,9 @@ static int write_terms(const char *bad, const char *good) if (check_term_format(bad, "bad") || check_term_format(good, "good")) return -1; - fp = fopen(git_path_bisect_terms(), "w"); - if (!fp) - return error_errno(_("could not open the file BISECT_TERMS")); + res = write_to_file(git_path_bisect_terms(), "%s\n%s\n", bad, good); - res = fprintf(fp, "%s\n%s\n", bad, good); - res |= fclose(fp); - return (res < 0) ? -1 : 0; + return res; } static int is_expected_rev(const char *expected_hex) From patchwork Fri Aug 28 12:46:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11742701 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80E4014E5 for ; Fri, 28 Aug 2020 12:48:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 63AD720872 for ; Fri, 28 Aug 2020 12:48:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f1aFRsxW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729418AbgH1MsG (ORCPT ); Fri, 28 Aug 2020 08:48:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729414AbgH1MrU (ORCPT ); Fri, 28 Aug 2020 08:47:20 -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 F31FCC061234 for ; Fri, 28 Aug 2020 05:47:17 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id i7so253722wre.13 for ; Fri, 28 Aug 2020 05:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VyLXkwQ3/HkrtKdVLWhHqYP4nvTAof/JNG9ta8LJpxA=; b=f1aFRsxWVP1OhT6/WQX41uh2aoAVbsdwkrhZd2kFA1qAP0LcXlHDFtmJTUr1BCHaBa lcoyBcMLPR9VHfnxD7ltDwWLVgZ6VNFiynQs6NJjsRZfcrxPI7puUNvoW1+mOFnfattl o2V3edQoHeU9bO2dew0WMwR2CVdTMQacDz0UTtt6RxDNR4+w6+HF/LLGBMfIxtAC+/VZ ejyPYG9k+RhUgQx/SZOu5QQ3Vm9uVNsuzP9c3xFRJN+UqbzTD/RxNQhHPxovvKXACb3e XVRA/Ugz5TuPFzSrSS2eJqi2lMSplQHegQ41SH48sz5yA8YXJmauczOEbYPmS44HYK1O +znw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VyLXkwQ3/HkrtKdVLWhHqYP4nvTAof/JNG9ta8LJpxA=; b=rPaBi83kAppKwJg4YBnAozRmIIZiwqGyDg3xwA+eAnCsQtDH7pMPZyzQS2tUq3q/AO lK6BIZ3TexbSULzTNX3XO1OXYBUSsX6dXFBspCzv0oYIWLArJWNStTJ9R59L92hiGhv5 ns1Et77/51JDq0VcC7R0W4E4sBf+apXAWbYYk9ttKcd0uHXvoEItP2h/YQ27UOqADoN6 snGSKq+JE84JTfcOACiUkdmBTJ7dgpTqDx744aaXD6c+bjAFVw99FGdaRNeVWGqHzrIQ CFGM5tVQyaSMRmdQ7+kJqvKaS9jX3v4rqtD5MIheX602nJGFoqWFzOAQD1WX2i4t4HCG Ibgg== X-Gm-Message-State: AOAM532dhmlSafNzdzYyFZ1vwlYaAuhe7zScPHuBQh8Gea8x5avnP7yc zq8F67icMIlwrbfKa4XSwZEtQcTTfKs= X-Google-Smtp-Source: ABdhPJw4ondE/YB/SaXSQKxxvoRL0S/q1y7aT1NUe4ZRpbnCx1DjOfRr59oEsfUjF8wdM2Ik8Uqi5g== X-Received: by 2002:a5d:4210:: with SMTP id n16mr1435347wrq.426.1598618834710; Fri, 28 Aug 2020 05:47:14 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id o66sm2176878wmb.27.2020.08.28.05.47.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 05:47:14 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH v6 04/13] bisect--helper: reimplement `bisect_autostart` shell function in C Date: Fri, 28 Aug 2020 14:46:08 +0200 Message-Id: <20200828124617.60618-5-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200828124617.60618-1-mirucam@gmail.com> References: <20200828124617.60618-1-mirucam@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Pranit Bauva Reimplement the `bisect_autostart()` shell function in C and add the C implementation from `bisect_next()` which was previously left uncovered. Add `--bisect-autostart` subcommand to be called from git-bisect.sh. Using `--bisect-autostart` subcommand is a temporary measure to port the shell function to C so as to use the existing test suite. As more functions are ported, this subcommand will be retired and bisect_autostart() will be called directly by `bisect_state()`. Mentored-by: Lars Schneider Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- builtin/bisect--helper.c | 44 +++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 25 ++--------------------- 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index bae09ce65d..f71e8e54d2 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -29,6 +29,7 @@ static const char * const git_bisect_helper_usage[] = { N_("git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]"), N_("git bisect--helper --bisect-start [--term-{old,good}= --term-{new,bad}=]" " [--no-checkout] [--first-parent] [ [...]] [--] [...]"), + N_("git bisect--helper --bisect-autostart"), NULL }; @@ -653,6 +654,38 @@ static int bisect_start(struct bisect_terms *terms, const char **argv, int argc) return res; } +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) +{ + int res; + const char *yesno; + + if (file_is_not_empty(git_path_bisect_start())) + return 0; + + fprintf_ln(stderr, _("You need to start by \"git bisect " + "start\"\n")); + + if (!isatty(STDIN_FILENO)) + return 0; + + /* + * TRANSLATORS: Make sure to include [Y] and [n] in your + * translation. The program will only accept English input + * at this point. + */ + 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); + + return res; +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { @@ -665,7 +698,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) CHECK_AND_SET_TERMS, BISECT_NEXT_CHECK, BISECT_TERMS, - BISECT_START + BISECT_START, + BISECT_AUTOSTART, } cmdmode = 0; int res = 0, nolog = 0; struct option options[] = { @@ -689,6 +723,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) 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-autostart", &cmdmode, + N_("start the bisection if it has not yet been started"), BISECT_AUTOSTART), OPT_BOOL(0, "no-log", &nolog, N_("no log for BISECT_WRITE")), OPT_END() @@ -748,6 +784,12 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) set_terms(&terms, "bad", "good"); res = bisect_start(&terms, argv, argc); break; + case BISECT_AUTOSTART: + if (argc) + return error(_("--bisect-autostart does not accept arguments")); + set_terms(&terms, "bad", "good"); + res = bisect_autostart(&terms); + break; default: BUG("unknown subcommand %d", cmdmode); } diff --git a/git-bisect.sh b/git-bisect.sh index c7580e51a0..9ca583d964 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -49,27 +49,6 @@ bisect_head() fi } -bisect_autostart() { - test -s "$GIT_DIR/BISECT_START" || { - gettextln "You need to start by \"git bisect start\"" >&2 - if test -t 0 - then - # TRANSLATORS: Make sure to include [Y] and [n] in your - # translation. The program will only accept English input - # at this point. - gettext "Do you want me to do it for you [Y/n]? " >&2 - read yesno - case "$yesno" in - [Nn]*) - exit ;; - esac - bisect_start - else - exit 1 - fi - } -} - bisect_start() { git bisect--helper --bisect-start $@ || exit @@ -108,7 +87,7 @@ bisect_skip() { } bisect_state() { - bisect_autostart + git bisect--helper --bisect-autostart state=$1 git bisect--helper --check-and-set-terms $state $TERM_GOOD $TERM_BAD || exit get_terms @@ -149,7 +128,7 @@ bisect_auto_next() { bisect_next() { case "$#" in 0) ;; *) usage ;; esac - bisect_autostart + git bisect--helper --bisect-autostart git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD $TERM_GOOD|| exit # Perform all bisection computation, display and checkout From patchwork Fri Aug 28 12:46:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11742699 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5B1D14E5 for ; Fri, 28 Aug 2020 12:47:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A462620872 for ; Fri, 28 Aug 2020 12:47:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HXM9vR0E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729461AbgH1Mrj (ORCPT ); Fri, 28 Aug 2020 08:47:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729410AbgH1MrT (ORCPT ); Fri, 28 Aug 2020 08:47:19 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 483E4C061264 for ; Fri, 28 Aug 2020 05:47:17 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id h15so1176338wrt.12 for ; Fri, 28 Aug 2020 05:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2I9Y2hRuXgRqT6FgB1KECR88tDHWd7i0V/IscrZ+zbo=; b=HXM9vR0EUWVF0uqOEGtL99oEWRvtB+uetlY/V0gxz76X1lySFhJuDHhgAzfl9doa+O 6kX7cixW3KVS4wCg+ydtZCvkM/kyVa6OWdfayOj2Vfhltqo3LYVrZ7MSGgZXHFrLcySq MhUj7Dkbfg8p229oIQH8VX5dVmClqtrfGgMIapy2wEMuyDLtDYg2cEpw2QErdNrhtmMp feVMA8+ZR3qKEL1B3v8zfJ1JKVbf0++S/Ke41kHBBK2EQ7MAed/zvpfrjvKhtAAzbelx y0KdoCKFA3JCMyZ2T2RzsNhUjFbddwXGx6+PGXW7AkCm+dMh/sv2PI1UpB4PS2VROa0Q AFqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2I9Y2hRuXgRqT6FgB1KECR88tDHWd7i0V/IscrZ+zbo=; b=GUV0xbuvi7+c1gf4kmj8cb7DkXGAiC4tve0btC1RnsSFcvM4gLAiCn5PxfVHwKw3iq xo+CYGJMiOQeh2lyl3oLxzD+zJx2zRZ0PhqKxLo1o9v9UAN1/wBP0ZsEIkumC/5xjavY rA0A00kNihR9gHFfraZO52kvM1sl+WVEaix/nktSRTIYqLuWeXO8eTBurAhwiNI8D6vX tJS/aBeT27kMPrXfAMV2hJPsvBOItLjprrsDqeTI/bkidQMKTkcx179JA77P2FykmiBI zR8M4969xJ4YXkkG/i71MRoGnWO2uYUIrrUy5M6Mtv9PGfdZPKISfnBXPnjiUCzcVaP6 V8Lw== X-Gm-Message-State: AOAM531r78ZsdoB2ujtWbU4tADWlJj44gXDcVXnRabuDnLBuJMwZJKNV Bq8pdsHu2//LmtwgRwd29rPjeSbDjpQ= X-Google-Smtp-Source: ABdhPJwn0+h6DeSdq+KqtUAyxBQWEPVR7lKlG6gWEyjIGtKw25oySxbHUT0sjlMTDfXJK0F8UGDQuA== X-Received: by 2002:adf:e449:: with SMTP id t9mr1425895wrm.154.1598618835792; Fri, 28 Aug 2020 05:47:15 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id o66sm2176878wmb.27.2020.08.28.05.47.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 05:47:15 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Miriam Rubio , Christian Couder Subject: [PATCH v6 05/13] bisect: call 'clear_commit_marks_all()' in 'bisect_next_all()' Date: Fri, 28 Aug 2020 14:46:09 +0200 Message-Id: <20200828124617.60618-6-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200828124617.60618-1-mirucam@gmail.com> References: <20200828124617.60618-1-mirucam@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org As there can be other revision walks after bisect_next_all(), let's add a call to a function to clear all the marks at the end of bisect_next_all(). Mentored-by: Christian Couder Signed-off-by: Miriam Rubio --- bisect.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bisect.c b/bisect.c index d42a3a3767..c6aba2b9f2 100644 --- a/bisect.c +++ b/bisect.c @@ -1082,6 +1082,8 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix) "Bisecting: %d revisions left to test after this %s\n", nr), nr, steps_msg); free(steps_msg); + /* Clean up objects used, as they will be reused. */ + clear_commit_marks_all(ALL_REV_FLAGS); return bisect_checkout(bisect_rev, no_checkout); } From patchwork Fri Aug 28 12:46:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11742703 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 575621575 for ; Fri, 28 Aug 2020 12:48:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 316C82087D for ; Fri, 28 Aug 2020 12:48:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FnNoAjIv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729414AbgH1MsP (ORCPT ); Fri, 28 Aug 2020 08:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729416AbgH1MrW (ORCPT ); Fri, 28 Aug 2020 08:47:22 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9D16C061235 for ; Fri, 28 Aug 2020 05:47:18 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id q9so816910wmj.2 for ; Fri, 28 Aug 2020 05:47:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NqJAa24aXt7XkNFoKLAjRUSlD+KeojnIECQGhM640xQ=; b=FnNoAjIv2So5MC8H5yj8BPzpbF20RM2BfYbrfxsLI5BWtOU/p24zYTwD5UxDYaicpB ITUJPX9pPVYKIA6L1GHL/n5eOPCNGxLsqiwn2Yg4PsEDCLUYPNdR82LAP+7Al1+ZLnUd nYJnZ8NMGwfY0hglscppxz2ZHwubnz7DAa9IWw+v7vgYRi5Ul47mQL4O6EWmUpVzq05j KqUjdcr+3ZZa6Q+69k0yqWl/+NNalXpSZ/WLJ1v03+JRlPAbs60NUCqeJJnQq2+CyYYB 23Kig7pNnMMstQhH3YHcXAW+QlwhjbcriCRyyw9i1Y9OKPqtJn1yZn0CKHlXw20dYEdi PqTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NqJAa24aXt7XkNFoKLAjRUSlD+KeojnIECQGhM640xQ=; b=GCURFhDqUySqZ9Y29ylq76sn4tAn3lfFJ3LeYZr6mNXu/tafgSPrpCMduhvEK5Dleg fQsA6r5LOoaLjfd0St9jMGoHAzei8nn+l4TRX0W5hmx/x1NtCwYL/0KDlT3f9Er5Aehn VDSorjimamsz08Z+WtT8cQ0mxZY2mGX45wSsKurFs/2qOOO1t40MoFa6fESLQCqFyEHH H/g/2t93rMfUG6FSsdFCY1o9nbA7d0EszcOEte6dImzXhbO2o7Js3bNRelN7Tin/OqQu E1gdcrf/3sSCxXR6ZgkVRlznSiB8lc6nCDs7e7p9KbYP/XRO842MKxMXO7S0AtY5lltn yFOA== X-Gm-Message-State: AOAM53251KOGY5MIpPspdiFq8mxmH1GBvzWJ9AsTwN5dVq3PvJxoLXwn dktGwkakf/fQuGeaU8Rwx2nY3XlOOGc= X-Google-Smtp-Source: ABdhPJysCnCdLQslGluf6rL4FfsL1fMFxEUwpLlndWMvQN2OspcYTaxBLr9pYvco81reNPzfiI/yhg== X-Received: by 2002:a7b:cb47:: with SMTP id v7mr1468199wmj.36.1598618837071; Fri, 28 Aug 2020 05:47:17 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id o66sm2176878wmb.27.2020.08.28.05.47.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 05:47:16 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH v6 06/13] bisect--helper: reimplement `bisect_next` and `bisect_auto_next` shell functions in C Date: Fri, 28 Aug 2020 14:46:10 +0200 Message-Id: <20200828124617.60618-7-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200828124617.60618-1-mirucam@gmail.com> References: <20200828124617.60618-1-mirucam@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Pranit Bauva Reimplement the `bisect_next()` and the `bisect_auto_next()` shell functions in C and add the subcommands to `git bisect--helper` to call them from git-bisect.sh . bisect_auto_next() function returns an enum bisect_error type as whole `git bisect` can exit with an error code when bisect_next() does. Using `--bisect-next` and `--bisect-auto-next` subcommands is a temporary measure to port shell function to C so as to use the existing test suite. As more functions are ported, `--bisect-auto-next` subcommand will be retired and will be called by some other methods. Mentored-by: Lars Schneider Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- bisect.c | 6 ++ builtin/bisect--helper.c | 183 ++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 47 +--------- 3 files changed, 190 insertions(+), 46 deletions(-) diff --git a/bisect.c b/bisect.c index c6aba2b9f2..f0fca5c6f3 100644 --- a/bisect.c +++ b/bisect.c @@ -988,6 +988,12 @@ void read_bisect_terms(const char **read_bad, const char **read_good) * the bisection process finished successfully. * In this case the calling function or command should not turn a * BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND return code into an error or a non zero exit code. + * + * Checking BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND + * in bisect_helper::bisect_next() and only transforming it to 0 at + * the end of bisect_helper::cmd_bisect__helper() helps bypassing + * all the code related to finding a commit to test. + * * If no_checkout is non-zero, the bisection process does not * checkout the trial commit but instead simply updates BISECT_HEAD. */ diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index f71e8e54d2..5d443829e0 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -8,6 +8,7 @@ #include "run-command.h" #include "prompt.h" #include "quote.h" +#include "revision.h" static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS") static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV") @@ -29,10 +30,17 @@ static const char * const git_bisect_helper_usage[] = { N_("git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]"), N_("git bisect--helper --bisect-start [--term-{old,good}= --term-{new,bad}=]" " [--no-checkout] [--first-parent] [ [...]] [--] [...]"), + N_("git bisect--helper --bisect-next"), + N_("git bisect--helper --bisect-auto-next"), N_("git bisect--helper --bisect-autostart"), NULL }; +struct add_bisect_ref_data { + struct rev_info *revs; + unsigned int object_flags; +}; + struct bisect_terms { char *term_good; char *term_bad; @@ -56,6 +64,8 @@ static void set_terms(struct bisect_terms *terms, const char *bad, static const char vocab_bad[] = "bad|new"; static const char vocab_good[] = "good|old"; +static int bisect_autostart(struct bisect_terms *terms); + /* * Check whether the string `term` belongs to the set of strings * included in the variable arguments. @@ -80,7 +90,7 @@ static int write_in_file(const char *path, const char *mode, const char *format, FILE *fp = NULL; int res = 0; - if (strcmp(mode, "w")) + if (strcmp(mode, "w") && strcmp(mode, "a")) BUG("write-in-file does not support '%s' mode", mode); fp = fopen(path, mode); if (!fp) @@ -109,6 +119,18 @@ static int write_to_file(const char *path, const char *format, ...) return res; } +static int append_to_file(const char *path, const char *format, ...) +{ + int res; + va_list args; + + va_start(args, format); + res = write_in_file(path, "a", format, args); + va_end(args); + + return res; +} + static int check_term_format(const char *term, const char *orig_term) { int res; @@ -451,6 +473,143 @@ static int bisect_append_log_quoted(const char **argv) return res; } +static int add_bisect_ref(const char *refname, const struct object_id *oid, + int flags, void *cb) +{ + struct add_bisect_ref_data *data = cb; + + add_pending_oid(data->revs, refname, oid, data->object_flags); + + return 0; +} + +static int prepare_revs(struct bisect_terms *terms, struct rev_info *revs) +{ + int res = 0; + struct add_bisect_ref_data cb = { revs }; + char *good = xstrfmt("%s-*", terms->term_good); + + /* + * 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); + + /* + * It is important to reset the flags used by revision walks + * as the previous call to bisect_next_all() in turn + * sets up a revision walk. + */ + reset_revision_walk(); + init_revisions(revs, NULL); + setup_revisions(0, NULL, revs, NULL); + for_each_glob_ref_in(add_bisect_ref, bad, "refs/bisect/", &cb); + cb.object_flags = UNINTERESTING; + for_each_glob_ref_in(add_bisect_ref, good, "refs/bisect/", &cb); + if (prepare_revision_walk(revs)) + res = error(_("revision walk setup failed\n")); + + free(good); + free(bad); + return res; +} + +static int bisect_skipped_commits(struct bisect_terms *terms) +{ + int res; + FILE *fp = NULL; + struct rev_info revs; + struct commit *commit; + struct pretty_print_context pp = {0}; + struct strbuf commit_name = STRBUF_INIT; + + res = prepare_revs(terms, &revs); + if (res) + return res; + + fp = fopen(git_path_bisect_log(), "a"); + if (!fp) + return error_errno(_("could not open '%s' for appending"), + git_path_bisect_log()); + + if (fprintf(fp, "# only skipped commits left to test\n") < 0) + return error_errno(_("failed to write to '%s'"), git_path_bisect_log()); + + while ((commit = get_revision(&revs)) != NULL) { + strbuf_reset(&commit_name); + 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), + commit_name.buf); + } + + /* + * Reset the flags used by revision walks in case + * there is another revision walk after this one. + */ + reset_revision_walk(); + + strbuf_release(&commit_name); + fclose(fp); + return 0; +} + +static int bisect_successful(struct bisect_terms *terms) +{ + 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); + int res; + + read_ref(bad_ref, &oid); + commit = lookup_commit_reference_by_name(bad_ref); + 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), + commit_name.buf); + + strbuf_release(&commit_name); + free(bad_ref); + return res; +} + +static enum bisect_error bisect_next(struct bisect_terms *terms, const char *prefix) +{ + int no_checkout; + enum bisect_error res; + + bisect_autostart(terms); + if (bisect_next_check(terms, terms->term_good)) + return BISECT_FAILED; + + no_checkout = ref_exists("BISECT_HEAD"); + + /* Perform all bisection computation */ + res = bisect_next_all(the_repository, prefix); + + if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) { + res = bisect_successful(terms); + return res ? res : BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND; + } else if (res == BISECT_ONLY_SKIPPED_LEFT) { + res = bisect_skipped_commits(terms); + return res ? res : BISECT_ONLY_SKIPPED_LEFT; + } + return res; +} + +static enum bisect_error bisect_auto_next(struct bisect_terms *terms, const char *prefix) +{ + if (bisect_next_check(terms, NULL)) + return BISECT_OK; + + return bisect_next(terms, prefix); +} + static int bisect_start(struct bisect_terms *terms, const char **argv, int argc) { int no_checkout = 0; @@ -699,7 +858,9 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_NEXT_CHECK, BISECT_TERMS, BISECT_START, - BISECT_AUTOSTART, + BISECT_NEXT, + BISECT_AUTO_NEXT, + BISECT_AUTOSTART } cmdmode = 0; int res = 0, nolog = 0; struct option options[] = { @@ -723,6 +884,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) 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-auto-next", &cmdmode, + N_("verify the next bisection state then checkout the next bisection commit"), BISECT_AUTO_NEXT), OPT_CMDMODE(0, "bisect-autostart", &cmdmode, N_("start the bisection if it has not yet been started"), BISECT_AUTOSTART), OPT_BOOL(0, "no-log", &nolog, @@ -784,6 +949,18 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) set_terms(&terms, "bad", "good"); res = bisect_start(&terms, argv, argc); break; + case BISECT_NEXT: + if (argc) + return error(_("--bisect-next requires 0 arguments")); + get_terms(&terms); + res = bisect_next(&terms, prefix); + break; + case BISECT_AUTO_NEXT: + if (argc) + return error(_("--bisect-auto-next requires 0 arguments")); + get_terms(&terms); + res = bisect_auto_next(&terms, prefix); + break; case BISECT_AUTOSTART: if (argc) return error(_("--bisect-autostart does not accept arguments")); @@ -799,7 +976,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) * Handle early success * From check_merge_bases > check_good_are_ancestors_of_bad > bisect_next_all */ - if (res == BISECT_INTERNAL_SUCCESS_MERGE_BASE) + if ((res == BISECT_INTERNAL_SUCCESS_MERGE_BASE) || (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND)) res = BISECT_OK; return -res; diff --git a/git-bisect.sh b/git-bisect.sh index 9ca583d964..59424f5b37 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -65,8 +65,7 @@ bisect_start() { # # Check if we can proceed to the next bisect state. # - get_terms - bisect_auto_next + git bisect--helper --bisect-auto-next || exit trap '-' 0 } @@ -119,45 +118,7 @@ bisect_state() { *) usage ;; esac - bisect_auto_next -} - -bisect_auto_next() { - git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD && bisect_next || : -} - -bisect_next() { - case "$#" in 0) ;; *) usage ;; esac - git bisect--helper --bisect-autostart - git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD $TERM_GOOD|| exit - - # Perform all bisection computation, display and checkout - git bisect--helper --next-all - res=$? - - # Check if we should exit because bisection is finished - if test $res -eq 10 - then - bad_rev=$(git show-ref --hash --verify refs/bisect/$TERM_BAD) - bad_commit=$(git show-branch $bad_rev) - echo "# first $TERM_BAD commit: $bad_commit" >>"$GIT_DIR/BISECT_LOG" - exit 0 - elif test $res -eq 2 - then - echo "# only skipped commits left to test" >>"$GIT_DIR/BISECT_LOG" - good_revs=$(git for-each-ref --format="%(objectname)" "refs/bisect/$TERM_GOOD-*") - for skipped in $(git rev-list refs/bisect/$TERM_BAD --not $good_revs) - do - skipped_commit=$(git show-branch $skipped) - echo "# possible first $TERM_BAD commit: $skipped_commit" >>"$GIT_DIR/BISECT_LOG" - done - exit $res - fi - - # Check for an error in the bisection process - test $res -ne 0 && exit $res - - return 0 + git bisect--helper --bisect-auto-next } bisect_visualize() { @@ -213,7 +174,7 @@ bisect_replay () { esac done <"$file" IFS="$oIFS" - bisect_auto_next + git bisect--helper --bisect-auto-next } bisect_run () { @@ -310,7 +271,7 @@ case "$#" in bisect_skip "$@" ;; next) # Not sure we want "next" at the UI level anymore. - bisect_next "$@" ;; + git bisect--helper --bisect-next "$@" || exit ;; visualize|view) bisect_visualize "$@" ;; reset) From patchwork Fri Aug 28 12:46:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11742705 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DD7614E5 for ; Fri, 28 Aug 2020 12:48:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F2C7208C9 for ; Fri, 28 Aug 2020 12:48:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZMvYpf9I" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729350AbgH1Msp (ORCPT ); Fri, 28 Aug 2020 08:48:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729052AbgH1MrX (ORCPT ); Fri, 28 Aug 2020 08:47:23 -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 0C3FFC061236 for ; Fri, 28 Aug 2020 05:47:20 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id w5so397415wrp.8 for ; Fri, 28 Aug 2020 05:47:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QPqYWsmyls6diwkH/bPIeLyotbIXmZpz9z2VVOcwTNo=; b=ZMvYpf9IM/su1Rt0ZrV19KtJirToodFq6gtbV3hNMzHFpT2D826asq/ebWIlBj5syk 1PVUikQL8FZZ3Zo5R6mn+b/95ur0rRkvKwiK5l08kz4Uq0LX/FG9PldTB/JO0nE5rzSv 6tpGOK3iT98sprIFWF36m6Y4l0g3g5b1gi7AUx8sZa/EkrgEk3Vx3bVX0scOkATM+zMq QwwGBw+nG57VLYjDPcOulPrjW70aMHKh6WFSziBepZ7e0vlSqsMBU4dUtRMYuDdvADUF p5KoDfPy5oiWxGdkxPSZq+/mIt838lDH/VhXavy+6RY8u9tfPuH3ZjksGsSYE173u2uX Ywpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QPqYWsmyls6diwkH/bPIeLyotbIXmZpz9z2VVOcwTNo=; b=jwzlzapfS37zjRkqAwYhEbtIpJUL9ITXxz47GVhNv4+RSzVIb6Wjh5MZvssCS8PXTr 9Fd8tlXQbWKusQTjQOFoLefCuQd7MnWOiDefcOWVxa4sA9+pPvtxdNtnuS9cF0b5Q6SS 6CDiNa+6C/J51WdhsZMTaOxoI+RueJWoVZfwN/bt2C91qyrNQnyiW7azNf2Z4vJCb7EX x1u4WCK/TQ5BF/UyfLLT4aJiqTB0sMdTMNWPRpQjdgMjbnhlShLOU/WGc8U4Vj/qt1Vb Vokt8AKDeXth1fDAl7dCQuF0nE0UUaGZzs0cMhN/CIACheH/bx7uySAomGJYAUMtXy2p hAnw== X-Gm-Message-State: AOAM5336B1O5bohxtv0Sd3W4sS+lZIAt0uAHm5K0hMduHJtU1fz3ZWDv 9t54255OE9BYwLTKjXo+4vfoAqOT4dU= X-Google-Smtp-Source: ABdhPJx3ipR4+e0mZsylCA40hGV92DuywWulh3G/Ofd51tQ+q3K8zdZkL7FR/OJ3lFsk93bPNVUFMg== X-Received: by 2002:a5d:6288:: with SMTP id k8mr1347366wru.273.1598618838210; Fri, 28 Aug 2020 05:47:18 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id o66sm2176878wmb.27.2020.08.28.05.47.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 05:47:17 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH v6 07/13] bisect--helper: finish porting `bisect_start()` to C Date: Fri, 28 Aug 2020 14:46:11 +0200 Message-Id: <20200828124617.60618-8-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200828124617.60618-1-mirucam@gmail.com> References: <20200828124617.60618-1-mirucam@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Pranit Bauva Add the subcommand to `git bisect--helper` and call it from git-bisect.sh. With the conversion of `bisect_auto_next()` from shell to C in a previous commit, `bisect_start()` can now be fully ported to C. So let's complete the `--bisect-start` subcommand of `git bisect--helper` so that it fully implements `bisect_start()`, and let's use this subcommand in `git-bisect.sh` instead of `bisect_start()`. Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- builtin/bisect--helper.c | 56 ++++++++++++++++++++++++++++------------ git-bisect.sh | 26 ++----------------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 5d443829e0..56da407871 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -85,6 +85,19 @@ static int one_of(const char *term, ...) return res; } +/* + * return code BISECT_INTERNAL_SUCCESS_MERGE_BASE + * and BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND are codes + * that indicate special success. + */ + +static int is_bisect_success(enum bisect_error res) +{ + return !res || + res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND || + res == BISECT_INTERNAL_SUCCESS_MERGE_BASE; +} + static int write_in_file(const char *path, const char *mode, const char *format, va_list args) { FILE *fp = NULL; @@ -610,12 +623,13 @@ static enum bisect_error bisect_auto_next(struct bisect_terms *terms, const char return bisect_next(terms, prefix); } -static int bisect_start(struct bisect_terms *terms, const char **argv, int argc) +static enum bisect_error bisect_start(struct bisect_terms *terms, const char **argv, int argc) { int no_checkout = 0; int first_parent_only = 0; int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0; - int flags, pathspec_pos, res = 0; + int flags, pathspec_pos; + enum bisect_error res = BISECT_OK; struct string_list revs = STRING_LIST_INIT_DUP; struct string_list states = STRING_LIST_INIT_DUP; struct strbuf start_head = STRBUF_INIT; @@ -675,9 +689,12 @@ static int bisect_start(struct bisect_terms *terms, const char **argv, int argc) return error(_("unrecognized option: '%s'"), arg); } else { char *commit_id = xstrfmt("%s^{commit}", arg); - if (get_oid(commit_id, &oid) && has_double_dash) - die(_("'%s' does not appear to be a valid " - "revision"), arg); + if (get_oid(commit_id, &oid) && has_double_dash) { + error(_("'%s' does not appear to be a valid " + "revision"), arg); + free(commit_id); + return BISECT_FAILED; + } string_list_append(&revs, oid_to_hex(&oid)); free(commit_id); @@ -755,14 +772,7 @@ static int bisect_start(struct bisect_terms *terms, const char **argv, int argc) * Get rid of any old bisect state. */ if (bisect_clean_state()) - return -1; - - /* - * In case of mistaken revs or checkout error, or signals received, - * "bisect_auto_next" below may exit or misbehave. - * We have to trap this to be able to clean up using - * "bisect_clean_state". - */ + return BISECT_FAILED; /* * Write new start state @@ -779,7 +789,7 @@ static int bisect_start(struct bisect_terms *terms, const char **argv, int argc) } if (update_ref(NULL, "BISECT_HEAD", &oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR)) { - res = -1; + res = BISECT_FAILED; goto finish; } } @@ -791,25 +801,37 @@ static int bisect_start(struct bisect_terms *terms, const char **argv, int argc) for (i = 0; i < states.nr; i++) if (bisect_write(states.items[i].string, revs.items[i].string, terms, 1)) { - res = -1; + res = BISECT_FAILED; goto finish; } if (must_write_terms && write_terms(terms->term_bad, terms->term_good)) { - res = -1; + res = BISECT_FAILED; goto finish; } res = bisect_append_log_quoted(argv); if (res) - res = -1; + res = BISECT_FAILED; finish: string_list_clear(&revs, 0); string_list_clear(&states, 0); strbuf_release(&start_head); strbuf_release(&bisect_names); + if (res) + return res; + + res = bisect_auto_next(terms, NULL); + /* + * In case of mistaken revs or checkout error, + * "bisect_auto_next" above may exit or misbehave. + * We have to handle this to be able to clean up using + * "bisect_clean_state". + */ + if (!is_bisect_success(res)) + bisect_clean_state(); return res; } diff --git a/git-bisect.sh b/git-bisect.sh index 59424f5b37..356264caf0 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -49,27 +49,6 @@ bisect_head() fi } -bisect_start() { - git bisect--helper --bisect-start $@ || exit - - # - # Change state. - # In case of mistaken revs or checkout error, or signals received, - # "bisect_auto_next" below may exit or misbehave. - # We have to trap this to be able to clean up using - # "bisect_clean_state". - # - trap 'git bisect--helper --bisect-clean-state' 0 - trap 'exit 255' 1 2 3 15 - - # - # Check if we can proceed to the next bisect state. - # - git bisect--helper --bisect-auto-next || exit - - trap '-' 0 -} - bisect_skip() { all='' for arg in "$@" @@ -163,8 +142,7 @@ bisect_replay () { get_terms case "$command" in start) - cmd="bisect_start $rev $tail" - eval "$cmd" ;; + eval "git bisect--helper --bisect-start $rev $tail" ;; "$TERM_GOOD"|"$TERM_BAD"|skip) git bisect--helper --bisect-write "$command" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit;; terms) @@ -264,7 +242,7 @@ case "$#" in help) git bisect -h ;; start) - bisect_start "$@" ;; + git bisect--helper --bisect-start "$@" ;; bad|good|new|old|"$TERM_BAD"|"$TERM_GOOD") bisect_state "$cmd" "$@" ;; skip) From patchwork Fri Aug 28 12:46:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11742707 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5888D14E5 for ; Fri, 28 Aug 2020 12:48:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FD9B2087D for ; Fri, 28 Aug 2020 12:48:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eIqTEPPL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729396AbgH1Msr (ORCPT ); Fri, 28 Aug 2020 08:48:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729423AbgH1MrX (ORCPT ); Fri, 28 Aug 2020 08:47:23 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1025AC061237 for ; Fri, 28 Aug 2020 05:47:21 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id q9so817021wmj.2 for ; Fri, 28 Aug 2020 05:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Dqoj8YIWKOZHzn9GJCr2gqt5Uhl4GCOAZ0C4bFvsLPY=; b=eIqTEPPLT8MNOadAn6o+mmwlAAoqGSp1h/lpWooFOcg2YqOhuYfUCh9dezOIatuOzs c63+WjZAoXYCtdCoPi5Lg1XR4ul94nCd+mwWCWLxsQYnibWd7FN/FcH/jnMoxevadTWL 0XbZ/IBUYNeEtUMEqtE4ICAtelZL7l2qR4yKEP5y4tpyyXn4g0Z/pKvKPSedDUAFYYlQ veSj+5bLo8KJvmRMQFxkBPeZ2KZPFxFgSxGAjYwsgfD0QbLMKrGmqF/c88Ag4VCpRYYQ ug69iPK4eIJVwRkvvROCmzUZegaGYo7RXod2g5CsdfgnJiH/hSILiIlylRUfyG8w5S2B aiCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Dqoj8YIWKOZHzn9GJCr2gqt5Uhl4GCOAZ0C4bFvsLPY=; b=cPKpXUDz0XhIc/NQavAFnHw4nnIwaRSdYFQSxFEFPw/LROwa/fpQ97Ug2KePmun4T4 ORluFcTqy7R2BRTwtbMk0+EnwnAe+EpR/I0dowZlVSNxtQLqCgtbuXYplFcoqxCbkCjf ZqOL6au/0sNBQ3qrq3/sKwoNprs5Q71ibz6YL6/y+t2Je5dF6tR2FWaT56pc3KrGxflA CJnNdGhOjb6uPJBjNLupMJlmMUF7vG4lqTzTSJej+YMNHZ0N8QC5LfPIsu1VAwtodYtb Us77Dmtl8XsOCPqqvYOpu6PdWUU/oWuECrKZdnB9CRxsSWMeLBuTQ5Mt55DC/+2fWTxh /dDQ== X-Gm-Message-State: AOAM532XUPX1BPCvKn+hrIpUwqqKnQaLp/MME/0cQ235jy40KpSRPf2g BUHZ6uqtmDKzIjvPyRgqUhTVXrR05WA= X-Google-Smtp-Source: ABdhPJxhIAVzyw80zyK6IUAVf7uhSv0zpYow1176RmHi6oVl4YxsjAc0zFrV+vxFNa6klbo6Y22Lrg== X-Received: by 2002:a05:600c:224e:: with SMTP id a14mr1518139wmm.80.1598618839497; Fri, 28 Aug 2020 05:47:19 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id o66sm2176878wmb.27.2020.08.28.05.47.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 05:47:18 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Tanushree Tumane , Miriam Rubio Subject: [PATCH v6 08/13] bisect--helper: retire `--bisect-clean-state` subcommand Date: Fri, 28 Aug 2020 14:46:12 +0200 Message-Id: <20200828124617.60618-9-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200828124617.60618-1-mirucam@gmail.com> References: <20200828124617.60618-1-mirucam@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Pranit Bauva The `--bisect-clean-state` subcommand is no longer used from the git-bisect.sh shell script. Instead the function `bisect_clean_state()` is directly called from the C implementation. Mentored-by: Lars Schneider Mentored-by: Christian Couder Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- builtin/bisect--helper.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 56da407871..106e5b788e 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -22,7 +22,6 @@ static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") static const char * const git_bisect_helper_usage[] = { N_("git bisect--helper --next-all"), N_("git bisect--helper --write-terms "), - N_("git bisect--helper --bisect-clean-state"), N_("git bisect--helper --bisect-reset []"), N_("git bisect--helper --bisect-write [--no-log] "), N_("git bisect--helper --bisect-check-and-set-terms "), @@ -872,7 +871,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) enum { NEXT_ALL = 1, WRITE_TERMS, - BISECT_CLEAN_STATE, CHECK_EXPECTED_REVS, BISECT_RESET, BISECT_WRITE, @@ -890,8 +888,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("perform 'git bisect next'"), NEXT_ALL), OPT_CMDMODE(0, "write-terms", &cmdmode, N_("write the terms to .git/BISECT_TERMS"), WRITE_TERMS), - OPT_CMDMODE(0, "bisect-clean-state", &cmdmode, - N_("cleanup the bisection state"), BISECT_CLEAN_STATE), OPT_CMDMODE(0, "check-expected-revs", &cmdmode, N_("check for expected revs"), CHECK_EXPECTED_REVS), OPT_CMDMODE(0, "bisect-reset", &cmdmode, @@ -933,10 +929,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) if (argc != 2) return error(_("--write-terms requires two arguments")); return write_terms(argv[0], argv[1]); - case BISECT_CLEAN_STATE: - if (argc != 0) - return error(_("--bisect-clean-state requires no arguments")); - return bisect_clean_state(); case CHECK_EXPECTED_REVS: check_expected_revs(argv, argc); return 0; From patchwork Fri Aug 28 12:46:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11742711 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA73E1575 for ; Fri, 28 Aug 2020 12:48:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D03120872 for ; Fri, 28 Aug 2020 12:48:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Eh0fxJOQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729254AbgH1Msx (ORCPT ); Fri, 28 Aug 2020 08:48:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729436AbgH1Mr2 (ORCPT ); Fri, 28 Aug 2020 08:47:28 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A29FC061239 for ; Fri, 28 Aug 2020 05:47:22 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id k20so779479wmi.5 for ; Fri, 28 Aug 2020 05:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TKnZ+drwbqtabpSBbsR1ki49dxB2yuxXqAP0x8+0NXk=; b=Eh0fxJOQX4dvzzWEz4JAbZbtbfSfiEQ0K2xKrRQujQKRZGZU5yEqny0mV4jl4xqq5K 6WI9Hg3ArglftG8kLhzxOInG63C2+Et/tIFGkPeQOikwuln+ZRWCUmdEs5PN/RopOgCT 4Gj4neDXwdHAGFAgcufxztNZWA+c5FNg+WaIuakvIgdePU7Wjwjye7hEUBaxJx6QfTdR Z+woygtl69rKwaQx8FHYt7St8+ClpfaEsUX7PaN19oaJUavMGnkpldIyt7HMHHLffnJG Am2NEZi9cWpY3D8u6P9kANDkYsIrJY79xEvDYyep+zlVrnGvsQHOHvBo9q8SRo+J5698 Knxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TKnZ+drwbqtabpSBbsR1ki49dxB2yuxXqAP0x8+0NXk=; b=F3AtIP49VT+pJ6kTtfF8iOaAaHmT/A1lw0F9tOQ0axg2IO1ZaSgUw2b6PGI2wv7LGv cS5cai+oILfW6bWopvDqGkzh6I/bTeK2Pc0hVrhsRGhMbyj8Bo6FwwT753btXWrcys7G 0tvt98o5hEt7eUoSSVFwdakDlFg7joMgMAuficnWavgpzEOvzkfRYldgHeqgj5Kb0s7+ sp5nd+jnVAQoVoI0IhFnRdYsLqv+ZfANCW7yxil9PVny0/oJBTRjRq/pUQ/k9rI4Uuwq g8vP55yJ31SDTyZi5nYPJ1IKHuf2Tm5nm5BCOFxuv7xVxtm33JCOK+GrJHZPdGiz2U9Z x4AQ== X-Gm-Message-State: AOAM531vKv6PQ4zw+c/zslt1MR7S+HlTjS2EZizaDbklEXqErDj2LHi1 nxT/VEmvCq6zfSJ46gMueEq9yppVgJ8= X-Google-Smtp-Source: ABdhPJyEInW/k/4Ai7w04dGhlC9q0rJivng6DZVGJvZn2l8yTRItFEYxLQn6YhpxTmQt8MiOY4OVQQ== X-Received: by 2002:a7b:c156:: with SMTP id z22mr1437375wmi.101.1598618840803; Fri, 28 Aug 2020 05:47:20 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id o66sm2176878wmb.27.2020.08.28.05.47.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 05:47:20 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Tanushree Tumane , Miriam Rubio Subject: [PATCH v6 09/13] bisect--helper: retire `--next-all` subcommand Date: Fri, 28 Aug 2020 14:46:13 +0200 Message-Id: <20200828124617.60618-10-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200828124617.60618-1-mirucam@gmail.com> References: <20200828124617.60618-1-mirucam@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Pranit Bauva The `--next-all` subcommand is no longer used from the git-bisect.sh shell script. Instead the function `bisect_next_all()` is called from the C implementation of `bisect_next()`. Mentored-by: Lars Schneider Mentored-by: Christian Couder Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- 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 106e5b788e..0a32dbb68f 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -20,7 +20,6 @@ static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") static const char * const git_bisect_helper_usage[] = { - N_("git bisect--helper --next-all"), N_("git bisect--helper --write-terms "), N_("git bisect--helper --bisect-reset []"), N_("git bisect--helper --bisect-write [--no-log] "), @@ -869,8 +868,7 @@ static int bisect_autostart(struct bisect_terms *terms) int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { - NEXT_ALL = 1, - WRITE_TERMS, + WRITE_TERMS = 1, CHECK_EXPECTED_REVS, BISECT_RESET, BISECT_WRITE, @@ -884,8 +882,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) } cmdmode = 0; int res = 0, nolog = 0; struct option options[] = { - OPT_CMDMODE(0, "next-all", &cmdmode, - N_("perform 'git bisect next'"), NEXT_ALL), OPT_CMDMODE(0, "write-terms", &cmdmode, N_("write the terms to .git/BISECT_TERMS"), WRITE_TERMS), OPT_CMDMODE(0, "check-expected-revs", &cmdmode, @@ -922,9 +918,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) usage_with_options(git_bisect_helper_usage, options); switch (cmdmode) { - case NEXT_ALL: - res = bisect_next_all(the_repository, prefix); - break; case WRITE_TERMS: if (argc != 2) return error(_("--write-terms requires two arguments")); From patchwork Fri Aug 28 12:46:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11742713 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94E4814E5 for ; Fri, 28 Aug 2020 12:48:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 707D72087D for ; Fri, 28 Aug 2020 12:48:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nGzwbCgI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729416AbgH1Ms4 (ORCPT ); Fri, 28 Aug 2020 08:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729445AbgH1Mr2 (ORCPT ); Fri, 28 Aug 2020 08:47:28 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97644C06121B for ; Fri, 28 Aug 2020 05:47:23 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id t14so784011wmi.3 for ; Fri, 28 Aug 2020 05:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xbrniexBZ0gYU+YQdW9xSXjq0+1QXCMa9esGoHTHjD8=; b=nGzwbCgI3BiZvyrb9hIX+dMFmGM8WkBuN/mkTIrfQn7XzfAlzKfoRQ35dgq9m3rvPr NXw4JOmk4XlfqnYHUTeGdEGTgcNJtfYX7ZOMhD0zK+J2+fnKIIJ3XliTqnDb1YNWWDsd yg6MBlu3bTXP0nBBCIgN1qBOaS7xfjw9tOhVx9I8Px7H7i+iX9xfYXgG2pP75CVYu6dm dhgvInK+E+cfesVozn5uzZ4k/usc5p6MIYJ5WAsQW58UnlvZtf3eP6qj37N9oCPzUcgJ Y4MFG4Rk0r7Wc+sPs0tpGr+oKr7Kndgxt+7r8tMwqKO9qHvNyIDbCt95eh4cHsyQCPnH vjDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xbrniexBZ0gYU+YQdW9xSXjq0+1QXCMa9esGoHTHjD8=; b=WrrTSheZ1mjQxYKPH+UmeFyMYDQRwSVHNFX4sVnNoOCOVbtuS0G9V8B/tikqgMKRZd G+a4lq1b9muTlLZoI8uubUab7wtICnLV08LGoCFecEEMGdT+t939qMZoa0FQS+vwybxJ 3s+dQHoeFcMvpxPeHjtOWPY3rwuqQWJ5CuhIbQiKUoPpQ9lxZWigmnNnUya+PKYs73G4 ZTbsMWrEHtxs3Uo33uDLBlrGgqjKh/xmGhdYsQAoZqdNVTLXHrHbpIKMQ3bBJSds58lQ PKxAtCSIxxijFETC/dwhDm73GYkatx1gE+3LUIzjlmHIkmLQgqFzu4Zz3HW770iZTDRO 1kag== X-Gm-Message-State: AOAM532LFjz0cH3CjRdo4xFg+I7KFYD68L99nmzVcAwETGbCBuhsCRGq U/dNuAo0D+lvJkayirn/9G43xO339go= X-Google-Smtp-Source: ABdhPJw0UbFrK/zkRj/HpuZVOXeHoMGA8rxfWv8JEVkYfiQ4b4URAkLc+0PcFgwsEKPXVmeK70w6CA== X-Received: by 2002:a1c:38c5:: with SMTP id f188mr1507038wma.58.1598618841926; Fri, 28 Aug 2020 05:47:21 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id o66sm2176878wmb.27.2020.08.28.05.47.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 05:47:21 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH v6 10/13] bisect--helper: reimplement `bisect_state` & `bisect_head` shell functions in C Date: Fri, 28 Aug 2020 14:46:14 +0200 Message-Id: <20200828124617.60618-11-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200828124617.60618-1-mirucam@gmail.com> References: <20200828124617.60618-1-mirucam@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Pranit Bauva Reimplement the `bisect_state()` shell functions in C and also add a subcommand `--bisect-state` to `git-bisect--helper` to call them from git-bisect.sh . Using `--bisect-state` subcommand is a temporary measure to port shell function to C so as to use the existing test suite. As more functions are ported, this subcommand will be retired and will be called by some other methods. `bisect_head()` is only called from `bisect_state()`, thus it is not required to introduce another subcommand. Mentored-by: Lars Schneider Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- builtin/bisect--helper.c | 78 +++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 55 +++------------------------- 2 files changed, 81 insertions(+), 52 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 0a32dbb68f..6d2847dc9c 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -31,6 +31,8 @@ static const char * const git_bisect_helper_usage[] = { N_("git bisect--helper --bisect-next"), N_("git bisect--helper --bisect-auto-next"), N_("git bisect--helper --bisect-autostart"), + N_("git bisect--helper --bisect-state (bad|new) []"), + N_("git bisect--helper --bisect-state (good|old) [...]"), NULL }; @@ -865,6 +867,72 @@ static int bisect_autostart(struct bisect_terms *terms) return res; } +static enum bisect_error bisect_state(struct bisect_terms *terms, const char **argv, + int argc) +{ + const char *state; + int i, verify_expected = 1; + struct object_id oid, expected; + 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")); + + state = argv[0]; + if (check_and_set_terms(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 == 0) { + enum get_oid_result res_head = get_oid("BISECT_HEAD", &oid); + if (res_head == MISSING_OBJECT) + res_head = get_oid("HEAD", &oid); + if (res_head) { + error(_("Bad bisect_head rev input")); + return BISECT_FAILED; + } + oid_array_append(&revs, &oid); + } + + /* + * All input revs must be checked before executing bisect_write() + * to discard junk revs. + */ + + for (; argc; argc--, argv++) { + if (get_oid(*argv, &oid)){ + error(_("Bad rev input: %s"), *argv); + return BISECT_FAILED; + } + oid_array_append(&revs, &oid); + } + + if (strbuf_read_file(&buf, git_path_bisect_expected_rev(), 0) < the_hash_algo->hexsz || + get_oid_hex(buf.buf, &expected) < 0) + verify_expected = 0; /* Ignore invalid file contents */ + strbuf_release(&buf); + + for (i = 0; i < revs.nr; i++) { + if (bisect_write(state, oid_to_hex(&revs.oid[i]), terms, 0)) + return BISECT_FAILED; + + if (verify_expected && !oideq(&revs.oid[i], &expected)) { + unlink_or_warn(git_path_bisect_ancestors_ok()); + unlink_or_warn(git_path_bisect_expected_rev()); + verify_expected = 0; + } + } + + oid_array_clear(&revs); + return bisect_auto_next(terms, NULL); +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { @@ -878,7 +946,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_START, BISECT_NEXT, BISECT_AUTO_NEXT, - BISECT_AUTOSTART + BISECT_AUTOSTART, + BISECT_STATE } cmdmode = 0; int res = 0, nolog = 0; struct option options[] = { @@ -904,6 +973,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("verify the next bisection state then checkout the next bisection commit"), BISECT_AUTO_NEXT), OPT_CMDMODE(0, "bisect-autostart", &cmdmode, N_("start the bisection if it has not yet been started"), BISECT_AUTOSTART), + OPT_CMDMODE(0, "bisect-state", &cmdmode, + N_("mark the state of ref (or refs)"), BISECT_STATE), OPT_BOOL(0, "no-log", &nolog, N_("no log for BISECT_WRITE")), OPT_END() @@ -974,6 +1045,11 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) set_terms(&terms, "bad", "good"); res = bisect_autostart(&terms); break; + case BISECT_STATE: + set_terms(&terms, "bad", "good"); + get_terms(&terms); + res = bisect_state(&terms, argv, argc); + break; default: BUG("unknown subcommand %d", cmdmode); } diff --git a/git-bisect.sh b/git-bisect.sh index 356264caf0..7a8f796251 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -39,16 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" TERM_BAD=bad TERM_GOOD=good -bisect_head() -{ - if git rev-parse --verify -q BISECT_HEAD > /dev/null - then - echo BISECT_HEAD - else - echo HEAD - fi -} - bisect_skip() { all='' for arg in "$@" @@ -61,43 +51,7 @@ bisect_skip() { esac all="$all $revs" done - eval bisect_state 'skip' $all -} - -bisect_state() { - git bisect--helper --bisect-autostart - state=$1 - git bisect--helper --check-and-set-terms $state $TERM_GOOD $TERM_BAD || exit - get_terms - case "$#,$state" in - 0,*) - die "Please call 'bisect_state' with at least one argument." ;; - 1,"$TERM_BAD"|1,"$TERM_GOOD"|1,skip) - bisected_head=$(bisect_head) - rev=$(git rev-parse --verify "$bisected_head") || - die "$(eval_gettext "Bad rev input: \$bisected_head")" - git bisect--helper --bisect-write "$state" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit - git bisect--helper --check-expected-revs "$rev" ;; - 2,"$TERM_BAD"|*,"$TERM_GOOD"|*,skip) - shift - hash_list='' - for rev in "$@" - do - sha=$(git rev-parse --verify "$rev^{commit}") || - die "$(eval_gettext "Bad rev input: \$rev")" - hash_list="$hash_list $sha" - done - for rev in $hash_list - do - git bisect--helper --bisect-write "$state" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit - done - git bisect--helper --check-expected-revs $hash_list ;; - *,"$TERM_BAD") - die "$(eval_gettext "'git bisect \$TERM_BAD' can take only one argument.")" ;; - *) - usage ;; - esac - git bisect--helper --bisect-auto-next + eval git bisect--helper --bisect-state 'skip' $all } bisect_visualize() { @@ -187,8 +141,7 @@ exit code \$res from '\$command' is < 0 or >= 128" >&2 state="$TERM_GOOD" fi - # We have to use a subshell because "bisect_state" can exit. - ( bisect_state $state >"$GIT_DIR/BISECT_RUN" ) + git bisect--helper --bisect-state $state >"$GIT_DIR/BISECT_RUN" res=$? cat "$GIT_DIR/BISECT_RUN" @@ -203,7 +156,7 @@ exit code \$res from '\$command' is < 0 or >= 128" >&2 if [ $res -ne 0 ] then eval_gettextln "bisect run failed: -'bisect_state \$state' exited with error code \$res" >&2 +'git bisect--helper --bisect-state \$state' exited with error code \$res" >&2 exit $res fi @@ -244,7 +197,7 @@ case "$#" in start) git bisect--helper --bisect-start "$@" ;; bad|good|new|old|"$TERM_BAD"|"$TERM_GOOD") - bisect_state "$cmd" "$@" ;; + git bisect--helper --bisect-state "$cmd" "$@" ;; skip) bisect_skip "$@" ;; next) From patchwork Fri Aug 28 12:46:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11742721 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BAA4414E5 for ; Fri, 28 Aug 2020 12:49:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9EC43208C9 for ; Fri, 28 Aug 2020 12:49:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N9UHQKrL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729470AbgH1Ms5 (ORCPT ); Fri, 28 Aug 2020 08:48:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729450AbgH1Mrb (ORCPT ); Fri, 28 Aug 2020 08:47:31 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BC48C06123A for ; Fri, 28 Aug 2020 05:47:25 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id a5so1188511wrm.6 for ; Fri, 28 Aug 2020 05:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aPLJydSBHk0ZlwmYcmGusQ7CAHUxAOCrGBOXVO8QGOY=; b=N9UHQKrLmPiPUR+7Gx/mwybQdoYTepOCnVcM9xTvzqdipaMrKfC/Boj5ZWnosBx13q 9qjsGxvbtVGpPv1dlNJzNSw2B/ZHIrgOR3Z/zFe5oJCFZQSBdL/aqSdNOWch4s0EyKoA jgHjTblobPa0+3K2Q5paDnvnC7S3b97u03S97wDcMv4VnKCv3LqzcsKHbFTNcMnYZinp EB4CVYVNuUgjiPNYkx1l+ewquDqySanNVVGgr8DgIFLNxMin3GQxZ6jYPdA0ETbFkXBB av9G0DPKuBAF2CLlZuwwKHwYKAm6PaKPUTsTkbP1ppolVzVI8y98FaDquPu72ytAtIgQ nIrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aPLJydSBHk0ZlwmYcmGusQ7CAHUxAOCrGBOXVO8QGOY=; b=EgEODPxATqp0bmhgK9NCSlbqaVxfBp8sCvEXKh/zyl5RBgic0FcE6S80aPdv/Cx6Tj PrWkeyFFCy7dOql+I5TAsuQmFMbrCPZGF+fKn/BCduBjkfimyPaP0Aj+JANKHMyhZeW7 79T5KkZd2OvcnQXih14Wt+KbGEA2wW+ZJNsgcdbmJ4M3GuPl1Qkx+Vi8ujgbkosEaiM8 2zSZJB3W/lJmjEYZ5ShmrFqYRrNsxeGMTsZ18iU2JMv9D4q9OFi0YyOPYor2V693rBTv gQ+He+Qt1nDgoEg9O3zw3dleH+Pqmtz++6yOfCCYA1temSTBe7cItNtwAIBkoAzHsSFB Sq5A== X-Gm-Message-State: AOAM532Ood+J5eLxmwBBoYDp3mN2uMyTBTA+3ZlT9xdIBuwfrSqnoBDQ fcqqfNcSfmmp7UeKL02Vquo91D5YH6o= X-Google-Smtp-Source: ABdhPJxsikyBZVXtxhtdtlCw73VXKGVqzq7K+3jNaWXozoVvno7ZN7poMpdYyj/FNDUDzBafq46aaA== X-Received: by 2002:adf:81a3:: with SMTP id 32mr1409590wra.368.1598618843677; Fri, 28 Aug 2020 05:47:23 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id o66sm2176878wmb.27.2020.08.28.05.47.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 05:47:22 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH v6 11/13] bisect--helper: retire `--check-expected-revs` subcommand Date: Fri, 28 Aug 2020 14:46:15 +0200 Message-Id: <20200828124617.60618-12-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200828124617.60618-1-mirucam@gmail.com> References: <20200828124617.60618-1-mirucam@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Pranit Bauva The `--check-expected-revs` subcommand is no longer used from the git-bisect.sh shell script. Functions `check_expected_revs` and `is_expected_revs` are also deleted. Mentored-by: Lars Schneider Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- builtin/bisect--helper.c | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 6d2847dc9c..d795f2e5c7 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -187,30 +187,6 @@ static int write_terms(const char *bad, const char *good) return res; } -static int is_expected_rev(const char *expected_hex) -{ - struct strbuf actual_hex = STRBUF_INIT; - int res = 0; - if (strbuf_read_file(&actual_hex, git_path_bisect_expected_rev(), 0) >= 40) { - strbuf_trim(&actual_hex); - res = !strcmp(actual_hex.buf, expected_hex); - } - strbuf_release(&actual_hex); - return res; -} - -static void check_expected_revs(const char **revs, int rev_nr) -{ - int i; - - for (i = 0; i < rev_nr; i++) { - if (!is_expected_rev(revs[i])) { - unlink_or_warn(git_path_bisect_ancestors_ok()); - unlink_or_warn(git_path_bisect_expected_rev()); - } - } -} - static int bisect_reset(const char *commit) { struct strbuf branch = STRBUF_INIT; @@ -937,7 +913,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { WRITE_TERMS = 1, - CHECK_EXPECTED_REVS, BISECT_RESET, BISECT_WRITE, CHECK_AND_SET_TERMS, @@ -953,8 +928,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) struct option options[] = { OPT_CMDMODE(0, "write-terms", &cmdmode, N_("write the terms to .git/BISECT_TERMS"), WRITE_TERMS), - OPT_CMDMODE(0, "check-expected-revs", &cmdmode, - N_("check for expected revs"), CHECK_EXPECTED_REVS), OPT_CMDMODE(0, "bisect-reset", &cmdmode, N_("reset the bisection state"), BISECT_RESET), OPT_CMDMODE(0, "bisect-write", &cmdmode, @@ -993,9 +966,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) if (argc != 2) return error(_("--write-terms requires two arguments")); return write_terms(argv[0], argv[1]); - case CHECK_EXPECTED_REVS: - check_expected_revs(argv, argc); - return 0; case BISECT_RESET: if (argc > 1) return error(_("--bisect-reset requires either no argument or a commit")); From patchwork Fri Aug 28 12:46:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11742723 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6662814E5 for ; Fri, 28 Aug 2020 12:49:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D07F2087D for ; Fri, 28 Aug 2020 12:49:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lVEyuz9a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729474AbgH1Mte (ORCPT ); Fri, 28 Aug 2020 08:49:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729453AbgH1Mrb (ORCPT ); Fri, 28 Aug 2020 08:47:31 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FAECC06123B for ; Fri, 28 Aug 2020 05:47:26 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id y3so1194049wrl.4 for ; Fri, 28 Aug 2020 05:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZjplHTeHYlf81AEWP3juSrt5cTHxoQA2uRp6OIai7kc=; b=lVEyuz9auZIQQ4PCVY/5w4vF09V0gNR6lVJV4ZyK+3n98ntyIrqF9fW1sHOD0CKAqA ZrhA+oj8VBJYDjAeO8EwlBo87ZAt/iG+RmWn26Rd4NYTLmQhbJw3xIooYrxtqvof5C+c a7FDb9FAbyrjASGYxWPaNjxTd8/nl4neUVx5w9hDDilj4ezugPPVY+K/pA89heJeg/2f el0uzb2KFaIm7a1+LgmlB/D09Y4pA+kM9u3RniMqblRD2znBt1T8JAGIsoD3al7z73/t Al++ujJl3NWW8EKI5UEU4WWnQ0KO27DLoP5tXGCn5GNsbfHASUbS9QqqqtgnOHGW88fF j3qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZjplHTeHYlf81AEWP3juSrt5cTHxoQA2uRp6OIai7kc=; b=ZPeUQLDesg8sOA7PxM5ADElDzYeoWa2FAS+tZ+ttF/4OrEYIfuIIhcfQ8IqsfaKyfW gn9LwkIcGbGY04LUNYdO8/xidVVeO2GgmPgM1AwtKGN3VIhDCPAVMgzI8sdCvnaZIy87 YQkUbCqH9Qpp14c1IZRx9jibF9Fm/Ujxz5AQ4eS107D3WDnkwQtVvBbgfgaYbXX0J/e/ QQmzL9z512DWz/fUHj9CrCAHPARsQYQgWttAa3nigFybjE9mLAkQyMoKObWpc2Hj2rU9 NIe79lNRpz8I0ZKQ0THeOW9pnHMZsFSlMNskG+aVwVv76e7XUZDpghuePql+tUUjsTUJ 6Hsg== X-Gm-Message-State: AOAM530HdSvragOaCLgyy9h18wmz+NAxiy/0L1j3CBwkOGE/u/wAd5p7 D0TRA4QQQYmH0qZSBoe66iMKYkbrWTc= X-Google-Smtp-Source: ABdhPJzEA1z0M8L8hmWqamC1VTnWIdyarehLu5tjxGn1vmkJGE+4NF1hxyZaDXvxWzfZBfFkIqOgFQ== X-Received: by 2002:adf:ea0b:: with SMTP id q11mr1270034wrm.285.1598618844923; Fri, 28 Aug 2020 05:47:24 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id o66sm2176878wmb.27.2020.08.28.05.47.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 05:47:24 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH v6 12/13] bisect--helper: retire `--write-terms` subcommand Date: Fri, 28 Aug 2020 14:46:16 +0200 Message-Id: <20200828124617.60618-13-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200828124617.60618-1-mirucam@gmail.com> References: <20200828124617.60618-1-mirucam@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Pranit Bauva The `--write-terms` subcommand is no longer used from the git-bisect.sh shell script. Instead the function `write_terms()` is called from the C implementation of `set_terms()` and `bisect_start()`. Mentored-by: Lars Schneider Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- builtin/bisect--helper.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index d795f2e5c7..a6282d54a2 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -20,7 +20,6 @@ static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") static const char * const git_bisect_helper_usage[] = { - N_("git bisect--helper --write-terms "), N_("git bisect--helper --bisect-reset []"), N_("git bisect--helper --bisect-write [--no-log] "), N_("git bisect--helper --bisect-check-and-set-terms "), @@ -912,8 +911,7 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, const char **a int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { - WRITE_TERMS = 1, - BISECT_RESET, + BISECT_RESET = 1, BISECT_WRITE, CHECK_AND_SET_TERMS, BISECT_NEXT_CHECK, @@ -926,8 +924,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) } cmdmode = 0; int res = 0, nolog = 0; struct option options[] = { - OPT_CMDMODE(0, "write-terms", &cmdmode, - N_("write the terms to .git/BISECT_TERMS"), WRITE_TERMS), OPT_CMDMODE(0, "bisect-reset", &cmdmode, N_("reset the bisection state"), BISECT_RESET), OPT_CMDMODE(0, "bisect-write", &cmdmode, @@ -962,10 +958,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) usage_with_options(git_bisect_helper_usage, options); switch (cmdmode) { - case WRITE_TERMS: - if (argc != 2) - return error(_("--write-terms requires two arguments")); - return write_terms(argv[0], argv[1]); case BISECT_RESET: if (argc > 1) return error(_("--bisect-reset requires either no argument or a commit")); From patchwork Fri Aug 28 12:46:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11742725 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D37C1575 for ; Fri, 28 Aug 2020 12:49:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64E1E2087D for ; Fri, 28 Aug 2020 12:49:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PCgiwDXQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729478AbgH1Mtr (ORCPT ); Fri, 28 Aug 2020 08:49:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729455AbgH1Mrg (ORCPT ); Fri, 28 Aug 2020 08:47:36 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C56EFC06123C for ; Fri, 28 Aug 2020 05:47:27 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id y3so1194096wrl.4 for ; Fri, 28 Aug 2020 05:47:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NXxMtopeJlIDy0Y/iz+K2ZtFarELYfjiV1J6/3GJVEU=; b=PCgiwDXQMm55pVzOQOwkoBhG7VU6kaL3hrGr47e3fpcDJI47aeHZ/ypNI0TzpxZzz6 nsS1yHKhjg+ovYTQ3dVs2vI/CS8/PfMxCOtl78y7LCPIps44Dg9d6DR1TxHq5mKmp1C3 SewS9BO+PuDFbC0MGyRsm858+H3HI8THzolHAl1X8YsWPLBLIY6pcWFJTkuw/vIHTsTE Ta0iyGlTCjiJjxhyqruSmeLLtX91TcaEwChOYj+DcSJSmlScZseiqljY3qles/GqjKeS 6+GGKq0MpMmySxdNCKnb0J+JBqy/Q8WS6TCV8k2TgGJnxXkNUV3/Vo1FTquPNZoEY7bX sx8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NXxMtopeJlIDy0Y/iz+K2ZtFarELYfjiV1J6/3GJVEU=; b=TQGGWb01ZIjlkW4YMOVsSEAIYjO94wjhA4KNqiPd1ZOwfnjnZ9QkA8dvd3X/UjrMJS kL9w/oGoUynVhwZgr828OH8Dr85kmQhe/rRwKpCTITSVY23TkBy5wppV+7vjWj3IRFwd SKQdjrAdRt7oLr4rtsVBqiEvpi5kl7SD7ElqtseQz80P/aMLKcM7bWib3RjBuVAeik4e 7Zd9mRecDXGE789KMslcHDramRp9S9ijHePnJaXG3FffB0wTDFXAloYTWju5leJw+t1C udo4VdODdtnUHV7WXcSN9VUK9t295HXheiagWyTX/NV5ELx+amgLp7NXfWssv8FAFEti +z8Q== X-Gm-Message-State: AOAM532Cm+BuaTOj3Iy8s5/RCGmrTzhBMZpTa5XnGpxxX5+CWXwMSS1J 5gozOYXheOEw6eGDfmgqs3EUSOgUOrQ= X-Google-Smtp-Source: ABdhPJyIytkUUM0wzn/u24jlHwcaZ8Cu3xMwL2KkM95KJyDK8KoiK6fBpqX9sg7uztzIctpWaqjJpQ== X-Received: by 2002:a5d:56c1:: with SMTP id m1mr1322330wrw.87.1598618846065; Fri, 28 Aug 2020 05:47:26 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id o66sm2176878wmb.27.2020.08.28.05.47.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 05:47:25 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH v6 13/13] bisect--helper: retire `--bisect-autostart` subcommand Date: Fri, 28 Aug 2020 14:46:17 +0200 Message-Id: <20200828124617.60618-14-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200828124617.60618-1-mirucam@gmail.com> References: <20200828124617.60618-1-mirucam@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Pranit Bauva The `--bisect-autostart` subcommand is no longer used from the git-bisect.sh shell script. Instead the function `bisect_autostart()` is directly called from the C implementation. Mentored-by: Lars Schneider Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- builtin/bisect--helper.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index a6282d54a2..be1291f036 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -29,7 +29,6 @@ static const char * const git_bisect_helper_usage[] = { " [--no-checkout] [--first-parent] [ [...]] [--] [...]"), N_("git bisect--helper --bisect-next"), N_("git bisect--helper --bisect-auto-next"), - N_("git bisect--helper --bisect-autostart"), N_("git bisect--helper --bisect-state (bad|new) []"), N_("git bisect--helper --bisect-state (good|old) [...]"), NULL @@ -919,7 +918,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_START, BISECT_NEXT, BISECT_AUTO_NEXT, - BISECT_AUTOSTART, BISECT_STATE } cmdmode = 0; int res = 0, nolog = 0; @@ -940,8 +938,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("find the next bisection commit"), BISECT_NEXT), OPT_CMDMODE(0, "bisect-auto-next", &cmdmode, N_("verify the next bisection state then checkout the next bisection commit"), BISECT_AUTO_NEXT), - OPT_CMDMODE(0, "bisect-autostart", &cmdmode, - N_("start the bisection if it has not yet been started"), BISECT_AUTOSTART), OPT_CMDMODE(0, "bisect-state", &cmdmode, N_("mark the state of ref (or refs)"), BISECT_STATE), OPT_BOOL(0, "no-log", &nolog, @@ -1001,12 +997,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) get_terms(&terms); res = bisect_auto_next(&terms, prefix); break; - case BISECT_AUTOSTART: - if (argc) - return error(_("--bisect-autostart does not accept arguments")); - set_terms(&terms, "bad", "good"); - res = bisect_autostart(&terms); - break; case BISECT_STATE: set_terms(&terms, "bad", "good"); get_terms(&terms);