From patchwork Mon Aug 31 10:50:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11746137 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 9F3E61575 for ; Mon, 31 Aug 2020 10:51:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 875D620936 for ; Mon, 31 Aug 2020 10:51:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uFKkevJE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727111AbgHaKvU (ORCPT ); Mon, 31 Aug 2020 06:51:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726359AbgHaKvL (ORCPT ); Mon, 31 Aug 2020 06:51:11 -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 0B031C061755 for ; Mon, 31 Aug 2020 03:51:11 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id w2so4939355wmi.1 for ; Mon, 31 Aug 2020 03:51:10 -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=uFKkevJEgYbTDKCr6voE9ZCAic0AhftDZXcfotgzGcFvAm7a/jn9+Hjn9gw2ezpnvS 2RqY/49obWcvZG26EBvdvQ0kOP4/KrlWrS6PJC5z4kmraWZKGEg2JBgd9vMZZrwjTryk NlbVgHVDiDl5duCZcbhty1lhsBUVbw31hnSByaDhz++v2pKmKNqbDl8CsNZVcoxvdnvA 81b+rwiyQVPJ4OGSmsdqI4qoOTQ3wqLk+8L8IHU+993/rWXiPrCKzCkfLTe+uBR/KVo1 vGJgQBsmyuWsgO5BjHwv2XRJhudd5sbwojyPzsSwbcTZqAkCmbxrcU8iNzKYRw0wLp7U tsUg== 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=kLJH25N/ULzbFXYX2Sy2RHLMiw4iUqOHCUqCTQWRP1Q9wYON+/KqGGHlUkfmaKJb+t HOieyVt6kPe3SVYa5woR768TKnRL+xVEWQHJhHVZvveU2tbtcbyhAh90s+K25nWa60IO 5C314b2HuVwgaaEZa5OtB9IvpGu42JlLk+o0ztYxzzsjBgATR7pGfs1bwzzC+tqAs8ol ukGeDX/xX92zjh/HnVmEDsfW3saQCnfpOcPP67NDmMJE6LtO1umtduTOdUdvhS6FJJ/g +OBlcG2wM8jQjeCHCR1cDK0Tbi/q65SqCTLXqT9enrGdm9QHFYTdzjtmWEaUwyCIruew dyDQ== X-Gm-Message-State: AOAM531tHRH+zuq5vIB0aQH7jGygfce1i3i+Oat50qv46d1mpM7pxthH PvD0kc+3+CluNQ0j9OOyup85xW7HADs= X-Google-Smtp-Source: ABdhPJwlQLcBBkkQZluOoLzKK0PRR6uSD1JzZOwd7/Bmch1Xi+X3hS/xMhbLlViDrioLqRtoZQjlGw== X-Received: by 2002:a1c:ab06:: with SMTP id u6mr851979wme.172.1598871069525; Mon, 31 Aug 2020 03:51:09 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id k84sm7674454wmf.6.2020.08.31.03.51.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 03:51:08 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Miriam Rubio , Christian Couder , Johannes Schindelin Subject: [PATCH v7 01/13] bisect--helper: BUG() in cmd_*() on invalid subcommand Date: Mon, 31 Aug 2020 12:50:31 +0200 Message-Id: <20200831105043.97665-2-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200831105043.97665-1-mirucam@gmail.com> References: <20200831105043.97665-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 Mon Aug 31 10:50:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11746139 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 E618B13A4 for ; Mon, 31 Aug 2020 10:51:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC5372068F for ; Mon, 31 Aug 2020 10:51:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QRiAdEtq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726503AbgHaKvf (ORCPT ); Mon, 31 Aug 2020 06:51:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbgHaKvM (ORCPT ); Mon, 31 Aug 2020 06:51:12 -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 0B950C061575 for ; Mon, 31 Aug 2020 03:51:12 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id a65so4914744wme.5 for ; Mon, 31 Aug 2020 03:51:11 -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=QRiAdEtqt6Cn+e+wvnf1gZwhRnjB+txFVPUtq6rWI6DwXfjbw0owYUBhCPoL1Cnd7g C4ynKMicJQkKkV7vIzvYVdQP1esU9c1HTAv0xeKLxjQV3zQ9TnqVtBQc2l2q+XesmoVh u64ibr7BzYTQGv9MDDfR2qxR3pClmMt63u8mE0VMASO+7TRTS1gOH40qj3T8AqbpcpG0 zlFWsAvYT+DWRkJFF/w+wO+pjaN9f1e28VJEGmtwDbpZbHzwjKcxR36FGBVLQDj6bWQy /rdrcGSXhlRA483tsIHLRy2HD6lFUCffuMmAbJPZBsKkvyutVku+mqG4lQhIHaEnqXyE lSVQ== 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=j2ENdlVoVASpZw1u8PbP4/QOL4j9Eh3uT9i3fWIghGZnC56PEHEQPXwZSZnI6RWVzx iSMpnWFeZBthmF3yRLKugETQCirC8duk+gmZfVw5KdH2xW/MTa1X8k/H+0Ez3UPHXwI4 EfrFLDW537TpMeYwfcO10Dgl3E0nkFCZ9EsARmsfuNZXqu81Hsb1Vlh9U/hhrAuLLo54 AQJJrWqWqvSL/3yr0Xs/dsAiZbL90lYRnabziHM4xC9VQcSuZz3iPSP5djKv8mz85J3y IjrsBYTedT/oLF3YG/FJ5H7B2zg6amkiDxH7boEU4vQmXjET/qL9Vlpx2AbA9w0n2Ovt EByg== X-Gm-Message-State: AOAM5333NvYN+oSbxxIUkAyC+DZHOyYC5YOTV70ppW/dcoMPxwGc5v8i EwjfQd9OzzIw5SzJVE2SRuleqYpfUhA= X-Google-Smtp-Source: ABdhPJyN6Q1Kk+rGIZVaM+wYQbxYdeaKHWkqFxn4EEvhbybBP+9G6lH6RaMhInT4Uj8itA9D0uRYHg== X-Received: by 2002:a1c:f30f:: with SMTP id q15mr840667wmq.60.1598871070462; Mon, 31 Aug 2020 03:51:10 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id k84sm7674454wmf.6.2020.08.31.03.51.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 03:51:10 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Miriam Rubio , Christian Couder , Junio C Hamano Subject: [PATCH v7 02/13] bisect--helper: use '-res' in 'cmd_bisect__helper' return Date: Mon, 31 Aug 2020 12:50:32 +0200 Message-Id: <20200831105043.97665-3-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200831105043.97665-1-mirucam@gmail.com> References: <20200831105043.97665-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 Mon Aug 31 10:50:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11746141 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 3E6A513A4 for ; Mon, 31 Aug 2020 10:51:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 228752068F for ; Mon, 31 Aug 2020 10:51:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mbJow04o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726857AbgHaKvj (ORCPT ); Mon, 31 Aug 2020 06:51:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbgHaKvN (ORCPT ); Mon, 31 Aug 2020 06:51:13 -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 29C03C061236 for ; Mon, 31 Aug 2020 03:51:13 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id z1so1980870wrt.3 for ; Mon, 31 Aug 2020 03:51: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=6SFHZnVCeS0qHqgRhbltpkrDBqLd+6jSYWAfeJlUWPM=; b=mbJow04oKlBALfadvsg4HOyPZggj4aY9lQ8Mn1peIyTl4ZU3gpAMsVkO0C88V2WuQ3 bfr16CUUngYusa/r9cKLO3+1pU22H9YVsiN5TVaXckYbJlIErGDV3QGnM7FxY0fGMrvP jeXi9yN5qaTCwEJpMjX0Scb8yucC0vtl4W0LbBYKsYhnVIx7TE8WHzO1faPh5Hx0oSwb 7GDxJFAybwXZuFQYULvw1Hyib9sJzUWz2ADmUaq6apc5H1l7USTiLll/ivp9YGgzjtB7 9iKNsOF4iYGG7vBj7hlW4KgzIAY5ZZodxxK4BzAHMEHTvyHRXtAl0UQxl4xLTr4zFuZ+ gvFQ== 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=k4U6fre0xJdv7cp35nsleGY/Iy37XpnHs8+kxmRhvDX5vFc1VMAXyYPs+JQWY690BG /9cgj+ckBCy+vTUyza2KuRmFHFDLWk9PcRGsnZW2v06fmya8rwMcDiCMwBbPEe1ZwmrQ 4PxV17Bpkahsq/Y8rqBqYgwGl9SdnpUyFP3R9Ur/54dLonfYfCOaGezl4p6zGTuwCIEQ bR1JdjbYJPIffysIO5LUzeGfYOPvgHYrKSmNE0TIjSRuVOvg5784YIZG3RQekCdbcsct YrQQp/U3bn+4g5FJwwMGqlM2XrorIDr1rKXk62nRl0BVcL4CjauDGTpjZiouAKoja6fm LIYg== X-Gm-Message-State: AOAM531g6XklMUnfJ6PWP6RD861rWe6VTbcb5BaRwugTELzJ9rhpimtC usi08rVRXniDECpsNugks15hOaOay1Y= X-Google-Smtp-Source: ABdhPJyP7kIEzceO0EZQubAIYKgBArsasPFnFX8tnjyAR0ROD7x2id1EXUnt5tyF+ChWq5SG6oItPQ== X-Received: by 2002:adf:cf01:: with SMTP id o1mr1077320wrj.421.1598871071584; Mon, 31 Aug 2020 03:51:11 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id k84sm7674454wmf.6.2020.08.31.03.51.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 03:51:11 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Miriam Rubio , Christian Couder , Johannes Schindelin Subject: [PATCH v7 03/13] bisect--helper: introduce new `write_in_file()` function Date: Mon, 31 Aug 2020 12:50:33 +0200 Message-Id: <20200831105043.97665-4-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200831105043.97665-1-mirucam@gmail.com> References: <20200831105043.97665-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 Mon Aug 31 10:50:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11746143 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 A14E713A4 for ; Mon, 31 Aug 2020 10:51:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84E9020DD4 for ; Mon, 31 Aug 2020 10:51:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A5EkeCmT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727783AbgHaKvs (ORCPT ); Mon, 31 Aug 2020 06:51:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbgHaKvQ (ORCPT ); Mon, 31 Aug 2020 06:51:16 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E32FC061239 for ; Mon, 31 Aug 2020 03:51:15 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id o5so1559257wrn.13 for ; Mon, 31 Aug 2020 03:51:15 -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=A5EkeCmTu0pPeS4UfDL+pOMQ/siTBGGNNN9d+myLni8/NS/LMYcFSkNYPRFyuaedhP JTCPS9izXm7ucOASaXOTStQYrMy+kPp3GqCv7i4UohJvatgE0sHYqFp2SWSm7uJ1ifQX jp1Hw4oTsBixbaMQZ4rH54er++u/XJpmJrsvq62lp8lDhdS2AVVgUPEwlHJfikJ2Jegu dih0ayGp+vodHh+youyMimmG6m8n/uYGAjrIe5TgyxJ2HNCLGn0VIp50AX1K66s4vSbn hSqTzS+5UEapfedxR5SNTvwOhGJoLq/0+b6Avd+asRwXY3xdT7C6fmcKbMEwBD/naa+d HN8g== 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=d+eYiMVYDjh6xIC05zBkyCR8B5cWWZ8VY66A0nO4iOK6sr3mTX29cORK5It7GNq01G VRCfUpLOhmAZqJL9IlTV68d/FpSdNyvbtoUTEg/ypw12ND5BJX7Ezmc39tFuvTsPYI7L YFTx9VIoH32fOCdiLeS94ABgJ+hF0OrGa+1XZLNOJZb5OuEcr3vAkAv2KNywONWHiGMG eFJLPSiIBoLmDmmmL4J2Z4NRRdV+S526N0o/YwKt2tr+rc3n16EqYwBGMr+MspDLC7w5 Hq0AQTNSI3eW581hGQgEg4sG0yFQ9YVVXHxMdlkhoXG+++2OfbMf5siT96ltpxPSSLqr ljGw== X-Gm-Message-State: AOAM531VxBD/m3t6MCV0/zTla7tm28TOMYrSYB/xj8CzSvsaTf8PGNnP cmC2vH+CoCEg9B8XHZ13gYFRTg/p5k0= X-Google-Smtp-Source: ABdhPJzckneV7tWAqR3/Cv4yGdF1ay4DdpIyV9DYViiWLBV2biXuIGKbHkGDR5Sa7b95Tw9Hj8ZQ2A== X-Received: by 2002:adf:f34f:: with SMTP id e15mr1022745wrp.387.1598871072666; Mon, 31 Aug 2020 03:51:12 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id k84sm7674454wmf.6.2020.08.31.03.51.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 03:51:12 -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 v7 04/13] bisect--helper: reimplement `bisect_autostart` shell function in C Date: Mon, 31 Aug 2020 12:50:34 +0200 Message-Id: <20200831105043.97665-5-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200831105043.97665-1-mirucam@gmail.com> References: <20200831105043.97665-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 Mon Aug 31 10:50:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11746145 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 CC94E13A4 for ; Mon, 31 Aug 2020 10:52:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4D612068F for ; Mon, 31 Aug 2020 10:52:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NmvjQ+h9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726507AbgHaKv7 (ORCPT ); Mon, 31 Aug 2020 06:51:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727105AbgHaKvS (ORCPT ); Mon, 31 Aug 2020 06:51:18 -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 7EE48C061755 for ; Mon, 31 Aug 2020 03:51:16 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id e17so4798635wme.0 for ; Mon, 31 Aug 2020 03:51:16 -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=NmvjQ+h9yl7Jvlrc91falnnqQJZKq1nTMgDSKywBooTVkwHSyyQ8cidCZl3VBJf0bE hwRCtJpgCDpQM08wlzrd4dyww9zthZlRroo3UeKMM3+vZEl6/FWj+uSRqcVQt5jWcesx yLUHSe5KOgnSNrAWOV4+QJlmDDRlZrdlOq02/6Qkx7MDhxuCM8R1eq2gdSbDm99cCnKe Ix+f4RjAF9oqU7jrfDo2FtbxgARRnQrW+M2MGskaNAku7xGnxMFrpYZCrWIOtjQQ1M6O jE3XNLuJyfF7NiYoQhuiZRxYfk9MtCCkhrf36xveTkAId0jvEUthrlx5lCRIAdPTgmss 9p9A== 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=U4irJkq7wulMkHJY80q5bBDvrdXMVPWDg3cypKTOR9kwXAVCkZ883xTDKu0mqku17f RmkA2LTVBYVfIyo2BKVPqW9fciEn7PmK/nJNjNJkeRPLKSyup3aLia9WUTem7A59ihIF 47r+YZod9XWPjEr16EP+kJ9/p83+skC9xxUvbZVSa6krkRk+yH1hp6dGv9qGUJskgJ1U nnLKX3T8RRx6De+bg+w48zAw+FBuW2xWEa8mOLRKtA2cwwjp9c4YIMjDSxhMdENKyyCz hSbnspT2KInqZqg8CbThLNKqiCPGJpi5YARC3D/fSMuNqbpqLRBoLU12g/893kKk2Vd6 s4EQ== X-Gm-Message-State: AOAM531GV8m+IIY3fGjL0wLk595dC5AqHSyHgRTlnIgmXY5TNafReTRf mmhaDnKmUGRvtZn7fXqAa9SnspMg7OQ= X-Google-Smtp-Source: ABdhPJy8dWp4D5JWhqpgcSmE+xMzrTGfSiC90wPJGt66ttM/ZoKhY5JHLJVhhSruztjsT+m1fMBXXw== X-Received: by 2002:a1c:b703:: with SMTP id h3mr783714wmf.131.1598871075064; Mon, 31 Aug 2020 03:51:15 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id k84sm7674454wmf.6.2020.08.31.03.51.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 03:51:14 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Miriam Rubio , Christian Couder Subject: [PATCH v7 05/13] bisect: call 'clear_commit_marks_all()' in 'bisect_next_all()' Date: Mon, 31 Aug 2020 12:50:35 +0200 Message-Id: <20200831105043.97665-6-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200831105043.97665-1-mirucam@gmail.com> References: <20200831105043.97665-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 Mon Aug 31 10:50:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11746163 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 E82131575 for ; Mon, 31 Aug 2020 10:52:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BAB8D20936 for ; Mon, 31 Aug 2020 10:52:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mpvSE3J9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727814AbgHaKwh (ORCPT ); Mon, 31 Aug 2020 06:52:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726384AbgHaKvT (ORCPT ); Mon, 31 Aug 2020 06:51:19 -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 46CA2C061573 for ; Mon, 31 Aug 2020 03:51:19 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id a9so1124047wmm.2 for ; Mon, 31 Aug 2020 03:51: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=cOKvw6mlQcRzNZm2dpTTK39j/sJSlP1fNpO4FWO575M=; b=mpvSE3J9+PW152DFneCEYsKY7TXkCKlfFyZmIUGTeBM3eii+JmjdDcrx6eOqXihZU+ 7rw6s/v2oVxMdWmj9X9ByC8kTXDIyyoniijK45MXAAIlj+yw6iyFQ8U9hJDgpaBSSPRe 6eTAg+Cq5qP3KSn7uNDaFLoExJilChw4KiME/K0CNodpOZDHtweRa+1RyGiBbeCYU62J ptHylih6ZFh4i+OSj5VOhNfoRiGQbrnpQpzlC9V65umcSTXF4DzLe74BCOaDsc8BPTcN c3jpQjqA9jdrrgjxHVjp3IHqXd6HjMEay0uZjej7vhEMYQN6ognrBJ/eiiYxoDyUcOLa AyeA== 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=cOKvw6mlQcRzNZm2dpTTK39j/sJSlP1fNpO4FWO575M=; b=QpiycuT+7IzEj4PGnJMoW9qS209szGMS+C6TURZaw0mkwUwNzAFuzDUIxAOH3SPBXA VoawuHTmXQYysQNGry8xzCX18y5Gbw10uhiHUWE8TY9OTU7AsP/GNbMu8y+3Dc01F2zN QDkOcHM9T7XDu9xvvY4y8saC5wI0OTOiemqUWMLCxXFB80apmdkER4YBj9UmNWATdT0K CflUvp+geusA/EWARTMLM1qhp0g4mg8KHKoBt/ZNS1+HMN8EPX6URzxN47UUzkhmNMhJ oL+FK0xvZwtECRfp1BL0S5mPjA7Qr8z1Snp/agDoVwKiUBJvwOrh3POSuNifG11rkkSU 9pwg== X-Gm-Message-State: AOAM532Zf9yL09QAtockkj2cjZ7XTPDuyAoftuBAw4rKx0HWZSscJ1tz QvphCmLKVRSoflBYDlRiA0LTi58b2VQ= X-Google-Smtp-Source: ABdhPJyRB9RvEu42FDNkYc+9l7tmN+Kx3pC7plbtOoqg/53wgQSc+TlJjH5AWUKgldpJl61nqUkl1A== X-Received: by 2002:a1c:7708:: with SMTP id t8mr803045wmi.67.1598871076275; Mon, 31 Aug 2020 03:51:16 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id k84sm7674454wmf.6.2020.08.31.03.51.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 03:51:15 -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 v7 06/13] bisect--helper: reimplement `bisect_next` and `bisect_auto_next` shell functions in C Date: Mon, 31 Aug 2020 12:50:36 +0200 Message-Id: <20200831105043.97665-7-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200831105043.97665-1-mirucam@gmail.com> References: <20200831105043.97665-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 | 11 ++- builtin/bisect--helper.c | 180 ++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 47 +--------- 3 files changed, 190 insertions(+), 48 deletions(-) diff --git a/bisect.c b/bisect.c index c6aba2b9f2..f5b1368128 100644 --- a/bisect.c +++ b/bisect.c @@ -988,8 +988,11 @@ 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. - * If no_checkout is non-zero, the bisection process does not - * checkout the trial commit but instead simply updates BISECT_HEAD. + * + * 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. */ enum bisect_error bisect_next_all(struct repository *r, const char *prefix) { @@ -999,6 +1002,10 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix) enum bisect_error res = BISECT_OK; struct object_id *bisect_rev; char *steps_msg; + /* + * If no_checkout is non-zero, the bisection process does not + * checkout the trial commit but instead simply updates BISECT_HEAD. + */ int no_checkout = ref_exists("BISECT_HEAD"); unsigned bisect_flags = 0; diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index f71e8e54d2..e29e86142a 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,140 @@ 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) +{ + enum bisect_error res; + + bisect_autostart(terms); + if (bisect_next_check(terms, terms->term_good)) + return BISECT_FAILED; + + /* Perform all bisection computation */ + res = bisect_next_all(the_repository, prefix); + + if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) { + res = bisect_successful(terms); + 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 +855,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 +881,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 +946,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 +973,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 Mon Aug 31 10:50:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11746161 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 0809913A4 for ; Mon, 31 Aug 2020 10:52:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D923520936 for ; Mon, 31 Aug 2020 10:52:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l20fQvjo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727115AbgHaKwe (ORCPT ); Mon, 31 Aug 2020 06:52:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726572AbgHaKvV (ORCPT ); Mon, 31 Aug 2020 06:51:21 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0A32C061236 for ; Mon, 31 Aug 2020 03:51:20 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id z9so4875765wmk.1 for ; Mon, 31 Aug 2020 03:51: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=UnQ1kkgwV25WfVmhZ97e1ZSdPFpdCpqgxABGRetOF2g=; b=l20fQvjo6jXdxCJAsx24l673mKGo/6+u9KK5bfpKTr3ssPaf0zmDvecvMWnXSnqppv zh4Koj1IrupeWAVojRQe2x6YfzhZOW4GFpzKUAR7/A1pJagbQIVV0yNHUNTABCJFJEKO fIdeN6zdcV5wSnVVeE+g/3PUIDYHOxKvaiy/BIZ+GFohmhST2sJv9xOoV8uHrl48f7oR 1HGyUsFYSjdvusLYNadUxK+3g4kXC1ZEq+xCOlT8HQQbuFZLgxO+Zy93EBwuStyqejaS Z+FMBu+pBnQj6EpMKJaPJMAzy9k57YAdScdqTOsEaeD2JjlvoG17u/1/cUE3RhGQFbxn kMug== 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=UnQ1kkgwV25WfVmhZ97e1ZSdPFpdCpqgxABGRetOF2g=; b=KD5Ta/Rw3qJ/1GUo50ULEYJQ0Shn88cmDrF93tSFejvILoNfwIOYcw5VNkRl/jS7k4 KVFKY/VXxY3EVijqQ77qgnAhKqkoM3HPz5LH1SegeQQjzsrCjBZVBMATKzQZmTlfKKoK PLNO6S+92xCa2/SLII5we5ohSbHDAHFuDWIWq0FMExKJZOwG/WtZ8EPjk0f8Tugzuury eBjO7cn5vkUDUIar1xJehhTGIpz5oHwpoxBNbS3ssrjpsqTfH4FnJAkfAKcZknD/HdHj BUbmhj2Ow2E/PkzbdHQIxrslYViSE73cxyWBwLRDmrYTWmmqNeJucgdwhYWo2tOVIzHU XtWQ== X-Gm-Message-State: AOAM532YDzyOFWNS/MbY+fHSvMac7nB5jbx1FYhn0m+tUK2sp2A5tnp+ +0Oo6ZtsDbA026fUpMt/bpEKm7sqZEs= X-Google-Smtp-Source: ABdhPJzzboxYJaFwK74qLPq7F7d52KXRIICNlj335jvyH4jmohuzPTVgwT4nyuXDwTkD1jguu1jedg== X-Received: by 2002:a1c:f207:: with SMTP id s7mr858817wmc.22.1598871077420; Mon, 31 Aug 2020 03:51:17 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id k84sm7674454wmf.6.2020.08.31.03.51.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 03:51:16 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH v7 07/13] bisect--helper: finish porting `bisect_start()` to C Date: Mon, 31 Aug 2020 12:50:37 +0200 Message-Id: <20200831105043.97665-8-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200831105043.97665-1-mirucam@gmail.com> References: <20200831105043.97665-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 e29e86142a..b40369e8aa 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; @@ -607,12 +620,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; @@ -672,9 +686,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); @@ -752,14 +769,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 @@ -776,7 +786,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; } } @@ -788,25 +798,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 Mon Aug 31 10:50:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11746147 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 D51B713A4 for ; Mon, 31 Aug 2020 10:52:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB76420DD4 for ; Mon, 31 Aug 2020 10:52:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QSx1nccn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726839AbgHaKwH (ORCPT ); Mon, 31 Aug 2020 06:52:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726312AbgHaKvU (ORCPT ); Mon, 31 Aug 2020 06:51:20 -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 DE8AEC061575 for ; Mon, 31 Aug 2020 03:51:19 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id c19so4166603wmd.1 for ; Mon, 31 Aug 2020 03:51: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=LTDMjVi2Mz9bRPnbb6JXdOSiMTMzq1b0Krp0/r9I70g=; b=QSx1nccn3Q6/kTzoNgW3L9k4oVjx1y2VLonVu1fTNoz3uaiZhQCyxWf9ASfmpTVU8F 1OAXaNuHDtSWD8MrMZuusc/cxb9LXY/DjTB5mzRcrv/nRsv6LPoqLPDrUYaaNgOf6hpU MuPpzzttFhe0zG658vCSvXVymiI4Lx1ANtTUaY7w7Fr3+6QzGoEzRQ/+b8ZrZB55Ehh4 XNk+W0w3l2ylHSeEnIMaTVmdPPovaZ4svaMrZ6l6DTQ+yWvhXi+ba+FMVJN4xZ507aTU BWjNE/20Uz4isG94HSuXJU8o48PLotP5xapPgibQuDt6i2o3CjYVPwPn5Ms9KFdlZOOd Frdg== 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=LTDMjVi2Mz9bRPnbb6JXdOSiMTMzq1b0Krp0/r9I70g=; b=VVkbLagCKfW5EjvZ0OiEEF2N24STRLMiRzqNZbrk5kBIVgK5F4y/c4CiDcHEKcoFSs 2ZSJCrk/SJXn+G+BTooA18O0rxk0ZJvMOLs30K1AVztfBm42tve3mIbpsoFZhvn0uD6u pJm5qvdqEEHjTltwlxDmOwMWlMiPgMXAm5IghEpgqQBBTCKg6hscdqPzaH2t1KPelP6S iUEpSFyl0mQviuGfxHYEnZVyzCfuGLTtARCJN2NWXFcgSJIa7buWo9xtnqeq/Ffj9YLY nJ37IsDhgEZhDc0q68BPTZeqOHxz8pl/b9Eoscs16FXNk1HLioKjJjrq40LpQ2KQoKdN exWw== X-Gm-Message-State: AOAM531N0ZmtInJ3oHMUqp79XsE3jzEM9AR8nZpUaQJGUIM1Z9AmjPkz EjcnZTngu0FCbtbjA5eTsHC/GsiNuD0= X-Google-Smtp-Source: ABdhPJzTVp5AhjQrqG1JWeKGeRJYBcRg7cgz4w5sVOewj280rq8GFOTw0SGJAxZSSbJgoOuQAy2sUQ== X-Received: by 2002:a1c:6254:: with SMTP id w81mr824064wmb.94.1598871078427; Mon, 31 Aug 2020 03:51:18 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id k84sm7674454wmf.6.2020.08.31.03.51.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 03:51:17 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Tanushree Tumane , Miriam Rubio Subject: [PATCH v7 08/13] bisect--helper: retire `--bisect-clean-state` subcommand Date: Mon, 31 Aug 2020 12:50:38 +0200 Message-Id: <20200831105043.97665-9-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200831105043.97665-1-mirucam@gmail.com> References: <20200831105043.97665-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 b40369e8aa..b8b8a7473c 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 "), @@ -869,7 +868,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, @@ -887,8 +885,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, @@ -930,10 +926,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 Mon Aug 31 10:50:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11746159 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 70CC613A4 for ; Mon, 31 Aug 2020 10:52:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57B90206F0 for ; Mon, 31 Aug 2020 10:52:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Eg12/VnB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727802AbgHaKwb (ORCPT ); Mon, 31 Aug 2020 06:52:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727115AbgHaKvV (ORCPT ); Mon, 31 Aug 2020 06:51:21 -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 2B16BC06123A for ; Mon, 31 Aug 2020 03:51:21 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id e11so2027454wme.0 for ; Mon, 31 Aug 2020 03:51:21 -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=mjlcmqDkoBU4zYuVyCyhpOVtSC+VbYEAFixsbaU2PfY=; b=Eg12/VnBaIfd47QhdmPqm46t9lzrT3ePolXlue1a8zEosNPog/MGOcPZjpP30D/UYS EThYeW4wYS/98TkS8zAWpy4rI+OblxsTx5vzMMsXdnVUJTDpISR38gUE2Kpm+olqdv99 KtLadryHtutfU7oqmy7KG63YYNeJr3xmoab30WSpYKCASF0OaCnK5kzG8D6EsyAOBsec JXbIsey2nDpcc357mbX+4cLFqAs4Dv8yuIUjexwI2KlLHKlcIf7SpzD+JxGN0s9iIoD+ XxxcUXQSkTu6mHsEd+2oxu6xmP3AzbqA63sVUtxJ8ZEVMRxG+8FdMQYV8+RvPlPZK4Z5 rLbA== 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=mjlcmqDkoBU4zYuVyCyhpOVtSC+VbYEAFixsbaU2PfY=; b=s1WLcNkGKpMuIna845F/8Fmn6ixUMWYw0e4rvvwhgb5++F/ayU5z1XevFUIapn1aNl e8xFevKvNYEDkt8WkW2sdGXArKQyBy4wzqeUIOtkQ2UWw0yty/gekrAkn7+c4XjxWhQW 5fOecfHFz8AiPRVzLte29PlN8/cFhNKP28dy88kSVRb/Su2APWs0leD+KTcAiXRYoq3W HKy9bitF0x8AIP3vAeV/pB83Qm3fFsrAmD5fMuPAhxLrEq0vDIchvhr0bQuxrxI5QGEv UMGCxC88s+Oo6KXrua1WTNG3u/PG5ljV+hKF7P7AvmGiACBDZ6Xo7kLyweUTZQjH2Nss VxEA== X-Gm-Message-State: AOAM533i3E7uc/3GWHi0A+iI9IYsElaMsMRuqw29vDCj1PdzarGDv0uz fJrPjvJB9lSxbAQlVJbqsCQIFYfl6Vk= X-Google-Smtp-Source: ABdhPJwr4I/NSnmr/S/udodXNmxzCqGR6+hn3wlwpD8M/Z9d1oADDpkrKzqeMsSh/cNYSEdU10feZg== X-Received: by 2002:a05:600c:2cc1:: with SMTP id l1mr826534wmc.78.1598871079626; Mon, 31 Aug 2020 03:51:19 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id k84sm7674454wmf.6.2020.08.31.03.51.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 03:51:18 -0700 (PDT) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Tanushree Tumane , Miriam Rubio Subject: [PATCH v7 09/13] bisect--helper: retire `--next-all` subcommand Date: Mon, 31 Aug 2020 12:50:39 +0200 Message-Id: <20200831105043.97665-10-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200831105043.97665-1-mirucam@gmail.com> References: <20200831105043.97665-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 b8b8a7473c..0796e51672 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] "), @@ -866,8 +865,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, @@ -881,8 +879,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, @@ -919,9 +915,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 Mon Aug 31 10:50:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11746157 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 CEC7413A4 for ; Mon, 31 Aug 2020 10:52:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2BFE206F0 for ; Mon, 31 Aug 2020 10:52:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E9EXvSbf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727799AbgHaKw3 (ORCPT ); Mon, 31 Aug 2020 06:52:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726359AbgHaKvY (ORCPT ); Mon, 31 Aug 2020 06:51:24 -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 5B344C061239 for ; Mon, 31 Aug 2020 03:51:22 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id q9so4933547wmj.2 for ; Mon, 31 Aug 2020 03:51: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=6Z/LVXtxZy5CMgpTFC21tg5SpQuOaQmHthSakNFJ6DU=; b=E9EXvSbfAUc0FSv85JAkqjh9N5y4oCniN8udSoSUdcWMcitSKjsz1wFd5hXrPnQI8O ujouKMcRHp4Tap/dv3jnQf28w9SPdhCHm5L8orsMfdByIVnIHayoCBKYORa8VjpZBMzT uu6PvrgqpFdtr9vSbiwXfqZUWAmn2IFUvCVyXG1NmFhjJhPj03Ji+aGvI/JKzmC7aRya 9C5GaThMzbB5i9foplFsVISldJbe9qI7irSmd0bRRpjws92+28R023ag7CqJtYPiNn3H RPTOoIXmM7VCzqC0FJSyX68698wcUF07NZNzX+xV9yaeDCxfNvRm0Mo14FV2P7Zfetej TV7Q== 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=6Z/LVXtxZy5CMgpTFC21tg5SpQuOaQmHthSakNFJ6DU=; b=fjLo9xcTENvapOXIKjgVWV7+GtGjPUOa0ep1BiRAEFlHNsvBfQlY2+bskPHQdpUbDG d8+yXgbg4JNAolyYUzyvTXOAZRsLnS2aWCfUwhoUJLny7SRV85LrzF+rCqxfLl8+o+6C MNTGF7+kguu5R264mYewbxXFCsEP0j8M2yMN6nQ+4PQo4g1XElJCtkOWhAwyDxYpRrU+ OUdwpfCPaiTcx7LAo5MMrx2w+cTHlEH6w6HhdbAJIhZuMrUCRt7vl27lPg0HazKktRTE fXfAmyiSmS6dk1HpkeT3PcmUnGVuBPgAXJUqDQlxT1DALrIrexaVIQX8h8ccq0gdCiGo WtVw== X-Gm-Message-State: AOAM53281RXqTMUZedeOSgqkjrir5tW+AnOAOqrUf7w80zqdK/ccv6PQ oIhLKYfCModH/8YUhgVcQYGWWmfIwZo= X-Google-Smtp-Source: ABdhPJx9aZ4BZauXDvbN7UD0JbLhHuE1V9jyuX62C2lvRutC4Yn7gJ+2mPsefYG1EdAwCKTNoiaiag== X-Received: by 2002:a1c:e1d6:: with SMTP id y205mr848904wmg.92.1598871080710; Mon, 31 Aug 2020 03:51:20 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id k84sm7674454wmf.6.2020.08.31.03.51.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 03:51:20 -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 v7 10/13] bisect--helper: reimplement `bisect_state` & `bisect_head` shell functions in C Date: Mon, 31 Aug 2020 12:50:40 +0200 Message-Id: <20200831105043.97665-11-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200831105043.97665-1-mirucam@gmail.com> References: <20200831105043.97665-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 0796e51672..a976f4739c 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 }; @@ -862,6 +864,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 { @@ -875,7 +943,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[] = { @@ -901,6 +970,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() @@ -971,6 +1042,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 Mon Aug 31 10:50:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11746153 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 369F61575 for ; Mon, 31 Aug 2020 10:52:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F94120936 for ; Mon, 31 Aug 2020 10:52:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="t0fFUmah" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726824AbgHaKwY (ORCPT ); Mon, 31 Aug 2020 06:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726540AbgHaKvZ (ORCPT ); Mon, 31 Aug 2020 06:51:25 -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 6C7FDC06123B for ; Mon, 31 Aug 2020 03:51:23 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id u18so4932886wmc.3 for ; Mon, 31 Aug 2020 03:51: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=DHURdtxHIaMnZdalG8YCxuwDCoOMBsyowGCZ5kqBK7k=; b=t0fFUmah5DuMsFYR7CTR3RV1w4w4vAfc7OlJf2zXl5OMGHMth4TU8JPylj+/Q4ijF5 NsXOAJ90rWKalr+WlSNtYN2EOsVk75O3y8zCo2imZmkyk9eE59xiOXnChPiyOlh92vmv uI9ladU1vA7jhRPQaplK7hyw/VxFviTs8YDOxKpLInVHZMhdW/pceCvogW4Cieekcq+B f2k/fQoFvmUDxweMkXNEYDP5IxjPQKJkPUaSiwM/YUnSE2dVcaVXO9/wkaMGXunmz1nD Ibo7gQCdlAk90EFLTCeuGj+iUB7SLUaEOpMn9A0EpywJTiTU24toXwQ27RU7H3UQgX/d c82w== 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=DHURdtxHIaMnZdalG8YCxuwDCoOMBsyowGCZ5kqBK7k=; b=F5bbt2aUOCePUzW2eWZDQbwDTWShpj+ZLTSlzeXflpQwPObxFOcVN9BXBABlJ2scMp H65YK/Kxa7+qbl6rGOKqqLHZHMQ3t21EyrLBUWKr566UOVomeJKngg1SkMIW3rrV3uwn ZOmU1e2wWqLoDmXAJB5DRRMyYFEu7nvbAXI+TQHVxdp4oBCgkdoBCrWAfsyVb3OHOQ88 CRjyO4oRZqGqR7wz37RAUzuZnT5rbAMjac8vpVA78RaoNw6j6jc1htDOIFL0NCpeHGKL tYEmBEgLeFuVINVXDfnbqvr6tA0iabADKYSnFz/118eknND45io4TiXJa0VBDKwmO1h1 SfGQ== X-Gm-Message-State: AOAM530LJnWiczEhi4aIE/0N1EtTFkBPvYIj4nDgiPly98cfAzuCxHXl vVtvNT/Fm+ADu1eIwcRChGq8T0sifD4= X-Google-Smtp-Source: ABdhPJxMrbTkYqplYpsyHgMOhvG+EMxNHXcI2O/BHFxeIgV+zNz6B3JeC6FtzIqTus3phyznNxBkDA== X-Received: by 2002:a1c:ab06:: with SMTP id u6mr852746wme.172.1598871081903; Mon, 31 Aug 2020 03:51:21 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id k84sm7674454wmf.6.2020.08.31.03.51.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 03:51: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 v7 11/13] bisect--helper: retire `--check-expected-revs` subcommand Date: Mon, 31 Aug 2020 12:50:41 +0200 Message-Id: <20200831105043.97665-12-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200831105043.97665-1-mirucam@gmail.com> References: <20200831105043.97665-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 a976f4739c..da203c2091 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; @@ -934,7 +910,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, @@ -950,8 +925,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, @@ -990,9 +963,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 Mon Aug 31 10:50:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11746155 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 C020B13A4 for ; Mon, 31 Aug 2020 10:52:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4A7720936 for ; Mon, 31 Aug 2020 10:52:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M0HuCuEW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726459AbgHaKw1 (ORCPT ); Mon, 31 Aug 2020 06:52:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbgHaKvZ (ORCPT ); Mon, 31 Aug 2020 06:51:25 -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 83D24C06123C for ; Mon, 31 Aug 2020 03:51:24 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id v4so4129573wmj.5 for ; Mon, 31 Aug 2020 03:51:24 -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=f9PSN2XV2fPFK8tKe/1D2bkQXSX7LTlnPhd4r2tNgxU=; b=M0HuCuEWe4Cb7SpD4SX1BtSXTXqCnF+bJejotrJuATNqoCtvetnFn/qerYtpYCx2G+ LEOgbNiWXbIC9eYqfzNZJaFWczrp3WxhxpsV5SrA8PN4kIEhFvPRHuDHZqopg9mGHOkZ NKLGpiJ1oTIU0Cs3Aik2Qft9ZXlvdEmTvRfuX+A2c03CBXHGWYd9Iu1xDaPpOeUuT/az 9X+VMgdJaKgeOWEkGzO3zLVzyJsZVTBVD28P70yCN6dP7eo1zvQLToKb6wnDpKA9dzGX sj9yInPLuRoSnnopvLkY8zy+IeHoWs2uQlwlUGtE0ilHXgywL44U13kvhmCOHqlyxHSv kcDw== 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=f9PSN2XV2fPFK8tKe/1D2bkQXSX7LTlnPhd4r2tNgxU=; b=cc3yDAymUa0r1YpWLK9pUy58UvgnuALg1/VNj1MzleilzoUMYyHPLqO5zgeznN2T3y jmleVEJO1y3FhOIy+olHfY6CWNetgluTnynyzcRz1sDzC9zdadZbViYEl4KL8vDvWnal oL8rWpJ1u3NVaewZDtoh0mPEPaE3mdw5H2JOyLFxmzm1Wb5LTvOzg4U/A/MJZXIFoGAw 1Ien+8r27EVFCzGeJxDsxtt/BspWhJj0llGz1YoQJ07hvE0hBlP3N4VyTYQxWpY2Ee/U e8dZ3eBavNSQqI8Gslx/Y2gbvGRUcZPGiKvW5G/6mak6jCQqccNoA7FRW/9vZBcLtBtv My7Q== X-Gm-Message-State: AOAM530a/QwKfWcduKcp5Nw+DaH5+Yv5AQC+7IgNs5XaAgMUZ6jHdI/1 d3L+YyGjNmXmHGTKztzoPJ9BR4M4OCA= X-Google-Smtp-Source: ABdhPJwDHRGV1AhHbXp59hnQVfz40/NPPzR+ovZ2s3aXxjG/T/qpWZ/yEZrIjCJKsf+HNrV+GtNZuw== X-Received: by 2002:a1c:f30f:: with SMTP id q15mr841412wmq.60.1598871083035; Mon, 31 Aug 2020 03:51:23 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id k84sm7674454wmf.6.2020.08.31.03.51.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 03:51: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 v7 12/13] bisect--helper: retire `--write-terms` subcommand Date: Mon, 31 Aug 2020 12:50:42 +0200 Message-Id: <20200831105043.97665-13-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200831105043.97665-1-mirucam@gmail.com> References: <20200831105043.97665-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 da203c2091..46ddfd5710 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 "), @@ -909,8 +908,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, @@ -923,8 +921,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, @@ -959,10 +955,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 Mon Aug 31 10:50:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11746151 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 E90BA13A4 for ; Mon, 31 Aug 2020 10:52:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF4DE206F0 for ; Mon, 31 Aug 2020 10:52:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NI7ZwzWh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726586AbgHaKwW (ORCPT ); Mon, 31 Aug 2020 06:52:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbgHaKv1 (ORCPT ); Mon, 31 Aug 2020 06:51:27 -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 91BFAC06123D for ; Mon, 31 Aug 2020 03:51:25 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id a65so4915314wme.5 for ; Mon, 31 Aug 2020 03:51: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=QKmyIQ9aj2TmCg7rEZp9XmRDa/r98jYMzgK1OYEkziE=; b=NI7ZwzWhoeSmvlELDszmPMH3Z64km7/iQsYP+l7Z+79k4EVy5t9OxoSubvcc9Pacuo JVPrwKh/kYwf14UfKiKNKbiNf6H2k43Gm69QjXdCFAyWWeR0rAB3OF3Ime6kx4lYabP9 jfO83/q8uV9Hj/sn5zaX2ra16fjcVUNU8e+SqnSzzVvamA9MdTl4JTkEOZU/5qnNgl2u nK2PIiYqgv9Y8csWpixqaOGhGNVfTT5FzWy2icYlaWeVHwW3tdRDp8e3IlXXWnt1wZ+r DIPwhzU9yJJT0fuUDjYzm16A2/MFX4njzK2LyTk27xq9YNnDUXPMc9Sh50HhI9IZLo/o Efpw== 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=QKmyIQ9aj2TmCg7rEZp9XmRDa/r98jYMzgK1OYEkziE=; b=uYg8rVazSrDILv0D/bkEf0Losx+eluwGlQEFJqSmAUuqQ9DyeJYzGbjWsesMtj5bAM 59fM7NSUFwxUiPoE4EzJfZgDkuXJpKp01Yvtbrbu14khwRuHHfiMdGAjux0AjK8Kky1i viUFnHv7/q20Avt7DFfJsUADXeziRPzNV4jpu3KyOd3ioZxL/md12j01lDQmebvQjJV3 lbvWDSI1vyN47RAqoZUmk1674HrpT5m0oorpDYEaDZqjVr1CXFOcBZztRlQ+SxWMAh+K ATPJE6RU5pQlqd30B/QlX2dQaXIUfN4yqqzrAsNWO2QKDQubHmx8sDTYSI3cYH1/Rc7t Iciw== X-Gm-Message-State: AOAM532Y8F8wQhmIlL25MPJEHb85Diy6+7WTV8Jnd9QIe+mjE0mSBaac lvWoC1Y8qxWQllXatcW8WW1wH7FPdXk= X-Google-Smtp-Source: ABdhPJzKJq8DLebMlU35F2klbLbmEFHR2j6xH6wYnzplA8bezbs8LDN0o1qIuuLkk31UiuISaHrLrA== X-Received: by 2002:a1c:541b:: with SMTP id i27mr792872wmb.179.1598871084085; Mon, 31 Aug 2020 03:51:24 -0700 (PDT) Received: from localhost.localdomain ([178.237.236.228]) by smtp.gmail.com with ESMTPSA id k84sm7674454wmf.6.2020.08.31.03.51.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 03:51:23 -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 v7 13/13] bisect--helper: retire `--bisect-autostart` subcommand Date: Mon, 31 Aug 2020 12:50:43 +0200 Message-Id: <20200831105043.97665-14-mirucam@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200831105043.97665-1-mirucam@gmail.com> References: <20200831105043.97665-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 46ddfd5710..8a48c1ef8e 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 @@ -916,7 +915,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; @@ -937,8 +935,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, @@ -998,12 +994,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);