From patchwork Mon Jan 20 14:37: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: 11342355 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 E10C96C1 for ; Mon, 20 Jan 2020 14:38:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BFC2722314 for ; Mon, 20 Jan 2020 14:38:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lP9TjTEq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727045AbgATOie (ORCPT ); Mon, 20 Jan 2020 09:38:34 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33197 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726885AbgATOic (ORCPT ); Mon, 20 Jan 2020 09:38:32 -0500 Received: by mail-wr1-f65.google.com with SMTP id b6so29871433wrq.0 for ; Mon, 20 Jan 2020 06:38:30 -0800 (PST) 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=Z1w/Hc4cOkaibn8kvCOgrzsn1RxBbiqlk6Mv4m5lJ4c=; b=lP9TjTEqjpmJMf7Ydfp7c4k1zHuDGG4M58rxboREdfLoNixWuNhpfioE2NUkGv/sIi 3tW51o/KT3ChNOb/2FrK59zmRBAl7S+0PW2Cv3o48lnhw2S83RiIoAjYUSGz0XNRqEB0 0cXcdEn2h+fMKpnvaAFJR5eI7Ba9190IhRdcZ+ScEFIG+2B91VBLFaR5PNq36FGW+A/Q AFTkTEPl+Ety/2HDRTZTvgRjTGuvbAJYfPqVzrShgFZHEfxhAGI+DXfFrA1jnIczZCfH HIAhPMox8S9T8o4+mBly2r99sgd/D4qsDQv8B7XqamwBxoH6g6HHDfXj/aFksN/QMqnB klPA== 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=Z1w/Hc4cOkaibn8kvCOgrzsn1RxBbiqlk6Mv4m5lJ4c=; b=gAXUUi3v0ggq6gZa2wuaJRTxPoaHp0A5eWkTuKEEE9nRXShT+Ewh5RBhYGO+3YK9KU 5te5JPIsRI2ttxh/LCAw7AZFFENe4xO6+jcLPnysUlrbPq0+OvwYi0CZ27X+q+qxjjgN vkQua5gVvT5LfdkI+vyi25DCltUZggtrY4GFF9xiswuX5/kHYRHk+sIhRCXT6p5Tra7W DscO0Fh+NTNIyjHh2wasokn/csIczzJzVHM2Yc4m091ChWp0PruBaLt9h/oMeX4Sgc7z 4MN2Xs2dHKRoX6rCQdhTibA5fg96MtGrRrQgKhVYJT4BVot1bfgRmXASOwUjWRypZOWs lOtQ== X-Gm-Message-State: APjAAAWPKbFYHkb1lImoU2d1jpGbc04JJg2Mb/YfSK40EzHpgLT8r2wW nvOMMUk/8+SYEAnu6D4L2vL+/nT1 X-Google-Smtp-Source: APXvYqwQPnTpSvXCpdDzE4duFoBUn4ygwPJUa+RXvPAVDYDnQQkbK27Ty1MKY5Lf5Fhou+4OOVQjOg== X-Received: by 2002:adf:e290:: with SMTP id v16mr19244200wri.16.1579531110024; Mon, 20 Jan 2020 06:38:30 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:29 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Miriam Rubio , Christian Couder Subject: [PATCH 01/29] bisect--helper: convert `vocab_*` char pointers to char arrays Date: Mon, 20 Jan 2020 15:37:32 +0100 Message-Id: <20200120143800.900-2-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 Instead of using a pointer that points at a constant string, just give name directly to the constant string; this way, we do not have to allocate a pointer variable in addition to the string we want to use. Let's convert `vocab_bad` and `vocab_good` char pointers to char arrays. Mentored-by: Christian Couder Signed-off-by: Miriam Rubio --- builtin/bisect--helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 1718df7f09..36c09b7238 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -52,8 +52,8 @@ static void set_terms(struct bisect_terms *terms, const char *bad, terms->term_bad = xstrdup(bad); } -static const char *vocab_bad = "bad|new"; -static const char *vocab_good = "good|old"; +static const char vocab_bad[] = "bad|new"; +static const char vocab_good[] = "good|old"; /* * Check whether the string `term` belongs to the set of strings From patchwork Mon Jan 20 14:37: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: 11342357 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 0AE756C1 for ; Mon, 20 Jan 2020 14:38:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3E1622464 for ; Mon, 20 Jan 2020 14:38:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XHYNVVIY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727573AbgATOig (ORCPT ); Mon, 20 Jan 2020 09:38:36 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34839 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbgATOie (ORCPT ); Mon, 20 Jan 2020 09:38:34 -0500 Received: by mail-wr1-f65.google.com with SMTP id g17so29792328wro.2 for ; Mon, 20 Jan 2020 06:38:32 -0800 (PST) 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=E+ZezR0wGUOg+FjlOgC+pT3lOJ8VVLkCSBEvw6cqiKw=; b=XHYNVVIYBfKmzDdnnS/sG/QOjZknnLoE270VaT5uHLwR4DIeKyqg6wgGFwCoGX69to 0DfnZDeg3iNrzsEwyA4HezPA3J4ao3ELXOMKYmVZJ1iP6eMS4KOd7wT8EcZFdnYZAH6E JFXmFKsVhUuAxZ7/hTY+4PtV1nNlh4rJlNb43mQIqDQoKpm1IPsJ6sd4p1kCWKar4wbK +MpxzGChBJGODNmQIiW3kOJ+NipzdhT6zT+Fv/HT6A9cSm4uOsd85fxQZK7Uen/9/j3o JbZ4Frx0L7unk709p4iXBmNidIu++e6y+sRJ/3VqrWevHsZ0KVN46VfQyhSwtDlgJakl YlTg== 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=E+ZezR0wGUOg+FjlOgC+pT3lOJ8VVLkCSBEvw6cqiKw=; b=b+boANsZsidDWEHa3RfWMNvml+WoaU39b9EWOYPgz+L9RL7HMpZMfjt+mUNxh2gNhN fBSZCgWBvdu1JWD6EDgzlBMYtyPLJk33IImZHDUX7kv0y5rwSfrowP2Gkf9slBPWyCIj PDIQhTDXXpZK9QW1CDgChIiW7/7kYJlH5ROp6ssL8M44QNiXQvirTbcxuW0B0BfDD7kY sPz4ekPtJ+Z/8nKtm3+pD4R2TUrCP7AU3LtvfQ83/EoIBO2Tppo5FJj2v3fh7ZJ8WDN+ DHY/k/jTg9HtccFnQ3fhu0AefUU/healVgOEuKuaWLjAlxOe0z3ECAgGh6Vr8f5EAcO8 YlrA== X-Gm-Message-State: APjAAAWJ7JpiWYzeHyj9wnqsaE9RbU+h5Q2ORRqnoMC8/2JbTPY2oylk vcwymgia4Xm6jFZHUuyysp0bTZg9 X-Google-Smtp-Source: APXvYqwAegTTypzqs2TZKRprYhVrwjmA1syEakAPDbAC5AUeWvqnfQzoODWaChQrYt+rqW5I9Fa+KA== X-Received: by 2002:a5d:4ec2:: with SMTP id s2mr17550003wrv.291.1579531111141; Mon, 20 Jan 2020 06:38:31 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:30 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Tanushree Tumane , Christian Couder , Miriam Rubio Subject: [PATCH 02/29] bisect--helper: change `retval` to `res` Date: Mon, 20 Jan 2020 15:37:33 +0100 Message-Id: <20200120143800.900-3-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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: Tanushree Tumane Let's rename variable retval to res, so that variable names in bisect--helper.c are more consistent. After this change, there are 110 occurrences of res in the file and zero of retval, while there were 26 instances of retval before. Mentored-by: Christian Couder Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- builtin/bisect--helper.c | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 36c09b7238..21de5c096c 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -206,31 +206,31 @@ static int bisect_write(const char *state, const char *rev, struct object_id oid; struct commit *commit; FILE *fp = NULL; - int retval = 0; + int res = 0; if (!strcmp(state, terms->term_bad)) { strbuf_addf(&tag, "refs/bisect/%s", state); } else if (one_of(state, terms->term_good, "skip", NULL)) { strbuf_addf(&tag, "refs/bisect/%s-%s", state, rev); } else { - retval = error(_("Bad bisect_write argument: %s"), state); + res = error(_("Bad bisect_write argument: %s"), state); goto finish; } if (get_oid(rev, &oid)) { - retval = error(_("couldn't get the oid of the rev '%s'"), rev); + res = error(_("couldn't get the oid of the rev '%s'"), rev); goto finish; } if (update_ref(NULL, tag.buf, &oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR)) { - retval = -1; + res = -1; goto finish; } fp = fopen(git_path_bisect_log(), "a"); if (!fp) { - retval = error_errno(_("couldn't open the file '%s'"), git_path_bisect_log()); + res = error_errno(_("couldn't open the file '%s'"), git_path_bisect_log()); goto finish; } @@ -244,7 +244,7 @@ static int bisect_write(const char *state, const char *rev, if (fp) fclose(fp); strbuf_release(&tag); - return retval; + return res; } static int check_and_set_terms(struct bisect_terms *terms, const char *cmd) @@ -294,7 +294,7 @@ static const char need_bisect_start_warning[] = static int bisect_next_check(const struct bisect_terms *terms, const char *current_term) { - int missing_good = 1, missing_bad = 1, retval = 0; + int missing_good = 1, missing_bad = 1, res = 0; const char *bad_ref = xstrfmt("refs/bisect/%s", terms->term_bad); const char *good_glob = xstrfmt("%s-*", terms->term_good); @@ -308,7 +308,7 @@ static int bisect_next_check(const struct bisect_terms *terms, goto finish; if (!current_term) { - retval = -1; + res = -1; goto finish; } @@ -329,21 +329,21 @@ static int bisect_next_check(const struct bisect_terms *terms, */ yesno = git_prompt(_("Are you sure [Y/n]? "), PROMPT_ECHO); if (starts_with(yesno, "N") || starts_with(yesno, "n")) - retval = -1; + res = -1; goto finish; } if (!is_empty_or_missing_file(git_path_bisect_start())) { - retval = error(_(need_bad_and_good_revision_warning), + res = error(_(need_bad_and_good_revision_warning), vocab_bad, vocab_good, vocab_bad, vocab_good); } else { - retval = error(_(need_bisect_start_warning), + res = error(_(need_bisect_start_warning), vocab_good, vocab_bad, vocab_good, vocab_bad); } finish: free((void *) good_glob); free((void *) bad_ref); - return retval; + return res; } static int get_terms(struct bisect_terms *terms) @@ -397,7 +397,7 @@ static int bisect_terms(struct bisect_terms *terms, const char *option) static int bisect_append_log_quoted(const char **argv) { - int retval = 0; + int res = 0; FILE *fp = fopen(git_path_bisect_log(), "a"); struct strbuf orig_args = STRBUF_INIT; @@ -405,25 +405,25 @@ static int bisect_append_log_quoted(const char **argv) return -1; if (fprintf(fp, "git bisect start") < 1) { - retval = -1; + res = -1; goto finish; } sq_quote_argv(&orig_args, argv); if (fprintf(fp, "%s\n", orig_args.buf) < 1) - retval = -1; + res = -1; finish: fclose(fp); strbuf_release(&orig_args); - return retval; + return res; } static int 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, retval = 0; + int flags, pathspec_pos, res = 0; struct string_list revs = STRING_LIST_INIT_DUP; struct string_list states = STRING_LIST_INIT_DUP; struct strbuf start_head = STRBUF_INIT; @@ -524,7 +524,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, argv_array_pushl(&argv, "checkout", start_head.buf, "--", NULL); if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) { - retval = error(_("checking out '%s' failed." + res = error(_("checking out '%s' failed." " Try 'git bisect start " "'."), start_head.buf); @@ -572,12 +572,12 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, if (no_checkout) { if (get_oid(start_head.buf, &oid) < 0) { - retval = error(_("invalid ref: '%s'"), start_head.buf); + res = error(_("invalid ref: '%s'"), start_head.buf); goto finish; } if (update_ref(NULL, "BISECT_HEAD", &oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR)) { - retval = -1; + res = -1; goto finish; } } @@ -589,26 +589,26 @@ 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)) { - retval = -1; + res = -1; goto finish; } if (must_write_terms && write_terms(terms->term_bad, terms->term_good)) { - retval = -1; + res = -1; goto finish; } - retval = bisect_append_log_quoted(argv); - if (retval) - retval = -1; + res = bisect_append_log_quoted(argv); + if (res) + res = -1; finish: string_list_clear(&revs, 0); string_list_clear(&states, 0); strbuf_release(&start_head); strbuf_release(&bisect_names); - return retval; + return res; } int cmd_bisect__helper(int argc, const char **argv, const char *prefix) From patchwork Mon Jan 20 14:37: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: 11342353 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 D62D1924 for ; Mon, 20 Jan 2020 14:38:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B503B22464 for ; Mon, 20 Jan 2020 14:38:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Nuz/mJSt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727289AbgATOie (ORCPT ); Mon, 20 Jan 2020 09:38:34 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39332 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbgATOid (ORCPT ); Mon, 20 Jan 2020 09:38:33 -0500 Received: by mail-wm1-f66.google.com with SMTP id 20so14953418wmj.4 for ; Mon, 20 Jan 2020 06:38:33 -0800 (PST) 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=o2IfjAS33MrmsZyy2B/KfIloY6ksKTkGV+CHSOBHGjw=; b=Nuz/mJStIaff3iRsnQraUC4hdl+NMPBmLfEhIZtnX0bAlMdhol58lsHeBER3b1OV2r QMW2WbFzzA32+reCyFDTzfzhMtJxzNwKICspkhScckQEKNmP3PjaYBjzE03DjG1pIkFN E1Wukn9ixhLlQe/eIEYdBXqbidipJnnmqh/BvQNHw3xlz4gTaUkZ7/d/E5Sk5JALQmEg 7TFXQBKD5ngeX3WdStMWuxqjcbFC2KFTLljQDIRu7aLuSy2Qx28ILwWA56wu4OSkImQg F2sEIANFMUnQ/k5LMR1ynD09EuRXbWgjt9k4tpbfVbt/7SS5LJZcsrFxqQBFBZ+rWNll Gabg== 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=o2IfjAS33MrmsZyy2B/KfIloY6ksKTkGV+CHSOBHGjw=; b=dZFGvggzk+Jvc5Gv3Ni457DuiZk15bYLiLOfQob4UJZ0HudRaADYJbwpPTlOOdzdKQ GdR66XTrJWUMGzX1cKquBaK3yBM9n4R7PYtbGF3oX2X5jDInqNAEd2GNIxMJ1TcL0mH2 OIJPBcnyQ31u63T9pbDqWyX4DOM5LX+NbOO69TSMbP7EQHU2ZaqVhePvANB+4n9CwjUD JuSTQ/6FCeo2pxP1lqE5Ow1QCF+aghBJnW28tiZRazJBvnP2g7iAaFdyXuyP/2aXPE15 k5dbMtDqYXqCF8r+KK7VK4yJdFyFsw6lQ0mp9wxx3CcTCTPPdlpu/4nyjmv2ct+TQb8m +S8w== X-Gm-Message-State: APjAAAXVtCiw2R+ESZaWudBNFNuaGL8dTDxH89a09xH+aiaHUC61oDZ8 bCZCQbc2UU+w9Rm4fE7FJHPypbxB X-Google-Smtp-Source: APXvYqxdOlK0N19Yao1GLqKYXtuJw1HwhEX4ASML+CdFJtGKI2dGBQl97reu1X8LFL8xRMS9L7CReQ== X-Received: by 2002:a1c:f20c:: with SMTP id s12mr18978167wmc.173.1579531112178; Mon, 20 Jan 2020 06:38:32 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:31 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Miriam Rubio , Christian Couder Subject: [PATCH 03/29] bisect: use the standard 'if (!var)' way to check for 0 Date: Mon, 20 Jan 2020 15:37:34 +0100 Message-Id: <20200120143800.900-4-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 Instead of using 'var == 0' in an if condition, let's use '!var' and make 'bisect.c' more consistent with the rest of the code. Mentored-by: Christian Couder Signed-off-by: Miriam Rubio --- bisect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bisect.c b/bisect.c index e81c91d02c..83cb5b3a98 100644 --- a/bisect.c +++ b/bisect.c @@ -572,7 +572,7 @@ static int sqrti(int val) { float d, x = val; - if (val == 0) + if (!val) return 0; do { @@ -869,7 +869,7 @@ static void check_good_are_ancestors_of_bad(struct repository *r, goto done; /* Bisecting with no good rev is ok. */ - if (good_revs.nr == 0) + if (!good_revs.nr) goto done; /* Check if all good revs are ancestor of the bad rev. */ From patchwork Mon Jan 20 14:37: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: 11342361 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 33B05924 for ; Mon, 20 Jan 2020 14:38:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1296622464 for ; Mon, 20 Jan 2020 14:38:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RuGxWyRi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728712AbgATOik (ORCPT ); Mon, 20 Jan 2020 09:38:40 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37468 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726885AbgATOie (ORCPT ); Mon, 20 Jan 2020 09:38:34 -0500 Received: by mail-wr1-f65.google.com with SMTP id w15so29887096wru.4 for ; Mon, 20 Jan 2020 06:38:34 -0800 (PST) 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=ZIkzFJFrWjAGcsgOxUxMnP7DxuoQar/odsNZaPNu02g=; b=RuGxWyRiW1imp8n1nCTKkmsP2OsnoNTJfLjkvkqQYzZQ3O1H2fOv+gGdNZ5+Z3sqz8 W6SJdCpoua7bzSYjYmilXWO2EQIfz4UXrKkpxCaR/mVZ9O28VZ4mIF1vlzyZ1rf6Dbf8 6z70E1YRahZrTPLSJ3TuDRPMJA3B+U9eCJ1LO8goQczoukgif9+UWb6Ua2L/w5W+TLly guEMgvFduSeqnyc4DYpC9vEEY4H6qIEAg0DF7YEx8sr98lZQDLnt34ESHzvLzHJDqCAg BMBWp33/kHfTmIrxVqPyHV/K7hjj2mXlQnEGFpZiFSpxUGonh9zWQO4N0dTH0lFE1IPV +RZQ== 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=ZIkzFJFrWjAGcsgOxUxMnP7DxuoQar/odsNZaPNu02g=; b=LWmJpgWn1Ud5x04C2Ksd01HN4XF2HARp+0mSR2pWpvLQzCwAvBPe6EQTYj+u79NYF5 iFfoLNSkpSW3NXA7YExBaKGsGHd7VZHJ1Bn27vKwK5RPLFClmYD22daV7FdC/ex59QYH A1q23NImfWg5/sqmJsE3W3U3qj6j5CsNx+yWv7+2+sE7DdYf7R+A25UY2/0vJ70S9Mwg S950SPgmegmq+4l69rmP5PZJB3T3ytKs3b7dTgXAwu7xZJdaRE2zWqjkdtc1MmkEYl6m CnesZgESimIzkVygibTbahxU1x7hBqAjw9O9Y04YcI19ZqpUyHCzdFoqMc71Zs0R9RKM gB2g== X-Gm-Message-State: APjAAAU9D8XVVvsxwvDC+Y0LCb5UYAWe0pmL6jGp/Q81cuTE0YPgn4gw 6WRAkTIULTOlLe85D2fhid/jL9nEMls= X-Google-Smtp-Source: APXvYqwJvBnc5FUT1q2TYPg0h+ik8btiyxAWrYFDkxqmtsgjQj3L/axm8JwqhkriWqqu6ynr0+hRyA== X-Received: by 2002:a5d:55d1:: with SMTP id i17mr18589592wrw.165.1579531113235; Mon, 20 Jan 2020 06:38:33 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:32 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Tanushree Tumane , Miriam Rubio Subject: [PATCH 04/29] run-command: make `exists_in_PATH()` non-static Date: Mon, 20 Jan 2020 15:37:35 +0100 Message-Id: <20200120143800.900-5-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 Removes the `static` keyword from `exists_in_PATH()` function and declares the function in `run-command.h` file. The function will be used in bisect_visualize() in a later commit. Mentored by: Christian Couder Mentored by: Johannes Schindelin Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- run-command.c | 2 +- run-command.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/run-command.c b/run-command.c index 9942f120a9..096faea5b9 100644 --- a/run-command.c +++ b/run-command.c @@ -210,7 +210,7 @@ static char *locate_in_PATH(const char *file) return NULL; } -static int exists_in_PATH(const char *file) +int exists_in_PATH(const char *file) { char *r = locate_in_PATH(file); free(r); diff --git a/run-command.h b/run-command.h index 592d9dc035..7c8e206d97 100644 --- a/run-command.h +++ b/run-command.h @@ -172,6 +172,17 @@ void child_process_clear(struct child_process *); int is_executable(const char *name); +/** + * Returns if a $PATH given by parameter is found or not (it is NULL). This + * function uses locate_in_PATH() function that emulates the path search that + * execvp would perform. Memory used to store the resultant path is freed by + * the function. + * + * The caller should ensure that $PATH contains no directory + * separators. + */ +int exists_in_PATH(const char *); + /** * Start a sub-process. Takes a pointer to a `struct child_process` * that specifies the details and returns pipe FDs (if requested). From patchwork Mon Jan 20 14:37: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: 11342367 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 C7E28924 for ; Mon, 20 Jan 2020 14:38:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A574422314 for ; Mon, 20 Jan 2020 14:38:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VPWzixn2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728668AbgATOij (ORCPT ); Mon, 20 Jan 2020 09:38:39 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:40685 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbgATOig (ORCPT ); Mon, 20 Jan 2020 09:38:36 -0500 Received: by mail-wm1-f65.google.com with SMTP id t14so14926305wmi.5 for ; Mon, 20 Jan 2020 06:38:35 -0800 (PST) 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=z+0sLYrP58eeovRExl7dsWUvPzeYQuBQyVbe8IQ/XvY=; b=VPWzixn2jURgQl1d033nvbMfYp+SyrefILWBcdY5SBEN9pCJAotA0HTKQPiXCeYlnE USA2l3jfnS8rZ6saKYNUhqCgjgnHIyECwfYZx5gGeNwWsj1YaQaKjE0d2gHbz6XZqcFC EON+NZSsySzyBlb2NIf1/4NbulhsLs4kjSSTm8GvRJ2//yUckh4SESR+QnbMG+/Y7j03 MRA+hEG+B80koVqFopjP6Dt2mbfw8YWHH5vd/pTk2w8OENzB9yoh3kg9WeDvQfaEOqiL zjHd46xVAW27HWmHBWcG7MGzFVzmUPj3FdZ68HQMyzxCvewtft8GgIGRKUO7CT62ECug ypgQ== 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=z+0sLYrP58eeovRExl7dsWUvPzeYQuBQyVbe8IQ/XvY=; b=q74BBFbgmywMp8Ci3xv+5CDC58qOrxwT2YDhfUzIWIehFOCARSCHwQTVPLXgFtl7m/ VAFQ68FaAMpC8NVt/TuUaQaufciKftymLvdvpK9DY72jsyk2r99uqKgWTopf2NHjx+oB isPmaPzlxP/LtVx77s6JWzjzt3Uv4qiBE7eqsl2TdLm2B+v7fwhVIPCHZxscerH9zFcq AgoxWsI7v9X778UYQsFSr1AR+OS8fUisE50x0TXxZbWZ+bU1FGkXLXh1SUThbWjEywQW juWIDqeh38PFNdizENCi8iyfwtbaS6vrBlKs5+GmPDLQFY8Yx0EJ+eholFShozHy0bvj UC+g== X-Gm-Message-State: APjAAAXXtlTRKbvB16XuJLwS68TqDnQA50iUPrfTnR0VMtoEjNIJHaza wmuCIRrdChkDFVhjcWGyR7gYiwXv+UM= X-Google-Smtp-Source: APXvYqxUrTAb88ANWpHqWkHXp0SDAWSCznMb32r5NjX5E+4jLqz4CX7xFlGPKxvcPdB8ZqCmmii11Q== X-Received: by 2002:a1c:5419:: with SMTP id i25mr19583521wmb.150.1579531114335; Mon, 20 Jan 2020 06:38:34 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:33 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Tanushree Tumane , Christian Couder , Miriam Rubio Subject: [PATCH 05/29] bisect--helper: introduce new `decide_next()` function Date: Mon, 20 Jan 2020 15:37:36 +0100 Message-Id: <20200120143800.900-6-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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: Tanushree Tumane Let's refactor code from bisect_next_check() into a new decide_next() helper function. This removes some goto statements and makes the code simpler, clearer and easier to understand. Mentored-by: Christian Couder Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- builtin/bisect--helper.c | 62 +++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 21de5c096c..826fcba2ed 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -291,26 +291,14 @@ static const char need_bisect_start_warning[] = "You then need to give me at least one %s and %s revision.\n" "You can use \"git bisect %s\" and \"git bisect %s\" for that."); -static int bisect_next_check(const struct bisect_terms *terms, - const char *current_term) +static int decide_next(const struct bisect_terms *terms, + const char *current_term, int missing_good, + int missing_bad) { - int missing_good = 1, missing_bad = 1, res = 0; - const char *bad_ref = xstrfmt("refs/bisect/%s", terms->term_bad); - const char *good_glob = xstrfmt("%s-*", terms->term_good); - - if (ref_exists(bad_ref)) - missing_bad = 0; - - for_each_glob_ref_in(mark_good, good_glob, "refs/bisect/", - (void *) &missing_good); - if (!missing_good && !missing_bad) - goto finish; - - if (!current_term) { - res = -1; - goto finish; - } + return 0; + if (!current_term) + return -1; if (missing_good && !missing_bad && !strcmp(current_term, terms->term_good)) { @@ -321,7 +309,7 @@ static int bisect_next_check(const struct bisect_terms *terms, */ warning(_("bisecting only with a %s commit"), terms->term_bad); if (!isatty(0)) - goto finish; + return 0; /* * TRANSLATORS: Make sure to include [Y] and [n] in your * translation. The program will only accept English input @@ -329,21 +317,35 @@ static int bisect_next_check(const struct bisect_terms *terms, */ yesno = git_prompt(_("Are you sure [Y/n]? "), PROMPT_ECHO); if (starts_with(yesno, "N") || starts_with(yesno, "n")) - res = -1; - goto finish; - } - if (!is_empty_or_missing_file(git_path_bisect_start())) { - res = error(_(need_bad_and_good_revision_warning), - vocab_bad, vocab_good, vocab_bad, vocab_good); - } else { - res = error(_(need_bisect_start_warning), - vocab_good, vocab_bad, vocab_good, vocab_bad); + return -1; + return 0; } -finish: + if (!is_empty_or_missing_file(git_path_bisect_start())) + return error(_(need_bad_and_good_revision_warning), + vocab_bad, vocab_good, vocab_bad, vocab_good); + else + return error(_(need_bisect_start_warning), + vocab_good, vocab_bad, vocab_good, vocab_bad); +} + +static int bisect_next_check(const struct bisect_terms *terms, + const char *current_term) +{ + int missing_good = 1, missing_bad = 1; + const char *bad_ref = xstrfmt("refs/bisect/%s", terms->term_bad); + const char *good_glob = xstrfmt("%s-*", terms->term_good); + + if (ref_exists(bad_ref)) + missing_bad = 0; + + for_each_glob_ref_in(mark_good, good_glob, "refs/bisect/", + (void *) &missing_good); + free((void *) good_glob); free((void *) bad_ref); - return res; + + return decide_next(terms, current_term, missing_good, missing_bad); } static int get_terms(struct bisect_terms *terms) From patchwork Mon Jan 20 14:37: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: 11342377 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 913306C1 for ; Mon, 20 Jan 2020 14:38:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6F97422522 for ; Mon, 20 Jan 2020 14:38:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RZng50aw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728516AbgATOij (ORCPT ); Mon, 20 Jan 2020 09:38:39 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33207 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbgATOih (ORCPT ); Mon, 20 Jan 2020 09:38:37 -0500 Received: by mail-wr1-f68.google.com with SMTP id b6so29871750wrq.0 for ; Mon, 20 Jan 2020 06:38:36 -0800 (PST) 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=o5O2mOhEEB/3yyhH7Yak7Hvy8bfFkBykevEU+u0WAWY=; b=RZng50awghOV3zrOD3BFp7TD8fq+UqJEM3idUnI3j0l2hRGIXY9UNbCqO1tcp+Ivx/ n2Xu5Q032FetRGa0nuQF7KnIw5UhkWgdfEGl5pkJFHT/391rooXBkWdIC2J2JbBGCbz3 R3wKfbBpxu2eczEJfbr0ijaTEvhpMXRo4p7zrGi3MB+hTEkYpRSLLiF1CI2WPKuQ8LW0 CYKBWnRKV4HXTKmQLra1rd6YqkzJUnvWnkWWZGycqHhdgc9TMZTK7vtjQk9nYXm9Lzuv E26uM6djLiUD3rMNxdt6/mo9jtInCkK2hIOoIH4dN9giH4RzScs/gs7XG+rbX/lgJF19 7/Vw== 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=o5O2mOhEEB/3yyhH7Yak7Hvy8bfFkBykevEU+u0WAWY=; b=mgTW6OdnRYgesmJwAfcjyhA2zMz4BO5w0hGwX/0Clka/dKYFk/QI4Gyfk6LHrt6ZkA 9l7HlfmPyfzNI4pk2xThj4MfO/O750mLKk6EnL6y1eJt9CytTAvMBkmqyhDhJvmklBXW c9+9X+K+0WYACHFL5pi0DrUZTZ3kWRLy4L0sMK944bqoEa3XkUT45PTKTjisVC1RAHek 7J9R79U6BrEslBwgg12EvOARyQ0zwaHDruylvBvazMBim6UmOEFn/Q/CNCwTlMa+Z+/f wwH7p5ZtY7y1a0111US8+NoP0Ff03G3hvwWN0FPTLrBQmjCwut0qXdZlCBOhPMcK6Oy4 KjWg== X-Gm-Message-State: APjAAAWZf2/Z/c+Q5ph88LBxe1VcSNmZcxd3WxaYgbVbKr3u4ipEVKB2 OMd1BTOm3kuqI+N2PqUS2dYwsxO1RUU= X-Google-Smtp-Source: APXvYqwuW3yRpu7ItTH5dKB1Hw+o9ScsHgzeY1EDwYdlZ7ZkGKOd9ZzUmYuA95GBdKqJkPa+S22OJQ== X-Received: by 2002:adf:c54e:: with SMTP id s14mr17840781wrf.385.1579531115518; Mon, 20 Jan 2020 06:38:35 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:35 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 06/29] bisect: libify `exit_if_skipped_commits` to `error_if_skipped*` and its dependents Date: Mon, 20 Jan 2020 15:37:37 +0100 Message-Id: <20200120143800.900-7-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 Since we want to get rid of git-bisect.sh it would be necessary to convert those exit() calls to return statements so that errors can be reported. Emulate try catch in C by converting `exit()` to `return `. Follow POSIX conventions to return to indicate error. Modify `cmd_bisect_helper()` to handle these negative returns. Turn `exit()` to `return` calls in `exit_if_skipped_commits()` and rename the method to `error_if_skipped_commits()`. Handle this return in dependant function `bisect_next_all()`. 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 | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/bisect.c b/bisect.c index 83cb5b3a98..2ac0463327 100644 --- a/bisect.c +++ b/bisect.c @@ -661,11 +661,11 @@ static void bisect_common(struct rev_info *revs) mark_edges_uninteresting(revs, NULL, 0); } -static void exit_if_skipped_commits(struct commit_list *tried, +static int error_if_skipped_commits(struct commit_list *tried, const struct object_id *bad) { if (!tried) - return; + return 0; printf("There are only 'skip'ped commits left to test.\n" "The first %s commit could be any of:\n", term_bad); @@ -676,7 +676,13 @@ static void exit_if_skipped_commits(struct commit_list *tried, if (bad) printf("%s\n", oid_to_hex(bad)); printf(_("We cannot bisect more!\n")); - exit(2); + + /* + * We don't want to clean the bisection state + * as we need to get back to where we started + * by using `git bisect reset`. + */ + return -2; } static int is_expected_rev(const struct object_id *oid) @@ -949,7 +955,7 @@ int bisect_next_all(struct repository *r, const char *prefix, int no_checkout) { struct rev_info revs; struct commit_list *tried; - int reaches = 0, all = 0, nr, steps; + int reaches = 0, all = 0, nr, steps, res; struct object_id *bisect_rev; char *steps_msg; @@ -972,8 +978,9 @@ int bisect_next_all(struct repository *r, const char *prefix, int no_checkout) * We should exit here only if the "bad" * commit is also a "skip" commit. */ - exit_if_skipped_commits(tried, NULL); - + res = error_if_skipped_commits(tried, NULL); + if (res) + exit(-res); printf(_("%s was both %s and %s\n"), oid_to_hex(current_bad_oid), term_good, @@ -990,7 +997,9 @@ int bisect_next_all(struct repository *r, const char *prefix, int no_checkout) bisect_rev = &revs.commits->item->object.oid; if (oideq(bisect_rev, current_bad_oid)) { - exit_if_skipped_commits(tried, current_bad_oid); + res = error_if_skipped_commits(tried, current_bad_oid); + if (res) + exit(-res); printf("%s is the first %s commit\n", oid_to_hex(bisect_rev), term_bad); show_diff_tree(r, prefix, revs.commits->item); From patchwork Mon Jan 20 14:37: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: 11342359 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 1E5A2924 for ; Mon, 20 Jan 2020 14:38:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0BD0217F4 for ; Mon, 20 Jan 2020 14:38:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G69OrLl9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728655AbgATOij (ORCPT ); Mon, 20 Jan 2020 09:38:39 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:38522 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727683AbgATOii (ORCPT ); Mon, 20 Jan 2020 09:38:38 -0500 Received: by mail-wr1-f68.google.com with SMTP id y17so29849578wrh.5 for ; Mon, 20 Jan 2020 06:38:37 -0800 (PST) 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=oDX/Xy/xSLCaRjH5SbpbSxWGAIWXngsvdpc/dPrz69k=; b=G69OrLl9rPs84RXMTtfiorOPQXVib/RGhfZeFiNCOU4QjHycifIJn9FVFcC1ZMfRF+ i1BzSvrB+T7D71ZAVVTLZg9Yhj+H/Z3JzMsoOD4LY5UtrXXBh2Vc5Yijjv5Hr0ouVY9Y /thexeNo/SUnBP/YUx6wJ1mI1XYh1Nd+LDVCkC/eWyittWvQGcfLtooAg1/IUWGCwkqm VUHmtFi4xfGA4in3FgssCl9pn/jMb7jcZaqUhKGrwdVpC2ugK7P2tzvZSkRBRnT4rn4b Vc8ogJNjjilcSr9pWL85VLCPlqXuWKvSfdchT7bFDLyTMAGoJZtcwiyEAxYyLMUoJVuD y31Q== 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=oDX/Xy/xSLCaRjH5SbpbSxWGAIWXngsvdpc/dPrz69k=; b=I/PQOS5UeO4I1dxScDaci6sdOeGuRG6pbA1SE+PXWSVZ/BNJ8xepNDwBXtnDmrpNWR m4RMobTOUB1pqfJl5UQP+vZ0W05n7KBwdkcJNHYevCbWJdoGEfSBA1RtpjFjx8yfeUI1 g5fPfoWDv5qq6TNnP3afTegV6YvsC1ZH+KemNdd2/gHIcLGvIWU6dS57YE66Gid5FJsj 1mqzKsW6I2z9+fA3hjlXSCtUm00HJAR+IUDI/j8clRJIUGhJw6POHupwhExICp2hOWxn +DihPsq7IoSgwVH4s6vRVno7bQRnq+r7onY1W/U8xqi2hRVyQPjmYercoOUd6Sg1BU3y cnNQ== X-Gm-Message-State: APjAAAV0JyPSvYnCqkiL3o00GiyIBT9U+Kc00gMuwTcbhZmdOWZCED/c 9Bed8Zkl+0rVzi6S2mF8xcjgGLQ+Ai0= X-Google-Smtp-Source: APXvYqx9o/Vw6kRoRBVhhbnhdk92+VM5F5b2eDy4M4KlP7GZYhkPbLUzdhLR5WK5CtJjHHqc3Snd0A== X-Received: by 2002:adf:d846:: with SMTP id k6mr17741011wrl.337.1579531116743; Mon, 20 Jan 2020 06:38:36 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:36 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 07/29] bisect: libify `bisect_checkout` Date: Mon, 20 Jan 2020 15:37:38 +0100 Message-Id: <20200120143800.900-8-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 Since we want to get rid of git-bisect.sh it would be necessary to convert those exit() calls to return statements so that errors can be reported. Emulate try catch in C by converting `exit()` to `return `. Follow POSIX conventions to return to indicate error. Turn `exit()` to `return` calls in `bisect_checkout()`. Changes related to return values have no bad side effects on the code that calls `bisect_checkout()`. 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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bisect.c b/bisect.c index 2ac0463327..385afaf875 100644 --- a/bisect.c +++ b/bisect.c @@ -713,6 +713,7 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout) { char bisect_rev_hex[GIT_MAX_HEXSZ + 1]; + int res = 0; memcpy(bisect_rev_hex, oid_to_hex(bisect_rev), the_hash_algo->hexsz + 1); update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR); @@ -721,14 +722,14 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout) update_ref(NULL, "BISECT_HEAD", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR); } else { - int res; res = run_command_v_opt(argv_checkout, RUN_GIT_CMD); if (res) - exit(res); + return res > 0 ? -res : res; } argv_show_branch[1] = bisect_rev_hex; - return run_command_v_opt(argv_show_branch, RUN_GIT_CMD); + res = run_command_v_opt(argv_show_branch, RUN_GIT_CMD); + return res > 0 ? -res : res; } static struct commit *get_commit_reference(struct repository *r, From patchwork Mon Jan 20 14:37: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: 11342363 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 9E2826C1 for ; Mon, 20 Jan 2020 14:38:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7CA8122314 for ; Mon, 20 Jan 2020 14:38:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hbOuBVwC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728765AbgATOik (ORCPT ); Mon, 20 Jan 2020 09:38:40 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33209 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727688AbgATOik (ORCPT ); Mon, 20 Jan 2020 09:38:40 -0500 Received: by mail-wr1-f68.google.com with SMTP id b6so29871897wrq.0 for ; Mon, 20 Jan 2020 06:38:38 -0800 (PST) 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=tTB/m8VkZYS/JJf+6MC8iCuMTVLqOlueF2pee02iWyg=; b=hbOuBVwCzZJVyQ6aSnKXgXjgke6XbGbkQB9gHHDao491hwc5L2w99blqipVZbb9NtB 8luSA+oOVjZBcfd5ARY20P/TA0HjMnKfgC3+nQCe1uJamenrTh4q49r6Qmu/+ss5d0D/ Py+bvfBC7YriWvmPzkvGsvEQrEMrtHvzpj+XinLWjFM+AHRURfl274kDiNKefyLKomZi wRKIFnfwwKUEJI0x+sSHIgfW7EUY4zCIv8mkxr5iBfhVY7OCogNOxCpeORTKQj42hhkg ChUn6BBZiVLATwWCrd8E9R3LQ+DNxOxbBQlW50YdVI0zwtOLsC7oPYY5AnigWnX3xdIL FAdw== 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=tTB/m8VkZYS/JJf+6MC8iCuMTVLqOlueF2pee02iWyg=; b=prTOQpy5pllj19N+I4HeRodwJHynGO6zqHvzAvFW1s7Mb+i89R5llYI5RjQYgCv/KN uy956PzHtSUxJayDLVtg86auv0mgCuJtkcLbA6aK6bM0SCde5GFWMQSxLM7gmHRkN2Kt f2X8gwQW1JxgV4Iz/U24mxrjf1HReeCgOiR2dUv9sRSB1eeJ+yM2JNqnS9dClSumgy0x tvkhXSq8mmIYAYmDAbLg5xlnLgDxb/yX0kVOD9JHSK+jiOBwSvHhnalORJpt4l/jHOMA w1SRxfTWegSaIjr5/wpqxvkYM1F2IdLI9/lB2RVdql1E862+IDetHyvlvbeVyAIk6w0m lmhw== X-Gm-Message-State: APjAAAWLDVx9cZKiCUewDEeHcaweFu/gBYj7ggwSs2Gx4FyAmYaQPt+S Ah+Ez0pbmLrGniQtyBhB14qYjdJY9Ks= X-Google-Smtp-Source: APXvYqwfoZKYuMBs1DTPVcpFlvYt3nsc1y9qGmes5+TFLEghlrwlN9q0a2QinGFEZ3qBznrroJYN+Q== X-Received: by 2002:a5d:44cd:: with SMTP id z13mr19076767wrr.104.1579531117915; Mon, 20 Jan 2020 06:38:37 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:37 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Christian Couder , Tanushree Tumane , Miriam Rubio Subject: [PATCH 08/29] bisect: libify `check_merge_bases` and its dependents Date: Mon, 20 Jan 2020 15:37:39 +0100 Message-Id: <20200120143800.900-9-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 Since we want to get rid of git-bisect.sh it would be necessary to convert those exit() calls to return statements so that errors can be reported. Emulate try catch in C by converting `exit()` to `return `. Follow POSIX conventions to return to indicate error. Turn `exit()` to `return` calls in `check_merge_bases()`. In `check_merge_bases()` there is an early success special case, so we have introduced special error code `-11` which indicates early success. This `-11` is converted back to `0` in `check_good_are_ancestors_of_bad()`. Handle the return value in dependent function `check_good_are_ancestors_of_bad()`. 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 | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/bisect.c b/bisect.c index 385afaf875..367258b0dd 100644 --- a/bisect.c +++ b/bisect.c @@ -806,13 +806,16 @@ static void handle_skipped_merge_base(const struct object_id *mb) * "check_merge_bases" checks that merge bases are not "bad" (or "new"). * * - If one is "bad" (or "new"), it means the user assumed something wrong - * and we must exit with a non 0 error code. + * and we must return error with a non 0 error code. * - If one is "good" (or "old"), that's good, we have nothing to do. * - If one is "skipped", we can't know but we should warn. * - If we don't know, we should check it out and ask the user to test. + * - If a merge base must be tested, on success return -11 a special condition + * for early success, this will be converted back to 0 in check_good_are_ancestors_of_bad(). */ -static void check_merge_bases(int rev_nr, struct commit **rev, int no_checkout) +static int check_merge_bases(int rev_nr, struct commit **rev, int no_checkout) { + int res = 0; struct commit_list *result; result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1); @@ -827,11 +830,16 @@ static void check_merge_bases(int rev_nr, struct commit **rev, int no_checkout) handle_skipped_merge_base(mb); } else { printf(_("Bisecting: a merge base must be tested\n")); - exit(bisect_checkout(mb, no_checkout)); + res = bisect_checkout(mb, no_checkout); + if (!res) + /* indicate early success */ + res = -11; + break; } } free_commit_list(result); + return res; } static int check_ancestors(struct repository *r, int rev_nr, @@ -865,7 +873,7 @@ static void check_good_are_ancestors_of_bad(struct repository *r, { char *filename = git_pathdup("BISECT_ANCESTORS_OK"); struct stat st; - int fd, rev_nr; + int fd, rev_nr, res = 0; struct commit **rev; if (!current_bad_oid) @@ -880,10 +888,13 @@ static void check_good_are_ancestors_of_bad(struct repository *r, goto done; /* Check if all good revs are ancestor of the bad rev. */ + rev = get_bad_and_good_commits(r, &rev_nr); if (check_ancestors(r, rev_nr, rev, prefix)) - check_merge_bases(rev_nr, rev, no_checkout); + res = check_merge_bases(rev_nr, rev, no_checkout); free(rev); + if(res) + exit(res == -11 ? 0 : -res); /* Create file BISECT_ANCESTORS_OK. */ fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600); From patchwork Mon Jan 20 14:37: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: 11342365 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 E39EC924 for ; Mon, 20 Jan 2020 14:38:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C2EA822464 for ; Mon, 20 Jan 2020 14:38:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uRyMrN82" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728778AbgATOim (ORCPT ); Mon, 20 Jan 2020 09:38:42 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46471 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728709AbgATOil (ORCPT ); Mon, 20 Jan 2020 09:38:41 -0500 Received: by mail-wr1-f67.google.com with SMTP id z7so29771909wrl.13 for ; Mon, 20 Jan 2020 06:38:40 -0800 (PST) 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=T0XwTj8wOlFkbFN5Ngh75qyxq8FkCrsUb3XwmE9iUZk=; b=uRyMrN82iNP1KfCouH8Iq0Xh6sBfhk3caxEV9Jl+tpLDXc6GsqziKPy9NLYE9WSqIW PLFqDNN+v+xKF8TLXsYSkZ0vCSGHCW6FPutV8Ijqk9aXen2T/1JJRfsz1dU1OSlQBc9w 6PAOFuQ1mTKJ7q9X+Vccue0UVBotiSiCCA94TLQe8n74m7/baqoYsXd6yTvyt/xf+/X3 F8lxOusz6QQFvFwrWCXaEoLDTesN2qPm1KXzJRbVZsCpmCbHm+5kpgsekKV7VzhE25/C 3xnJIjYRq0oI8Z+Lc+zZerR5p9UOx+zG/icMtY2ctiGssfe6kBvfDqnURH8jqt9uYP1a NCLg== 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=T0XwTj8wOlFkbFN5Ngh75qyxq8FkCrsUb3XwmE9iUZk=; b=R9qBJxSt09QCKXqTr4RYu57ISumdRDpY8wzOs90fh46MY4hpCM+El3MoA8G+A0Tf92 7L8a2Zaant7/KMty2araU2n2Z3/G7Lk600RFn7hDR+RQZzcy3RGNttQfhWB42vCuuPM/ UG17TaMrwzIk6vH1A9oibpp+ALOs8nAwzmBIP1qPFlhL2MNNIJo69AVdbNHEHHyaoxmT t5hW+4n7QGC9XDXTZZxyxJvfMek4EHk9PJ8TTbZz/tv1tx0pqgHkutiDkpNaV2z2oo5V DsunylDotwx7bAZirknC/evrIzmxL7+GZvi0VeU07bWNoX8XEO5FTAr2oGX1mj2KDnel jKsA== X-Gm-Message-State: APjAAAWvJ/kjLS4uREu80ITRbkM6n9sptMxEJlcl8kRmGWrSfFYlZUQG 6qwcER99PeiiTGg4A6JyHNgq0MdG64s= X-Google-Smtp-Source: APXvYqzjevKsv7ZWv4eWPuVqBsHnskndK2HsvPiBwW8VyqmCB0XMxP0yXU/wI5Ery190SV5wuf8mlQ== X-Received: by 2002:a5d:4281:: with SMTP id k1mr18363598wrq.72.1579531119079; Mon, 20 Jan 2020 06:38:39 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:38 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Christian Couder , Tanushree Tumane , Miriam Rubio Subject: [PATCH 09/29] bisect: libify `check_good_are_ancestors_of_bad` and its dependents Date: Mon, 20 Jan 2020 15:37:40 +0100 Message-Id: <20200120143800.900-10-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 Since we want to get rid of git-bisect.sh it would be necessary to convert those exit() calls to return statements so that errors can be reported. Emulate try catch in C by converting `exit()` to `return `. Follow POSIX conventions to return to indicate error. Turn `exit()` to `return` calls in `check_good_are_ancestors_of_bad()`. Code that turns -11(early success code) to 0 from `check_good_are_ancestors_of_bad()` has been moved to `cmd_bisect__helper()`. Handle the return value in dependent function `bisect_next_all()`. 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 | 42 ++++++++++++++++++++++++++-------------- builtin/bisect--helper.c | 12 ++++++++++-- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/bisect.c b/bisect.c index 367258b0dd..2b80597a1d 100644 --- a/bisect.c +++ b/bisect.c @@ -865,9 +865,10 @@ static int check_ancestors(struct repository *r, int rev_nr, * * If that's not the case, we need to check the merge bases. * If a merge base must be tested by the user, its source code will be - * checked out to be tested by the user and we will exit. + * checked out to be tested by the user and we will return. */ -static void check_good_are_ancestors_of_bad(struct repository *r, + +static int check_good_are_ancestors_of_bad(struct repository *r, const char *prefix, int no_checkout) { @@ -876,8 +877,15 @@ static void check_good_are_ancestors_of_bad(struct repository *r, int fd, rev_nr, res = 0; struct commit **rev; - if (!current_bad_oid) - die(_("a %s revision is needed"), term_bad); + /* + * We don't want to clean the bisection state + * as we need to get back to where we started + * by using `git bisect reset`. + */ + if (!current_bad_oid) { + res = error(_("a %s revision is needed"), term_bad); + goto done; + } /* Check if file BISECT_ANCESTORS_OK exists. */ if (!stat(filename, &st) && S_ISREG(st.st_mode)) @@ -893,18 +901,20 @@ static void check_good_are_ancestors_of_bad(struct repository *r, if (check_ancestors(r, rev_nr, rev, prefix)) res = check_merge_bases(rev_nr, rev, no_checkout); free(rev); - if(res) - exit(res == -11 ? 0 : -res); - - /* Create file BISECT_ANCESTORS_OK. */ - fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600); - if (fd < 0) - warning_errno(_("could not create file '%s'"), - filename); - else - close(fd); + + if (!res) + { + /* Create file BISECT_ANCESTORS_OK. */ + fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600); + if (fd < 0) + warning_errno(_("could not create file '%s'"), + filename); + else + close(fd); + } done: free(filename); + return res; } /* @@ -975,7 +985,9 @@ int bisect_next_all(struct repository *r, const char *prefix, int no_checkout) if (read_bisect_refs()) die(_("reading bisect refs failed")); - check_good_are_ancestors_of_bad(r, prefix, no_checkout); + res = check_good_are_ancestors_of_bad(r, prefix, no_checkout); + if (res) + return res; bisect_rev_setup(r, &revs, prefix, "%s", "^%s", 1); revs.limited = 1; diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 826fcba2ed..5e0f759d50 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -666,7 +666,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) switch (cmdmode) { case NEXT_ALL: - return bisect_next_all(the_repository, prefix, no_checkout); + res = bisect_next_all(the_repository, prefix, no_checkout); + break; case WRITE_TERMS: if (argc != 2) return error(_("--write-terms requires two arguments")); @@ -713,5 +714,12 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) return error("BUG: unknown subcommand '%d'", cmdmode); } free_terms(&terms); - return !!res; + /* + * Handle early success + * From check_merge_bases > check_good_are_ancestors_of_bad > bisect_next_all + */ + if (res == -11) + res = 0; + + return res < 0 ? -res : res; } From patchwork Mon Jan 20 14:37: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: 11342369 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 21A1F6C1 for ; Mon, 20 Jan 2020 14:38:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 00CFE22464 for ; Mon, 20 Jan 2020 14:38:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="u6Z5/yvB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728792AbgATOin (ORCPT ); Mon, 20 Jan 2020 09:38:43 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45747 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727688AbgATOim (ORCPT ); Mon, 20 Jan 2020 09:38:42 -0500 Received: by mail-wr1-f65.google.com with SMTP id j42so29782240wrj.12 for ; Mon, 20 Jan 2020 06:38:41 -0800 (PST) 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=KgrNvyZ4hU4hCrIsAMfvAtcrnW/D/9n/Gv8WyOb52nQ=; b=u6Z5/yvBGvPx1SGQbFCnHhKf9FM2GFzSSl5vPxcp5YkbaK0mLH8ycIQ2YAy1Buqhkc dBBErlALdY/SeMDIrYwT3nH3SpG0hWcZHnMCNUMw7uhmwtSgFMn9wgpWDHX8TL/8AfXM pdBNREbCkpOJxIpaHDF+Q0Xooitqphp0K2IyyH9fl1VJElYCJGwtIqssIn34qw2U5rMt yuRTmUM1XVW08sPqk6wiHRFuLMup41OSicE5P1nXcv2ZCa1RkoD0E/F1ZUzVhoQsAx2Y JRIUdhf+RMkFrTDv96vGWcffSzvMqxiqmFY4zs8+p5PANQ2NhwMc0Bn0HNTxtpUPW7Pm rsFA== 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=KgrNvyZ4hU4hCrIsAMfvAtcrnW/D/9n/Gv8WyOb52nQ=; b=CHpHXuAjK9e0kuM7YnM2k420VvIPTBhBa/zoDMj0BTkUF811G4U7AaZLOr4b9DcWZ+ 5gYd8BdjAdH2dvvAadl1RFzuRCNmOFEcNikpAJbWobxkuCjNaxbr0SHp+b55MWTfxwAo 76apB/8KgIJa7raTjXeX5esGQklPgivg7rFmwnCXmJWkP5EYXl2cUS9EadN0E+pgUPcj ntqqMlJzRQgRZYFptQGLuOdKpzLp0KIpRyBVa2LAEG34lwD/dzeM6keVNfQAY3uIDF0I 8mSrWnCtU1vPmiDi2ZtYpbIvWpk+VAOn4eO9e5TsYV+w04r77EHWkPjc+8lxWkoNCnnu OvEw== X-Gm-Message-State: APjAAAWCvGknk4gYWIIUFAnugn++RcfpgpNcONKpKkRuOfaBUKbzBk/m Tk8doIf8ecr7KFMPE7yv75W7I+I321k= X-Google-Smtp-Source: APXvYqyJM8lV0V2ec4jKfYObJEmcAH1sE8W8vtUU/GdJg//cxokzjBjBX+pndROaNsJXueyRO5exeg== X-Received: by 2002:adf:e70d:: with SMTP id c13mr18440111wrm.248.1579531120270; Mon, 20 Jan 2020 06:38:40 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:39 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 10/29] bisect: libify `handle_bad_merge_base` and its dependents Date: Mon, 20 Jan 2020 15:37:41 +0100 Message-Id: <20200120143800.900-11-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 Since we want to get rid of git-bisect.sh it would be necessary to convert those exit() calls to return statements so that errors can be reported. Emulate try catch in C by converting `exit()` to `return `. Follow POSIX conventions to return to indicate error. Turn `exit()` to `return` calls in `handle_bad_merge_base()`. Handle the return value in dependent function check_merge_bases(). 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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bisect.c b/bisect.c index 2b80597a1d..acb5a13911 100644 --- a/bisect.c +++ b/bisect.c @@ -756,7 +756,7 @@ static struct commit **get_bad_and_good_commits(struct repository *r, return rev; } -static void handle_bad_merge_base(void) +static int handle_bad_merge_base(void) { if (is_expected_rev(current_bad_oid)) { char *bad_hex = oid_to_hex(current_bad_oid); @@ -777,14 +777,14 @@ static void handle_bad_merge_base(void) "between %s and [%s].\n"), bad_hex, term_bad, term_good, bad_hex, good_hex); } - exit(3); + return -3; } fprintf(stderr, _("Some %s revs are not ancestors of the %s rev.\n" "git bisect cannot work properly in this case.\n" "Maybe you mistook %s and %s revs?\n"), term_good, term_bad, term_good, term_bad); - exit(1); + return -1; } static void handle_skipped_merge_base(const struct object_id *mb) @@ -823,7 +823,8 @@ static int check_merge_bases(int rev_nr, struct commit **rev, int no_checkout) for (; result; result = result->next) { const struct object_id *mb = &result->item->object.oid; if (oideq(mb, current_bad_oid)) { - handle_bad_merge_base(); + res = handle_bad_merge_base(); + break; } else if (0 <= oid_array_lookup(&good_revs, mb)) { continue; } else if (0 <= oid_array_lookup(&skipped_revs, mb)) { From patchwork Mon Jan 20 14:37: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: 11342371 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 59E5F6C1 for ; Mon, 20 Jan 2020 14:38:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3873F22522 for ; Mon, 20 Jan 2020 14:38:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="scExUJ3N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728829AbgATOip (ORCPT ); Mon, 20 Jan 2020 09:38:45 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55914 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728709AbgATOio (ORCPT ); Mon, 20 Jan 2020 09:38:44 -0500 Received: by mail-wm1-f65.google.com with SMTP id q9so14716365wmj.5 for ; Mon, 20 Jan 2020 06:38:42 -0800 (PST) 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=G+qoZnKDmxBY28zZvEzOZGWsh750eTqr5jD+v4kUyMo=; b=scExUJ3NBpjFhX5aU/wB/uh2TYr34r/38j8OZ9SAiRfdXvnZ+NC5QP5XkOJest2JTB fk2A0E8D2L+8/jvna3CzFnla8an+PHaLmM3A1QUnXahbFmTmPpNDx/9q0MjtOtn+YZiu 4JckQ55rTB1c/bc2TC1ISw0oE4pHXwDAq27dkA3pyi/RxpkOLyd+zjU0GmMo539GwCUZ BMNCm6oEeoZR3Wj0Tfz0AYYgjKRzMshK3gjS7CV+bNAYmYUsqPUm9VzCLbCqUTjhJ0mo gOkyOFblKr+AU+BkvQxIBkf07Ncjm69w3Oc4h071fd40z+UurAppLXs0U/pXVkYlbkKr qrdA== 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=G+qoZnKDmxBY28zZvEzOZGWsh750eTqr5jD+v4kUyMo=; b=D565r3l00HY/F78FohowRIoc2VwHcpL1eNgfumd3EwI0s7IFTFJ+AVEZMgLBqIj1sp eETZiiohaI5/DZw4z9bI83yOgw0SnLAy9qWmrwdCKpmlrzrrrp1sp3biMg1B7cM0uyh5 tuTKWVgKOVVJNcZ/X0QaYCOniCR6NKFuaM74NImkMERl9G1G+pMuu48e92pT+j7zuyU7 6Ly5EaesyKqZVBNQQ1CXAxF28DU4qBangsT0+ihytfFkK/3BjurEjr2EaW6lA06z5xZN 4rAebST64m4Uz6+YVTof5tOpJmfDiZlifhf99fOGUqDjvYcmW/8IOkYVbqkz5IWCyX/u bW+g== X-Gm-Message-State: APjAAAUpVWuh0SfIIadmJ431qLAVRHrJcmo8IathlsorZ/pM0ahtPezR VEufW2dmjXKyCFW5Qw/ktl51UI4iEoI= X-Google-Smtp-Source: APXvYqwO+T+DGB8GyW53tXTfUXy3k8iC/uj0RONE2SLZp22xUoCEf1pc/waEnWEGKNUExIcZ9gpXUw== X-Received: by 2002:a05:600c:108a:: with SMTP id e10mr18727402wmd.38.1579531121725; Mon, 20 Jan 2020 06:38:41 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:41 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 11/29] bisect: libify `bisect_next_all` Date: Mon, 20 Jan 2020 15:37:42 +0100 Message-Id: <20200120143800.900-12-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 Since we want to get rid of git-bisect.sh it would be necessary to convert those exit() calls to return statements so that errors can be reported. Emulate try catch in C by converting `exit()` to `return `. Follow POSIX conventions to return to indicate error. Turn `exit()` to `return` calls in `bisect_next_all()`. All the functions calling `bisect_next_all()` are already able to handle return values from it. 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 | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/bisect.c b/bisect.c index acb5a13911..33f2829c19 100644 --- a/bisect.c +++ b/bisect.c @@ -967,10 +967,10 @@ void read_bisect_terms(const char **read_bad, const char **read_good) } /* - * We use the convention that exiting with an exit code 10 means that - * the bisection process finished successfully. - * In this case the calling shell script should exit 0. - * + * We use the convention that return -10 means the bisection process + * finished successfully. + * In this case the calling function or command should not turn a -10 + * 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. */ @@ -1000,23 +1000,35 @@ int bisect_next_all(struct repository *r, const char *prefix, int no_checkout) if (!revs.commits) { /* - * We should exit here only if the "bad" + * We should return error here only if the "bad" * commit is also a "skip" commit. */ res = error_if_skipped_commits(tried, NULL); if (res) - exit(-res); + return res; printf(_("%s was both %s and %s\n"), oid_to_hex(current_bad_oid), term_good, term_bad); - exit(1); + + /* + * We don't want to clean the bisection state + * as we need to get back to where we started + * by using `git bisect reset`. + */ + return -1; } if (!all) { fprintf(stderr, _("No testable commit found.\n" "Maybe you started with bad path parameters?\n")); - exit(4); + + /* + * We don't want to clean the bisection state + * as we need to get back to where we started + * by using `git bisect reset`. + */ + return -4; } bisect_rev = &revs.commits->item->object.oid; @@ -1024,12 +1036,18 @@ int bisect_next_all(struct repository *r, const char *prefix, int no_checkout) if (oideq(bisect_rev, current_bad_oid)) { res = error_if_skipped_commits(tried, current_bad_oid); if (res) - exit(-res); + return res; printf("%s is the first %s commit\n", oid_to_hex(bisect_rev), term_bad); + show_diff_tree(r, prefix, revs.commits->item); - /* This means the bisection process succeeded. */ - exit(10); + /* + * This means the bisection process succeeded. + * Using -10 so that the call chain can simply check + * for negative return values for early returns up + * until the cmd_bisect__helper() caller. + */ + return -10; } nr = all - reaches - 1; From patchwork Mon Jan 20 14:37: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: 11342373 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 17346924 for ; Mon, 20 Jan 2020 14:38:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF80622525 for ; Mon, 20 Jan 2020 14:38:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mtD/Cwt/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728847AbgATOiq (ORCPT ); Mon, 20 Jan 2020 09:38:46 -0500 Received: from mail-wr1-f53.google.com ([209.85.221.53]:40686 "EHLO mail-wr1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727688AbgATOip (ORCPT ); Mon, 20 Jan 2020 09:38:45 -0500 Received: by mail-wr1-f53.google.com with SMTP id c14so29821132wrn.7 for ; Mon, 20 Jan 2020 06:38:44 -0800 (PST) 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=K2VV//69jZjLr4stMC0AtgDVmJefR1zjy/6aYQIDjN8=; b=mtD/Cwt/W079jMFqQQSGw3fJ8OLdQa2gfEUmszhuuN8wQRBOXQEKbJHkFO9e49UMP0 ZtumvSys/Wa5Hh53OKXUQ+BqW0M1ktXSBDdQDXCUJo7BN8JLcQyDs9NhV3PgdCYuEweq IklkCGXv9OVK09MS2GZrND0VaKg/wB/1MVMzY2Xgra79jjGTVM03nHaZ5j9OJEEld/nw CfDWS/kxBChtDdiLEwOHFyyRKIJCm4z6eIgWMA6ambsnjCuRlfgV+t5khmprCvgzBPlB 3ZDNkPKJMnvL1xp4Kuf2iKEXFl74uyXaweIM4byFGXaDzSNHtzxSkvrip1Q8BOqMKJDX wISQ== 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=K2VV//69jZjLr4stMC0AtgDVmJefR1zjy/6aYQIDjN8=; b=sw/YkF22B9Put+IlvoXz5BR50d7teztPI8Ggm/mgxVy/16vNe6zrfSUJuLhFaTNDc9 F2pLhgps8Wodq5jq82s2keQTSvbT6Nmv8x9Bq4ZVda3ABtoYC4IiJt4e6t+JkQ9fUnJh L3bRi3/eupbhZ3S9ZGVcya05VVGASrKLmkXkDQYzuGEbyzG6Y08EVVKUhsfQ8AoOUHxH 6O0rxmy+XSF320V1KCPZ/Lb9t2XEC0SLEBFq4NFNHNAN6b007y+88qhgIqonPE3eXVYj EWsDITUqwcl8VcEU56akEGOL/NVj+RCqV9SLwjEmD2EYq9tFx79kdzDQq6XAZuI2GED9 YCSg== X-Gm-Message-State: APjAAAWJbu2QBKQXQknWRKBnJt2MxPutirkWxKVEFKRS/2xWuA/6HXNG Iow748nhS/+EK22xGqS381YLr0vySJs= X-Google-Smtp-Source: APXvYqw2XUvopHwnVqskPQlAmRXSq2h9RNiq1cBl2602XFqH5KktCBPRCGBM5AAQU/yWDnaAI3ggUQ== X-Received: by 2002:a5d:44cd:: with SMTP id z13mr19077153wrr.104.1579531122991; Mon, 20 Jan 2020 06:38:42 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:42 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 12/29] bisect--helper: reimplement `bisect_next` and `bisect_auto_next` shell functions in C Date: Mon, 20 Jan 2020 15:37:43 +0100 Message-Id: <20200120143800.900-13-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 . Using `--bisect-next` and `--bisect-auto-start` 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-start` 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 | 10 +++ builtin/bisect--helper.c | 174 ++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 47 ++--------- 3 files changed, 188 insertions(+), 43 deletions(-) diff --git a/bisect.c b/bisect.c index 33f2829c19..1c13da8a28 100644 --- a/bisect.c +++ b/bisect.c @@ -635,6 +635,12 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs, struct argv_array rev_argv = ARGV_ARRAY_INIT; int i; + /* + * Since the code is slowly being converted to C, there might be + * instances where the revisions were initialized before. Thus + * we first need to reset it. + */ + reset_revision_walk(); repo_init_revisions(r, revs, prefix); revs->abbrev = 0; revs->commit_format = CMIT_FMT_UNSPECIFIED; @@ -971,6 +977,10 @@ void read_bisect_terms(const char **read_bad, const char **read_good) * finished successfully. * In this case the calling function or command should not turn a -10 * return code into an error or a non zero exit code. + * This returned -10 is checked in bisect_helper::bisect_next() and + * eventually transformed to 0 at the end of + * bisect_helper::cmd_bisect__helper(). + * * If no_checkout is non-zero, the bisection process does not * checkout the trial commit but instead simply updates BISECT_HEAD. */ diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 5e0f759d50..29bbc1573b 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"), NULL }; @@ -421,6 +424,157 @@ 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 string_list *good_refs = cb_data; + string_list_append(good_refs, oid_to_hex(oid)); + return 0; +} + +static void prepare_rev_argv(struct bisect_terms *terms, struct argv_array *rev_argv) +{ + struct string_list good_revs = STRING_LIST_INIT_DUP; + char *term_good = xstrfmt("%s-*", terms->term_good); + + for_each_glob_ref_in(register_good_ref, term_good, + "refs/bisect/", &good_revs); + + argv_array_pushl(rev_argv, "skipped_commits", "refs/bisect/bad", "--not", NULL); + for (int i = 0; i < good_revs.nr; i++) + argv_array_push(rev_argv, good_revs.items[i].string); + + string_list_clear(&good_revs, 0); + 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 + * setups 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") < 1) + return -1; + + 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); + } + + 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) +{ + FILE *fp = NULL; + 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 = 0; + + 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); + + fp = fopen(git_path_bisect_log(), "a"); + if (fp) { + if (fprintf(fp, "# first %s commit: [%s] %s\n", + terms->term_bad, oid_to_hex(&oid), + commit_name.buf) < 1) + res = -1; + fclose(fp); + } else { + res = error_errno(_("could not open '%s' for " + "appending"), + git_path_bisect_log()); + } + strbuf_release(&commit_name); + free(bad_ref); + return res; +} + +static int bisect_next(struct bisect_terms *terms, const char *prefix) +{ + int res, no_checkout; + + if (bisect_next_check(terms, terms->term_good)) + return -1; + + no_checkout = !is_empty_or_missing_file(git_path_bisect_head()); + + /* Perform all bisection computation, display and checkout */ + res = bisect_next_all(the_repository, prefix, no_checkout); + + if (res == -10) { + res = bisect_successful(terms); + return res ? res : -11; + } else if (res == -2) { + res = bisect_skipped_commits(terms); + return res ? res : -2; + } + return res; +} + +static int bisect_auto_next(struct bisect_terms *terms, const char *prefix) +{ + if (!bisect_next_check(terms, NULL)) + return bisect_next(terms, prefix); + + return 0; +} + static int bisect_start(struct bisect_terms *terms, int no_checkout, const char **argv, int argc) { @@ -625,7 +779,9 @@ 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_NEXT, + BISECT_AUTO_NEXT, } cmdmode = 0; int no_checkout = 0, res = 0, nolog = 0; struct option options[] = { @@ -649,6 +805,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_BOOL(0, "no-checkout", &no_checkout, N_("update BISECT_HEAD instead of checking out the current commit")), OPT_BOOL(0, "no-log", &nolog, @@ -710,6 +870,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; default: return error("BUG: unknown subcommand '%d'", cmdmode); } diff --git a/git-bisect.sh b/git-bisect.sh index efee12b8b1..7531b74708 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -87,7 +87,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 } @@ -140,45 +140,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 - 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() { @@ -232,7 +194,7 @@ bisect_replay () { die "$(gettext "?? what are you talking about?")" ;; esac done <"$file" - bisect_auto_next + git bisect--helper --bisect-auto-next } bisect_run () { @@ -329,7 +291,8 @@ case "$#" in bisect_skip "$@" ;; next) # Not sure we want "next" at the UI level anymore. - bisect_next "$@" ;; + get_terms + git bisect--helper --bisect-next "$@" || exit ;; visualize|view) bisect_visualize "$@" ;; reset) From patchwork Mon Jan 20 14:37:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11342375 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 A3944159A for ; Mon, 20 Jan 2020 14:38:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 818D822525 for ; Mon, 20 Jan 2020 14:38:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ClUFNhTj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728863AbgATOir (ORCPT ); Mon, 20 Jan 2020 09:38:47 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43472 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728831AbgATOiq (ORCPT ); Mon, 20 Jan 2020 09:38:46 -0500 Received: by mail-wr1-f68.google.com with SMTP id d16so29830615wre.10 for ; Mon, 20 Jan 2020 06:38:45 -0800 (PST) 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=XIy0Duhk99PbPXdNOWsjgIubuTGfCEk54TwIYCfF2Ic=; b=ClUFNhTjZ68/9Sv0q6jguCj55ynYdNM0dmLO1qZmUp/TKjppfW+hD2IwUtGuHVOvjh /Ih8c3uUgtziFm+XpqFvYiaplt5tbbGl2g4DmJiS4XU3pYAUlnGfNomf7lKxMMjtpfWx uMXoN/1whsl8xZAQxJ95YF4NYG/P0ealxhVVQ0rNuBIgzg8sbfaB+4tSx3hlNI+e4S/d xSZ6xaxgvHqpRdjIvDnrD5Y0TJwxJHRkeE7uog/JpyiMpJVf/Ej47d+Yol8iaAEEx6u0 j8jleNrsPgShJ4Nj3/+bgDBmBNhD04qJmKl2fZMe01RAP5pxSj6+tK5jQBZmMae4kmZS 8JjQ== 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=XIy0Duhk99PbPXdNOWsjgIubuTGfCEk54TwIYCfF2Ic=; b=BTwZRChz9O+hveY/j0Zput+4wpNzQtIVJh1pLLtX1fCzaZDEVxyy4iJN+bc4MxKcVD wS53LXPoBDmK2maf4ox0YctYSJNRHk/FSiyCJ6bhjajgO535FVc3wg1PwBzunp4i5my2 lqUsj+6kH27XFM1WIdRERla6Wfg7gc0ibFAv5WybDeoDI+sWhz1k8p6z+waL1W3pCmwb 7CxbiqGFrdKntXB04KO3SEXksxX34lk2ZTuN0RQAhOntK9mPNs6JiHKDuYU7Z4HEqbBP kqxzo4WS8BL6PgdiZla46LHfSRk70AL9xnT9ZYl6qmrV0WarbLO8lfVGEqZ48FFCNrWi Y/FA== X-Gm-Message-State: APjAAAU5mltVrl40VkKJY1GbrlRhjKkwE/BbocRAHTBIsihjJzRWwYxg 4UU0n3gGMkbOcmFIK8IVFhj2oyKSHMg= X-Google-Smtp-Source: APXvYqyXKDhDMsach+PM8va9JShphP5+WvshncigKSxL5tUNQzrZrwIwOB8Hc3apqu9ya8hWCQVnCQ== X-Received: by 2002:adf:ea4f:: with SMTP id j15mr18742090wrn.356.1579531124277; Mon, 20 Jan 2020 06:38:44 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:43 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 13/29] bisect--helper: finish porting `bisect_start()` to C Date: Mon, 20 Jan 2020 15:37:44 +0100 Message-Id: <20200120143800.900-14-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 | 38 +++++++++++++++++++++++++++++++++----- git-bisect.sh | 29 +++-------------------------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 29bbc1573b..e604334c91 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -632,9 +632,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 -1; + } string_list_append(&revs, oid_to_hex(&oid)); free(commit_id); @@ -715,9 +718,9 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, return -1; /* - * 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". */ @@ -764,6 +767,31 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, 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 -11 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 = -11 + */ + if (res && res != -11) + bisect_clean_state(); return res; } diff --git a/git-bisect.sh b/git-bisect.sh index 7531b74708..fec527e1ef 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -63,35 +63,13 @@ bisect_autostart() { [Nn]*) exit ;; esac - bisect_start + git bisect--helper --bisect-start else exit 1 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. - # - get_terms - git bisect--helper --bisect-auto-next || exit - - trap '-' 0 -} - bisect_skip() { all='' for arg in "$@" @@ -184,8 +162,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) @@ -284,7 +261,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 Jan 20 14:37:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11342379 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 1F362924 for ; Mon, 20 Jan 2020 14:38:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2D5B22522 for ; Mon, 20 Jan 2020 14:38:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KInWb7g+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728896AbgATOit (ORCPT ); Mon, 20 Jan 2020 09:38:49 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36315 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728709AbgATOir (ORCPT ); Mon, 20 Jan 2020 09:38:47 -0500 Received: by mail-wr1-f67.google.com with SMTP id z3so29847948wru.3 for ; Mon, 20 Jan 2020 06:38:46 -0800 (PST) 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=Qo+K54LDNNvRakb2fu62WPC6I5xEcHpgOLSRcyDPBO0=; b=KInWb7g+TLl22mN+uLyTbK2wYroC8Hav+Ay5GdBPF9sPaTRTyKpu78zNbLW/TPoyH0 +Y72WcIxh7MmvgzUTyZS7rp69tIz5es74rx9p7ieswpu5MyKhG0DZew7l+t9C5moUya9 6YTjCnv5yCuoqP65OQoXxVneclZze6wdocO5B8e5mpmvYkGGEDHu38az2fhSjjXGKdHT z3vi9+lqDWjX7Ycay0/6RLE2VDuHDrDqs5OVlP6NRWEfGmbfjkjWwsPd34YFNyRmbAas oB6Cv2GivQlOfnSY2XHrxBKrJPzf0HscXQkIUAuU8LMZfy79IzByVYnFvCYcxp1fkk9H /sYA== 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=Qo+K54LDNNvRakb2fu62WPC6I5xEcHpgOLSRcyDPBO0=; b=O93ogqYz81bftieUoCiH+eRyr353ko/MsuAgy9eGY1e8rEh6d3ynS3Zhlkj9xL0hLw rIq0q2b29gINozNcM37fXEkI5fXmqF8H1xZcJ4fl25hbz1v9p86GcnYg+aUuTvewHmb1 NWal+VwTABJPgM4MeqqPVcJ7zN1HtEE+R7eeRY31DArZ30Wc38NtsvijJJTQ9gQcE5tN fZSI/dWonQ3eucrzHuA53GgbhNUd+G/PqEbW6wY6KTgk0RsutIjYAU7kdrBuKP95zIip uUWSYx602RNW9uAqkQbiwh8DukEe5yUFw1Th4Oh284UMfu7fiU3nE0arZWalHAQ5V3Cv 2dgA== X-Gm-Message-State: APjAAAVg8VUeXh9zLuKOYau97a4NYx/nCf5w4V82KthplRc03wO1wvr4 mmjKllxaBTN1vHmGSTYHqIvatTZuD9Q= X-Google-Smtp-Source: APXvYqw3ZjZQVOxLHFZzEahQ8zSahs7OFIvF1Yp6sb7MGDw68rYUUAXou/WTRWQqOLEQ4pDpROXGEw== X-Received: by 2002:a5d:6305:: with SMTP id i5mr18944474wru.399.1579531125437; Mon, 20 Jan 2020 06:38:45 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:45 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Tanushree Tumane , Miriam Rubio Subject: [PATCH 14/29] bisect--helper: retire `--bisect-clean-state` subcommand Date: Mon, 20 Jan 2020 15:37:45 +0100 Message-Id: <20200120143800.900-15-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 e604334c91..7190304a98 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 "), @@ -800,7 +799,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, @@ -817,8 +815,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, @@ -860,10 +856,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 Jan 20 14:37:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11342381 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 140BC924 for ; Mon, 20 Jan 2020 14:38:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E675922464 for ; Mon, 20 Jan 2020 14:38:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MqsSApb4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728913AbgATOiv (ORCPT ); Mon, 20 Jan 2020 09:38:51 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46484 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728853AbgATOis (ORCPT ); Mon, 20 Jan 2020 09:38:48 -0500 Received: by mail-wr1-f68.google.com with SMTP id z7so29772380wrl.13 for ; Mon, 20 Jan 2020 06:38:47 -0800 (PST) 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=IhNlePj7c7w7f9rdB4Q9xDKd38rWgO5jV1D012eatZA=; b=MqsSApb4KZkETzVCA42LFr2EYs0aCjsYocOIhHFVyvu3UXpnY/54D8xeAKne+foOUn z6TLm6PfSt5plxsGVSjckJ9DRoky0hHUwglTNJNsiDPeGyesNFIQKc/d0iOQ/OXttcdL vO57w1/PimFX0PI0d0TJrlkuMhaLoBlesOLQOpffNpdz0Z/UhMJaUW9CZwBQRKagKVRH vQcK1hA/9AEcqmb1wwitrJXkiDUgfjthkjXzzr+RaTSBQr/5MY8Sm/zKVytfcIHMmzaV oQUoMhGQfU0Xsr2bHWWKFbWTtAlRT4AsHFru+iWcotDK7e+gqAzu1AlZV2ZbBnNyjZ9I 1zVQ== 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=IhNlePj7c7w7f9rdB4Q9xDKd38rWgO5jV1D012eatZA=; b=TXNn1fEdBGouXYrl64YqffkiUFVUUmXAQwIiOwsP++VuCTFmbnP6p0aH0b87pF2EL9 nmfxb6tUIuw6zW1/AagP1F7TT/a0j8HOOthRupOyl2LSman+QjSy6I7PTAd7JCBj/nlf XCihssnwroUVD0fh2LOeFwhFgBcCDcISgoKzmtAI14LTi9DP/SVQP6bV4eHzK0U0MfNm bLaCIE3kiiTybmkdIMArAaHl8m1KoIgLtUquhFXJXF9UliDQK0GfVp/7UdBWKA5ae7qK 0tQM9uLjxcdNOHXIycYf1VL/jd+uEdpiHFWgFQCYJUa8IotBnE4hD5qjqIWrDULsFR5R 7Rsw== X-Gm-Message-State: APjAAAWKFKnlBNaN3OTAG60CAOSJrnUazkxfesQIITOS2H1yjnaLbZuY 8UDG+mn5X99LUZKViqW+BbX3o3bSB8I= X-Google-Smtp-Source: APXvYqy9Uz+arvprwEKQVfFpxO8mwPkdeZHWixjjuykSlFsufKPbyzkVcRQzKFZCMcRo0ezsx24rYQ== X-Received: by 2002:adf:ff84:: with SMTP id j4mr18826333wrr.27.1579531126602; Mon, 20 Jan 2020 06:38:46 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:46 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Tanushree Tumane , Miriam Rubio Subject: [PATCH 15/29] bisect--helper: retire `--next-all` subcommand Date: Mon, 20 Jan 2020 15:37:46 +0100 Message-Id: <20200120143800.900-16-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 7190304a98..6953c68f93 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] "), @@ -797,8 +796,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, 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, @@ -811,8 +809,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, @@ -849,9 +845,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 Mon Jan 20 14:37:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11342385 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 0E932159A for ; Mon, 20 Jan 2020 14:38:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2A5722464 for ; Mon, 20 Jan 2020 14:38:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MI12mwFT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728928AbgATOiw (ORCPT ); Mon, 20 Jan 2020 09:38:52 -0500 Received: from mail-wr1-f46.google.com ([209.85.221.46]:38187 "EHLO mail-wr1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728831AbgATOit (ORCPT ); Mon, 20 Jan 2020 09:38:49 -0500 Received: by mail-wr1-f46.google.com with SMTP id y17so29850247wrh.5 for ; Mon, 20 Jan 2020 06:38:48 -0800 (PST) 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=GOlUYXysL8hTlc9pOBhOuUOphhwKLaK2FXy+Dwox900=; b=MI12mwFTmCp6qUVESALvvU/qIa29q/pxDS3bQ/di+q5b+84KaRoSfwwDDeKUsr5pVA uZjEDqbIzGHJ4iHzBxWJohPBvnZ85ftYHzPl10idNggWZ55kFhYLRXGahGOhJx7lP9PV yi/raZ/7bDB3lIpvJr+6gGLiQiFoHx8VSl8bXf5EqLH8rrwBhxpMWznwbdXsN/oVfSQb 0tY8uFTmBY/LSV8/MbZxRg4EUQPuMnajLUoZ6fo18FFqLC99HzFvYXoek1msvCtqZ+qY ZUZvW4hd+q6p2k91XobL8AubE6v+UBD1PAu/wlm5T2lq9ysQF4RoZaZEtf7TvdSS8WiN /4vw== 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=GOlUYXysL8hTlc9pOBhOuUOphhwKLaK2FXy+Dwox900=; b=JYrRmr14qZIlrRkwDm1S0IM7iTgK87EuruleCqH+LAB/DlvGsQVuP+FoT46QAo+WrB 2QbgnCv5cNiRE+KWsWCkj3qiqoHYP5syjOh1D62ScvBo8L/TwICripd270YqRi77F3Q3 8Ck+v8edxiVdXInkns5dum+sF8840tt9qOPJGdtA93vZYZ4C1lbqm4sLl2TD9ZqGfqcy 8VjdfSh/AaXMK9nIqiPrcbQFITpvf0oVty/iSOVxhOD4MTQXpVb+63ZsdEpWuOWC08tN gtqcY3H1VD5S1lLw1FIyNXTe1Az1DyIu7fm/mzead/z1QcKs9ZvZkfdp+k9/YtRQOUNJ lA/w== X-Gm-Message-State: APjAAAUecCSUIuboqj2zgpdnHnOqu7c5MiAI+1BEzCbmvdfv86N7jGUz ewGLBIFFK3O4YHUmFm3AcyHPqHKa7/E= X-Google-Smtp-Source: APXvYqys8RSIhA3rNCdKpVU/EaBtDv19lKdFN+/Ns9d8HXDhovUpA7HN4Dwx1kKFnViZPzblho6ziQ== X-Received: by 2002:adf:82a7:: with SMTP id 36mr19134512wrc.203.1579531127935; Mon, 20 Jan 2020 06:38:47 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:47 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 16/29] bisect--helper: reimplement `bisect_autostart` shell function in C Date: Mon, 20 Jan 2020 15:37:47 +0100 Message-Id: <20200120143800.900-17-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 | 39 +++++++++++++++++++++++++++++++++++++++ git-bisect.sh | 23 +---------------------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 6953c68f93..f03ed23431 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -30,6 +30,7 @@ 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"), NULL }; @@ -56,6 +57,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. @@ -547,6 +550,7 @@ static int bisect_next(struct bisect_terms *terms, const char *prefix) { int res, no_checkout; + bisect_autostart(terms); if (bisect_next_check(terms, terms->term_good)) return -1; @@ -793,6 +797,32 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, return res; } +static int bisect_autostart(struct bisect_terms *terms) +{ + if (is_empty_or_missing_file(git_path_bisect_start())) { + const char *yesno; + const char *argv[] = {NULL}; + 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, argv, 0); + } + return 0; +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { @@ -806,6 +836,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_START, BISECT_NEXT, BISECT_AUTO_NEXT, + BISECT_AUTOSTART, } cmdmode = 0; int no_checkout = 0, res = 0, nolog = 0; struct option options[] = { @@ -829,6 +860,8 @@ 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_BOOL(0, "no-checkout", &no_checkout, N_("update BISECT_HEAD instead of checking out the current commit")), OPT_BOOL(0, "no-log", &nolog, @@ -895,6 +928,12 @@ 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; default: return error("BUG: unknown subcommand '%d'", cmdmode); } diff --git a/git-bisect.sh b/git-bisect.sh index fec527e1ef..97bb15b38f 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 - git bisect--helper --bisect-start - else - exit 1 - fi - } -} - bisect_skip() { all='' for arg in "$@" @@ -86,7 +65,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 From patchwork Mon Jan 20 14:37:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11342383 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 7221C6C1 for ; Mon, 20 Jan 2020 14:38:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4661522314 for ; Mon, 20 Jan 2020 14:38:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RXMCaUhs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728978AbgATOix (ORCPT ); Mon, 20 Jan 2020 09:38:53 -0500 Received: from mail-wr1-f45.google.com ([209.85.221.45]:34115 "EHLO mail-wr1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728709AbgATOiw (ORCPT ); Mon, 20 Jan 2020 09:38:52 -0500 Received: by mail-wr1-f45.google.com with SMTP id t2so29834678wrr.1 for ; Mon, 20 Jan 2020 06:38:50 -0800 (PST) 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=0d36u0TnqROHGHw4em5qvi5lNbyt5d5MgsR7trTkb0U=; b=RXMCaUhsAWB/JPc7pOLUfZfGHm7TsM3mIIKNTo5s6U8NIvG5vQzAYxrQYpRFB5Sx6Z iPjxz9E4NeCDZ78cPz1LDXEfOQfOVD/7apPAikEp5NKUfhWnqNGPdk1B8qVhnC4lla8R US0PNBzN8O5f0pYTH2aDsD13PpztkPa1/IfzqirDsNz2EsDCULKpJbmg4JoJBzvOGm4D +Gka4VUOFAzABcY+KP1CXReGRjBzO5bvXW/LIRV9qwyLgpYwlofSw1czmnmDnUVW0f3v YJpAQDE5sF5aCN1n81tQHeRL7l+CUVEJ25YLShrAHza0aDEm+ciC2ZYoKA/BiQk6Qw4x coAA== 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=0d36u0TnqROHGHw4em5qvi5lNbyt5d5MgsR7trTkb0U=; b=MOmAPueNvrA8kwsWyAyj7CfyVkD1/3c4fk6bLaPxLa9db7eo/4KMGJIHl5ZgZ1ThfQ iEROz8LJuDU4K0yA2qoN/YmNWKwzUYf0cZAQOjcsTkSjLLQGZen4S+kt62j9v1X9kyyQ gaXGJABi6yzERnXVodbpyJEujhTO8cHjNiVbZpMzqg4qkMdUA7KvJiqXLyleHyuLpMjz NmiOhPKhO7h9elHE/iO5NwXcsRC8s8c2ZnedXOhzQf2uQ3EOA7As/j8BcjDxCP9Ydfs1 /gddAuz1QDMAUbrLDQztqHllRo8o+IbMDwzNMvahKsBHJIIAlvi0hM7WK94diW0wLTqd t5eA== X-Gm-Message-State: APjAAAU6JbP/Pd2H0zXpVtF6YHksov4cILU10+OPcfHpXMgFM0uLkrF6 CaDmtfB4Voxm4EJ6aN9t5I6O2Ne+eP4= X-Google-Smtp-Source: APXvYqyBSOMJU+s9H+k0OFiJ1S5FF+HaKUlv3Pw8o+KX6eZ1fLDfh60VTys0XxsKaraRJinQrrhJJw== X-Received: by 2002:a5d:5452:: with SMTP id w18mr17774231wrv.333.1579531129251; Mon, 20 Jan 2020 06:38:49 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:48 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 17/29] bisect--helper: reimplement `bisect_state` & `bisect_head` shell functions in C Date: Mon, 20 Jan 2020 15:37:48 +0100 Message-Id: <20200120143800.900-18-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 | 80 ++++++++++++++++++++++++++++++++++++++++ git-bisect.sh | 55 ++------------------------- 2 files changed, 84 insertions(+), 51 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index f03ed23431..fdcc5f47ec 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 }; @@ -823,6 +825,74 @@ static int bisect_autostart(struct bisect_terms *terms) return 0; } +static char *bisect_head(void) +{ + if (is_empty_or_missing_file(git_path_bisect_head())) + return "HEAD"; + else + return "BISECT_HEAD"; +} + +static int bisect_state(struct bisect_terms *terms, const char **argv, + int argc) +{ + const char *state = argv[0]; + + if (check_and_set_terms(terms, state)) + return -1; + + if (!argc) + return error(_("Please call `--bisect-state` with at least one argument")); + + if (argc == 1 && one_of(state, terms->term_good, + terms->term_bad, "skip", NULL)) { + const char *bisected_head = xstrdup(bisect_head()); + const char *hex[1]; + struct object_id oid; + + if (get_oid(bisected_head, &oid)) + return error(_("Bad rev input: %s"), bisected_head); + if (bisect_write(state, oid_to_hex(&oid), terms, 0)) + return -1; + + *hex = xstrdup(oid_to_hex(&oid)); + check_expected_revs(hex, 1); + return bisect_auto_next(terms, NULL); + } + + if ((argc == 2 && !strcmp(state, terms->term_bad)) || + one_of(state, terms->term_good, "skip", NULL)) { + int i; + struct string_list hex = STRING_LIST_INIT_DUP; + + for (i = 1; i < argc; i++) { + struct object_id oid; + + if (get_oid(argv[i], &oid)) { + string_list_clear(&hex, 0); + return error(_("Bad rev input: %s"), argv[i]); + } + string_list_append(&hex, oid_to_hex(&oid)); + } + for (i = 0; i < hex.nr; i++) { + const char **hex_string = (const char **) &hex.items[i].string; + if (bisect_write(state, *hex_string, terms, 0)) { + string_list_clear(&hex, 0); + return -1; + } + check_expected_revs(hex_string, 1); + } + string_list_clear(&hex, 0); + return bisect_auto_next(terms, NULL); + } + + if (!strcmp(state, terms->term_bad)) + return error(_("'git bisect %s' can take only one argument."), + terms->term_bad); + + return -1; +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { @@ -837,6 +907,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_NEXT, BISECT_AUTO_NEXT, BISECT_AUTOSTART, + BISECT_STATE } cmdmode = 0; int no_checkout = 0, res = 0, nolog = 0; struct option options[] = { @@ -862,6 +933,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, @@ -934,6 +1007,13 @@ 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: + if (!argc) + return error(_("--bisect-state requires at least one revision")); + set_terms(&terms, "bad", "good"); + get_terms(&terms); + res = bisect_state(&terms, argv, argc); + break; default: return error("BUG: unknown subcommand '%d'", cmdmode); } diff --git a/git-bisect.sh b/git-bisect.sh index 97bb15b38f..4a5afc7a93 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 Mon Jan 20 14:37:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11342389 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 68C94924 for ; Mon, 20 Jan 2020 14:38:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 47B4522464 for ; Mon, 20 Jan 2020 14:38:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="We8Ve89p" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729008AbgATOi4 (ORCPT ); Mon, 20 Jan 2020 09:38:56 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37499 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728901AbgATOiw (ORCPT ); Mon, 20 Jan 2020 09:38:52 -0500 Received: by mail-wr1-f68.google.com with SMTP id w15so29888244wru.4 for ; Mon, 20 Jan 2020 06:38:51 -0800 (PST) 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=gkIG+TgGuReEDBRCRuROnJGRBmrj5UKSDbP9LCNLUjQ=; b=We8Ve89pRYZYIWq7zynWfBmRio1hIwggzb27jZy8bGp4d1VY5ijXTGsgrvPL0NFiwL QSOzEeY499MRcVAGGNv1djpmBPImCgak8vl1OBJxTCnAtnTsdlNnxIV81AI/HRApWYGl Es8RTnye4fE/kBzxm4DnwqTl+RMewASRxmM2bHIDwUo31JHzaGVaO7sBGjEcQXk8jQXn 07uQmEbxAyPslFGLTJB/z7JBFJjvIuE35bMdRpBa+3072+K0DJmiDsuRJCvniDUf/86J iJ8TNr0hpN253PHzxFG0IHs08+i42D/4PJ6ygpAuAsPZufLcqbgZ/4TLLyaSeDPQP448 vurQ== 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=gkIG+TgGuReEDBRCRuROnJGRBmrj5UKSDbP9LCNLUjQ=; b=Pgn8SKERYLZDqAYpWkRtKnGPRwMBfAbSpfkQZKWpDnq6LX0KZVbuc2GxGQjVCfSuei iipoaYjCji20NtnKI7a+pGjAxluF5eaDaWl5c22cRFV2FAWlHQB7W8ebB6CGOXs2tk99 2wiQ6Z32VPVpupCKAZQybBuPM/sydo7Y31hyZBmSZFJgF7BO/KTOoCAgZwLvCXvuHNi5 YEosR5HBFiiM+tJ6gStLPTOH5piGtKb+pnPGNmysdtBsWPQoGGEGUgDO8+Tz9d8ur9WS atVfjjWQD1B3ZmTr+BjwUBkSuIuuu2AwIiyiEB9aVZeklR09bAVRhpacE/7NZ0KPpQWn J64g== X-Gm-Message-State: APjAAAUFQStYT5NWGhSvNpw9onpvre7sHPB2XK3J6ewr9ZrpmGYL/iwB 83AWMPPivRAIXtjmxK7VdPtUWyigTHo= X-Google-Smtp-Source: APXvYqwU2XBsf3eB8xZUpogfYEWGnxgk2U1Znuegqksi1R1tTdJcJ2yvkEwKgjBy7zChuR70CBxnqw== X-Received: by 2002:adf:a109:: with SMTP id o9mr18740593wro.189.1579531130525; Mon, 20 Jan 2020 06:38:50 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:50 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 18/29] bisect--helper: retire `--check-expected-revs` subcommand Date: Mon, 20 Jan 2020 15:37:49 +0100 Message-Id: <20200120143800.900-19-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 fdcc5f47ec..3868d34a29 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -897,7 +897,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, @@ -913,8 +912,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, @@ -955,9 +952,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 Jan 20 14:37:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11342387 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 511E1924 for ; Mon, 20 Jan 2020 14:38:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2FC6722314 for ; Mon, 20 Jan 2020 14:38:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XUfS95Fi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728988AbgATOiz (ORCPT ); Mon, 20 Jan 2020 09:38:55 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42095 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728921AbgATOiy (ORCPT ); Mon, 20 Jan 2020 09:38:54 -0500 Received: by mail-wr1-f66.google.com with SMTP id q6so29729899wro.9 for ; Mon, 20 Jan 2020 06:38:52 -0800 (PST) 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=JPzfknqnB/AQ3WDH8t/xlCoGz47tpu6JaVcaUDNnLGY=; b=XUfS95FiflQNzxSYF8hYFOt4kffhDRjYeCUBZJ+Fb6hYvKas3bhS8/VlNtM8GZZYJF jECAzdrDtctFs+Kd16SBcWCQw0ZadkQgrcZeAObCB9e3r1mDmhRO0E92FD5Ws3FSCFQt bAH0A5G//VvTFHwQORiFIPBJXej+RYkqdJrbmS1ststbZJN8YDVGc8XGtZrBvzNXueOC IRIsEoyO/8bGm1CSZMBeImtG11uDRSrljpp60OlZP9I9FX8I9GZo9bhBzeHe1IX8eZGR z3uDMGX69Oi4HinO78nDF1Rk1t8jN10RXzDAe5WzWSRrZe4J35fS9hpYMQkRw5w5sQTK AerA== 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=JPzfknqnB/AQ3WDH8t/xlCoGz47tpu6JaVcaUDNnLGY=; b=mT+gOHE4JDG45T8gL208trQYkWOw+uOtgMYDCtNyPeJFXcTwXOcFtMBRRIaF2Qrrn/ T4NZnRgCPV/8JIbqSSdz/CQ7SVZbMbQSv3bm4FHOfwqdWFx/M6diY5E8p2C4K263/69m tFij1xInzG0YK2mkAUefQKX7IyuZdIeZkyfb9GJNTvpAe6kpz9AMvkJoxC9VFumeUY8j iPffK1XIp2/vaOTTfGV7bS1XIjVZEmpNoWeyQ4ie6nnSIftX0iScLozTJ225qRW0i0l6 ss/2+0gt6gT7+BnXL11YLcFfuYX3dFm0yAB0+KsvT1M/NiYEK8Avak58NSMBGxftw1W/ vgqQ== X-Gm-Message-State: APjAAAXBsGRfdNF72trJzO6are0plWDiONDX3M0Ja9b5Mw7igUJCUkok ETgG5sILlT7/zzHy56bjJwsaYRbnAJo= X-Google-Smtp-Source: APXvYqwhoYAS27tkGWPZQDmj9HY2MYDHTkFlqjzRsR/znSclKko2Dpb5tw1uqdNK5HvSulN3bLUwsA== X-Received: by 2002:adf:e290:: with SMTP id v16mr19245751wri.16.1579531131848; Mon, 20 Jan 2020 06:38:51 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:51 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 19/29] bisect--helper: retire `--write-terms` subcommand Date: Mon, 20 Jan 2020 15:37:50 +0100 Message-Id: <20200120143800.900-20-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 3868d34a29..4ff8035cd8 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 "), @@ -896,8 +895,7 @@ static int bisect_state(struct bisect_terms *terms, const char **argv, 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, @@ -910,8 +908,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, @@ -948,10 +944,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 Jan 20 14:37:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11342391 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 D22936C1 for ; Mon, 20 Jan 2020 14:38:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B12F322464 for ; Mon, 20 Jan 2020 14:38:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NUEUQ0+t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729022AbgATOi6 (ORCPT ); Mon, 20 Jan 2020 09:38:58 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:50457 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728709AbgATOiy (ORCPT ); Mon, 20 Jan 2020 09:38:54 -0500 Received: by mail-wm1-f68.google.com with SMTP id a5so14748208wmb.0 for ; Mon, 20 Jan 2020 06:38:53 -0800 (PST) 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=YH/6cvLSMNBqAwybMMY2K2J8ycTikeC6mftg5OrOzG0=; b=NUEUQ0+tFqdhQrhkdI142KSkFcKYNaUxfX6sNZNxGNfzl/vGBZtbmhpTr+yu5fi89E +zdoztxcJFCASuVYYR5d5Fu4olPX+rSK+OR5T/fuoDRI/BhnECPfV/JSl7TFxH4rmzjF YfC6PXeqi7X3QHtGqFxhOyQMSd4MDJfGJrhwtkUZA301GmHykk6HEfnCVy70zRGfrblc 1K+xq/br4bPogbso7i23bntJyqNrRy2yThw+VhTw9+ok3BbzuaqaKkpht/nzMHAZBeQR obwNGPZ11QjJHRCrBmfiR25p37bn6x6Kt6aimkuaqgmFpt+n0crjBIa0tr9KBr+lZn2j GTEg== 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=YH/6cvLSMNBqAwybMMY2K2J8ycTikeC6mftg5OrOzG0=; b=TDKsZdNOUnvSCNYITvajdMMb9YwqpDgOa34YPQhVYciKOddmwfInN5p0jMTYB2Iq/x jCVXEuYxGaxaDRevJMkxidZxNC8+J/gGGmticbWK8V/Kg895HW4hIrqQ8/1Cog6lhf3Y G+xWDEDhu2ZbTkavmCSQGycoHaRlt1ssFSPvPnjU97EZvx1eI5dMMDMOVZpDHUxFZndO qjltTJtttxuEqveujYsiQqcpFYo9aUHfYChmIy/Iz8nTeuRX6oT2GMzNRIWWKQ4g/BpW fcIRy8q6xOxd4P/wdBh3b2yPACAipckrxKtkpq+G4Ko6+oDVxQFMXzRkkjJ4sOewh6YJ wtFg== X-Gm-Message-State: APjAAAWdzJifRMs78siVoSgp6RbUs1bR7IfrennHAmyvT9xUl2mOdL7P CcUhA1oi46y7pu/gsbQtxjxFQpcvTYQ= X-Google-Smtp-Source: APXvYqxMlvbia7+aA3a5Gwt6Ve+NhXs7qPZcx0W+iIkeCNMNDI41P/RCdiuaN4d1y8k4A8S4LZwq4A== X-Received: by 2002:a05:600c:2c06:: with SMTP id q6mr20134629wmg.154.1579531133094; Mon, 20 Jan 2020 06:38:53 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:52 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 20/29] bisect--helper: reimplement `bisect_log` shell function in C Date: Mon, 20 Jan 2020 15:37:51 +0100 Message-Id: <20200120143800.900-21-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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_log()` shell function in C and also add `--bisect-log` subcommand to `git bisect--helper` to call it from git-bisect.sh . Using `--bisect-log` subcommand is a temporary measure to port shell function to C so as to use the existing test suite. 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 | 22 +++++++++++++++++++++- git-bisect.sh | 7 +------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 4ff8035cd8..4795b7880c 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -892,6 +892,18 @@ static int bisect_state(struct bisect_terms *terms, const char **argv, return -1; } +static int bisect_log(void) +{ + int fd, status; + fd = open(git_path_bisect_log(), O_RDONLY); + if (fd < 0) + return -1; + + status = copy_fd(fd, STDOUT_FILENO); + close(fd); + return status ? -1 : 0; +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { @@ -904,7 +916,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_NEXT, BISECT_AUTO_NEXT, BISECT_AUTOSTART, - BISECT_STATE + BISECT_STATE, + BISECT_LOG } cmdmode = 0; int no_checkout = 0, res = 0, nolog = 0; struct option options[] = { @@ -928,6 +941,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) 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_CMDMODE(0, "bisect-log", &cmdmode, + N_("output the contents of BISECT_LOG"), BISECT_LOG), OPT_BOOL(0, "no-checkout", &no_checkout, N_("update BISECT_HEAD instead of checking out the current commit")), OPT_BOOL(0, "no-log", &nolog, @@ -1000,6 +1015,11 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) get_terms(&terms); res = bisect_state(&terms, argv, argc); break; + case BISECT_LOG: + if (argc > 1) + return error(_("--bisect-log requires 0 arguments")); + res = bisect_log(); + break; default: return error("BUG: unknown subcommand '%d'", cmdmode); } diff --git a/git-bisect.sh b/git-bisect.sh index 4a5afc7a93..151358aeda 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -167,11 +167,6 @@ exit code \$res from '\$command' is < 0 or >= 128" >&2 done } -bisect_log () { - test -s "$GIT_DIR/BISECT_LOG" || die "$(gettext "We are not bisecting.")" - cat "$GIT_DIR/BISECT_LOG" -} - get_terms () { if test -s "$GIT_DIR/BISECT_TERMS" then @@ -209,7 +204,7 @@ case "$#" in replay) bisect_replay "$@" ;; log) - bisect_log ;; + git bisect--helper --bisect-log ;; run) bisect_run "$@" ;; terms) From patchwork Mon Jan 20 14:37:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Miriam R." X-Patchwork-Id: 11342393 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 966B0924 for ; Mon, 20 Jan 2020 14:39:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6B52922314 for ; Mon, 20 Jan 2020 14:39:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EBpQrKi2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729047AbgATOi7 (ORCPT ); Mon, 20 Jan 2020 09:38:59 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39892 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728992AbgATOi5 (ORCPT ); Mon, 20 Jan 2020 09:38:57 -0500 Received: by mail-wr1-f68.google.com with SMTP id y11so29822528wrt.6 for ; Mon, 20 Jan 2020 06:38:55 -0800 (PST) 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=JJqn+RjswlxjZ5TZ5CR3uaYYOaI2PlfIF5pz3kxr92A=; b=EBpQrKi2mmfOKR3uDJ+l50LAT0ioEShQHBoCOZmlxAwuaoL44Ox08mKu8UxdVnBuix jlQ2FDAin868ZLB1Du1/sSo6OQsYTkdSdXICa/n7/33Xrokxwl/foL4V2s/Lm0UQgqVV QAmC/tAtbL9Ka/La30FdLeAvgOaXnLXicZEcNbGjvjac2QkuVS0OlHN9ryCVdtYgDAIA 7d3OEUNtjusUdyBS9uJhh8swwUBgI9xRYoN3mhhNTgkjW5ESHxgbqG7U0/0Pc/na+lYp whJS06XJVW+QraSBqFX6mVolUNsm29N/K9e0Sro863fgzK+cGHPETGsFLae4nIu/+0vV ksLA== 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=JJqn+RjswlxjZ5TZ5CR3uaYYOaI2PlfIF5pz3kxr92A=; b=lWKyimC1CohADc8X4JDAd9xz6Dvh/ug6W2nIgJCcIOTmpDJImRdYpoxtVafyO3BAsq VYB+iZttqGYukIObzL0RdfBZZBG7tJ+0is6qYQ9ieIH/guS2C3QCaUiceT5ImSCziNMI xxjC6SdPNgOphyFEsTc4+1z4cR15AWG57ATHxMXJ9BWWPdPIMXNbUerSxKs3GsHcoxsM CW5c9fq7RmD64D+lNnyRBQSN3OVVsBtJsqz2Rz3dJLA35POdRL8yVMyEPLKkhKgN9jcB nMp/yMXPWHDF4lF9s9XSRkbamhuH3L3rlQeg0cdy7pPYIeBPNZrCUlxGCv+xQZJp7nwy QnjA== X-Gm-Message-State: APjAAAXOOoiEvw6Mo3piBBS/UyQKGQKNx67dep21+YKTMC7u+jCN+mmE +Awwxp6hAQ3ioj3UvtJW+Rc/ibjq5Kk= X-Google-Smtp-Source: APXvYqzhWPP96e4N6X50ecp+iAqYY+zpB8QWKoB4l6X3l7A//EAYZJ6k3sZnK5IQaNsi/z01c4ndSg== X-Received: by 2002:adf:b648:: with SMTP id i8mr18566296wre.91.1579531134338; Mon, 20 Jan 2020 06:38:54 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:53 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 21/29] bisect--helper: reimplement `bisect_replay` shell function in C Date: Mon, 20 Jan 2020 15:37:52 +0100 Message-Id: <20200120143800.900-22-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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_replay` shell function in C and also add `--bisect-replay` subcommand to `git bisect--helper` to call it from git-bisect.sh Using `--bisect-replay` subcommand is a temporary measure to port shell function to C so as to use the existing test suite. 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 | 127 ++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 32 +--------- 2 files changed, 127 insertions(+), 32 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 4795b7880c..4b4ce13b50 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -32,6 +32,7 @@ static const char * const git_bisect_helper_usage[] = { N_("git bisect--helper --bisect-autostart"), N_("git bisect--helper --bisect-state (bad|new) []"), N_("git bisect--helper --bisect-state (good|old) [...]"), + N_("git bisect--helper --bisect-replay "), NULL }; @@ -904,6 +905,121 @@ static int bisect_log(void) return status ? -1 : 0; } +static int get_next_word(const char *line, int pos, struct strbuf *word) +{ + int i, len = strlen(line), begin = 0; + + strbuf_reset(word); + for (i = pos; i < len; i++) { + if (line[i] == ' ' && begin) + return i + 1; + + if (!begin) + begin = 1; + strbuf_addch(word, line[i]); + } + + return i; +} + +static int process_line(struct bisect_terms *terms, struct strbuf *line, struct strbuf *word) +{ + int res = 0; + int pos = 0; + + while (pos < line->len) { + pos = get_next_word(line->buf, pos, word); + + if (!strcmp(word->buf, "git")) + continue; + else if (!strcmp(word->buf, "git-bisect")) + continue; + else if (!strcmp(word->buf, "bisect")) + continue; + else if (starts_with(word->buf, "#")) + break; + + get_terms(terms); + if (check_and_set_terms(terms, word->buf)) + return -1; + + if (!strcmp(word->buf, "start")) { + struct argv_array argv = ARGV_ARRAY_INIT; + int res; + sq_dequote_to_argv_array(line->buf+pos, &argv); + res = bisect_start(terms, 0, argv.argv, argv.argc); + argv_array_clear(&argv); + if (res) + return -1; + break; + } + + if (one_of(word->buf, terms->term_good, + terms->term_bad, "skip", NULL)) { + if (bisect_write(word->buf, line->buf+pos, terms, 0)) + return -1; + break; + } + + if (!strcmp(word->buf, "terms")) { + struct argv_array argv = ARGV_ARRAY_INIT; + int res; + sq_dequote_to_argv_array(line->buf+pos, &argv); + res = bisect_terms(terms, argv.argc == 1 ? argv.argv[0] : NULL); + argv_array_clear(&argv); + if (res) + return -1; + break; + } + + error(_("Replay file contains rubbish (\"%s\")"), + word->buf); + res = -1; + } + return res; +} + +static int process_replay_file(FILE *fp, struct bisect_terms *terms) +{ + struct strbuf line = STRBUF_INIT; + struct strbuf word = STRBUF_INIT; + int res = 0; + + while (strbuf_getline(&line, fp) != EOF) { + res = process_line(terms, &line, &word); + if (res) + break; + } + + strbuf_release(&line); + strbuf_release(&word); + return res; +} + +static int bisect_replay(struct bisect_terms *terms, const char *filename) +{ + FILE *fp = NULL; + int res = 0; + + if (is_empty_or_missing_file(filename)) + return error(_("cannot read file '%s' for replaying"), filename); + + if (bisect_reset(NULL)) + return -1; + + fp = fopen(filename, "r"); + if (!fp) + return -1; + + res = process_replay_file(fp, terms); + fclose(fp); + + if (res) + return -1; + + return bisect_auto_next(terms, NULL); +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { @@ -917,7 +1033,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_AUTO_NEXT, BISECT_AUTOSTART, BISECT_STATE, - BISECT_LOG + BISECT_LOG, + BISECT_REPLAY } cmdmode = 0; int no_checkout = 0, res = 0, nolog = 0; struct option options[] = { @@ -943,6 +1060,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("mark the state of ref (or refs)"), BISECT_STATE), OPT_CMDMODE(0, "bisect-log", &cmdmode, N_("output the contents of BISECT_LOG"), BISECT_LOG), + OPT_CMDMODE(0, "bisect-replay", &cmdmode, + N_("replay the bisection process from the given file"), BISECT_REPLAY), OPT_BOOL(0, "no-checkout", &no_checkout, N_("update BISECT_HEAD instead of checking out the current commit")), OPT_BOOL(0, "no-log", &nolog, @@ -1020,6 +1139,12 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) return error(_("--bisect-log requires 0 arguments")); res = bisect_log(); break; + case BISECT_REPLAY: + if (argc != 1) + return error(_("no logfile given")); + set_terms(&terms, "bad", "good"); + res = bisect_replay(&terms, argv[0]); + break; default: return error("BUG: unknown subcommand '%d'", cmdmode); } diff --git a/git-bisect.sh b/git-bisect.sh index 151358aeda..0555191c41 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -77,36 +77,6 @@ bisect_visualize() { eval '"$@"' --bisect -- $(cat "$GIT_DIR/BISECT_NAMES") } -bisect_replay () { - file="$1" - test "$#" -eq 1 || die "$(gettext "No logfile given")" - test -r "$file" || die "$(eval_gettext "cannot read \$file for replaying")" - git bisect--helper --bisect-reset || exit - while read git bisect command rev - do - test "$git $bisect" = "git bisect" || test "$git" = "git-bisect" || continue - if test "$git" = "git-bisect" - then - rev="$command" - command="$bisect" - fi - get_terms - git bisect--helper --check-and-set-terms "$command" "$TERM_GOOD" "$TERM_BAD" || exit - get_terms - case "$command" in - start) - 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) - git bisect--helper --bisect-terms $rev || exit;; - *) - die "$(gettext "?? what are you talking about?")" ;; - esac - done <"$file" - git bisect--helper --bisect-auto-next -} - bisect_run () { git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit @@ -202,7 +172,7 @@ case "$#" in reset) git bisect--helper --bisect-reset "$@" ;; replay) - bisect_replay "$@" ;; + git bisect--helper --bisect-replay "$@" ;; log) git bisect--helper --bisect-log ;; run) From patchwork Mon Jan 20 14:37: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: 11342395 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 67053924 for ; Mon, 20 Jan 2020 14:39:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4468E22464 for ; Mon, 20 Jan 2020 14:39:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sIzqkRpJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729044AbgATOi7 (ORCPT ); Mon, 20 Jan 2020 09:38:59 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:55083 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728901AbgATOi5 (ORCPT ); Mon, 20 Jan 2020 09:38:57 -0500 Received: by mail-wm1-f66.google.com with SMTP id b19so14687459wmj.4 for ; Mon, 20 Jan 2020 06:38:56 -0800 (PST) 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=bDV9a12WNuEaOQomBcJHl8yNKTTRQxq4FebZB+Il9ds=; b=sIzqkRpJxhSqXLxrc0UZ7VTt3gWDqyokuD5+Y5pUwnGWh7sOi6wrx3jdrJgbNp+Gw4 FVHMltaOVaBw1G70fPDnG00FZt9EV2rzTLXmF8DcExdJdHJuWrT3gPLZSkYKFXCaU9Fk sB617q9Q34eoxlMcrMWvlG2rMRn6rHzUiPawAavkXZT4mbTJ6TbqQs0ukA3GSaQm1oM3 fnHfMl8yh2FKMux3YcSbHbbeNZAZhvH6/zh7pSHV6mgFDFxOVg25SxQR12L63jEaa9GT OlSVaMSG0jnwUimmGa1oTs6M/w61R1JOx5Wkz78lAkjKDE7bBo+POwDC28/BFbRw8460 PxTA== 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=bDV9a12WNuEaOQomBcJHl8yNKTTRQxq4FebZB+Il9ds=; b=NT5NC9rXB6CCriJNcBoBNTikQ0vCgvMj+IRF/7ABahz3Sj9/USEx9LrPzSDatBPNSC Y4YzYavgN21gOgw7km5nx1KYcJm1knlOqsDZ7mtuZQB2rImUKmHyatZzFH1cAgUoPAtg O1iARbWrkDdm3JiniVMEnzeLmQXxiSDfeGpKSD3NG7+NZL2PkGO3LfbbuQru6W4DZF/B oBzTtlHbcE3HDuDPfgCHHjTbJaqFnON4WYcvI9FrAhI3SMkckAHKSvINTssqrF2cpJk0 pxLGSpjEvmsJFs28GDh8KhA1KzrXnUdPDwkxTNZSv0oECVAXpNOCWaz9suRTH0ha5093 dFAg== X-Gm-Message-State: APjAAAU7AccD4eUS57SalOniiICAvfe4XuoHmtowOc4YD0jIHdczkqy4 E5k8k8KzKafFgrI1UZBgbPH7kryG/PU= X-Google-Smtp-Source: APXvYqzRuvx0qytBKMbN3iMcYcZttk/2abNHwOCmgvSQRDdGI56KW/KHSBtfPN5yxxYXd2OOOx8yPA== X-Received: by 2002:a1c:9d8b:: with SMTP id g133mr19018608wme.27.1579531135593; Mon, 20 Jan 2020 06:38:55 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:55 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 22/29] bisect--helper: retire `--bisect-write` subcommand Date: Mon, 20 Jan 2020 15:37:53 +0100 Message-Id: <20200120143800.900-23-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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-write` subcommand is no longer used from the git-bisect.sh shell script. Instead the function `bisect_write()` 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 | 9 --------- 1 file changed, 9 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 4b4ce13b50..95ac1a4558 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -21,7 +21,6 @@ static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") static const char * const git_bisect_helper_usage[] = { N_("git bisect--helper --bisect-reset []"), - N_("git bisect--helper --bisect-write [--no-log] "), N_("git bisect--helper --bisect-check-and-set-terms "), N_("git bisect--helper --bisect-next-check []"), N_("git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]"), @@ -1024,7 +1023,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { BISECT_RESET = 1, - BISECT_WRITE, CHECK_AND_SET_TERMS, BISECT_NEXT_CHECK, BISECT_TERMS, @@ -1040,8 +1038,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) struct option options[] = { OPT_CMDMODE(0, "bisect-reset", &cmdmode, N_("reset the bisection state"), BISECT_RESET), - OPT_CMDMODE(0, "bisect-write", &cmdmode, - N_("write out the bisection state in BISECT_LOG"), BISECT_WRITE), OPT_CMDMODE(0, "check-and-set-terms", &cmdmode, N_("check and set terms in a bisection state"), CHECK_AND_SET_TERMS), OPT_CMDMODE(0, "bisect-next-check", &cmdmode, @@ -1082,11 +1078,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) if (argc > 1) return error(_("--bisect-reset requires either no argument or a commit")); return !!bisect_reset(argc ? argv[0] : NULL); - case BISECT_WRITE: - if (argc != 4 && argc != 5) - return error(_("--bisect-write requires either 4 or 5 arguments")); - set_terms(&terms, argv[3], argv[2]); - res = bisect_write(argv[0], argv[1], &terms, nolog); break; case CHECK_AND_SET_TERMS: if (argc != 3) From patchwork Mon Jan 20 14:37: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: 11342401 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 A3BC3159A for ; Mon, 20 Jan 2020 14:39:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82E1122314 for ; Mon, 20 Jan 2020 14:39:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Pi1LLWir" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729080AbgATOjD (ORCPT ); Mon, 20 Jan 2020 09:39:03 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:54213 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729016AbgATOi6 (ORCPT ); Mon, 20 Jan 2020 09:38:58 -0500 Received: by mail-wm1-f66.google.com with SMTP id m24so14728867wmc.3 for ; Mon, 20 Jan 2020 06:38:57 -0800 (PST) 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=mN4wVup1TbxTBWbrWa8w4Sm79LVObxeYH2Qg+4mqYn8=; b=Pi1LLWir4JopY2BjZP9NOvJYNFw3zvjpLj4SHMBdWxhKDqiV8/p+F4KObWBj22syY0 MTxCJo/Rx+tukDrlI9553M+7yAbhWFMXYSbFxf+hiQUNxf0F5S6EFu+p6yGxe7dHM42S +a7+cvy1ZTK5rf+kWFDUOMXnHkNpFzN9Qq2yDu9XB/etPmYKIcQ2aej32xCuEPcd5E5i ItYG1LoQNvJ2WmqswVmbVuAlIRFx4IzHwKxESpKNmBW8r15aFl/XEUmZCLHXcztlAXo/ 9qRNANltPa2o8PTTOeF5bnEFgodSdthWjx4Rr9Ilv1WVmBcDpC2dHFzFi6LrHDioBASY w4xA== 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=mN4wVup1TbxTBWbrWa8w4Sm79LVObxeYH2Qg+4mqYn8=; b=mKtY5nn3M+EYauYuEIxClmPNdlWTCfLbboFGGu6vHLKjtu1H2lEViAixCQ7XgJp8oO jz8wVHVduCGiu7jKQjTiLbqKgOgItIMym0W+cZiXSXMbMTsvIplWj4WfZKMDZ51Z7w/u 0eH0WJTJ6GkB9CbkTQQ6O8jZOj603KaR/9MvO1zJLY1DSG261JCGqiG4zSAJGl1nRtvz wdGVljc3RL/6nE5HOHya8Fy/sAEYN4rTPuq9BtE4patQOc7EK9YmuHpqpAd9kR/ZZG/D rNjEybfYURsA9nR/xJFYwuC6/ySLJlOLcAOmuH4UAXt7nDap/NoJgbwROFNvxefx3OVc Kedw== X-Gm-Message-State: APjAAAX92Yzw7Q76oAZyjui8sxaBVUUIuv0HaJyNNMsR/1fmt/czs8pU lu/cQzTdW7d820AG5lZnBx5NeIj8whE= X-Google-Smtp-Source: APXvYqx4h5XSotMzFhr7bTq0VyLaka2keeojbZkXSQZ8GzMxy/tYKrkBbXR3qqfpDeP6FGyO7we7Lw== X-Received: by 2002:a1c:a982:: with SMTP id s124mr18797150wme.132.1579531136666; Mon, 20 Jan 2020 06:38:56 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:56 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Christian Couder , Miriam Rubio Subject: [PATCH 23/29] bisect--helper: use `res` instead of return in BISECT_RESET case option Date: Mon, 20 Jan 2020 15:37:54 +0100 Message-Id: <20200120143800.900-24-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 Use `res` variable to store `bisect_reset()` output in BISECT_RESET case option to make bisect--helper.c more consistent. Mentored-by: Christian Couder 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 95ac1a4558..378b41cf70 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -1077,7 +1077,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) case BISECT_RESET: if (argc > 1) return error(_("--bisect-reset requires either no argument or a commit")); - return !!bisect_reset(argc ? argv[0] : NULL); + res = bisect_reset(argc ? argv[0] : NULL); break; case CHECK_AND_SET_TERMS: if (argc != 3) From patchwork Mon Jan 20 14:37: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: 11342397 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 C929D6C1 for ; Mon, 20 Jan 2020 14:39:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A772F22464 for ; Mon, 20 Jan 2020 14:39:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bOX68NQy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729052AbgATOjA (ORCPT ); Mon, 20 Jan 2020 09:39:00 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38556 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728709AbgATOjA (ORCPT ); Mon, 20 Jan 2020 09:39:00 -0500 Received: by mail-wr1-f67.google.com with SMTP id y17so29850818wrh.5 for ; Mon, 20 Jan 2020 06:38:58 -0800 (PST) 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=+wkLrKabkIpcF6ub4Zs4YogBSr046SKAALErewvEhNo=; b=bOX68NQyN8ZFCCixAjGD8wP5OsuYc6VoEwflwMJD1NJW2yy+ZFbCRwMP/WiYCpTEeT O9D3b5Cxh+7IpKs6Hg+SQx8bg4EPq/HQngo/Q5M+FhwLg4FZGt+yRss3rPLn4TMWtKN2 hdY/2gj67FxjUYTYYZG1Q0LJpS2M5RL1vmcmAEBXVoHFZ/Ki0bwzTKWV63yBcGM96NZ8 qKC3i1TICChos/4aGWQNxOXPvXeFrHgXDGzFhi/R0XgFwJg9/vZrKPqy72y8USArofZr RpltZWl0x9eSu2Zg1bTL/zhHnd8lwrSuruXdA+QElttgLLkPRzsP5/bN9WW7znMyR1mG tpOw== 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=+wkLrKabkIpcF6ub4Zs4YogBSr046SKAALErewvEhNo=; b=peYKPoMlH/7CjmmSQSY/iHhy7vczgE68B4I6rV+3FN2YlmydEirj3qg1ARy6OL/7Di LknIGCNPoN1p6R/HcdaBfBPSp+Ps4tuFoERsS+H/6x6Hhzwvx4ZNDXcAXblX/xLzJG6Y 1jUZ68jPJUatgC6zFzEZ/WQtkXrZw5zQbS7ez97U1TzEcoHvJ0wr4JBsnl8T/+R8BXOa +A4owFi38/3ldOw+dSLt1w7wiP6f1MZTCo102a9oQW9eXoHI8R27yX4lVbpQx3o8LJg8 t4KhcEu6ntxwXNvv6I1mxJT16f79z93VVxAbKvtt8TC6HB0iMCUoafTJHrT+UimVfx33 QwrQ== X-Gm-Message-State: APjAAAXZ3bd7VYiNn+1It4GNa/R0w7aDZffHdovlXT1gu8zzOYzQ1qCM zITTV9EL5hX2pQQbqY99wlieslzz7uQ= X-Google-Smtp-Source: APXvYqyWzvJh5dv/nEx3Q8BX9x8wrgwQ9+FE2AFIVfgEedEC+Uo2whr7NL7DtxdvnDscyu/U4Go6ug== X-Received: by 2002:adf:f288:: with SMTP id k8mr19566733wro.301.1579531137923; Mon, 20 Jan 2020 06:38:57 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:57 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 24/29] bisect--helper: retire `--bisect-autostart` subcommand Date: Mon, 20 Jan 2020 15:37:55 +0100 Message-Id: <20200120143800.900-25-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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 378b41cf70..9becc1d514 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -28,7 +28,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) [...]"), N_("git bisect--helper --bisect-replay "), @@ -1029,7 +1028,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_START, BISECT_NEXT, BISECT_AUTO_NEXT, - BISECT_AUTOSTART, BISECT_STATE, BISECT_LOG, BISECT_REPLAY @@ -1050,8 +1048,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_CMDMODE(0, "bisect-log", &cmdmode, @@ -1112,12 +1108,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: if (!argc) return error(_("--bisect-state requires at least one revision")); From patchwork Mon Jan 20 14:37: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: 11342399 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 4FF23924 for ; Mon, 20 Jan 2020 14:39:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2CAC422464 for ; Mon, 20 Jan 2020 14:39:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vKcg8Yi5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729073AbgATOjC (ORCPT ); Mon, 20 Jan 2020 09:39:02 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33908 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728992AbgATOjB (ORCPT ); Mon, 20 Jan 2020 09:39:01 -0500 Received: by mail-wr1-f65.google.com with SMTP id t2so29835241wrr.1 for ; Mon, 20 Jan 2020 06:39:00 -0800 (PST) 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=BPvrePRLFOriVYHvw8J3v/d4MJp8UlblmQNFQX4oVhA=; b=vKcg8Yi5dkWnl/KDSHmevyHOOb7Jr2mxg8gE6CpIka3BLFB+IVQduumoq6O0Sxwmm3 0R2S4R5zV7kbZIlmzUtGq16xIoCUEM9v0UcnNXqDH777wezFyMSdZV0kqCDn5OfKuboM XYMHwkKBnUUJsKNA1cNW7pbzSRVPurgW8mEODWTP5kIsuH+rt60Ur0D2QLMpzj7GrRqj h5aSBs4JoyjFAABup5ZxhaYgK2VYrJoou9fMAcv/IMEWfAOMlNobKRHr8z/IgDd7Aysb vCO89kUMGjkY1nQYd5WDlm9mt/4dOFL+O77/V3SUknU8D+QElWTCM8IUw+5+9CRqPnZO agrw== 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=BPvrePRLFOriVYHvw8J3v/d4MJp8UlblmQNFQX4oVhA=; b=ByDqOUwrCDnK8EJCPn+E+JccCopGKQoJbKZl6LhtK44kP3HSd7JU2Hhyh5cbHpFFqf lC81CmztDhF306OQc2t1ob5g56f2U9nGT6lBgL7cMPCq/hL7DpSDWLtJ+X4357aZpQyp bGGwpUigay3lne0yLdFnyMvrxcCKysh9vi8l/UNboYn/Y9XyB9T2mDt16RLpGOmGE/gx Mjxkwm4gfjOplQo+rB9r7W1fbxquUy3EgDhuEanmsb3l0YTlHkXcgvFmn1N8anWIwv5O ULi45LLW55kgrcuzOyfei0JNrZaC+MYPwxlEn60ohst4qa5986MiE9fTgqI10ZqwfklS cTDg== X-Gm-Message-State: APjAAAXnAxZVtmw/WRT7e3CXhATGkKFVTnDLaTmNWv1vB158wkYB6thk rLIMWUbxxLXXt6JKeXb/fVlQpoS5kxo= X-Google-Smtp-Source: APXvYqySxBcuy0F6LLz29MPdhBgSv4XKJP+TG76Ae54krCxnkUOtS1nIq0G1vQMHttg2W8onWEhguQ== X-Received: by 2002:a5d:4cc9:: with SMTP id c9mr15049204wrt.70.1579531139213; Mon, 20 Jan 2020 06:38:59 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:38:58 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 25/29] bisect--helper: retire `--bisect-auto-next` subcommand Date: Mon, 20 Jan 2020 15:37:56 +0100 Message-Id: <20200120143800.900-26-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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-auto-next subcommand is no longer used from the git-bisect.sh shell script. Instead the function bisect_auto_next() 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 9becc1d514..a40477811e 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -27,7 +27,6 @@ static const char * const git_bisect_helper_usage[] = { 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-state (bad|new) []"), N_("git bisect--helper --bisect-state (good|old) [...]"), N_("git bisect--helper --bisect-replay "), @@ -1027,7 +1026,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_TERMS, BISECT_START, BISECT_NEXT, - BISECT_AUTO_NEXT, BISECT_STATE, BISECT_LOG, BISECT_REPLAY @@ -1046,8 +1044,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) 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-state", &cmdmode, N_("mark the state of ref (or refs)"), BISECT_STATE), OPT_CMDMODE(0, "bisect-log", &cmdmode, @@ -1102,12 +1098,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) 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_STATE: if (!argc) return error(_("--bisect-state requires at least one revision")); From patchwork Mon Jan 20 14:37: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: 11342403 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 4D67F6C1 for ; Mon, 20 Jan 2020 14:39:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2117022314 for ; Mon, 20 Jan 2020 14:39:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="t4p0qu7i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729092AbgATOjE (ORCPT ); Mon, 20 Jan 2020 09:39:04 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:40746 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728709AbgATOjD (ORCPT ); Mon, 20 Jan 2020 09:39:03 -0500 Received: by mail-wm1-f65.google.com with SMTP id t14so14928027wmi.5 for ; Mon, 20 Jan 2020 06:39:01 -0800 (PST) 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=R8W2HmF+PR9JX5J6fMQs20rJdoG5VqweMrw7JI1tuJ4=; b=t4p0qu7iEaT9KcvDi+CBeaktIAhD2nXqrNtAV/VcslolrpXt6pSrp5ePObJysRTgwL wdIQSAzPnLHchQJhqrIHhbeIMxscyXRcqvFvfzoInb6Q9+k6IHk7ZXX99GzutpWGsxaV 7JMsioB0HweAVOSZl4f8vz+ynut73bIkmoiyftvzcX4OZ1dG1J23/FkaBptElcWRznld qb4VY9Cv5LXN48zOn7DXBYH5jQPwcjKSb8WghVGT8nGMyuuwTARQVxAS3KrWuIb32yCF ip2jJNh4pdQAGxez9IzjsclcO4Mylsz710yFqnhkiOOh7d0Sm+du0qv9MLOVAROo4zDe eiyg== 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=R8W2HmF+PR9JX5J6fMQs20rJdoG5VqweMrw7JI1tuJ4=; b=dGkmkON1PmSH01Z8GBYGoSbfK6deufmBd20HnhvLhX0/1eut58adPMIn0jxyTgVfV8 k5ivTnpsGAAqQaf4nANbfnULPzxZcQFrH/t5Wc/kZJysPGoFxVu8B7cKpwvrdsCD+rQc P7QHycrMBPPlVvIjIolT1I73DlmE/nYzp7OpFOVj/1VJf+jnQCTxt0R6OReat3v0+t+j a4p8y6jv/GI9NB4K653HsmBroNk3tfbh71V/98fqQ/ZOQE7bbUvaG+C5WU1nM++qmlyH i+Rf3zwUdnXZ4QLjDH0ZNdOZXBfJapvATjYs3XGNju9nre8DhPn5iyNOoPwxG9v6cysf J43A== X-Gm-Message-State: APjAAAV/uhQWFQ5so+Tu2JkhsK6tI2qqe92B6h5KnVp0y8KZFzpur1J0 VwGv6ZILVobcFb9GjTpP8j/uGCi6OgU= X-Google-Smtp-Source: APXvYqxh7JhGuIF2snOgwmoLUUalbgsYvp43U2ltlQpo/eVT8roUDbJZdPpL87a0knoBEy8cy4vYvg== X-Received: by 2002:a7b:c1c7:: with SMTP id a7mr19080367wmj.168.1579531140532; Mon, 20 Jan 2020 06:39:00 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.38.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:39:00 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 26/29] bisect--helper: reimplement `bisect_skip` shell function in C Date: Mon, 20 Jan 2020 15:37:57 +0100 Message-Id: <20200120143800.900-27-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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_skip()` shell function in C and also add `bisect-skip` subcommand to `git bisect--helper` to call it from git-bisect.sh Using `--bisect-skip` subcommand is a temporary measure to port shell function to C so as to use the existing test suite. 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 | 46 +++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 17 +-------------- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index a40477811e..841a76fc7c 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -30,6 +30,7 @@ static const char * const git_bisect_helper_usage[] = { N_("git bisect--helper --bisect-state (bad|new) []"), N_("git bisect--helper --bisect-state (good|old) [...]"), N_("git bisect--helper --bisect-replay "), + N_("git bisect--helper --bisect-skip [(|)...]"), NULL }; @@ -1017,6 +1018,42 @@ static int bisect_replay(struct bisect_terms *terms, const char *filename) return bisect_auto_next(terms, NULL); } +static int bisect_skip(struct bisect_terms *terms, const char **argv, int argc) +{ + int i, res; + const char *pattern = "*..*"; + struct argv_array argv_state = ARGV_ARRAY_INIT; + + argv_array_push(&argv_state, "skip"); + + for (i = 0; i < argc; i++) { + if (!wildmatch(pattern, argv[i], 0)) { + struct rev_info revs; + struct commit *commit; + struct argv_array rev_argv = ARGV_ARRAY_INIT; + + argv_array_pushl(&rev_argv, "skipped_commits", argv[i], NULL); + init_revisions(&revs, NULL); + setup_revisions(rev_argv.argc, rev_argv.argv, &revs, NULL); + argv_array_clear(&rev_argv); + + if (prepare_revision_walk(&revs)) + die(_("revision walk setup failed\n")); + while ((commit = get_revision(&revs)) != NULL) + argv_array_push(&argv_state, + oid_to_hex(&commit->object.oid)); + + reset_revision_walk(); + } else { + argv_array_push(&argv_state, argv[i]); + } + } + res = bisect_state(terms, argv_state.argv, argv_state.argc); + + argv_array_clear(&argv_state); + return res; +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { @@ -1028,7 +1065,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_NEXT, BISECT_STATE, BISECT_LOG, - BISECT_REPLAY + BISECT_REPLAY, + BISECT_SKIP } cmdmode = 0; int no_checkout = 0, res = 0, nolog = 0; struct option options[] = { @@ -1050,6 +1088,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("output the contents of BISECT_LOG"), BISECT_LOG), OPT_CMDMODE(0, "bisect-replay", &cmdmode, N_("replay the bisection process from the given file"), BISECT_REPLAY), + OPT_CMDMODE(0, "bisect-skip", &cmdmode, + N_("skip some commits for checkout"), BISECT_SKIP), OPT_BOOL(0, "no-checkout", &no_checkout, N_("update BISECT_HEAD instead of checking out the current commit")), OPT_BOOL(0, "no-log", &nolog, @@ -1116,6 +1156,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) set_terms(&terms, "bad", "good"); res = bisect_replay(&terms, argv[0]); break; + case BISECT_SKIP: + set_terms(&terms, "bad", "good"); + res = bisect_skip(&terms, argv, argc); + break; default: return error("BUG: unknown subcommand '%d'", cmdmode); } diff --git a/git-bisect.sh b/git-bisect.sh index 0555191c41..edfd3f8b3d 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -39,21 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" TERM_BAD=bad TERM_GOOD=good -bisect_skip() { - all='' - for arg in "$@" - do - case "$arg" in - *..*) - revs=$(git rev-list "$arg") || die "$(eval_gettext "Bad rev input: \$arg")" ;; - *) - revs=$(git rev-parse --sq-quote "$arg") ;; - esac - all="$all $revs" - done - eval git bisect--helper --bisect-state 'skip' $all -} - bisect_visualize() { git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit @@ -162,7 +147,7 @@ case "$#" in bad|good|new|old|"$TERM_BAD"|"$TERM_GOOD") git bisect--helper --bisect-state "$cmd" "$@" ;; skip) - bisect_skip "$@" ;; + git bisect--helper --bisect-skip "$@" ;; next) # Not sure we want "next" at the UI level anymore. get_terms From patchwork Mon Jan 20 14:37: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: 11342405 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 8251A159A for ; Mon, 20 Jan 2020 14:39:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 604AC22314 for ; Mon, 20 Jan 2020 14:39:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jRtw7qza" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729094AbgATOjF (ORCPT ); Mon, 20 Jan 2020 09:39:05 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:40750 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728992AbgATOjE (ORCPT ); Mon, 20 Jan 2020 09:39:04 -0500 Received: by mail-wm1-f67.google.com with SMTP id t14so14928095wmi.5 for ; Mon, 20 Jan 2020 06:39:02 -0800 (PST) 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=5QqPW++gfEQ6MjOHpQ88/wrQYYFq5e1qOb6oI1cos+o=; b=jRtw7qzaUtJr6/Uqq77I6iPJeVWKgcFk+Xvqw5IQPHs8sXpvchB1CJsAe5SBSeTFJD umd5eurzvICvvJYWZ6tZOjFi0Usf0XrGmd7bFn5zllM8wExe9k4H94cc2gNe0+9EtXRw OBJihvDauSC1VtGy1KoZzV0AbyVtRniYllHnJk0QXeIerFQGXyZTHrV3W12kMcvLvCAa /9YW7zsS9z2CDT2taN3lUCq09Nz/Bi554p4Fxh9vvpawEv7EbSVv9zNQaYePIE6CPJuW 4/z3B4ypCDUyNR5mMkdoS6NUYlk1KyrlQ9I+YjDagadqY945GAMGTZ4Z6GmH/V6JVK/Y VYoQ== 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=5QqPW++gfEQ6MjOHpQ88/wrQYYFq5e1qOb6oI1cos+o=; b=FiXZc1SX526Pzgf0mFbAmpulVmonVXo4LHLsgjxwhZcMOo3VHLMVEGZpEWYn7gXM7x e42dGcrDHuQRv4rEKd/SNBf8DL9MRDqjwcfvAKY2TPu0hmPN6hR9VJncwK0OzWEbyZvZ Oy9Ziy3RKR2ZoOZZMwmw8DiybPVDZIizc7Ip91SP9xYYcTqNu4jLgKQCAeTAJ9aDq9o7 WuL056ivFU5T0v5Q1kHN7xwEhFjL1YZhycG0cclWlSuq0K263uAiHQ4Rx39QHtx8qe7K GM3XcedntXg4741grxXXnLJ2tku7dvRegbzq9bjKzkNLdU/pCHEKjr75EpSeWdOQm7jp U+Uw== X-Gm-Message-State: APjAAAXjBG1r5P42Pifc1Ip3x8AhPlhN1CIw7VcgR+WGqZYpgaZDDmNX diIjpfmUtmBenqwf26xDs4kpKAxkN6E= X-Google-Smtp-Source: APXvYqwEqXa4VzgOAbToUBj9IjqwwVbY3iB4DbvzbJPDJwdWwlzJFeYozzhWL9io/6Dj53OFcYqwmQ== X-Received: by 2002:a7b:cc98:: with SMTP id p24mr19642154wma.139.1579531141808; Mon, 20 Jan 2020 06:39:01 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.39.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:39:01 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 27/29] bisect--helper: retire `--check-and-set-terms` subcommand Date: Mon, 20 Jan 2020 15:37:58 +0100 Message-Id: <20200120143800.900-28-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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-and-set-terms` subcommand is no longer from the git-bisect.sh shell script. Instead the function `check_and_set_terms()` is 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 841a76fc7c..7bc28d728e 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -21,7 +21,6 @@ static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") static const char * const git_bisect_helper_usage[] = { N_("git bisect--helper --bisect-reset []"), - N_("git bisect--helper --bisect-check-and-set-terms "), N_("git bisect--helper --bisect-next-check []"), 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}=]" @@ -1058,7 +1057,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { BISECT_RESET = 1, - CHECK_AND_SET_TERMS, BISECT_NEXT_CHECK, BISECT_TERMS, BISECT_START, @@ -1072,8 +1070,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) struct option options[] = { OPT_CMDMODE(0, "bisect-reset", &cmdmode, N_("reset the bisection state"), BISECT_RESET), - OPT_CMDMODE(0, "check-and-set-terms", &cmdmode, - N_("check and set terms in a bisection state"), CHECK_AND_SET_TERMS), OPT_CMDMODE(0, "bisect-next-check", &cmdmode, N_("check whether bad or good terms exist"), BISECT_NEXT_CHECK), OPT_CMDMODE(0, "bisect-terms", &cmdmode, @@ -1111,12 +1107,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) return error(_("--bisect-reset requires either no argument or a commit")); res = bisect_reset(argc ? argv[0] : NULL); break; - case CHECK_AND_SET_TERMS: - if (argc != 3) - return error(_("--check-and-set-terms requires 3 arguments")); - set_terms(&terms, argv[2], argv[1]); - res = check_and_set_terms(&terms, argv[0]); - break; case BISECT_NEXT_CHECK: if (argc != 2 && argc != 3) return error(_("--bisect-next-check requires 2 or 3 arguments")); From patchwork Mon Jan 20 14:37: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: 11342407 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 941716C1 for ; Mon, 20 Jan 2020 14:39:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 70C8822314 for ; Mon, 20 Jan 2020 14:39:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T4/ewVWT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729108AbgATOjG (ORCPT ); Mon, 20 Jan 2020 09:39:06 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52942 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729016AbgATOjF (ORCPT ); Mon, 20 Jan 2020 09:39:05 -0500 Received: by mail-wm1-f65.google.com with SMTP id p9so14753774wmc.2 for ; Mon, 20 Jan 2020 06:39:03 -0800 (PST) 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=MgqUhtYt3rl1yMH3xNNgjtpaX77opSuQtQCandelRJo=; b=T4/ewVWTZyJkLBLEY+CfAgZfGJ6pft8Ofs6ww9cpO7M5pC7+QlfYAPzSYcuueGokxN Vmds+nNGXpNV+Syoio9iaagdLBIw5nHRfy0GK5bewi1CVxSWt1czXPhaiZz8uga+46Jl bbH5RCZREIeLSPS0bY/Ad2eeFz5qJryWd1hVK3mV2hO8s42xfSRFtNrB4jsnhfl88vqW nidOeUU2EVP+0lytjMKAJmhKFGaShHs5LIu/v93HDAaDTKHBOo33nmnDZ3chByMsLKFR +LYnn5mMIfiOst8bLd3LHJxUSbnVuK6pMxWNRyQIOd6oL1gi3y1uPdEl/BHREI2r3s36 qQ/w== 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=MgqUhtYt3rl1yMH3xNNgjtpaX77opSuQtQCandelRJo=; b=a2+YNRN6PUJdD3P872gLRvUH9kgNnMcfa4Bvl6JDuG9AP4gqorg3C8W1y1KU3id5cL IQz0tkFJ0KZVXTYKalUSyIkDeJnZPcqxXesw6lQ2UXfCYUf3uTumOXR/l7jAcp/Kkp7O MiV6dh1PdiYEk4m9hN9bxs+7yQqn0Z4FEQyxpFthtHUcO+hDiNwvpOpSeTg3EFi5ogmh GrvRndCk8QAKXf97tJE9qw7x5y8yRsJdnr6pKcnpSIHjjpBGnOuTKiQ5JlsgMQla0AUP +E4FaXnJQRaLmWu9Pp1COODh9+N1HrChmj2W6g5ivTyyHyiSjDxsjTmYX24qz7VSDOBY WBiQ== X-Gm-Message-State: APjAAAUAuvK0H7WcE0YoNz6lAj3wJBuIPEtU4CqvHbq8xGe2TvjIUMcK SsYz1ACDUi2KImSjESvRz39xFc+mwPo= X-Google-Smtp-Source: APXvYqxbAnWiPbZKy1EheAhTW4cxqDp1kLZLtpH7A0kJbyTKKAAt0u+EfbxeHKMZN1Gxd8H8XMy+lA== X-Received: by 2002:a05:600c:2c06:: with SMTP id q6mr20135302wmg.154.1579531143073; Mon, 20 Jan 2020 06:39:03 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.39.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:39:02 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Pranit Bauva , Christian Couder , Johannes Schindelin , Tanushree Tumane , Miriam Rubio Subject: [PATCH 28/29] bisect--helper: reimplement `bisect_visualize()`shell function in C Date: Mon, 20 Jan 2020 15:37:59 +0100 Message-Id: <20200120143800.900-29-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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_visualize()` shell function in C and also add `--bisect-visualize` subcommand to `git bisect--helper` to call it from git-bisect.sh. Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- builtin/bisect--helper.c | 48 +++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 25 +-------------------- 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 7bc28d728e..4b41cc7749 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -30,6 +30,7 @@ static const char * const git_bisect_helper_usage[] = { N_("git bisect--helper --bisect-state (good|old) [...]"), N_("git bisect--helper --bisect-replay "), N_("git bisect--helper --bisect-skip [(|)...]"), + N_("git bisect--helper --bisect-visualize"), NULL }; @@ -1053,6 +1054,44 @@ static int bisect_skip(struct bisect_terms *terms, const char **argv, int argc) return res; } +static int bisect_visualize(struct bisect_terms *terms, const char **argv, int argc) +{ + struct argv_array args = ARGV_ARRAY_INIT; + int flags = RUN_COMMAND_NO_STDIN, res = 0; + struct strbuf sb; + + if (!bisect_next_check(terms, NULL)) + return -1; + + if (!argc) { + if ((getenv("DISPLAY") || getenv("SESSIONNAME") || getenv("MSYSTEM") || + getenv("SECURITYSESSIONID")) && exists_in_PATH("gitk")) + argv_array_push(&args, "gitk"); + else { + argv_array_pushl(&args, "log", NULL); + flags |= RUN_GIT_CMD; + } + } else { + if (argv[0][0] == '-') { + argv_array_pushl(&args, "log", NULL); + flags |= RUN_GIT_CMD; + } else if (strcmp(argv[0], "tig") && !starts_with(argv[0], "git")) + flags |= RUN_GIT_CMD; + + argv_array_pushv(&args, argv); + } + + argv_array_pushl(&args, "--bisect", NULL); + + strbuf_read_file(&sb, git_path_bisect_names(), 0); + argv_array_split(&args, sb.buf); + strbuf_release(&sb); + + res = run_command_v_opt(args.argv, flags); + argv_array_clear(&args); + return res; +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { @@ -1064,7 +1103,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_STATE, BISECT_LOG, BISECT_REPLAY, - BISECT_SKIP + BISECT_SKIP, + BISECT_VISUALIZE } cmdmode = 0; int no_checkout = 0, res = 0, nolog = 0; struct option options[] = { @@ -1086,6 +1126,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("replay the bisection process from the given file"), BISECT_REPLAY), OPT_CMDMODE(0, "bisect-skip", &cmdmode, N_("skip some commits for checkout"), BISECT_SKIP), + OPT_CMDMODE(0, "bisect-visualize", &cmdmode, + N_("visualize the bisection"), BISECT_VISUALIZE), OPT_BOOL(0, "no-checkout", &no_checkout, N_("update BISECT_HEAD instead of checking out the current commit")), OPT_BOOL(0, "no-log", &nolog, @@ -1150,6 +1192,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) set_terms(&terms, "bad", "good"); res = bisect_skip(&terms, argv, argc); break; + case BISECT_VISUALIZE: + get_terms(&terms); + res = bisect_visualize(&terms, argv, argc); + break; default: return error("BUG: unknown subcommand '%d'", cmdmode); } diff --git a/git-bisect.sh b/git-bisect.sh index edfd3f8b3d..084766636d 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -39,29 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" TERM_BAD=bad TERM_GOOD=good -bisect_visualize() { - git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit - - if test $# = 0 - then - if test -n "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" && - type gitk >/dev/null 2>&1 - then - set gitk - else - set git log - fi - else - case "$1" in - git*|tig) ;; - -*) set git log "$@" ;; - *) set git "$@" ;; - esac - fi - - eval '"$@"' --bisect -- $(cat "$GIT_DIR/BISECT_NAMES") -} - bisect_run () { git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit @@ -153,7 +130,7 @@ case "$#" in get_terms git bisect--helper --bisect-next "$@" || exit ;; visualize|view) - bisect_visualize "$@" ;; + git bisect--helper --bisect-visualize "$@" ;; reset) git bisect--helper --bisect-reset "$@" ;; replay) From patchwork Mon Jan 20 14:38: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: 11342409 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 E3A286C1 for ; Mon, 20 Jan 2020 14:39:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1F8422314 for ; Mon, 20 Jan 2020 14:39:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i/GKXyNk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729117AbgATOjH (ORCPT ); Mon, 20 Jan 2020 09:39:07 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:36985 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729096AbgATOjG (ORCPT ); Mon, 20 Jan 2020 09:39:06 -0500 Received: by mail-wm1-f68.google.com with SMTP id f129so14969979wmf.2 for ; Mon, 20 Jan 2020 06:39:05 -0800 (PST) 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=H8Stw97eWMONr6a8QPsDT9LSGfQY63VJ1CvSPOp3kY8=; b=i/GKXyNkbO+7FecUEka2DYqVshPnRged4MdXNY1qCmzw/lUmn9s0qxxhgTj9uG6dXJ AKcCQQ8F7fUJ+eHPsfpy09922F1h4SZD+aCIqfKgUEoxi6xiZG1RzAdtqC/PdCfUNySV ZF+4pGq5LLRzPgpd8tXXm65jBXTpjx3Injmq52g50SdQ6TlwuXV4IMMBJzSMPNfus9rK h9RXd9bticLyoWTXl4ItiBygY7QjuXFwA4MW/CwFq2yMgpS3vpRkyZkA9GWtT6r0s32Y /+bsRu4bbe4k2BmCYPh0Fo4WX80yYkQdQqsrwCNUrAehhMK5Nc4cXsjFbVI0hAVWvFLS 9P1Q== 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=H8Stw97eWMONr6a8QPsDT9LSGfQY63VJ1CvSPOp3kY8=; b=saIcecc3aMSZp4X2lgfqm/g52onSKjA9swobEIC6loWw+inRbKygF7/mA+dChrLXOF vQNeb5LILdsiA/yiRUp9QMbsbRbWnJViEi8oMb4B5OxkxChb5u4Fnw3hWlZO7eznMSUl HnyYfbGWxr1rxYoZfagI6PZc5cNaHFlqtaKEsMShGUM1BAc/J4aG1a7CJjdQuXv+TDAM 204bMljx+UtBpUfRghIihjm8qTEa+g5Gdu4RFPW4F3Og+fscwllEnkNStJAnciHhqI83 IdI1oc5bJDBkMoonAdgVZUcoV1HjOw7xcMeLrDGa5BhMd7yRxXrK0t96jacaC/ZFX6Ro 0JoA== X-Gm-Message-State: APjAAAVeygMqv51herUn5Ox1nUm34CwPvauypIxloSv+FaBX/uzpVANx I1h2mw1xtJeTm2TBXbu9s9cruFhhSJI= X-Google-Smtp-Source: APXvYqw5LZOCllP0SV0ftGvu4ep3nlnUaUHi/SjeuewxtAXOeVBX0i3XhgWVfqgVTPu9D4QNbAyDNg== X-Received: by 2002:a1c:4c5:: with SMTP id 188mr19060896wme.82.1579531144329; Mon, 20 Jan 2020 06:39:04 -0800 (PST) Received: from localhost.localdomain ([139.47.115.4]) by smtp.gmail.com with ESMTPSA id u8sm23192588wmm.15.2020.01.20.06.39.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2020 06:39:03 -0800 (PST) From: Miriam Rubio To: git@vger.kernel.org Cc: Tanushree Tumane , Christian Couder , Miriam Rubio Subject: [PATCH 29/29] bisect--helper: reimplement `bisect_run` shell function in C Date: Mon, 20 Jan 2020 15:38:00 +0100 Message-Id: <20200120143800.900-30-mirucam@gmail.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200120143800.900-1-mirucam@gmail.com> References: <20200120143800.900-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: Tanushree Tumane Reimplement the `bisect_run()` shell function in C and also add `--bisect-run` subcommand to `git bisect--helper` to call it from git-bisect.sh. Mentored-by: Christian Couder Signed-off-by: Tanushree Tumane Signed-off-by: Miriam Rubio --- builtin/bisect--helper.c | 66 +++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 62 +------------------------------------ 2 files changed, 66 insertions(+), 62 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 4b41cc7749..1899cc8114 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -31,6 +31,7 @@ static const char * const git_bisect_helper_usage[] = { N_("git bisect--helper --bisect-replay "), N_("git bisect--helper --bisect-skip [(|)...]"), N_("git bisect--helper --bisect-visualize"), + N_("git bisect--helper --bisect-run ..."), NULL }; @@ -1092,6 +1093,60 @@ static int bisect_visualize(struct bisect_terms *terms, const char **argv, int a return res; } +static int bisect_run(struct bisect_terms *terms, const char **argv, int argc) +{ + int i, res = 0; + struct strbuf command = STRBUF_INIT; + struct argv_array args = ARGV_ARRAY_INIT; + + if (bisect_next_check(terms, NULL)) + return -1; + + for (i = 0; i < argc; i++) { + strbuf_addstr(&command, argv[i]); + strbuf_addstr(&command, " "); + } + + while (1) { + argv_array_clear(&args); + + printf(_("running %s"), command.buf); + res = run_command_v_opt(argv, RUN_USING_SHELL); + + if (res < 0 && res >= 128) { + error(_("bisect run failed: exit code %d from" + " '%s' is < 0 or >= 128"), res, command.buf); + strbuf_release(&command); + return res; + } + + if (res == 125) + argv_array_push(&args, "skip"); + else if (res > 0) + argv_array_push(&args, terms->term_bad); + else + argv_array_push(&args, terms->term_good); + + res = bisect_state(terms, args.argv, args.argc); + + if (res == -11) { + printf(_("bisect run success")); + res = 0; + } + else if (res == -2) + error(_("bisect run cannot continue any more")); + else if (res) + error(_("bisect run failed:'git bisect--helper --bisect-state" + " %s' exited with error code %d"), args.argv[0], res); + else + continue; + + strbuf_release(&command); + argv_array_clear(&args); + return res; + } +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { @@ -1104,7 +1159,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_LOG, BISECT_REPLAY, BISECT_SKIP, - BISECT_VISUALIZE + BISECT_VISUALIZE, + BISECT_RUN, } cmdmode = 0; int no_checkout = 0, res = 0, nolog = 0; struct option options[] = { @@ -1128,6 +1184,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("skip some commits for checkout"), BISECT_SKIP), OPT_CMDMODE(0, "bisect-visualize", &cmdmode, N_("visualize the bisection"), BISECT_VISUALIZE), + OPT_CMDMODE(0, "bisect-run", &cmdmode, + N_("use ... to automatically bisect."), BISECT_RUN), OPT_BOOL(0, "no-checkout", &no_checkout, N_("update BISECT_HEAD instead of checking out the current commit")), OPT_BOOL(0, "no-log", &nolog, @@ -1196,6 +1254,12 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) get_terms(&terms); res = bisect_visualize(&terms, argv, argc); break; + case BISECT_RUN: + if (!argc) + return error(_("bisect run failed: no command provided.")); + get_terms(&terms); + res = bisect_run(&terms, argv, argc); + break; default: return error("BUG: unknown subcommand '%d'", cmdmode); } diff --git a/git-bisect.sh b/git-bisect.sh index 084766636d..d4f64674fe 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -39,66 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" TERM_BAD=bad TERM_GOOD=good -bisect_run () { - git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit - - test -n "$*" || die "$(gettext "bisect run failed: no command provided.")" - - while true - do - command="$@" - eval_gettextln "running \$command" - "$@" - res=$? - - # Check for really bad run error. - if [ $res -lt 0 -o $res -ge 128 ] - then - eval_gettextln "bisect run failed: -exit code \$res from '\$command' is < 0 or >= 128" >&2 - exit $res - fi - - # Find current state depending on run success or failure. - # A special exit code of 125 means cannot test. - if [ $res -eq 125 ] - then - state='skip' - elif [ $res -gt 0 ] - then - state="$TERM_BAD" - else - state="$TERM_GOOD" - fi - - ( git bisect--helper --bisect-state $state >"$GIT_DIR/BISECT_RUN" ) - res=$? - - cat "$GIT_DIR/BISECT_RUN" - - if sane_grep "first $TERM_BAD commit could be any of" "$GIT_DIR/BISECT_RUN" \ - >/dev/null - then - gettextln "bisect run cannot continue any more" >&2 - exit $res - fi - - if [ $res -ne 0 ] - then - eval_gettextln "bisect run failed: -'git bisect--helper --bisect-state \$state' exited with error code \$res" >&2 - exit $res - fi - - if sane_grep "is the first $TERM_BAD commit" "$GIT_DIR/BISECT_RUN" >/dev/null - then - gettextln "bisect run success" - exit 0; - fi - - done -} - get_terms () { if test -s "$GIT_DIR/BISECT_TERMS" then @@ -138,7 +78,7 @@ case "$#" in log) git bisect--helper --bisect-log ;; run) - bisect_run "$@" ;; + git bisect--helper --bisect-run "$(git rev-parse --sq-quote "$@")" ;; terms) git bisect--helper --bisect-terms "$@" || exit;; *)