From patchwork Thu Apr 23 07:06:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11505057 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 66CAB112C for ; Thu, 23 Apr 2020 07:09:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DE3821569 for ; Thu, 23 Apr 2020 07:09:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DKERQOXU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726830AbgDWHJh (ORCPT ); Thu, 23 Apr 2020 03:09:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbgDWHJh (ORCPT ); Thu, 23 Apr 2020 03:09:37 -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 EF1E5C03C1AB for ; Thu, 23 Apr 2020 00:09:36 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id x17so4765244wrt.5 for ; Thu, 23 Apr 2020 00:09:36 -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=URG5S9Gb+4uj3txSvkoDvh025lJpgIkTibCjFFMw/Pc=; b=DKERQOXUF+lNQJ4pPjg4uNC0aJAO4EGWyVpgFq2ENbq3UFrGhtVOI8/+4BQ7fO5pmn Jc/WjTz5x8vR9r/36CFgh7sClyY+aFYosGLQZx2hmazfBRpUlUobugwxF+O0z6YtiIZ5 HvMlJR6HEzIQehhcnzZUtGae0k/kXoFe2Y9k8iJuRFqzLJeozHY1tKc1Jyi1WZoCTpam yOCdyDqXPN8GTjFbFRTn+89qDvsmz1fhFUfMsQ+C2JKNbSKxJ04RS/G+k4SET41EBYKn U1KrnJ0R7MkgT0/jkv+Dgq1mjkAfNRDB3TMuMY1+aNpLRCUJC+DeNglQ4pvwMuBKq4+5 pjqQ== 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=URG5S9Gb+4uj3txSvkoDvh025lJpgIkTibCjFFMw/Pc=; b=YIsg2r+/grQTQ2fv6TUoKw9JE5BJsY4i8l5jPXozP/bEXItIN2Qikxm9c09sketo/l shxtwQfz4Q6RckfPR916UqpPBTPGqtWqMHYinK4yxIdOQVnW7+ohRD4kd/i0zEDPEmBW H4yZ3+i2xq7Z/Y7XXJNIV0fJdcF0/n9o7lx/vdp1Spe/tIcnXO1vzN8QdEJ2uWU8Fskp ygzhTCrXdpUB9tHy22WMS/Gn771oS3r7uw32Z/2dLhHotNl0N7agbahdAfuL+X6x2lxX LGyOsPD92+hZ5yXXG1gVZx42vYd77v7DwgfuYRaBi+yXtW3WinWiRQKdfXTYG/qKx58a GXjw== X-Gm-Message-State: AGi0PuaBawZAa/f6nh7IMXVKj28u9SmMiity1DIJ4P7mdgTg/Kq86wr1 4cvyl4FiaGzu7X2JAZkuv++V4WMQPVg= X-Google-Smtp-Source: APiQypL14VT1RoRakmN58ZA0RbKd0S1Jo/TvDtjRf6M0baLDbb9iHltdYLzmx3qEejvkNXwZy93LPg== X-Received: by 2002:adf:fecd:: with SMTP id q13mr3432350wrs.12.1587625775433; Thu, 23 Apr 2020 00:09:35 -0700 (PDT) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u17sm2518585wra.63.2020.04.23.00.09.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 00:09:35 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Miriam Rubio , Christian Couder , Johannes Schindelin Subject: [PATCH v3 01/12] bisect--helper: fix `cmd_*()` function switch default return Date: Thu, 23 Apr 2020 09:06:53 +0200 Message-Id: <20200423070704.39872-2-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200423070704.39872-1-mirucam@gmail.com> References: <20200423070704.39872-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 a `cmd_*()` function, return `error()` cannot be used because that translates to `-1` and `cmd_*()` functions need to return exit codes. Let's fix switch default return. 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 c1c40b516d..a81a2c76ff 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -711,7 +711,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) res = bisect_start(&terms, no_checkout, argv, argc); break; default: - return error("BUG: unknown subcommand '%d'", cmdmode); + BUG("unknown subcommand %d", (int)cmdmode); } free_terms(&terms); From patchwork Thu Apr 23 07:06:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11505061 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 381F91575 for ; Thu, 23 Apr 2020 07:09:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 207BB21582 for ; Thu, 23 Apr 2020 07:09:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HSCMsEHY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726834AbgDWHJk (ORCPT ); Thu, 23 Apr 2020 03:09:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbgDWHJi (ORCPT ); Thu, 23 Apr 2020 03:09:38 -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 1DB0AC03C1AB for ; Thu, 23 Apr 2020 00:09:38 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id j2so5494274wrs.9 for ; Thu, 23 Apr 2020 00:09:38 -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=jP/bwdW/LYWRCE8uqOGcqRjd1/CiBIduGpeiCQOOgVg=; b=HSCMsEHY/1GCJGO1iDWjvhB2dOmsIb6hqSBxoRbmx99mX5l5acjtUq8ad9T1Ns5H43 m0vDSpAB3GVkjAxrn27tmGdla+JvLGRHXjCcHeHqW8vmXxprHp9eRLnPwWZtXSJF+Txk SfnGBzZN5QROW+Fl4Jl1UKETJZreJEXbvkD3LMxBrpXPnSOxACooqIAyVwoAqLew6hnl AYIyxCUDUbYFKlC9zrvTaA2FI0ScPCyBfV9TtEfVpn2cI9C10TEKDkacYjsG4KulyK3a 1gGYfuRePdvltm5fwSnM7ED0Pjrm775XlJn8smcyr5yTKa+fMB6ToKV8JJc2Qd8wSa2o kJww== 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=jP/bwdW/LYWRCE8uqOGcqRjd1/CiBIduGpeiCQOOgVg=; b=IiR9RROUolNNUhqm6vQDWtKmLt/x198lcmkJcCQIh9FAFFZvdPGJ6jj7dVkqE/Shz6 PtPEm9eRMlwbwmV2pe6lSq3D+TSvG2PDvwXFDwghpZXbsOibKUdVWwTWZtKHz0FWyHqH eM/qIW+exndW5Yq50afhRm4XiecBdsgdn0IwWGp0fcpJtOZOu8puCn23ZOI3CsWu+GLF F+/h9kbtpvGKDRe07q99ADJq4Vsn+fvlAiFiklhGDtBzfincB0ADFwkgmwTZG5va9pRb BOQVghV2/NWjxRkDGKgJSu74RXu/1xmsBTgUnJYRx5ijBQIkAn20JOr2LdM0JGMsM15C 8IVg== X-Gm-Message-State: AGi0PuaPQ0naDeV0TvOPwhg3evXmEb6rpzxT+8Q4yIATiHi8iQ2nMYe7 RFMQjzwhcHASRE//YVzcG4f6BJeXDqw= X-Google-Smtp-Source: APiQypI9SGUcUboAGwwQJlH4LWfWXj9BN2VMFr0sx2lNd01hAm5iHCGh9yaYiTOwTdLfIieBZkOpXw== X-Received: by 2002:a5d:544f:: with SMTP id w15mr3397248wrv.77.1587625776712; Thu, 23 Apr 2020 00:09:36 -0700 (PDT) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u17sm2518585wra.63.2020.04.23.00.09.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 00:09:36 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Miriam Rubio , Christian Couder , Junio C Hamano Subject: [PATCH v3 02/12] bisect--helper: use '-res' in 'cmd_bisect__helper' return Date: Thu, 23 Apr 2020 09:06:54 +0200 Message-Id: <20200423070704.39872-3-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200423070704.39872-1-mirucam@gmail.com> References: <20200423070704.39872-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 Signed-off-by: Miriam Rubio Helped-by: Junio C Hamano --- 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 a81a2c76ff..0fbd924aac 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -722,5 +722,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 Thu Apr 23 07:06:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11505059 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 86F2C13B2 for ; Thu, 23 Apr 2020 07:09:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DAFC21582 for ; Thu, 23 Apr 2020 07:09:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="u+B8fQm9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726845AbgDWHJk (ORCPT ); Thu, 23 Apr 2020 03:09:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbgDWHJj (ORCPT ); Thu, 23 Apr 2020 03:09:39 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59DA0C03C1AF for ; Thu, 23 Apr 2020 00:09:39 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id u127so5348586wmg.1 for ; Thu, 23 Apr 2020 00:09:39 -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=NOXbS34irrxI9f7XExooH+K1aBCXSlH3jCrBenNNPjs=; b=u+B8fQm9m4FF4Ius9+xm6+S4w33Q9vI7ZYJ9t6u6WdcSWNn1RxzMfyK6KX88/+Tw8H gdPd2IyDzW6hY5tYF60nUrv4xz7CIOkpcc0UGGCI9oETo/MKdRd775AsnSssDyj3fy+g TbIRjYa14m9pgvHZGu57dGJDIG/eDjSvupmgjvvjFkJlK+f/u9fek0wEqHMeEJMv8//l YeZD4Vw/ecQJ1rX0GmjmlBL4s7Dtof8sLeJFbGPze5HZv0D6Eln649a5KKefgifQOHCf R/2J0mzbUFHxkxR3U2wI/JyshtXocaQ8eG3cGP8pMp6C0YuMewZCgUb2h9A6O44GZF9q AdzQ== 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=NOXbS34irrxI9f7XExooH+K1aBCXSlH3jCrBenNNPjs=; b=HrAFN6vQN9y2ubzS+Tbj51uTe977+JimlFusURNDHjSy55UsGnLholzjgY5awoC3gv ITXAoX4R7rXdmVGoWb2Ri6J2xAkn0ck+dC1kRlaxyDkdvfAaLCAHidhsyI9CU/QYpsgz eFz49yPXZzwn0GO9cz9bNSw9a4ncd5T1tedd08RuWhX1NNs1PBDF0dajcIIZKp5lqf2A LZKkROOXAph7uHDMkwi+S/doJ9BBYTKnbYJIQ5xNFRxaDxq1MHYESGGG1AXgUSyaFkNV 03sUjogldoc+OveP4OpCoBYaRkj1qiJm9tS5mgig91sozWV3nswMDXqexUWk/hnsJFpC sXIQ== X-Gm-Message-State: AGi0PubYstQJdWpnIzpaPgvIv9Je9ftlqgQDiBiHYOgaAZw2sgy/iOP8 JU5/t5WxRSLQlZYgl+48YvbQSGjlxJ8= X-Google-Smtp-Source: APiQypJQ7NNNW9/pEJfZpcp7m6Tfr0ISJEIqrwi4aK/tf2Mc5MCICwrHeQU9m3CXjpQiUsS/qBcNUw== X-Received: by 2002:a7b:c772:: with SMTP id x18mr2603645wmk.39.1587625777905; Thu, 23 Apr 2020 00:09:37 -0700 (PDT) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u17sm2518585wra.63.2020.04.23.00.09.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 00:09:37 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Miriam Rubio , Christian Couder , Johannes Schindelin Subject: [PATCH v3 03/12] bisect--helper: introduce new `write_in_file()` function Date: Thu, 23 Apr 2020 09:06:55 +0200 Message-Id: <20200423070704.39872-4-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200423070704.39872-1-mirucam@gmail.com> References: <20200423070704.39872-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. 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 | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 0fbd924aac..d3b2b33df0 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -74,6 +74,28 @@ static int one_of(const char *term, ...) return res; } +static int write_in_file(const char *path, const char *mode, const char *format,...) +{ + FILE *fp = NULL; + va_list args; + int res = 0; + + if (!strcmp(mode, "a") && !strcmp(mode, "w")) + return error(_("wrong writing mode '%s'"), mode); + fp = fopen(path, mode); + if (!fp) + return error_errno(_("cannot open file '%s' in mode '%s'"), path, mode); + va_start(args, format); + res = vfprintf(fp, format, args); + va_end(args); + if (!res) { + fclose(fp); + return error_errno(_("could not write to file '%s'"), path); + } + + return fclose(fp); +} + static int check_term_format(const char *term, const char *orig_term) { int res; @@ -104,7 +126,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,12 +134,8 @@ 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_in_file(git_path_bisect_terms(), "w", "%s\n%s\n", bad, good); - res = fprintf(fp, "%s\n%s\n", bad, good); - res |= fclose(fp); return (res < 0) ? -1 : 0; } From patchwork Thu Apr 23 07:06:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11505063 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 82D8E112C for ; Thu, 23 Apr 2020 07:09:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6332421569 for ; Thu, 23 Apr 2020 07:09:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A2BusIAW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726857AbgDWHJn (ORCPT ); Thu, 23 Apr 2020 03:09:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbgDWHJm (ORCPT ); Thu, 23 Apr 2020 03:09:42 -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 BA214C03C1AB for ; Thu, 23 Apr 2020 00:09:40 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id z6so5352376wml.2 for ; Thu, 23 Apr 2020 00:09:40 -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=owAgqsYyhbNZZxr7DGdJQM8sc4QHTU2PXw0FK8VVF80=; b=A2BusIAWLq34GumztXRoAnde3nbEMIbTVvxSbtzLT5sZPIqHQjhGwBBH3iWCMZsyGr //vbHcTNfYeJZbMw/vh5mW6Epgy7EnWK/cpA1r0SSm2x4eSYbiECUjMOPsWnaDXHbnCW 7bRLi8rTg4xG9U7VgJG3rbPEaqjz+9uI0Vm9V4GptqUC9euOyG6f8m6+Sg6osa74SRTi ZXbpuBBDUBUh6XC1z7Tph7B5Wt080DzeYx08221tid1FCduU0YFvQlINb6f+g0tMa903 rdfO0mScwM9W5GeYZ/+dmeXcGSxlj2qkw0OADTYLx+KuIkU2SjWTUeeQaHN5iCd3NRqo UobA== 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=owAgqsYyhbNZZxr7DGdJQM8sc4QHTU2PXw0FK8VVF80=; b=TbFB2NO9eKLqiMcmBAUpReZvkzbpwFGoBMoseUbJwFIPGYHfsybbpuyNGgi3P3YkY4 Os2wBXOKhjGMvdnevmtT8L1X0DARf8/ajMumxfeicILLUuKuUY9otd+wmk+VUMbOTBNr 6Did+T7DsdZbnwVmimXSOHznlBE5Li60iuH+K83vv4YDG73EXMa1FlPxDYjmQxRgPSqR /jEvfFKvzZApD8FKwM5bqccys74GbVw0Yotr4qVKU/znruxOgJBqDO6HQkmPtxWEy7QF R7MRffS+oFWi1JL8pMpmrkDAIcqet61sda//53mkDcpNJlLNdVf7heQp8TR4aHGIG8M2 Ug8w== X-Gm-Message-State: AGi0PuZA1jw8BZeq6xWGg2QYa4ElY/nRA2yb+MgV6JU6l4IkhtyN6enM H7aqBZhprg4WOFMfJ2g/VVvdNeBZwH6qJg== X-Google-Smtp-Source: APiQypL8r9nwAjnnlNr759kN7IrxyxY7C/K1hix3U4fZJIteRwYiJM3rg47UW3TEiqSbuywVF7GJnA== X-Received: by 2002:a7b:cd10:: with SMTP id f16mr2580792wmj.21.1587625779186; Thu, 23 Apr 2020 00:09:39 -0700 (PDT) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u17sm2518585wra.63.2020.04.23.00.09.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 00:09:38 -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 v3 04/12] bisect--helper: reimplement `bisect_autostart` shell function in C Date: Thu, 23 Apr 2020 09:06:56 +0200 Message-Id: <20200423070704.39872-5-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200423070704.39872-1-mirucam@gmail.com> References: <20200423070704.39872-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. Also add a subcommand `--bisect-autostart` to `git bisect--helper` be called from `bisect_state()` from git-bisect.sh . Using `--bisect-autostart` 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 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 | 40 +++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 25 ++----------------------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index d3b2b33df0..9df69800e3 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] [ [...]] [--] [...]"), + N_("git bisect--helper --bisect-autostart"), NULL }; @@ -55,6 +56,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. @@ -630,6 +633,32 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, return res; } +static int bisect_autostart(struct bisect_terms *terms) +{ + const char *yesno; + + if (!is_empty_or_missing_file(git_path_bisect_start())) + return 0; + + fprintf(stderr, _("You need to start by \"git bisect " + "start\"\n")); + + if (!isatty(STDIN_FILENO)) + return 1; + + /* + * 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); + if (starts_with(yesno, _("n")) || starts_with(yesno, _("N"))) + return 1; + + return bisect_start(terms, 0, NULL, 0); +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { @@ -642,7 +671,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 no_checkout = 0, res = 0, nolog = 0; struct option options[] = { @@ -666,6 +696,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 BISECT_START is empty or missing"), BISECT_AUTOSTART), OPT_BOOL(0, "no-checkout", &no_checkout, N_("update BISECT_HEAD instead of checking out the current commit")), OPT_BOOL(0, "no-log", &nolog, @@ -727,6 +759,12 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) set_terms(&terms, "bad", "good"); res = bisect_start(&terms, no_checkout, argv, argc); break; + case BISECT_AUTOSTART: + if (argc) + return error(_("--bisect-autostart requires 0 arguments")); + set_terms(&terms, "bad", "good"); + res = bisect_autostart(&terms); + break; default: BUG("unknown subcommand %d", (int)cmdmode); } diff --git a/git-bisect.sh b/git-bisect.sh index efee12b8b1..426d443e7e 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 Thu Apr 23 07:06:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11505065 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 0DC0E13B2 for ; Thu, 23 Apr 2020 07:09:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E554821582 for ; Thu, 23 Apr 2020 07:09:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mpTghm1X" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726905AbgDWHJo (ORCPT ); Thu, 23 Apr 2020 03:09:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbgDWHJn (ORCPT ); Thu, 23 Apr 2020 03:09:43 -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 09251C03C1AB for ; Thu, 23 Apr 2020 00:09:43 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id x25so5215282wmc.0 for ; Thu, 23 Apr 2020 00:09:42 -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=4+PWo85AlycXUUMEUYHlBu2WrkYKhvD0yxDn0yeXUCY=; b=mpTghm1X5EZq7gBjvNsi46c9yX9Vmis+p1LrghIKsl2Ajg1uk5C12RG6GKoZzQFN4z 7D42Sndygyfu+uXU3imc6yCWlIBqRO5U179Ja3ckJ7QsukLIqAdooTD3mtAeimRCe/yo +8GEi8MBzh73qh7q0XuMfCbJ5LgswpQYfidsQjddFnRbe2GgKr3piKgZb9siyz+IuZIr 8M1RbHBwsj6AnnoNMvmpPCmdSiM3Qs0tluzMCcaLwPDyazrtM0jtJYRqAerOjCsM8M9I IlBCpmH5Twq959YjvYMn1CAsJN1K0A66NBe8Zt7293+6wHJhoRmAq8hbtvnnkAwnzns/ 64Mg== 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=4+PWo85AlycXUUMEUYHlBu2WrkYKhvD0yxDn0yeXUCY=; b=MRxrzhOd7rU59P9nrpFHJVyfIGfPvLo715qYB8h67ZjmbWm2Mgm7GfA1591svFJXvq nW7m31MBwTCH3XEk6v3QAuDsOg7kw9VBY2R4P3HisNMIf9biQbHiXaEi11DA6uwd/2qL i2EHv48y119qs8vkS0S5rKPIDL3K5hNSjS9WMy6W5pPKftX8JD99wXp3sBhsVrK61VCo RanQxJfQv9OKDtKIhMCBGa9VBNp1i7l/ZbY10GXCPPSxJe6yspk8Rdsl5nTKW961IVLD IBI8fGkUCQKbbOUoMY1/VVk+h5p7U6qXVSPiq2XumZqOBOcll5twJ9Tj2vPxOZahgx0g O6Ow== X-Gm-Message-State: AGi0Pub3kRFr7X2ViMXW9oenBfD1tQFd931g7VW1PKoPkeodhnMadQ1K hMulByA2WfY1AmIWMItWvfBm5kV9U1YYzg== X-Google-Smtp-Source: APiQypLsYDQ497MYKlb7Ig0cJhvaUbdmjpRfxlwONierZREiKrnT/tGIRrASVt9VpHriCnQKTM7o8A== X-Received: by 2002:a7b:c10d:: with SMTP id w13mr2465205wmi.78.1587625780806; Thu, 23 Apr 2020 00:09:40 -0700 (PDT) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u17sm2518585wra.63.2020.04.23.00.09.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 00:09:40 -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 v3 05/12] bisect--helper: reimplement `bisect_next` and `bisect_auto_next` shell functions in C Date: Thu, 23 Apr 2020 09:06:57 +0200 Message-Id: <20200423070704.39872-6-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200423070704.39872-1-mirucam@gmail.com> References: <20200423070704.39872-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 | 8 ++ builtin/bisect--helper.c | 169 ++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 47 +---------- 3 files changed, 179 insertions(+), 45 deletions(-) diff --git a/bisect.c b/bisect.c index 9154f810f7..31cab3f0b0 100644 --- a/bisect.c +++ b/bisect.c @@ -980,6 +980,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. */ @@ -1064,6 +1070,8 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int "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); } diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 9df69800e3..c6aaa8eb15 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,6 +30,8 @@ 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] [ [...]] [--] [...]"), + N_("git bisect--helper --bisect-next"), + N_("git bisect--helper --bisect-auto-next"), N_("git bisect--helper --bisect-autostart"), NULL }; @@ -441,6 +444,150 @@ static int bisect_append_log_quoted(const char **argv) return res; } +static int register_good_ref(const char *refname, + const struct object_id *oid, int flags, + void *cb_data) +{ + struct argv_array *rev_argv = cb_data; + + argv_array_push(rev_argv, oid_to_hex(oid)); + return 0; +} + +static void prepare_rev_argv(struct bisect_terms *terms, struct argv_array *rev_argv) +{ + char *term_good = xstrfmt("%s-*", terms->term_good); + + argv_array_pushl(rev_argv, "skipped_commits", "refs/bisect/bad", "--not", NULL); + for_each_glob_ref_in(register_good_ref, term_good, "refs/bisect/", rev_argv); + + free(term_good); +} + +static int prepare_revs(struct bisect_terms *terms, struct rev_info *revs) +{ + int res = 0; + struct argv_array rev_argv = ARGV_ARRAY_INIT; + + prepare_rev_argv(terms, &rev_argv); + + /* + * 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); + rev_argv.argc = setup_revisions(rev_argv.argc, rev_argv.argv, revs, NULL); + if (prepare_revision_walk(revs)) + res = error(_("revision walk setup failed\n")); + + argv_array_clear(&rev_argv); + return res; +} + +static int process_skipped_commits(FILE *fp, struct bisect_terms *terms, struct rev_info *revs) +{ + struct commit *commit; + struct pretty_print_context pp = {0}; + + 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) { + struct strbuf commit_name = STRBUF_INIT; + 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); + strbuf_release(&commit_name); + } + + /* + * Reset the flags used by revision walks in case + * there is another revision walk after this one. + */ + reset_revision_walk(); + + return 0; +} + +static int bisect_skipped_commits(struct bisect_terms *terms) +{ + int res = 0; + FILE *fp = NULL; + struct rev_info revs; + + fp = fopen(git_path_bisect_log(), "a"); + if (!fp) + return error_errno(_("could not open '%s' for appending"), + git_path_bisect_log()); + + res = prepare_revs(terms, &revs); + + if (!res) + res = process_skipped_commits(fp, terms, &revs); + + fclose(fp); + return res; +} + +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); + printf("%s\n", bad_ref); + commit = lookup_commit_reference(the_repository, &oid); + format_commit_message(commit, "%s", &commit_name, &pp); + + res = write_in_file(git_path_bisect_log(), "a", "# first %s commit: [%s] %s\n", + terms->term_bad, oid_to_hex(&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 = file_exists(git_path_bisect_head()); + + /* Perform all bisection computation, display and checkout */ + res = bisect_next_all(the_repository, prefix, no_checkout); + + 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, int no_checkout, const char **argv, int argc) { @@ -672,7 +819,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 no_checkout = 0, res = 0, nolog = 0; struct option options[] = { @@ -696,6 +845,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 BISECT_START is empty or missing"), BISECT_AUTOSTART), OPT_BOOL(0, "no-checkout", &no_checkout, @@ -759,6 +912,18 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) set_terms(&terms, "bad", "good"); res = bisect_start(&terms, no_checkout, 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 requires 0 arguments")); @@ -774,7 +939,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 426d443e7e..897825b675 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 $(test -f "$GIT_DIR/BISECT_HEAD" && echo --no-checkout) - 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() { @@ -211,7 +172,7 @@ bisect_replay () { die "$(gettext "?? what are you talking about?")" ;; esac done <"$file" - bisect_auto_next + git bisect--helper --bisect-auto-next } bisect_run () { @@ -308,7 +269,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 Thu Apr 23 07:06:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11505069 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 0A0A2112C for ; Thu, 23 Apr 2020 07:09:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E678C21582 for ; Thu, 23 Apr 2020 07:09:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nKfOXY3q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726909AbgDWHJq (ORCPT ); Thu, 23 Apr 2020 03:09:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726904AbgDWHJo (ORCPT ); Thu, 23 Apr 2020 03:09:44 -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 B9AEAC03C1AB for ; Thu, 23 Apr 2020 00:09:43 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id x4so5223410wmj.1 for ; Thu, 23 Apr 2020 00:09:43 -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=qTEo0Yt8Ey5QaDqniZ//5HvJkTw1TzA0j8wYQicD55g=; b=nKfOXY3q0WFHTVoOPLX8/zYPVOaGdi2on239knlUz6kMtRfXpVh171tGJhohj5ZsmE ZbPReYslAVkMik4VXhMfWT6s0/v2K83jGNxkrAjCGkaLOEI5d8cmP21fFr3pmVb12gl3 qPXqRGdveIjev2cAu7Zm6a5cV4iBHfHYG7lgyIs9VXsXJ17twPKaz8ScnhcTmOC6xAXA JZleCRED1Xxc8lI1dA5pnP9HYQifS0Br4WfF45iImtSiUNDu2hIlxUySeuzaOiGpa7US MpYR/nJRn8L8bqtxTJ1SlclKQA3iqygkRpd04qctEUNfwgB0JtMOwhifUCyYa747K17E +Qhw== 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=qTEo0Yt8Ey5QaDqniZ//5HvJkTw1TzA0j8wYQicD55g=; b=KEDj4/rZVcIwJvvPXgFlEyka/hEBWWFnV1FrHy4S51DljDAswtvA6zJT09ClrctwxP z7YOw1e/GATyCmGsNFoTZbDIyf3kDsgBI2C0EVHIQPudOtmIYkFt/u0pHsx79OElXBcg Ds6A0fzunbgLqtcU7ZVBdRg3E0IXht+tH73LeVdBU6iVof03hsu0Md+6gRBKXkGh0E6f PcJEy7rNPod7BBnuzefOmYWn4ipwHh/LWl1caR06Wyx2SlQ7Ot4lQZ6hDY7DTB4jrhRE cBP+yBmUrji/MeQnYV5Tsh0VB4X5GB2z9FgdrO7LdMXEuCGjYhJp/Q5wjKk60zXfHKVj e4ww== X-Gm-Message-State: AGi0PuaX6E+QZKuuz1ahgwJ+4jjzPNPQYMlr7Zy1t84Moy//sOekFVAZ wIZZepPVPwEpci6/n/v3ReP+Kk6XExk= X-Google-Smtp-Source: APiQypITTHNXBPkKS7kQPrC0laL1KLpIMyg2RkjHD4va0fcgEekQoEas2b8tHL7EPlUdDfTrfCCaCw== X-Received: by 2002:a1c:7301:: with SMTP id d1mr2653895wmb.26.1587625782158; Thu, 23 Apr 2020 00:09:42 -0700 (PDT) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u17sm2518585wra.63.2020.04.23.00.09.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 00:09:41 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH v3 06/12] bisect--helper: finish porting `bisect_start()` to C Date: Thu, 23 Apr 2020 09:06:58 +0200 Message-Id: <20200423070704.39872-7-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200423070704.39872-1-mirucam@gmail.com> References: <20200423070704.39872-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()`. This removes the signal handling we had in `bisect_start()` as we don't really need it. While at it, "trap" is changed to "handle". As "trap" is a reference to the shell "trap" builtin, which isn't used anymore. 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 | 54 +++++++++++++++++++++++++++++++--------- git-bisect.sh | 26 ++----------------- 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index c6aaa8eb15..f2ec7f89e4 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -588,11 +588,12 @@ 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, int no_checkout, +static enum bisect_error bisect_start(struct bisect_terms *terms, int no_checkout, const char **argv, int argc) { 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; @@ -645,9 +646,12 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, 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); @@ -725,12 +729,12 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, * Get rid of any old bisect state. */ if (bisect_clean_state()) - return -1; + return BISECT_FAILED; /* - * In case of mistaken revs or checkout error, or signals received, + * In case of mistaken revs or checkout error, * "bisect_auto_next" below may exit or misbehave. - * We have to trap this to be able to clean up using + * We have to handle this to be able to clean up using * "bisect_clean_state". */ @@ -746,7 +750,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, } if (update_ref(NULL, "BISECT_HEAD", &oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR)) { - res = -1; + res = BISECT_FAILED; goto finish; } } @@ -758,25 +762,51 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, 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, or signals received, + * "bisect_auto_next" below may exit or misbehave. + * We have to handle this to be able to clean up using + * "bisect_clean_state". + * return code BISECT_INTERNAL_SUCCESS_MERGE_BASE is special code + * that indicates special success. + * -> bisect_start() + * . res = bisect_auto_next() + * -> bisect_auto_next() + * . return bisect_next() + * -> bisect_next() + * . res = bisect_next_all() + * -> bisect_next_all() + * . res = check_good_are_ancestors_of_bad() + * -> check_good_are_ancestors_of_bad() + * . res = check_merge_bases() + * -> check_merge_bases() + * . res = BISECT_INTERNAL_SUCCESS_MERGE_BASE + */ + if (res && res != BISECT_INTERNAL_SUCCESS_MERGE_BASE) + bisect_clean_state(); return res; } diff --git a/git-bisect.sh b/git-bisect.sh index 897825b675..049ffacdff 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 "$@" @@ -162,8 +141,7 @@ bisect_replay () { get_terms case "$command" in start) - cmd="bisect_start $rev" - eval "$cmd" ;; + eval "git bisect--helper --bisect-start $rev" ;; "$TERM_GOOD"|"$TERM_BAD"|skip) git bisect--helper --bisect-write "$command" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit;; terms) @@ -262,7 +240,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 Thu Apr 23 07:06:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11505067 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 5216E112C for ; Thu, 23 Apr 2020 07:09:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3981B21569 for ; Thu, 23 Apr 2020 07:09:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tWbrldY7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726911AbgDWHJq (ORCPT ); Thu, 23 Apr 2020 03:09:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbgDWHJp (ORCPT ); Thu, 23 Apr 2020 03:09:45 -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 E77AFC03C1AB for ; Thu, 23 Apr 2020 00:09:44 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id g13so5490543wrb.8 for ; Thu, 23 Apr 2020 00:09:44 -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=6nh3q5T05d/rmpBzzqkvyp/gkxm+rUM9UNUlc6oSKmc=; b=tWbrldY7dpFiD88cGyW5EpJWu5UJzupvW5jFtev8KY18oMvPOQKF3bpoVgRc/d+JTa zUUbxnKZ/LIyLUUCAgXU5oC/jqF7yDRnCuXxeS4My8A69ntNeyBpUyxvEx991j/bilz0 6nFJjzm+y30+NAioqXNufrsHf4ATBxUVL/tvno6VzrZdRcMflshNDej8bnhAb+lnILfj F/b9ifxDvkK8kZBV1Bgcu6HPzPiQZGvd22BnEG3jch2hAoMQfh06352qqU7pNBmV19b6 8AJjXzEZS2oUYsCFjs6/G2CrI+q+tP3FwqcricN1igEF++5msW7S5CZnYQEWiF3suCQy 7Y3A== 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=6nh3q5T05d/rmpBzzqkvyp/gkxm+rUM9UNUlc6oSKmc=; b=Xb8vRQcbig5L1tuRSghppNrkzRg6uzd+FQgkvqyDnCjEZvvar0mewW1xiyyprH8MIu itP9IVtKe311mKgjisWmNV7CcuMada1eeEBHhLRwoAbK9O6iLyCmm9iHT5/2CyCb//qz xRcIyAurpYSuZG5dGi4IXdyA6OJjoM7/VTYhXPxwrQILNzOtsSvx1f6pWGb6CBp0gDaa cPhUtY3gCnodd0uGR7McRlI5WQSqHRwmmqtWNWbzu1zL+SznAYfvys7qMsGagRqKH9SI 8NXwPKCssQfEel+SPhnJE8k7sYyJbJZJIwzNPovnE+eD6MQVp7cTCML287MXmRlXgkDM laWg== X-Gm-Message-State: AGi0PuZSCNyAO4osk6X9MModA5F3+JFH/sQ95sB4lp26e6tAVRgsg2Tz avW0cO0UdPYX1LV+3h1CW6z+wuck6Mg= X-Google-Smtp-Source: APiQypJ/2NN720lySmkA1NcJ+zEd2ecxNnlje1NZF1lBNUXakLMXfztOP7VkjKymoiYCKlUfGlrHHQ== X-Received: by 2002:adf:a18c:: with SMTP id u12mr3134419wru.325.1587625783502; Thu, 23 Apr 2020 00:09:43 -0700 (PDT) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u17sm2518585wra.63.2020.04.23.00.09.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 00:09:43 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Tanushree Tumane , Miriam Rubio Subject: [PATCH v3 07/12] bisect--helper: retire `--bisect-clean-state` subcommand Date: Thu, 23 Apr 2020 09:06:59 +0200 Message-Id: <20200423070704.39872-8-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200423070704.39872-1-mirucam@gmail.com> References: <20200423070704.39872-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 f2ec7f89e4..1b4d0a0f87 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -22,7 +22,6 @@ static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") static const char * const git_bisect_helper_usage[] = { N_("git bisect--helper --next-all [--no-checkout]"), 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 "), @@ -841,7 +840,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, @@ -859,8 +857,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, @@ -904,10 +900,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 Thu Apr 23 07:07:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11505071 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 95226112C for ; Thu, 23 Apr 2020 07:09:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D5EE21582 for ; Thu, 23 Apr 2020 07:09:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nbt0FJM6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbgDWHJs (ORCPT ); Thu, 23 Apr 2020 03:09:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726912AbgDWHJq (ORCPT ); Thu, 23 Apr 2020 03:09:46 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A439C03C1AB for ; Thu, 23 Apr 2020 00:09:46 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id k13so5498260wrw.7 for ; Thu, 23 Apr 2020 00:09:46 -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=lMQYmzL6CcZW6Tyz4lAKQTH5zrrLc29qKEjy3wnk4GI=; b=nbt0FJM6C1Lv1jJ7U8c0KOXFbDb+zrWPylTDyzK54hgIM1cC2qQ13ERd3+BdzNHWRf l/ZYRHrOxdn+l0hUkCLYSSltIcBkHQXd6bnrWTOB6pkeIIcocaqqfG8IGdvBGL5o3cr8 AnHrJ5HROn1dcfCIdVRcqkzqPQx9OXIwwr7wz+jGFBhWasYByXSDBqzcOLGasgc8QiYB QPpA1z7btPbC1WO/w0Vl7Wx3Ofh6wuhGm4HDaXEJD/gISq3cDOmOHPEzyiRdHrx6y5PB To/XxY+4h+z5zaH8JEVmis7slfiQ3M/7z14m4vHsscjuMEZQx0/9W67v2zWJPtZofxX2 TT0A== 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=lMQYmzL6CcZW6Tyz4lAKQTH5zrrLc29qKEjy3wnk4GI=; b=OUUrvtozGNaL/SrIazNSqCefiUSKYu9afhwVLBGLHLYoPn77pb2CShEiwBGL0FJO5B j8qr43bdMwQDkqOra78/1xicsHLkmeHcCJGyqktquBN8LLQClhE2/oWFcdKDupkbPnN1 OVlLQqIVbj7CQDqzKBoElu1zKTI4IWu+s//FdKfoqO0NpgeFFhJyuAGsZ/C3rOpAOJIM y/D0+8h1APDdMx4+bHUYSZY9UQNR39obIlP3K9eYAbdYYk32mqQjjY5KMyOTnUdO+B5o 7saH14lfB8MLeY/Mhht8Lf5YqFOkBnfXL0M79nMMSMzvad7vKXmamTo7VlgWC942RU+c G2KA== X-Gm-Message-State: AGi0PuYWyU68sm4MtdAUPJZMz72e9WwQJuUxceNODKAExR+TlahbyIvY N4L7/MUD9QJNsT3dz+x3Z0PVqNj7asM= X-Google-Smtp-Source: APiQypKGbqkmXMgevdsuNJ6UL99tw50NXghBeUxmFUVgeEugnS56tmRD4UsEqXxwSc8pzqbYvsgJhA== X-Received: by 2002:adf:e88d:: with SMTP id d13mr3101878wrm.375.1587625784799; Thu, 23 Apr 2020 00:09:44 -0700 (PDT) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u17sm2518585wra.63.2020.04.23.00.09.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 00:09:44 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Tanushree Tumane , Miriam Rubio Subject: [PATCH v3 08/12] bisect--helper: retire `--next-all` subcommand Date: Thu, 23 Apr 2020 09:07:00 +0200 Message-Id: <20200423070704.39872-9-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200423070704.39872-1-mirucam@gmail.com> References: <20200423070704.39872-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 1b4d0a0f87..2d8660c79f 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -20,7 +20,6 @@ static GIT_PATH_FUNC(git_path_head_name, "head-name") static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") static const char * const git_bisect_helper_usage[] = { - N_("git bisect--helper --next-all [--no-checkout]"), N_("git bisect--helper --write-terms "), N_("git bisect--helper --bisect-reset []"), N_("git bisect--helper --bisect-write [--no-log] "), @@ -838,8 +837,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, @@ -853,8 +851,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) } cmdmode = 0; int no_checkout = 0, 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, @@ -893,9 +889,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, no_checkout); - break; case WRITE_TERMS: if (argc != 2) return error(_("--write-terms requires two arguments")); From patchwork Thu Apr 23 07:07:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11505073 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 1595913B2 for ; Thu, 23 Apr 2020 07:09:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC9C121569 for ; Thu, 23 Apr 2020 07:09:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BWjMTQcu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726917AbgDWHJt (ORCPT ); Thu, 23 Apr 2020 03:09:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726914AbgDWHJs (ORCPT ); Thu, 23 Apr 2020 03:09:48 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0B0CC03C1AB for ; Thu, 23 Apr 2020 00:09:47 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id v4so6685917wme.1 for ; Thu, 23 Apr 2020 00:09:47 -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=jpdbud4hfnMVUvj7AlpMG3y8rFTxRiD4XDqYg8qCQGU=; b=BWjMTQcuaFeiZtW5SxdEs7cTMXQ1sIKckp97sFH5wzbuJ7IBfQOJOYxU7+ArxuFgaA WLYGF1FSA3iw7Z7vBdsqPF0Xlk0843N2YPPlkWZocwTnnUT00DxHd52f+aGf0mW9Io+F IaShww0NznUtjkjCeYt+Obm/o0wQVQ/WiQrM1p3BfDrX4jXz7ofjypEUohyFZUETYd0U AZMagETK5Tmbjpv5BgFj/ALLJZ5TrWb8tv005f8Mzf9eqNNCiaKSZtypkfaS6R4O9dCw lvTirN7W5HA+UB4h5EpWhkkb0zG2HXNM8O3/Le7jKIFU3nuXNbQY3y5C+sWhMTTGdD8j tanA== 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=jpdbud4hfnMVUvj7AlpMG3y8rFTxRiD4XDqYg8qCQGU=; b=XWmChgE7mAVHCMiRrtV8J20med8bPeX5maewtBw+wBf6hM7rZdSGR6BZpxdZt31G7Y 2HF/9o1ndRJC7Uw3Y0xg6xi8MCZR6IjCYaXWLyJpyn4J6e0NxLXkP7H5vxt7TjdMnwqv b5JZWBLrlk/+OQLA7jC7RsQ5AjNYXMQAikgUxhlUj+UUJmrdX7I8YpT6ieemb2DzQ9Z/ Dt+8YtR31ybR5WD15QrZDKmgmducz5Xw02/z/1BMdy0UslnYAfzgyUMc1Eh0cKqzrv/G /u58LYycF2fVYYgIqs45G5wwAvpvMuRaxEmwdFbwzgShgquqac4PkSSMNxRU0evENSZS mvGw== X-Gm-Message-State: AGi0PubhRx1W9pYUMLxT9H7rHtUFsKsGSUsjM8d1Eqmlacfo7rqlvEd8 rIZU0QAPqd+BkUUF/BGO2DWa+Y1ZHrNfdA== X-Google-Smtp-Source: APiQypL5Tw5hkjBtRi61MBPne8x2Q6JHH/Z5ca7zP96NFcVmCqq0t9IBH+SS2dVBKKmou50eS4FazQ== X-Received: by 2002:a7b:ce13:: with SMTP id m19mr2405760wmc.76.1587625786081; Thu, 23 Apr 2020 00:09:46 -0700 (PDT) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u17sm2518585wra.63.2020.04.23.00.09.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 00:09:45 -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 v3 09/12] bisect--helper: reimplement `bisect_state` & `bisect_head` shell functions in C Date: Thu, 23 Apr 2020 09:07:01 +0200 Message-Id: <20200423070704.39872-10-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200423070704.39872-1-mirucam@gmail.com> References: <20200423070704.39872-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 | 70 +++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 55 +++---------------------------- 2 files changed, 73 insertions(+), 52 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 2d8660c79f..9db72f5891 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 }; @@ -834,6 +836,64 @@ static int bisect_autostart(struct bisect_terms *terms) return bisect_start(terms, 0, NULL, 0); } +static int bisect_head(struct object_id *oid) +{ + if (!file_exists(git_path_bisect_head())) + return get_oid("HEAD", oid); + + return get_oid("BISECT_HEAD", oid); +} + +static enum bisect_error bisect_state(struct bisect_terms *terms, const char **argv, + int argc) +{ + const char *state; + const char *hex; + int i; + struct oid_array revs = OID_ARRAY_INIT; + struct object_id oid; + + 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 (!strcmp(state, terms->term_bad) && (argc > 1)) + return error(_("'git bisect %s' can take only one argument."),terms->term_bad); + if (argc == 0) { + if (bisect_head(&oid)) + return error(_("Bad bisect_head rev input")); + hex = oid_to_hex(&oid); + if (bisect_write(state, hex, terms, 0)) + return BISECT_FAILED; + check_expected_revs(&hex, 1); + return bisect_auto_next(terms, NULL); + } + + /* Here argc > 0 */ + for (; argc; argc--, argv++) { + struct object_id oid; + if (get_oid(*argv, &oid)) + return error(_("Bad rev input: %s"), *argv); + oid_array_append(&revs, &oid); + } + + for (i = 0; i < revs.nr; i++) { + hex = oid_to_hex(&revs.oid[i]); + if (bisect_write(state, hex, terms, 0)) { + oid_array_clear(&revs); + return BISECT_FAILED; + } + check_expected_revs(&hex, 1); + } + + oid_array_clear(&revs); + return bisect_auto_next(terms, NULL); +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { @@ -847,7 +907,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 no_checkout = 0, res = 0, nolog = 0; struct option options[] = { @@ -873,6 +934,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 BISECT_START is empty or missing"), BISECT_AUTOSTART), + OPT_CMDMODE(0, "bisect-state", &cmdmode, + N_("mark the state of ref (or refs)"), BISECT_STATE), OPT_BOOL(0, "no-checkout", &no_checkout, N_("update BISECT_HEAD instead of checking out the current commit")), OPT_BOOL(0, "no-log", &nolog, @@ -945,6 +1008,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", (int)cmdmode); } diff --git a/git-bisect.sh b/git-bisect.sh index 049ffacdff..2da0810b1a 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 test -f "$GIT_DIR/BISECT_HEAD" - 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() { @@ -185,8 +139,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" @@ -201,7 +154,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 @@ -242,7 +195,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 Thu Apr 23 07:07:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11505075 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 6EF241575 for ; Thu, 23 Apr 2020 07:09:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5701C21582 for ; Thu, 23 Apr 2020 07:09:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Detnx1zO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726921AbgDWHJu (ORCPT ); Thu, 23 Apr 2020 03:09:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726912AbgDWHJt (ORCPT ); Thu, 23 Apr 2020 03:09:49 -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 C6AA2C03C1AF for ; Thu, 23 Apr 2020 00:09:48 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id t14so5478598wrw.12 for ; Thu, 23 Apr 2020 00:09:48 -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=esI1Ng8e5Z7BGgJcjrZLm8dM4R+mAX73nBXE1MnJiSs=; b=Detnx1zOvO+a7AGHB6H0hFTtUk7EnJBpbcsEOTHiwBNfL+BnDamRuZF+wPB4Znm5BW OOXgdWpu5QFPiAkSetfM2EJCSzQcLxCU/ui/D4QQEWJXv28Gh53K7mMefiS7LqI7Fhzm xTMzS47D5u/pperArRI1C9IP8iIEhwLzTg5X5VTlaT6vE0+TH5YutZX1v2U7jbGLFMdH dA3RVYyXnpTLhqmKWOjEVowl8Ai/2AKDy66lyEgPhIJxnP+G2RtgUgpMVnRmZUyujnSG DmMbE0l7Gl16xVNkI6jgajtp0RAX+ga1gMCu1BdSBxS9vJku6jt91ZkS2gUaRHnqwRq6 JAdQ== 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=esI1Ng8e5Z7BGgJcjrZLm8dM4R+mAX73nBXE1MnJiSs=; b=dj6xlJtG7012eqDP86L9dwv2CeasLhtzLznAoAAxlnHPMJj50P2Q27mJT0jJB7V7hR GL+PL97hHyWgJKlWBbczWkgIJ6Lpc+W8Jzunm2W5BcMqMSljUmyXSO7lMktY7unjNK/C CpyDSp6aGhV1Da1dTCnSDaRAUUyWWgOGcz3xRFsZD8HX9bZFOk8XWgh8qWbwUYj2XOLm 3K0gjTRKNoRpnYdT9oF3UCait4wyUfO9yWYBlxKBTD46bQODHdfEUHhxQbJ/kIEtX2Ut iWoa4Mip2mV98Ncemo8B4fnYKcuuu4feLu7FS8l9UKZHLgJel0se836T3Crj+CWMCtij RTNw== X-Gm-Message-State: AGi0PuY7HSi8DHJAiPOPqiKe5fK2K0fgBQy4jaJNU3z+9Tl3YJcfWESO B7aWUA7FyA1du31Xl9zHJMOY4XhOWzXWow== X-Google-Smtp-Source: APiQypKtSOj3ta59EwrgCOqJkgrrpmYrgbIDWHb7cUXIcG9aW3MSY4s6kjCcTaSgLG0tCId9DSL8PA== X-Received: by 2002:adf:e3c2:: with SMTP id k2mr3107700wrm.287.1587625787381; Thu, 23 Apr 2020 00:09:47 -0700 (PDT) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u17sm2518585wra.63.2020.04.23.00.09.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 00:09:46 -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 v3 10/12] bisect--helper: retire `--check-expected-revs` subcommand Date: Thu, 23 Apr 2020 09:07:02 +0200 Message-Id: <20200423070704.39872-11-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200423070704.39872-1-mirucam@gmail.com> References: <20200423070704.39872-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. Instead the function `check_expected_revs()` is called from the C implementation of `bisect-next()`. 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 | 6 ------ 1 file changed, 6 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 9db72f5891..7db58ada6f 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -898,7 +898,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, @@ -914,8 +913,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, @@ -956,9 +953,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 Thu Apr 23 07:07:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11505077 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 ED253112C for ; Thu, 23 Apr 2020 07:09:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D599621569 for ; Thu, 23 Apr 2020 07:09:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WNbhPgeW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726924AbgDWHJw (ORCPT ); Thu, 23 Apr 2020 03:09:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726920AbgDWHJu (ORCPT ); Thu, 23 Apr 2020 03:09:50 -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 32928C03C1AB for ; Thu, 23 Apr 2020 00:09:50 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id d15so3896419wrx.3 for ; Thu, 23 Apr 2020 00:09:50 -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=LnIuzROd4iMGvi2EDoEHmjqIjVc8ggiVmaobTiPSuxw=; b=WNbhPgeWaBzNG/T8p9th5IXJ8OWhGgvxYmP09O4c5SAW1ljMjFFmDacgiWPruMQV+O tuDzL26eTh5qKIXM+gSH9kpeUsj4VQJa6fmhL+NJ29pkUBgzz1St+3eSwXdp9O5MNCGx LARp3WDLfqxIqhbDFPi3JPvEtX1cJhJHfqiTkXvc50nK62VmLLVNYf/jyEyan+H7DLlE 7zKDBc2D2LsE+ca3s+XEqVhtJtIqYY3QP03Z2Zs94jyV20fTv/asVrbLh/lMgJaCvrpJ FxSZUlf5jYTePIO0fDFusnh+hty21UEZFFDaJVuTwmtHvz5Yw14I2wZrkWbgWUOBdl8z 2agA== 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=LnIuzROd4iMGvi2EDoEHmjqIjVc8ggiVmaobTiPSuxw=; b=aqkg8J2TscsXl3bEXisjgXwO3XcLr7rXG9DDNeUe9JxlTykrO7JtPWIysbU2pnqyob bcqLTMEWl++SFO+7MqCr9z4L7NiZqzuvU0y4UgtikkYMLSVYO4qYz6rmDas1jWMQZHvl NK0jcyN9/6a4bjYJQ17v13pwT5WqkQlv98QgakJKapvRO9wOb3BgrAL/1X2sZLp0u9HM tj4KKSxUoBIa+DIlvvpmemhSYgjTN3qGWWwAtpfeG7hZNAiCFISrkRwrHYW9XnO3xwcI FSSGnqaqAfkvt0MDxfK2oog4IZ/oU5xIj8I+SnokNQn69ggcc7QGZoF01quRN/mrOhcs +a3A== X-Gm-Message-State: AGi0Pua/otP2Xj/qHRXjYi6vPAOfAT8/zbm7zcp00NZaR9ZqGfQxXWtm 9ZSe8SMzPbTVPngzek3vQltfudtZywQacA== X-Google-Smtp-Source: APiQypJQlJxQAwuPjMo9gte1H7aG2qJN21NloCNchb5h22/nBf97tztC6qsHLL8EwEZ3XCJta8p4qw== X-Received: by 2002:adf:82b1:: with SMTP id 46mr3024749wrc.44.1587625788757; Thu, 23 Apr 2020 00:09:48 -0700 (PDT) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u17sm2518585wra.63.2020.04.23.00.09.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 00:09:48 -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 v3 11/12] bisect--helper: retire `--write-terms` subcommand Date: Thu, 23 Apr 2020 09:07:03 +0200 Message-Id: <20200423070704.39872-12-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200423070704.39872-1-mirucam@gmail.com> References: <20200423070704.39872-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 7db58ada6f..e7467dc1c7 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -20,7 +20,6 @@ static GIT_PATH_FUNC(git_path_head_name, "head-name") static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") 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 "), @@ -897,8 +896,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, @@ -911,8 +909,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) } cmdmode = 0; int no_checkout = 0, 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, @@ -949,10 +945,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 Thu Apr 23 07:07:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11505079 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 C1D27112C for ; Thu, 23 Apr 2020 07:09:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABD3521582 for ; Thu, 23 Apr 2020 07:09:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gZuUoQTt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726925AbgDWHJz (ORCPT ); Thu, 23 Apr 2020 03:09:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726922AbgDWHJv (ORCPT ); Thu, 23 Apr 2020 03:09:51 -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 90B5FC03C1AB for ; Thu, 23 Apr 2020 00:09:51 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id k13so5498515wrw.7 for ; Thu, 23 Apr 2020 00:09:51 -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=/X2BnggV6TCXtyL0UyOGZtASS8zBP6Iv4SDOAr+jcPE=; b=gZuUoQTt6/fuea9x1AvGCo7N1kET6jaEVr2gCHvH8FHvqT6P9ZCUlu/u6cpPvnAMIJ ETah/Kw5p0GYt2lknBy6F4whgNkVjSq0pG+OW5ckiet9q3W+zYMEPUqqNtsxEa5+ZG0h 7Fw5HZGa4TzschBbxFIei+MawZk2l4tY0pSe5TAXROtZTKYY8QRpsPhP6uwR0aVlemu8 J3pOJkvAC4dOTWvRttCvTGeBbvI1S4Ri/x31UAsZz/nyt/kW3UUut7dEhVR6ANy/YI8Z QYgNnb8beknDbe9zYT890X+liR5t55Y33Bfm1jIyhLnpcgjx4g5E4TARodwjN+ohhfWj FF5Q== 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=/X2BnggV6TCXtyL0UyOGZtASS8zBP6Iv4SDOAr+jcPE=; b=lm/mJ4cGTbf7zPVZ6tiZqAsPYtAzsTCtKPybXuurYWUL2ubOnn6trCvffdUfTgYpBu uAmsu83nruItXeNaAaoE9V/nQ6uEO0i7SAEykq48VqCgpeo+ZzV3VhmLjUaBnGu4NeoX 8MeKKwoF4GRT4RMR5N1eEou8oCnAzPmsdE4RgYf0c4L96iRppmtcfd0RfnfFj14B/Zew WI/jqPOqQdosLdoVx59hcTMFFyVtPEwKd9yJWjF4s+nw1YhBecxQG6gwf1yOyW2nbGj7 7Wxw9wqh+/kNx6SlXxXKrVDx0rUWtBPps6T0JH9qAKUNnJBEFtJ0yz0A9ZcdFUjao/Mb PGvg== X-Gm-Message-State: AGi0PuZqmLAYRTWqGMNZh+zwSM3D7f7FNjkwszIVFt0cJO9H+PZQr7rL hmbXgCG3Qx3bfxcB+V+AeTehZ1u/Xs+Ing== X-Google-Smtp-Source: APiQypKzpIge8b+3LWpLgcFTWpPn0OnCYInE2mPDih+PGRA3ECniPWif83sLWcYcKvMeiL2OR0C0Sw== X-Received: by 2002:adf:9564:: with SMTP id 91mr3325431wrs.246.1587625790111; Thu, 23 Apr 2020 00:09:50 -0700 (PDT) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u17sm2518585wra.63.2020.04.23.00.09.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 00:09:49 -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 v3 12/12] bisect--helper: retire `--bisect-autostart` subcommand Date: Thu, 23 Apr 2020 09:07:04 +0200 Message-Id: <20200423070704.39872-13-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200423070704.39872-1-mirucam@gmail.com> References: <20200423070704.39872-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 e7467dc1c7..66f9b8eab6 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] [ [...]] [--] [...]"), 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 @@ -904,7 +903,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 no_checkout = 0, res = 0, nolog = 0; @@ -925,8 +923,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 BISECT_START is empty or missing"), BISECT_AUTOSTART), OPT_CMDMODE(0, "bisect-state", &cmdmode, N_("mark the state of ref (or refs)"), BISECT_STATE), OPT_BOOL(0, "no-checkout", &no_checkout, @@ -988,12 +984,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 requires 0 arguments")); - set_terms(&terms, "bad", "good"); - res = bisect_autostart(&terms); - break; case BISECT_STATE: set_terms(&terms, "bad", "good"); get_terms(&terms);