From patchwork Sun Feb 24 10:11:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92F40180E for ; Sun, 24 Feb 2019 10:11:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F5082B9B1 for ; Sun, 24 Feb 2019 10:11:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C7502B9B2; Sun, 24 Feb 2019 10:11:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D68332B9B2 for ; Sun, 24 Feb 2019 10:11:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728232AbfBXKLT (ORCPT ); Sun, 24 Feb 2019 05:11:19 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:39359 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728096AbfBXKLS (ORCPT ); Sun, 24 Feb 2019 05:11:18 -0500 Received: by mail-ed1-f65.google.com with SMTP id p27so5215857edc.6 for ; Sun, 24 Feb 2019 02:11:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=UM8fr0OXySJJgyQkT/nGy1LNwfc8wqEF0ENr2nDpQAc=; b=jmQGhAywt+rsjJ/LwioIOeoAYj5fN7YHuKTswo2o5uiIeldXB8kAmBRggW/CraXEQT EIfuC7qOqgf8o42LCI4AKtHti8iVB0O6IXXvjANcwRLOum9EczZBSjAKrvmUXe+W3V75 /leRpjPa7sWZRev+lSkhh4vMsu5lwUU6z/9izfiaTgQxnJkPRLOwd+X1hEv0VC+SBpDN RniM0xPrcIB2o1cFwVjfwwcd2cMsL7tImx+xfDANmP0e+nHlzfetQ+lHYnGgYlnW46rE 8L/J4mBZqSP1qNtEZVOnugCDFc+uEJCOSRXNtYEGL3XRKVrNLrHdIu0YI2HFPEESJYGs UUag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=UM8fr0OXySJJgyQkT/nGy1LNwfc8wqEF0ENr2nDpQAc=; b=GyOY+KE2JLKjDmww/o5p6P3Rkg0miR78LMF1OiqR8o60jq5W1Vy6g2lTnuowqfFWmX QqIfetjOYp4wAkyzlBELs6vhblySt4ZOjh3Vq3xbsCtfReiWrdG+E9iL05GhOdYjY3Pg At2yadUOw5Mqsey93VnNrUAsWrHNBHiaK+Waz3lCa+oo9QcJW+2tflmQ/8X4ovzBKZ+r E2VJjPtCNFfEw6h4agKy23Qm3RNrc5aIbfhqFLbKNAKiaDfvkZ/Slz0g2PJMN4ky/sWH Wtkk78LOsgPJ2i5PbDBK1O9hoQcQyEgBum/Ant4BuuFnhpus7dv5PmBVWKuMwv/tUz6t YMjw== X-Gm-Message-State: AHQUAub1i1HmYUEKGjdg5gboIRlIcMZ0/ueyhMaqR3ZC/z6Ope5P9naz buCOJPFz64ymhTSnfBa1SoJQvRe3 X-Google-Smtp-Source: AHgI3IZoA0eFlqaOQUHrN1LnadAFg0Yy5VC36JR4cdyL2D8gT48cPx2AelDEPUTumyvA2qQDHk1xCg== X-Received: by 2002:a17:906:23f1:: with SMTP id j17mr9122425ejg.188.1551003076589; Sun, 24 Feb 2019 02:11:16 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j46sm1843254ede.6.2019.02.24.02.11.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:15 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:15 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:10:49 GMT Message-Id: <64117cde718f0d56ebfa4c30f4d8fe2155f5cf65.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Tanushree Tumane via GitGitGadget" Subject: [PATCH 01/26] bisect--helper: refer branch.buf before strbuf_release(...) Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Tanushree Tumane Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tanushree Tumane move `error("...%s...", branch.buf);` before `strbuf_release(&branch);`. add ' ' before "reset.." in error message. Mentored-by: Johannes Schindelin Mentored-by: Christian Couder Signed-off-by: Tanushree Tumane --- builtin/bisect--helper.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 22e669e3b1..e672ee9f18 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -169,11 +169,12 @@ static int bisect_reset(const char *commit) argv_array_pushl(&argv, "checkout", branch.buf, "--", NULL); if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) { + error(_("could not check out original" + " HEAD '%s'. Try 'git bisect" + " reset '."), branch.buf); strbuf_release(&branch); argv_array_clear(&argv); - return error(_("could not check out original" - " HEAD '%s'. Try 'git bisect" - "reset '."), branch.buf); + return -1; } argv_array_clear(&argv); } From patchwork Sun Feb 24 10:11:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827821 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED4BE1805 for ; Sun, 24 Feb 2019 10:11:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D855D2B9B5 for ; Sun, 24 Feb 2019 10:11:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5E472B9B2; Sun, 24 Feb 2019 10:11:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02FB72B9B4 for ; Sun, 24 Feb 2019 10:11:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728246AbfBXKLU (ORCPT ); Sun, 24 Feb 2019 05:11:20 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:45088 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728120AbfBXKLT (ORCPT ); Sun, 24 Feb 2019 05:11:19 -0500 Received: by mail-ed1-f65.google.com with SMTP id d9so5177989edh.12 for ; Sun, 24 Feb 2019 02:11:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=1KfqgYxo67isv1ht55+KiQb0LLDKefG1fDEjCa2V3uM=; b=KRfu+32ozHQAANmQWTLyatsr6PoFewF2MJSIegrd+McGwpqSVRg4Iz/eVqpgkNWETr QrckoUV83w4VVRKJRz49eILMRqFtoY3JRG1MtoL2upkH3+mTSh9MaIUpZH7cFJuJP2qS 2ztipv8g5OLz2bLL6tLykZKHGLVfino1vGiU3Wkkl4ibPKjhFIyfDy6wb43xGSfr/itO 3804bIw+DYRIJcDQm284Nqm+axkXXMZpfNvNtRRaUfbpQxdnbUWx4Rp+aUbSyIOdEnI0 xF20d7h8Lir+HkfHk95bWcqHT/Mo2z+xYhp8NJ16QPV8N9OGefq7G1GXbqonP91w6+zD 3uRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=1KfqgYxo67isv1ht55+KiQb0LLDKefG1fDEjCa2V3uM=; b=ajF2UUx5S3Czh6dIIB70sB+N4PTBdug+hwfHNEXv/fMjNNNO3oa5KBAQNklYArJhEk yAg2L/SLojLnXLWlFFg4K2snbx5Lmw4F5wuMeUCx1KsUINlNgfgbzGsPPN71OEKVWMw0 t1/Ch8pw4G37tTL9VSQ9x4P6xeqnt+2zJU6Vwe8Ty8tX9R5YRApijzi2ZjQeoK8UCixU ccKZQprGxFjxYHoontVufaCEAhuvjmdDhDRbuNvKHqz53XmAQVobV80sY8KmapNd1yJ+ ALIxZcRiPwJ+4rtNBoj9Nfv35RehyeVEFmkwJ39bHpy/k8tkYP/+FMeMVgV4AMSht0Z2 Sumw== X-Gm-Message-State: AHQUAuZNnCsmITgRm71LUTtDKdwK2bIpTm96kslO0ztG0/EYPZG0VBd4 w+hCz2Jt+8TpMBgwtixvp76WHvcT X-Google-Smtp-Source: AHgI3IYUVg0/KTdiY+x5hnpThKQRDMJyxIybiO2yaG3SVak3hqKseQKRQt5WnGyr59cZTdSJEwDeyw== X-Received: by 2002:aa7:cb52:: with SMTP id w18mr9817697edt.257.1551003077343; Sun, 24 Feb 2019 02:11:17 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t16sm1822374edi.53.2019.02.24.02.11.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:16 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:16 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:10:50 GMT Message-Id: In-Reply-To: References: From: "Tanushree Tumane via GitGitGadget" Subject: [PATCH 02/26] bisect--helper: change `retval` to `res` Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Tanushree Tumane Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tanushree Tumane Conversion of variable `retval` to `res` to have a uniformity of a single variable all over the patch series, which makes the patch series unvaried. Mentored-by: Christian Couder Signed-off-by: Tanushree Tumane --- builtin/bisect--helper.c | 50 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index e672ee9f18..5093e55273 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); @@ -574,7 +574,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, get_oid(start_head.buf, &oid); if (update_ref(NULL, "BISECT_HEAD", &oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR)) { - retval = -1; + res = -1; goto finish; } } @@ -586,26 +586,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 Sun Feb 24 10:11:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827839 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62CC31805 for ; Sun, 24 Feb 2019 10:11:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5031C2B9B1 for ; Sun, 24 Feb 2019 10:11:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4472B2B9B4; Sun, 24 Feb 2019 10:11:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDC7F2B9B2 for ; Sun, 24 Feb 2019 10:11:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728252AbfBXKLV (ORCPT ); Sun, 24 Feb 2019 05:11:21 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:39362 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbfBXKLU (ORCPT ); Sun, 24 Feb 2019 05:11:20 -0500 Received: by mail-ed1-f67.google.com with SMTP id p27so5215879edc.6 for ; Sun, 24 Feb 2019 02:11:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=QMmOFIwudwN2B1TBXm250Vc2BquDiZ9nel/R5Wcp+k0=; b=W3VySRbnupd0nmp7mykFSpQPEOeYazynXGmlKjXWz+0ULQBYdAeQb9RRH/2RDuvonN 3s3jm3/jrekDkrb40KPCgdwV9KIcJxum0mEVF/w8KKyW8r0qKtaDQBc8Xi/p+jsLKyim h5kcNxGtFPVZk2945m7/JVw5staNEsJnBYCAzHesP3sZmlEjJUOEmGJdM9EG1Oc+E2BV kiBgkY25hl1siwUanZjRIONF9i0E8atc4t9TG+hnb5mMDzhvgYNz7NEUKXimSbnPCEK1 Hv1bmJpR4Mq3EiwWVQBcCXx3ayl+CY4/c8FEyf98TFB9QOFhpoaKUp+IW4UHWy7sRBtq 111Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=QMmOFIwudwN2B1TBXm250Vc2BquDiZ9nel/R5Wcp+k0=; b=RYNIsWLHQKdKeE7dC/EDCxkMjXMr4MOhOhVqY1/VMm42nTUpMOIJ5xoSdfrtF74//Y /pDjU/frXqNBT9gTtoRE9D1ggbcpIFSrPK89MdDBaaLLQ8d13QF4fX8NYKyZhIcTp5OH RMf+Dph4io/KF5aHiuvi3/ZUWeWXYp9mEPtOzPeYEShz3qyP5elRDhufg0cn1+m8wx2s 6OKQZaMqIbo0sT8Ml1nibtvuz2RTCSoP4faVfQ7I1TgzENymPvGwTBqAHJvkVrqR+BN+ /qrH3WZBe675U4dngXD1ELkKwFPKAzE2gdI9c6GP73cKqSGiMBl65K/qFL0UxZI4SzRH 3zDA== X-Gm-Message-State: AHQUAuYgeZbYFjXbGw1yv3sFhN2QtkW3hX/UDe1qkvNXx3ha7a6i72EI A4QCb+cOA9Gui70eIvWa552YV5Ix X-Google-Smtp-Source: AHgI3IaUpcqDXk1upnKr/FiLtGSF1RQBRDvAuS5xENG30KylssXnf8pFjYOkP9wtYApQXRFBNVJSDA== X-Received: by 2002:a50:b639:: with SMTP id b54mr10061663ede.229.1551003078086; Sun, 24 Feb 2019 02:11:18 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id p93sm1777015edp.7.2019.02.24.02.11.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:17 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:17 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:10:51 GMT Message-Id: In-Reply-To: References: From: "Tanushree Tumane via GitGitGadget" Subject: [PATCH 03/26] bisect--helper: `decide_next()` helper function. Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Tanushree Tumane Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tanushree Tumane introduce `decide_next()` helper function from `bisect_next_check()` for better and clear understanding. convert `*...warning` char pointers to `...warning[]`char arrays, as char [] only creates char array while char * creates both char array and a pointer to that char array. Mentored-by: Christian Couder Signed-off-by: Tanushree Tumane --- builtin/bisect--helper.c | 66 +++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 5093e55273..f441ea85ff 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -282,35 +282,23 @@ static int mark_good(const char *refname, const struct object_id *oid, return 1; } -static const char *need_bad_and_good_revision_warning = +static const char need_bad_and_good_revision_warning[] = N_("You 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 const char *need_bisect_start_warning = +static const char need_bisect_start_warning[] = N_("You need to start by \"git bisect start\".\n" "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 Sun Feb 24 10:11:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA7C21880 for ; Sun, 24 Feb 2019 10:11:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C912B2B9B1 for ; Sun, 24 Feb 2019 10:11:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B54162B9B6; Sun, 24 Feb 2019 10:11:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2547C2B9B5 for ; Sun, 24 Feb 2019 10:11:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728262AbfBXKLW (ORCPT ); Sun, 24 Feb 2019 05:11:22 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:42396 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728096AbfBXKLU (ORCPT ); Sun, 24 Feb 2019 05:11:20 -0500 Received: by mail-ed1-f67.google.com with SMTP id j89so5191147edb.9 for ; Sun, 24 Feb 2019 02:11:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=hmWe158jp9FE67wVvBYJFEYdrHr9Pj7yRIiHYs5M3Eo=; b=ches+dAWis5TeNyK/O7qtMeRCEDOZVYT9HUVduz0II3I2Y8lZNVeyqVhrvXeehfpPw rvhrFxZJAGTMcsguBYH7M9hrGWUgIK79RGRVAENPsfVHC7DwHBYIyNJ0t8GGwhTArohg 4nOhZJc01BC1Y+s+AsY64xycI6ETAsj+AUJcwnUzkWBMA2a0iH5MPv789qmWSK6Izu08 WmJd5qOV85uaeXblwjt+iuTnWZT2WEXZNfM0vrdTD0YtxMhH+9zqCGDs09bMn6jetyaG OrDCbYFqzyPWjnjfo671zuhKfgFxLEXAAra0eCWykg4MH75I5rX8y20k0SHWcdaS4g3/ OCdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=hmWe158jp9FE67wVvBYJFEYdrHr9Pj7yRIiHYs5M3Eo=; b=dyxFEAL1yqGpVWf4RaST/mNexIpUSBPgm0YYqDoH3v0phWGKisQLzG7Uyf/KjQSwHa ueVjWMct8JJpiSFBC20kHitK9cotNeUCzuQmW3+SLzfAneAcvmlF4qsxld8Mkbsp5P7H oDWJ7pwjCGpG5NUW/c2XT88OTRf0ZU1psK2tiCYs1Pcb3HNFyDFfjB+hr5LG22VozI6/ 3kn4XirGrMdnYOjTRMS0UvHRYoujDLXhM1sCkvlsnd28VYu5JjuMw1w55tVKzNGEskBN hmNnPslJVbZByGIhL9bOXq9oVdIufE2AxBHS9JaEAWIq87WKa5NOv2WBSHTR9qRjz6O0 8Uqw== X-Gm-Message-State: AHQUAuYCahp9z+T6JKfF0m8ncnJcxHrfzKpmlwOzs46tH+Bffhl0UR0/ Mqji+LmkZk/QyRnSwWuVuq/6yqKl X-Google-Smtp-Source: AHgI3IavMYIxodSjMy8Gn2wE9qD7chk6/LLw4McgUQC/vN4qJtKeOyBZugGLhsT5JZsJySc88SR0uw== X-Received: by 2002:a17:906:7206:: with SMTP id m6mr9208756ejk.145.1551003078915; Sun, 24 Feb 2019 02:11:18 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i42sm1821362eda.86.2019.02.24.02.11.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:18 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:18 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:10:52 GMT Message-Id: In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 04/26] bisect.c: libify `exit_if_skipped_commits` to `error_if_skipped...` Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 method `bisect_next_all()`. Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane --- bisect.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/bisect.c b/bisect.c index 487675c672..bb926f09d0 100644 --- a/bisect.c +++ b/bisect.c @@ -659,11 +659,11 @@ static void bisect_common(struct rev_info *revs) mark_edges_uninteresting(revs, NULL); } -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); @@ -674,7 +674,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(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(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(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(prefix, revs.commits->item); From patchwork Sun Feb 24 10:11:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0CEFA1399 for ; Sun, 24 Feb 2019 10:11:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED7A12B9B2 for ; Sun, 24 Feb 2019 10:11:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1DA02B9B6; Sun, 24 Feb 2019 10:11:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C58312B9B2 for ; Sun, 24 Feb 2019 10:11:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728271AbfBXKLX (ORCPT ); Sun, 24 Feb 2019 05:11:23 -0500 Received: from mail-ed1-f54.google.com ([209.85.208.54]:45415 "EHLO mail-ed1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728120AbfBXKLV (ORCPT ); Sun, 24 Feb 2019 05:11:21 -0500 Received: by mail-ed1-f54.google.com with SMTP id d9so5178032edh.12 for ; Sun, 24 Feb 2019 02:11:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=UQ4CCD8hkcBwpkfRYkUR8c1ujID7gYubmdZdKWZ/jiU=; b=Phja/wg3QgjrA3yeJHv1fTjo0qQRsj0yNMLfGtO9MezMvjUw0uYxb1g9B5XObtsybV HRZaTwHFWJdRGdtmPzZoNZG5Cy8idk4xGofzdSKw29psIqrW2r10MVnHGMLlhj4Hnr6h q9nGr12HlWcah1vtYQ5XDEM4Us/Kbwyf+zwFcL4g5s1O23NEzB06dN+s9tr0hrncFOO7 qt/LzHmMx86Z8TDxnql3KIYgRtINF15gpYP25Jgf9lnksWNuCwHwy0LGrgT1rfVJjahV lN5Cf0aQRoc0PzXa0zLFuCuHmVE1A+lMvHKa1uK5VBfG0pzsBMqNXAGmSZrw3ad9+gCe dHLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=UQ4CCD8hkcBwpkfRYkUR8c1ujID7gYubmdZdKWZ/jiU=; b=nIFYgRlbh2etZ7DnHlXc/qYGCWrKC/B3kGGJPYBGMLHuPdSrMjllxH+Hr8gCbe4Ky8 I08XZLx9dAPtJLcUNLSSd8G1iClhx7+7cNfKagHVp4r8Rx4Xhj02khKBtAVGzYcGiv5Z VpFs5hn0zWJZvd8rk6Y8p+FqGPnURAe6yrc/1VAvvd/4uC0Hv6dr1nGoeUwfF+MY46ii d7kwWhR4L3Df5JUGwpeuTVeOqLx3h5H8nP2Zi8Uu8VdDJy1CVc2r4goIVZhkoxiRSlKp Yq678NWSDyK0T5couSYZEB0pZee4JbYcTkb86u+CiXwGVnWUZEuphTNXrSNnTzidbr3s UfcA== X-Gm-Message-State: AHQUAubrNchhwOQit6DjZQaV1lG6kUXZwvW3J/KDUhm31LOsUkvLwTWN voD6CeQuwuFmLovXOi08ybD4W6fX X-Google-Smtp-Source: AHgI3IY67SzmMKayjb/G063qZPdP6FPNnrNmYG9DxqML9JWb2/xnPW1Mb50SaCZp9zqE+Lw6ZMFmYw== X-Received: by 2002:a50:b613:: with SMTP id b19mr10183991ede.214.1551003079699; Sun, 24 Feb 2019 02:11:19 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n25sm1823443edd.83.2019.02.24.02.11.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:19 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:19 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:10:53 GMT Message-Id: <45c00ddf64982448361c461964e4ad77a328be74.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 05/26] bisect.c: libify `bisect_checkout` and its dependants Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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()`. Handle this return in dependant methods - `check_merge_bases()`. Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane --- bisect.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bisect.c b/bisect.c index bb926f09d0..1f2f3201a3 100644 --- a/bisect.c +++ b/bisect.c @@ -710,7 +710,7 @@ static int is_expected_rev(const struct object_id *oid) 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), GIT_SHA1_HEXSZ + 1); update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR); @@ -719,14 +719,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(const struct object_id *oid) @@ -822,7 +822,7 @@ 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)); + exit(-bisect_checkout(mb, no_checkout)); } } From patchwork Sun Feb 24 10:11:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D71AB1805 for ; Sun, 24 Feb 2019 10:11:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1D872B9B1 for ; Sun, 24 Feb 2019 10:11:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1E9C2B9B7; Sun, 24 Feb 2019 10:11:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94E432B9B1 for ; Sun, 24 Feb 2019 10:11:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728273AbfBXKLX (ORCPT ); Sun, 24 Feb 2019 05:11:23 -0500 Received: from mail-ed1-f45.google.com ([209.85.208.45]:41734 "EHLO mail-ed1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728251AbfBXKLW (ORCPT ); Sun, 24 Feb 2019 05:11:22 -0500 Received: by mail-ed1-f45.google.com with SMTP id x7so5198735eds.8 for ; Sun, 24 Feb 2019 02:11:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=jwJwlovIi86pVFsbXvj+6QMHOlznabX3ihIVBcOzS2E=; b=dWQCvK4hLK3sle8PB+TfdlR/kMAsKLXdHyCtK0eiEDbe63F8SynnXRSWIxmLV8IupW gfCIIaKVWPqJbo5mc4FCtNvfkGQxMF8Dlt790AfH4t+NQ8t/OV30DwbUg3ggAPbcLvGK /cbSdtAcKsp63HTwop7t6H2/11pERwtBnIW6NKoidmg/QW6C8+uXaLkig7hSy1iKliHh b33JE4jM/0AghSKX1/jETxIOvaWUjxgg9MFnnlmPPDdaPJX99KgJG0VGTLgT+QvREUNG 1nYt86YCz9gYDZpOd4FbWGyRrk38pm1VWvRH/dnHp3UsDDelJVlJfWg6g3j7yzTH2Vgc 2v5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=jwJwlovIi86pVFsbXvj+6QMHOlznabX3ihIVBcOzS2E=; b=Gicd0GjRDutK0QcnY7pFADW1ClmlgPwH8iH5TCbwdDj9uom/gRzneeC9KTmaqcaViJ EJ8jdRFlKLpxQJWNl9lSh9EByiliNJqdBj4LWIeeS8g4iCgGouxg2PH9NBUYiILmnTYo 6ri8soXCfKMeZ99dIR2l8XeL4I0w+UHHdnPy0HX4t1PhRpj6nxeZAfefDiMZIC8a0RKa lyyoT/NwcTsNui4UZUsafaqGGn/BLp+FVrjMpv7s9fXuSwjzTs6mXcYD63+Zvg0nQRs6 R8rMgj9tjRU6jfqQ28Fdwrso1Aodp2A4908SoW7lzGHslCZBdZkuEXCO7WQw9zmPyv6e Aswg== X-Gm-Message-State: AHQUAuYPKNhHmEipNkfdOjeFSaBhh1+On5AsXlEqAtvo87D/2NXF1/uQ RcIeFFGfqjjABY2fj3W/7NYTNHbE X-Google-Smtp-Source: AHgI3Ia0iFu6pp8Vp3atVmQfSwDYebhDRjMZ5Xw0L3RxV+gARqRI8A9MxlYaz1VpvZUpckaEOFKcIQ== X-Received: by 2002:a17:906:35d8:: with SMTP id p24mr9318084ejb.112.1551003080574; Sun, 24 Feb 2019 02:11:20 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l24sm1184624eja.57.2019.02.24.02.11.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:20 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:20 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:10:54 GMT Message-Id: <1a955345100ed3e953bc7b9f0c6ce66f6b2b4e2a.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 06/26] bisect.c: libify `check_merge_bases` and its dependents. Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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()`. Mentored-by: Christian Couder Mentored by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane --- bisect.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/bisect.c b/bisect.c index 1f2f3201a3..1134854fe2 100644 --- a/bisect.c +++ b/bisect.c @@ -801,13 +801,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 cmd_bisect__helper. */ -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); @@ -822,11 +825,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(int rev_nr, struct commit **rev, const char *prefix) @@ -857,7 +865,7 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout) { 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) @@ -874,8 +882,10 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout) /* Check if all good revs are ancestor of the bad rev. */ rev = get_bad_and_good_commits(&rev_nr); if (check_ancestors(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 Sun Feb 24 10:11:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827829 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50386180E for ; Sun, 24 Feb 2019 10:11:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A8252B9B1 for ; Sun, 24 Feb 2019 10:11:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EE652B9B2; Sun, 24 Feb 2019 10:11:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C8502B9B5 for ; Sun, 24 Feb 2019 10:11:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728274AbfBXKL1 (ORCPT ); Sun, 24 Feb 2019 05:11:27 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:33731 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728264AbfBXKLX (ORCPT ); Sun, 24 Feb 2019 05:11:23 -0500 Received: by mail-ed1-f68.google.com with SMTP id c55so5247520edb.0 for ; Sun, 24 Feb 2019 02:11:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=LW/rF5EpX3U/xvmr3B9KFzrTceCR4+8bAW4aFsti+dY=; b=skeuvulFT55eVve5jZ2YRB4cnDXMLW4TCSzfcTMGwW0LSXmbkdmGX4z5Y/ciblNC28 V29g9Wg59obkTwBwA2zL6bOpmgf/S59KsiTXagZAIavMUiDb8djBmiOpLcer+PhzE1bk eH18eYXuG0yJqpvBpUKLD2Dym1zz1oOqJxEk5GyPtzu9YZ2y6vjZzEvEcQguGvEMKqn4 66IYyKN074/BhfmZBj4SX8xY+1bZgB3ioofO3HKF8AK2w9pnFuK27lfkU66LupG8XXNJ s60q+sOR8USCrNEdkWU4rQB9/Sl7TPSfMG3KPiNhkk6TyHV6s90TiJnV+KjsRV4MgNQP OJig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=LW/rF5EpX3U/xvmr3B9KFzrTceCR4+8bAW4aFsti+dY=; b=f9mmnviBZOFFIWU7ut0WH88teUSUJGBAV3d3OTLca9AviRWRGjjcHhHmzNeL4OosPg dHqCtg/D0P2r818bNA0Yh/GHdiAhsnSHxhsxxtUSqcGozsPCRuCDwGLIKkUF+noRQwOr Rbn6Gy4KMklCgsc7Wf0gCBr2U8dBZPuh3qhgkx8cgZoIgBRtodJ5BZbHExo/u1s0v7rW juhY3WNY73XX18NkJotbuGvyboSTt35NxA6q/KIcW/K+NG+qEpkGbTBG2YM+tGs+sCUP 1RVDkTI/YzWwHsfRVb8zSLOQxY33pBQoJsy5yyExGF4GsL0NINV7x8I0SFXh9EfkkDDa bXNw== X-Gm-Message-State: AHQUAuYg1Ppx9/BEUR63sOkQqqcHst9NAhNbedjAhEGbifsiMXB4gQkK vx1Itz7sS0tMzUjxBXcw9UHxpcSu X-Google-Smtp-Source: AHgI3IbNqjZs1osF4r9LSOfKJowpnULYtGC1WFmAVfI6zPQR+Zs/pw4XvRtHjyQcnHss1+KsfErmlA== X-Received: by 2002:aa7:d58e:: with SMTP id r14mr46722edq.39.1551003081325; Sun, 24 Feb 2019 02:11:21 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c5sm1817685edm.36.2019.02.24.02.11.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:20 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:20 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:10:55 GMT Message-Id: <7b878b71d57104e4a2db78c74530e982469a9c9a.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 07/26] bisect.c: libify `check_good_are_ancestors_of_bad` and its dependents Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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()`. 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 `cmd_bisect_helper()`. Mentored-by: Christian Couder Mentored by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane --- bisect.c | 41 +++++++++++++++++++++++++--------------- builtin/bisect--helper.c | 12 ++++++++++-- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/bisect.c b/bisect.c index 1134854fe2..87db1cc4be 100644 --- a/bisect.c +++ b/bisect.c @@ -859,17 +859,24 @@ static int check_ancestors(int rev_nr, struct commit **rev, const char *prefix) * * 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(const char *prefix, int no_checkout) +static int check_good_are_ancestors_of_bad(const char *prefix, int no_checkout) { char *filename = git_pathdup("BISECT_ANCESTORS_OK"); struct stat st; 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)) @@ -884,18 +891,20 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout) if (check_ancestors(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; } /* @@ -973,7 +982,9 @@ int bisect_next_all(const char *prefix, int no_checkout) if (read_bisect_refs()) die(_("reading bisect refs failed")); - check_good_are_ancestors_of_bad(prefix, no_checkout); + res = check_good_are_ancestors_of_bad(prefix, no_checkout); + if (res) + return res; bisect_rev_setup(&revs, prefix, "%s", "^%s", 1); revs.limited = 1; diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index f441ea85ff..ffb5dbe4b3 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -663,7 +663,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) switch (cmdmode) { case NEXT_ALL: - return bisect_next_all(prefix, no_checkout); + res = bisect_next_all(prefix, no_checkout); + break; case WRITE_TERMS: if (argc != 2) return error(_("--write-terms requires two arguments")); @@ -710,5 +711,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 Sun Feb 24 10:11:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2394A1880 for ; Sun, 24 Feb 2019 10:11:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E55C2B9B1 for ; Sun, 24 Feb 2019 10:11:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02F292B9B8; Sun, 24 Feb 2019 10:11:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E67FD2B9B4 for ; Sun, 24 Feb 2019 10:11:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728290AbfBXKLZ (ORCPT ); Sun, 24 Feb 2019 05:11:25 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:40571 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728269AbfBXKLX (ORCPT ); Sun, 24 Feb 2019 05:11:23 -0500 Received: by mail-ed1-f68.google.com with SMTP id 10so5207095eds.7 for ; Sun, 24 Feb 2019 02:11:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=0t9+UdupVVOtJmlTrOVow9yfYJ9/Loi3LBLWoky97BQ=; b=um8GqkgH+xpbmB80O8h1SQcXwF76Cny8y1qmQfNKd1/L033Xndz2IawsUguUF7ZVNk ARhG0BpEVP6A0iBLf3e4srpguV36onk5wCxqz3zqvLrKk+Lg2KAdubH/JpYEIOgJyx/O E7/Kbmy/06XQTJ0NUNKr2Zi//AZmw38uQxGBLNlierb93LR+EtpghtyZBQ10OiMfFRs6 D3LM3Paa1b8PyPh3dMbjk4Zj4+DO/3cpG28brPIpNuV4a1Kui5/TZc74GQQJfT3417M2 PI+LLqioXi8YEcN/1ikt/7q+Z7fZxr8YaBYtux2KlpkUVK0O+1/lYspNNU7/ks533aV1 KLWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=0t9+UdupVVOtJmlTrOVow9yfYJ9/Loi3LBLWoky97BQ=; b=DTn4avXt1CjGI+0spkCFaSTIMT5Vdok4yUkStr2R61uyPwPgI+UTxeKUOdelLtvqQ8 RshCRNh1vbj6jvCiwEC9iBSA4EM5RfDMGljpQOgzhHw9Lqsps4p0EBiVyzKlztEiSons YaZ8yhh466G6w6vQuEb5wAmKnScSZ5r14EEu5ABHjzSQ3cGP5X2N7RdwhAiX5y0EhZ0z fkA6yDTl7uGO2h/otKUmagIkut+1S01tz6Z0NkAbQbuvi6dmg2nomfOR8Pg3XKVreN4F DOEHMPvuO77g8/W89uzWnsDtTKqBd/d6EfGa2ewylZTle5stVQjicgC1sK+Rucyu/bEb 2NEw== X-Gm-Message-State: AHQUAuZ0z0ql7th6U1ZTWcJhxy6B5RknTy+th7HkRdWNUFm8+v/E3tgM ejNjhIgsB08Is+sbUXJzkUBPIlTD X-Google-Smtp-Source: AHgI3IbtS/NCVJBoxkY1fDhWm+raeZQQttH9fLKLRHxfRmgT/MQ0BUbUyQhz7JQvIeF8fMsAkNfHyQ== X-Received: by 2002:a17:906:3496:: with SMTP id g22mr9153961ejb.193.1551003082023; Sun, 24 Feb 2019 02:11:22 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a58sm1817312eda.91.2019.02.24.02.11.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:21 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:21 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:10:56 GMT Message-Id: <1e8459ee7ceec845fd7c956e33c22d8158261d73.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 08/26] bisect.c: libify `handle_bad_merge_base` and its dependants Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/libify this return in dependant methods - `check_merge_bases()`. Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane --- bisect.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bisect.c b/bisect.c index 87db1cc4be..b1ea658a75 100644 --- a/bisect.c +++ b/bisect.c @@ -751,7 +751,7 @@ static struct commit **get_bad_and_good_commits(int *rev_nr) 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); @@ -772,14 +772,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) @@ -818,7 +818,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 Sun Feb 24 10:11:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 652B01805 for ; Sun, 24 Feb 2019 10:11:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52A5E2B9B1 for ; Sun, 24 Feb 2019 10:11:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46D272B9B4; Sun, 24 Feb 2019 10:11:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C58152B9B1 for ; Sun, 24 Feb 2019 10:11:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728306AbfBXKL2 (ORCPT ); Sun, 24 Feb 2019 05:11:28 -0500 Received: from mail-ed1-f54.google.com ([209.85.208.54]:46352 "EHLO mail-ed1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728251AbfBXKLZ (ORCPT ); Sun, 24 Feb 2019 05:11:25 -0500 Received: by mail-ed1-f54.google.com with SMTP id f2so5181045edy.13 for ; Sun, 24 Feb 2019 02:11:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ln1vhX2iRHfPcImzdK9B6NdovHLxlKgMq0rWgJ0mJFs=; b=HKvL8tCd/BbMU0iEoIwQBzUsoSI5ySwMvONE/r2aFqFijCSQ/We7UipgtGz9nkLgVD nWGPgyhh0CJcgapNkx1etKa0WpkpvciiZqweFPL5NY3kXxPhBnBREu5Dsb3vmZUJJq8G nz9BjzsTk8+amtskF+09B8I/LDJE9fsfLE+CoOuk8ZDzehvSsm7uQNx0cVB7D/DHuADr Vm3FOhNPyK2Gyyvy8xi6SXdU64nBZpgNBXwMKU5p9BU5qk4wSaVvHOCS4JUjzwtV/PC+ ASwms8QHV/wj3RTkYMXxAojXmQl4cMXsEn430FUEq55qQwAILmwwvljUUZW4qxKozFRn 7foQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ln1vhX2iRHfPcImzdK9B6NdovHLxlKgMq0rWgJ0mJFs=; b=W6+5nQYeX2sltd5/2wCAts0JifimRR/lADLTjaUt9cC0OwoTfxmpffdJo4S97ct7cW eBdzB/ckwNNvXy34vvo5MufWgBknUaTFwHictSAQlUcX41n8nAWj1H0YpE/PBHBOcTKM BZHmewVZDCgbGNVGnE8Z4a4BdddxMPvMrOLClrcuYYzEPbinrYSYzYHKLUB5w6ShSf4Z v7vyffmMyXJI1DwYFrHb+B0ldnNoNYM96hBccK7MitB/hZ4IXX9hPy+tlQMxVRy8CkPk RNLqcQFF66PxpvCdSao8J3kuey7UmHeRXidtmGzLfssZD4XrS0WZ50E4zXG0H+eqO3yS TQPw== X-Gm-Message-State: AHQUAuZ5NliJ+XFMJJ6FJn9LAGYPpvGVoCrGBbMVVwr0XoOvNsv2u1wY S+4N6XrjE8FAI4G1o4O14dik4wBK X-Google-Smtp-Source: AHgI3IaPF06c5ICGtbr4pPcpPGiTaZPLFzpKlfcRaQUppRX9vAUmvzfrRhIo9okTgxUAtlhdwer5uw== X-Received: by 2002:a50:9156:: with SMTP id f22mr10574771eda.172.1551003082814; Sun, 24 Feb 2019 02:11:22 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id e3sm1182862ejl.49.2019.02.24.02.11.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:22 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:22 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:10:57 GMT Message-Id: <152b7c1229616780e91e1191432a05d44b84be35.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 09/26] bisect.c: libify `bisect_next_all` and its dependants Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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()`. Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane --- bisect.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/bisect.c b/bisect.c index b1ea658a75..3d11a8eac7 100644 --- a/bisect.c +++ b/bisect.c @@ -964,10 +964,12 @@ 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. + * This returned -10 is converted to 10 at the end of cmd_bisect__helper(). + * * If no_checkout is non-zero, the bisection process does not * checkout the trial commit but instead simply updates BISECT_HEAD. */ @@ -997,23 +999,35 @@ int bisect_next_all(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; @@ -1021,12 +1035,17 @@ int bisect_next_all(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(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 Sun Feb 24 10:11:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F20151399 for ; Sun, 24 Feb 2019 10:11:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF3E52B9B1 for ; Sun, 24 Feb 2019 10:11:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D33862B9B5; Sun, 24 Feb 2019 10:11:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88BEB2B9B1 for ; Sun, 24 Feb 2019 10:11:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728321AbfBXKLd (ORCPT ); Sun, 24 Feb 2019 05:11:33 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:39367 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728275AbfBXKL0 (ORCPT ); Sun, 24 Feb 2019 05:11:26 -0500 Received: by mail-ed1-f66.google.com with SMTP id p27so5215982edc.6 for ; Sun, 24 Feb 2019 02:11:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=Igewf11QOd+QNZo/sYWCCtEvepayAFbcyohytZV7QRE=; b=nXhPUg7eazozZwqHuKmbI9oTmrCrrD936nelYk6d+T8IzvnIbgfn9rn1N29qreRxcV olg96D+nM1ZX51Sv4fl0Cmlh87BXjwoqpKeUvaHsWbEHOKOL2Kgxt8shDmJ+SDF5+ZPy skDqba7X07gCRgwYlGHieS61js7xi6TMe/UgeLnP+0DyK4Cj/dbEIGyHxbAIk8FNxeYi 7iU4bxWsqUNAenUKk1xAsJwrvI8oum2o5KcpQHqBGy9pCd9cCXKZ35snWuh0QiK+Day3 nPb9s9eJoJvc8zZ5nud9MDlB+yRdXULJ4MvfpzR37wtcljXxh+x5ViUfoxC+kVctAh7V TApA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=Igewf11QOd+QNZo/sYWCCtEvepayAFbcyohytZV7QRE=; b=BF4CHupRE4xZ7dEDQpj89fTfAR5SqvqlHrpm88vyM1jP6tcADPyXKAVhTDMA53ITfG MtNodlp9ki61dojUWQY+EmfKDvudCoBIBTCy4ACF5IqWBR4pM8Bn7zod4NUFeOv8Y3q/ MtJG68NGp158E7pLahkCMS3VNO5xXXEnVqALcmX3aeQXacwYkMqfV+08m3QcwYNtMfsx JxNQaWTmSCH+epLsMNKaah+2S7TLFn7xo291s2a4pZ/vylcOr7z/87ZCVC4vdEcGtGjV sKYyzjqnAEl/q902MjXGjCX8szoufEXhJDQMtYJ3O1g88kjvh3xWatSXgAUwgIJFoK1S wmdA== X-Gm-Message-State: AHQUAuaQZhyXM7r5MCFrUX0eIHKdK8eAQEeNKoutX6MOXS207A6BX1bK J6+gqQusuW1BCgeVb0zjpzHsUQVO X-Google-Smtp-Source: AHgI3IYtI9bMPHB3JyE4jrXo81vBd4RETWQI5cIGPVaTLqQpJTYUAe4bV8QLtrKbGt8tMlZssOfK7g== X-Received: by 2002:a50:86ce:: with SMTP id 14mr10440805edu.33.1551003083485; Sun, 24 Feb 2019 02:11:23 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s24sm357127edd.23.2019.02.24.02.11.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:23 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:23 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:10:58 GMT Message-Id: <7acd865946935378b75c65330a54e0c889f108b2.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 10/26] bisect--helper: `bisect_next` and `bisect_auto_next` shell function in C Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pranit Bauva Reimplement the `bisect_next()` and the `bisect_auto_next()` shell function in C and add the subcommands to `git bisect--helper` to call it 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, this 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 --- bisect.c | 6 ++ builtin/bisect--helper.c | 156 ++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 47 ++---------- 3 files changed, 166 insertions(+), 43 deletions(-) diff --git a/bisect.c b/bisect.c index 3d11a8eac7..78ac4de395 100644 --- a/bisect.c +++ b/bisect.c @@ -633,6 +633,12 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix, 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(the_repository, revs, prefix); revs->abbrev = 0; revs->commit_format = CMIT_FMT_UNSPECIFIED; diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index ffb5dbe4b3..2f19924471 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,139 @@ 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 int bisect_skipped_commits(struct bisect_terms *terms) +{ + FILE *fp = NULL; + struct rev_info revs; + struct argv_array rev_argv = ARGV_ARRAY_INIT; + struct string_list good_revs = STRING_LIST_INIT_DUP; + struct pretty_print_context pp = {0}; + struct commit *commit; + char *term_good = xstrfmt("%s-*", terms->term_good); + int i, res = 0; + + fp = fopen(git_path_bisect_log(), "a"); + if (!fp) { + res = error_errno(_("could not open '%s' for appending"), + git_path_bisect_log()); + goto leave_skipped_commits; + } + if (fprintf(fp, "# only skipped commits left to test\n") < 1) { + res = -1; + goto leave_skipped_commits; + } + + 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 (i = 0; i < good_revs.nr; i++) + argv_array_push(&rev_argv, good_revs.items[i].string); + + /* + * 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); + argv_array_clear(&rev_argv); + string_list_clear(&good_revs, 0); + if (prepare_revision_walk(&revs)) { + res = error(_("revision walk setup failed\n")); + goto leave_skipped_commits; + } + 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); + } + +leave_skipped_commits: + if (fp) + fclose(fp); + string_list_clear(&good_revs, 0); + argv_array_clear(&rev_argv); + free(term_good); + 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) { + res = error_errno(_("could not open '%s' for " + "appending"), + git_path_bisect_log()); + } else if (fprintf(fp, "# first %s commit: [%s] %s\n", + terms->term_bad, oid_to_hex(&oid), + commit_name.buf) < 1) { + res = -1; + } + + if (fp) + fclose(fp); + 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(prefix, no_checkout); + + if (res == -10) { + return bisect_successful(terms); + } 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) { @@ -622,7 +758,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[] = { @@ -646,6 +784,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, @@ -707,6 +849,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 Sun Feb 24 10:11:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827833 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BEC61399 for ; Sun, 24 Feb 2019 10:11:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 397C62B9B1 for ; Sun, 24 Feb 2019 10:11:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DA342B9B4; Sun, 24 Feb 2019 10:11:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3A092B9B1 for ; Sun, 24 Feb 2019 10:11:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728310AbfBXKL3 (ORCPT ); Sun, 24 Feb 2019 05:11:29 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:40572 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728286AbfBXKL1 (ORCPT ); Sun, 24 Feb 2019 05:11:27 -0500 Received: by mail-ed1-f67.google.com with SMTP id 10so5207130eds.7 for ; Sun, 24 Feb 2019 02:11:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=e/kkoqFiMnKOKsd4pRiVbgsvC/7a9DF4GVrtGAMNKMs=; b=ezBqc26IYhFtEdL+YWzoZ98yjxrrpYClTcVSPsg2iG6uxohATkfRHlWazlR+0OA8yK by4mNxWnNBCdj+2PC9w3yaWcTEwjRunAOMCC+kqkFKxMw4+a/vonLX/r7hcLlStch6M8 E/qUFHdBStBI/C8jyeBBaInlR4QJrnML89pZNMy7y+A6Pv67jEm0cjZEm4OVdRuBfBM+ oXUbe42D5BmxfSjCQsR7DWebqAdSKO+teRvGkeDtD+DHjtH9A5NgtVHTUwowyzqjSniy 4+A7QFY0u44qThElZeTZ+4ME+W0oRVvkUAKDgfiD83Dk05Y4xye7Xq+SF6xCwx3cmwdJ uS7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=e/kkoqFiMnKOKsd4pRiVbgsvC/7a9DF4GVrtGAMNKMs=; b=M1edro3ub8vt8mdCrPLjokSABlnMnGZPaLfpdhwxtwWQnJbyecefvdPntK7WuiVvmK f20+Y1i7OR0A4Qo5VAfAu85qG6iwwKQpBm5CXgz/MqYDtO2tikQz97EzsAoAR0qvsCIM akDhOi2td7+pVwGha8QPmg8GoM6Ag+AGM461Ak2suY4VQhnJJczT8xD0Rz1LxUM+cxAN C8oUsd/J5KWzVpRwVplyF3PTYL8rAtikDpP8oxzwnjxV75BvLGmlB3Gi+WpCcDKY6EkH VSzi3VitVRWpRNquHdHqTbheQ0PMVlxhJZY7e81OgNy2ov47SjeZrA7IfrDqPAjbQuMf aQtQ== X-Gm-Message-State: AHQUAubQieccKgZnEpfvmUDScUShgB8xPAu6OVhJiuQfx1o0cpuRHzwD l2SYx3U5T+ADjwhR4hQ5rOBt8r4J X-Google-Smtp-Source: AHgI3IZqk21RT3DQkcDYi8YZbjNG7FOhtVBza94cu3OUPMfNxwmq4URV21p2vLrFDabVeN7qdDxFDw== X-Received: by 2002:a17:906:28c4:: with SMTP id p4mr9246242ejd.63.1551003084392; Sun, 24 Feb 2019 02:11:24 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bq4sm1195860ejb.75.2019.02.24.02.11.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:23 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:23 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:10:59 GMT Message-Id: In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 11/26] bisect--helper: Finish `bisect_start()` conversion Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pranit Bauva With the conversion of `bisect_auto_next()` in previous commit, `bisect_start()` has been successfully ported to C. Add the subcommands to `git bisect--helper` and call it from git-bisect.sh. Remove `bisect_start()` shell method and call `git bisect--helper --bisect-start` subcommand from git-bisect.sh. Removing the part about signals as we are not doing anything anymore to trap signals. 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 --- builtin/bisect--helper.c | 29 +++++++++++++++++++++++++++-- git-bisect.sh | 29 +++-------------------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 2f19924471..d538cb04fb 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -697,9 +697,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". */ @@ -743,6 +743,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 trap 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 Sun Feb 24 10:11:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827835 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD7B21399 for ; Sun, 24 Feb 2019 10:11:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB2A42B9B1 for ; Sun, 24 Feb 2019 10:11:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F6D12B9B4; Sun, 24 Feb 2019 10:11:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36BA32B9B1 for ; Sun, 24 Feb 2019 10:11:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728317AbfBXKLb (ORCPT ); Sun, 24 Feb 2019 05:11:31 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:45094 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728269AbfBXKL1 (ORCPT ); Sun, 24 Feb 2019 05:11:27 -0500 Received: by mail-ed1-f65.google.com with SMTP id d9so5178131edh.12 for ; Sun, 24 Feb 2019 02:11:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=YvJYn5Toj5r0hLzPiPZsVOwhHSlqWsZ5C63ybPPSWoo=; b=VShtqZU6W6fS8h2MMYeeeqbuKjjgZPQLSXDLHGY6uQNglYhmRo7nqDltPXZVad+QW0 TzxjeQDJB8z8lywdJB4kazOs1oPV/obyKhg3kP87AfkQI726mhDn1bbnNVe1qZ3LMlu0 Xn1yKHqVdpUNuuf6MgoAAEFESvXTvvv34OZc+xUGF5OPvIYDHdyTaeqYYmH4uoRZktER Ukq+Anct7/1nS+qBgHLb42vV92PX+9JCqAaOXhJsTSgHByIELW/1xeLqI/RXU2CqTib/ /8xIVF4eaUqM0Rm2AVi401o4yzEieZMV5TW60Strnv4rCO1Qrfqoa7NEVgar336bbbjo iU/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=YvJYn5Toj5r0hLzPiPZsVOwhHSlqWsZ5C63ybPPSWoo=; b=ktDw/S6cDiX/hhBhrT/f10NqpMNY9xDsZsiaN0O60+qiU/OtGvYjKgtlJyM4bSHNzU 3vMMSTInyOtln2+XseNK0xUrOqQyYvPoVxqelFqN/B/xZCrRfdwH3MWnARkeBfh4QT05 Q9FMt1w/vLI1HmvwD9rxqE+8ZMNB4EjosSqgfh2lSmJF/Iodm9WfKpDEwHzP5zCYqNlk mZVqHwKBdp4qNuafhsZHpO5+eqyN2SDLc6GUxE8OhpycPnVwXsynfkuRBvu7Cv0o8vNr qhRTBex0/uWy46nvw6t/i9E3E+kgG/uX2gk/3ce0If1RZiCnEHfNaQRqCdyCnqbVGVid GLDw== X-Gm-Message-State: AHQUAuZisBjNE14J1qbnO6xbR/MIy4XxYmYIVPwe0uOxHmautYEw0aMc J6fMqzZrbJGuo5t1BxUddVHcl/s6 X-Google-Smtp-Source: AHgI3IYzQoRI7G8l7BLtiy3MCzcS3p15FxyI1CZ65gryNghpnEq8UkQpO7HngVakIV+qdYX/+nY2WA== X-Received: by 2002:a17:906:1d0d:: with SMTP id n13mr9285134ejh.23.1551003085163; Sun, 24 Feb 2019 02:11:25 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x21sm1178295ejf.65.2019.02.24.02.11.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:24 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:24 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:00 GMT Message-Id: <7a37c5ca752e1c5ac4dd56232ce94fd41fb49406.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 12/26] bisect--helper: dequote arguments in `bisect-start` Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pranit Bauva As more and more calls are happening to the subcommands in `git bisect--helper`, more specifically when `bisect_start $rev` is converted to `git bisect--helper --bisect-start $rev` it is necessary to dequote the arguments because of shell to C conversion. Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane --- builtin/bisect--helper.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index d538cb04fb..b9f2138811 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -557,6 +557,11 @@ static int bisect_auto_next(struct bisect_terms *terms, const char *prefix) return 0; } +static inline char *dequote_arg(const char *arg) +{ + return arg[0] != '\'' ? xstrdup(arg) : sq_dequote(xstrdup(arg)); +} + static int bisect_start(struct bisect_terms *terms, int no_checkout, const char **argv, int argc) { @@ -577,15 +582,22 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, * Check for one bad and then some good revisions */ for (i = 0; i < argc; i++) { - if (!strcmp(argv[i], "--")) { + char *arg = dequote_arg(argv[i]); + + if (!strcmp(arg, "--")) { has_double_dash = 1; + free(arg); break; } + free(arg); } for (i = 0; i < argc; i++) { - const char *arg = argv[i]; - if (!strcmp(argv[i], "--")) { + char *dequoted = dequote_arg(argv[i]); + const char *arg = dequoted; + + if (!strcmp(arg, "--")) { + free(dequoted); break; } else if (!strcmp(arg, "--no-checkout")) { no_checkout = 1; @@ -593,7 +605,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, !strcmp(arg, "--term-old")) { must_write_terms = 1; free((void *) terms->term_good); - terms->term_good = xstrdup(argv[++i]); + terms->term_good = dequote_arg(argv[++i]); } else if (skip_prefix(arg, "--term-good=", &arg) || skip_prefix(arg, "--term-old=", &arg)) { must_write_terms = 1; @@ -603,24 +615,31 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, !strcmp(arg, "--term-new")) { must_write_terms = 1; free((void *) terms->term_bad); - terms->term_bad = xstrdup(argv[++i]); + terms->term_bad = dequote_arg(argv[++i]); } else if (skip_prefix(arg, "--term-bad=", &arg) || skip_prefix(arg, "--term-new=", &arg)) { must_write_terms = 1; free((void *) terms->term_bad); terms->term_bad = xstrdup(arg); } else if (starts_with(arg, "--") && - !one_of(arg, "--term-good", "--term-bad", NULL)) { - return error(_("unrecognized option: '%s'"), arg); + !one_of(arg, "--term-good", "--term-bad", NULL)) { + error(_("unrecognized option: '%s'"), arg); + free(dequoted); + return -1; } 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); + free(dequoted); + return -1; + } string_list_append(&revs, oid_to_hex(&oid)); free(commit_id); } + free(dequoted); } pathspec_pos = i; From patchwork Sun Feb 24 10:11:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76DDD1805 for ; Sun, 24 Feb 2019 10:11:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 639D52B9B1 for ; Sun, 24 Feb 2019 10:11:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57EE62B9B4; Sun, 24 Feb 2019 10:11:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEB732B9B1 for ; Sun, 24 Feb 2019 10:11:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728352AbfBXKLy (ORCPT ); Sun, 24 Feb 2019 05:11:54 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:37680 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728292AbfBXKL2 (ORCPT ); Sun, 24 Feb 2019 05:11:28 -0500 Received: by mail-ed1-f65.google.com with SMTP id m12so5220730edv.4 for ; Sun, 24 Feb 2019 02:11:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=g7mAQqGPEEotq6e8Ltc1OVzXX9XqMuHLltGTK0Bo6GQ=; b=vALSPnDY1kQV5fALaDjmHFGNmtogV7aQ/g6o01lmnQi9oumbJo3EdrdnpTiL1KYMGH a5cU7js8FUtjUY8ZSJPwxzkbR4xOFSBqdkU+oYH8lLi4DRgQFTheP1UIWk3kPW3au0XQ 4WnFxAoxMOILNUvqNXMRWejZEoPeIgbHKuplqL7NknV1heVKtY1WXAAkXBvCC6DPORLk syH2R+ZWqZykKHzgJUaLna5BUkwMWmTGyAZ1Y6WEPRFAXKUKXHjvYa+da1rp0Xpa5jGp CDy9a4JSZEjoRWCh+V3bdjVOUc0Jk84ZnAYwP9kMlMWY0ZCF+k1gveCHP7lthRVCrIz0 UkNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=g7mAQqGPEEotq6e8Ltc1OVzXX9XqMuHLltGTK0Bo6GQ=; b=D79Tsu8saSkY2ahbZZ1OE6qct7xLJibtLUcv5wNj8PdIrMqiOtP2Z/kJBDG1EiUIgX O2QB7ptRF4cyc+AaTNRrzhKKfQmM80zynjINCXnWmPhK8DkuqQGwAN2jEN43JSzQx2fW 7/0nRt3OSJiDoHm0ln/62IKTWLbZ/DBpGtLxJQJV/E0xPndtvam4s0fwdKctRbnRICmc 7GlNq89luYA0BrXR8EA23XfBKF3fBOaR7C2mtEgWAD80w2ibNHCMQSivxkYGsw34TJgP f2OINUNam7TgLuHe0Tqp93i/MR8MykTqjs5adN3iMkMqMRS6orEg3mM/QnMH1PXCgCNw 9I3w== X-Gm-Message-State: AHQUAuZzuE4vTnBe3x4rwej8ttbHIl+6o1Gh1vprzHWY+Z3UYu+IZImT hLlI68PeTgYC7UsxGi9MzXgkxqxM X-Google-Smtp-Source: AHgI3IbYG7drEovvg44SM9imtrkpAbofxPzJJOuAg7WcReiJAfKJziDImzissbOHipBlCCKu5Qf+4g== X-Received: by 2002:a17:906:858e:: with SMTP id v14mr3519796ejx.15.1551003085970; Sun, 24 Feb 2019 02:11:25 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id p44sm1828580edc.1.2019.02.24.02.11.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:25 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:25 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:01 GMT Message-Id: <99c609453637611b1bd47030675cb4b635beed8c.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 13/26] bisect--helper: retire `--bisect-clean-state` subcommand Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pranit Bauva The `bisect-clean-state` subcommand is no longer used in the shell script while the C code uses `bisect_clean_state()` thus remove the subcommand. Mentored-by: Lars Schneider Mentored-by: Christian Couder Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane --- builtin/bisect--helper.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index b9f2138811..b4f84b3041 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 "), @@ -795,7 +794,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, @@ -812,8 +810,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, @@ -855,10 +851,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 Sun Feb 24 10:11:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5B0331805 for ; Sun, 24 Feb 2019 10:11:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 498122B9B1 for ; Sun, 24 Feb 2019 10:11:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DD592B9B4; Sun, 24 Feb 2019 10:11:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D325F2B9B1 for ; Sun, 24 Feb 2019 10:11:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728304AbfBXKLz (ORCPT ); Sun, 24 Feb 2019 05:11:55 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:45003 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728295AbfBXKL2 (ORCPT ); Sun, 24 Feb 2019 05:11:28 -0500 Received: by mail-ed1-f68.google.com with SMTP id b20so5190686edw.11 for ; Sun, 24 Feb 2019 02:11:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=bMojXkWX7U1iCqlvCmYP8jCehWsev2f4wdsNuVIS0ig=; b=O+11UUr8Zg9zEaTi6dg1lZ8qD+O1Dqwopf7OjXiCUYT7AwUjOXTeo99124FYzdDnqO w6hg9Im7yvWUT4Ef51jjIwkLeDeTwT4Ui/3ysjrEdiHLz9z3c8G8SRHcqejiSBIRLYkR KTdu2n4L/6PBEhgfnvsjXjjyWXWIKZTOVGPBYTiqGusfLF2RAg993uqnsjppG0ewhUFo ieXgfRgTKugeZquGisNplH9ICm8+BbLndk1ze7GMCg8/UeqjmcnfSoqRce1TvujjOLTb 1FVp7cwRgW2cPodrgQk0gs07xUvjYjCafdd/vmc6ZDMmjwAh5q3KBia4ULSVGmtcfRPk Vl3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=bMojXkWX7U1iCqlvCmYP8jCehWsev2f4wdsNuVIS0ig=; b=f7sH2AbemKNJWCFOrS+clEwU2MgSBuJeh5fuJfNugfp5n5CzRRnngM3YZCqvjE5YL5 sqngDW45lm3mZTxyi9LDavjty7Futwnre/I8qPZTbw30HIYdJCfO1TOb6YEW/28Qd+wr SdDbjsUgL/x2FlTLJ3zOM2xkHKqDe8Oz8ifxiMZMnh3ikq/mQoJLJFkHj7E2pjFslEJg KY7UycaF+N6TCzOFAWnIVBJx6hN1M21NPgKtJXHxgHT/hkWGlxgn7vwzU0BlLSXYDwQX 4zd1ffePVky/jvLqTNjty6HuiMuP9djG5Q/BaF75mueJ6fSwKk8VaEYC+VvtSUlgsn+6 TRSg== X-Gm-Message-State: AHQUAuYCG9t514lnW1CCm1ZhoFh+9ttc3lSQmqCarLyanZ9pt2+3/01v lhxKEUW3AqIIi8715lLRWo6MEFW7 X-Google-Smtp-Source: AHgI3IZMpUv8P+siZ39ETQX79I21/OzIlz6aoUwE5957O8ITvQ51hUhGA3skAJisVctQqUqhvJtStQ== X-Received: by 2002:a50:9737:: with SMTP id c52mr10601500edb.190.1551003086690; Sun, 24 Feb 2019 02:11:26 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s12sm1847537edb.11.2019.02.24.02.11.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:26 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:26 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:02 GMT Message-Id: <4b417e183243300d94ed26d9bcf530613cb6d8f7.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 14/26] bisect--helper: retire `--next-all` subcommand Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pranit Bauva The `--next-all` subcommand is no longer used in the shell script and 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 --- 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 b4f84b3041..1a525faf27 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] "), @@ -792,8 +791,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, @@ -806,8 +804,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, @@ -844,9 +840,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(prefix, no_checkout); - break; case WRITE_TERMS: if (argc != 2) return error(_("--write-terms requires two arguments")); From patchwork Sun Feb 24 10:11:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3BD81805 for ; Sun, 24 Feb 2019 10:11:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B109D2B9B1 for ; Sun, 24 Feb 2019 10:11:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A588E2B9B4; Sun, 24 Feb 2019 10:11:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 276872B9B1 for ; Sun, 24 Feb 2019 10:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728343AbfBXKLu (ORCPT ); Sun, 24 Feb 2019 05:11:50 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:46648 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728304AbfBXKL3 (ORCPT ); Sun, 24 Feb 2019 05:11:29 -0500 Received: by mail-ed1-f68.google.com with SMTP id f2so5181122edy.13 for ; Sun, 24 Feb 2019 02:11:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=3cXln+g4eS08s1IYGhPuWoWR4LXb0ZaLcI1AklOivA8=; b=dPe7MSI3XTK65OmcVS8e+l6sRpOs0zODbyMxh1lGmGTc+su7jjChR1Cwd4ifGg0hix eQZQCQAz3b0z6G05WkCPY5wW68Cqwkl1KRg0iwNnWL3d5jcrOZTkXSB7fnN8/j6V7GLc /ZceToIhtviOJSSbTbbyscoQXSte0z/yS4PMBWOeWyLXT26GPH8g86pSSr4ZC1LOV2UE 3+AId+KkH57+MgQLU0ZrhHr2URNrcnfkD0MXpRMRa3svpoB4TNwvAX9jiE9GwVGNcYtZ REaWZHSUiTKCPf3dDTHUosswOfPaKSSG2gO09OucIkk0Ac46ahIoRASPdMIf4QxokJGn 0+Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=3cXln+g4eS08s1IYGhPuWoWR4LXb0ZaLcI1AklOivA8=; b=X2uwAcedsy6ikDdTdpFM7O5OmVOaCr0zsB4ee9b42OqB2lEKG90xaz9kgqQCXisS2z hQhzxZxIapQvNFAHC1v+9D4IetXF7sxjAs90uhC9xSSBIL2ybsTepBSnDag17HUVCfHE Ir7cH4x2aNjyr32B6pAMACjcZ6l3VOWrtqdWOlt/5O9CH57XBHigUh/380uijJDZoZ+C 18YsXiCAtcoudzDDd1rboei4Tej98u/hGe1jLc2+dXWvE3Q9YnUfbH0QUIJF1eXx4gcM hVDFurjOZdmTMUHvhp2gMkO8UKgvJP0mFcN+7X8wKGo4N5ySlsMfoTXpNwQ/mxT/2JV4 YBjw== X-Gm-Message-State: AHQUAuY3wWVQui271fXNdpfk98vLvAgzMtneNBu6UoYlQjMZjlXJV30z uhwmuqsA8fvxC8SjR7fOVO9xE2Vj X-Google-Smtp-Source: AHgI3IbGcukBW8IdHxSOOaRGDotnKaCdyOTIw1ckGPJXVCEbWq/lEE1KDFXedBssSy8rGq/6prr7Fg== X-Received: by 2002:a50:a086:: with SMTP id 6mr10136713edo.88.1551003087432; Sun, 24 Feb 2019 02:11:27 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f10sm1838468edb.60.2019.02.24.02.11.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:26 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:26 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:03 GMT Message-Id: In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 15/26] bisect--helper: `bisect_autostart` shell function in C Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 will be called 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 --- 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 1a525faf27..61c3cc517a 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. @@ -530,6 +533,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; @@ -788,6 +792,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 { @@ -801,6 +831,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[] = { @@ -824,6 +855,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, @@ -890,6 +923,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 Sun Feb 24 10:11:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 290B81399 for ; Sun, 24 Feb 2019 10:11:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1678F2B9B1 for ; Sun, 24 Feb 2019 10:11:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B0322B9B4; Sun, 24 Feb 2019 10:11:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36F0A2B9B2 for ; Sun, 24 Feb 2019 10:11:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728347AbfBXKLp (ORCPT ); Sun, 24 Feb 2019 05:11:45 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:42401 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728307AbfBXKLa (ORCPT ); Sun, 24 Feb 2019 05:11:30 -0500 Received: by mail-ed1-f66.google.com with SMTP id j89so5191285edb.9 for ; Sun, 24 Feb 2019 02:11:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=KlJ9cMpqDkWyoV0Jjrl+Y9ejaSD6ZiIhkgFYc47D9Co=; b=FmAa/ntyjpJnHa9wBd8htHWvqb165X7Qhr6TbhyPk2rvl8hRoQR3nn5iwByVj5vbNA SVndSRNKAWy7n0S5WlbK0FbEqXcpq+60CCYRo1SVkaPRQIEr7nlxik/xpM+0CIjekz/B Ee/r/GXwS45dppiAS2nDecKzDNHVlrMovvQnDAjamnseYf30ItAqpfmjoFwdPK3K8dcl QJnpAkFC9Ps33UJvjw/jKcZwoMfEUuX0XCGZWy5e797sC7EQ8n9GdAh0xbOOyI3fhXFi xptnSvd6fAUmwv+NOj4DYRJz8XA2kw8wo1YXDVZBV5Fk0mlr39Qm8Zn+yqhqKybpnaSl Dw7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=KlJ9cMpqDkWyoV0Jjrl+Y9ejaSD6ZiIhkgFYc47D9Co=; b=jE8a8AjRuLIz2AZyYT3pQCJBU0WehQk4yI7N4gNOz758P00ddq+9w8lt0dxXLZyMHr tqqEYw+JLjD4HwE2S944JXsq/4n/iNVOPw6pzbnbD+MoRnVURjSjzG0CLks78jFAzOHw RkxNWnYpC8d3jpY2981kzpSp1f0FPb4skzkdesQkweJqBD3jMI/MLdlLrYChcSx2xhxm DnfRUaQRy5Ib4+CQeavxPxkmOjzOLMoLIyoONoHKJFOYojttND3g6R0dHgdt8U6aMMaR 6RlrluLTyiXndCJ+HwsFcccvoBuDuovbcEaWLZW7trPkOCr/Xd4HC0NrhDznyldXAmqS QYog== X-Gm-Message-State: AHQUAua3I7IwYgM8EfAEE4MLc8J5T37mfM3fF4yOX6NopkaqgExG9ftX x8UcwwIEvYeSSaMhLrcNm1pewQ1x X-Google-Smtp-Source: AHgI3IahJ5JBdw5srMVBqD5hkla6m7r5cx5KDc/QpDDX57QUSg4oQCAure1cZx87B/ioyxmRg+37wQ== X-Received: by 2002:a50:a7e6:: with SMTP id i93mr10158363edc.193.1551003088187; Sun, 24 Feb 2019 02:11:28 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h22sm202440ejj.43.2019.02.24.02.11.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:27 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:27 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:04 GMT Message-Id: <8e011fa67a0bf64a4ee0aeb0c76a943260316ed4.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 16/26] bisect--helper: `bisect_state` & `bisect_head` shell function in C Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pranit Bauva Reimplement the `bisect_state()` shell function in C and also add a subcommand `--bisect-state` to `git-bisect--helper` to call it 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 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 --- 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 61c3cc517a..49ef0ff6bc 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 }; @@ -818,6 +820,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 { @@ -832,6 +902,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[] = { @@ -857,6 +928,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, @@ -929,6 +1002,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 == 0) + 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 Sun Feb 24 10:11:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 257DD1399 for ; Sun, 24 Feb 2019 10:11:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14C112B9B2 for ; Sun, 24 Feb 2019 10:11:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08AB22B9B4; Sun, 24 Feb 2019 10:11:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A53F22B9B6 for ; Sun, 24 Feb 2019 10:11:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728344AbfBXKLn (ORCPT ); Sun, 24 Feb 2019 05:11:43 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:45004 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728311AbfBXKLb (ORCPT ); Sun, 24 Feb 2019 05:11:31 -0500 Received: by mail-ed1-f66.google.com with SMTP id b20so5190756edw.11 for ; Sun, 24 Feb 2019 02:11:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=gJVa9u1wfPiIxgZuqSzYZ9lWvlQNuPMM5dU5oM8uMr0=; b=B7N+wb/V0RWvydEPRdmrlprrK/7nJUY6tk/ZGQFEk0oV10RHV5eEFkWmj7WPmbQxyd 2qU0pVvgfx0cokcnDAQN5bgQ0EpyL7f5NB55qzk505uMMmd296G2FGFgayc4VrhZZQPu GaRQg87/4UZyBUrgR7FPFR3KpykHN5gNsnACnyKte4e/nSt35sbYOf9bhqlhviKrrSnE GykRWVr+H+1GDcLR4WGWWF2KC0I0VsgrC+vr1evLPrFt4h5dlP2Rz6IRvWFGFys+I8sX IvWaX+IwsaMjutWZBzw2Tn/CraYYT2cjQA9Ni0iIqxijpDnhX7AUpXQ0DoRmHWU2qzYg PsEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=gJVa9u1wfPiIxgZuqSzYZ9lWvlQNuPMM5dU5oM8uMr0=; b=rrscTbvgLl5SEmc6VWJBVfqMGOrFey3DY1D7GuQuH3GJF3L/vnQsYeyAbdSEvNFady pV9vo+EqmJocttILVydg9yRPxGAw25FJ5ff9Pohdd54IeAQGh+KlxwnltMa2GLVUUVi0 hHhQaVVuNH+JYsntsOFpl7e3HklZBjTtFmu7IPOYasVBuXSZhi/bBoEsr9V7XUReYZsa kxETdBdq8b3cw8PkGDm4+3lI+Fj3GSiJU08klUAyHxVf/t7UTvTR9TClWuaR7bnwi7SS r03sTfvw2EriBgs43NGOhs3w3zBpKNFTBW708atvBG2YEUfkZ2rgBnpaBMqbKE+6hVg0 pNzg== X-Gm-Message-State: AHQUAuYWoADxdBhMDNHt+e1WSdiTT9Vs1kr++7mVpz611l3Zw7NqSjhJ Brrt0uJCwAotqzJB2GzEa1nIZa8n X-Google-Smtp-Source: AHgI3IZ5vPmhDatiwFk4xiYs8y70QSO8LtiH9pv3fJDIR9mqSFqCVP6rGSlvieXbA99XSY6EG/sY4A== X-Received: by 2002:a50:8b8f:: with SMTP id m15mr568553edm.132.1551003089054; Sun, 24 Feb 2019 02:11:29 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m3sm1194778eja.11.2019.02.24.02.11.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:28 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:28 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:05 GMT Message-Id: In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 17/26] bisect--helper: retire `--check-expected-revs` subcommand Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pranit Bauva The `--check-expected-revs` subcommand is no longer used in the shell script and 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 --- builtin/bisect--helper.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 49ef0ff6bc..9cc11450f4 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -892,7 +892,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, @@ -908,8 +907,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, @@ -950,9 +947,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 Sun Feb 24 10:11:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B3328180E for ; Sun, 24 Feb 2019 10:11:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1A522B9B2 for ; Sun, 24 Feb 2019 10:11:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95AA42B9B5; Sun, 24 Feb 2019 10:11:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3851D2B9B2 for ; Sun, 24 Feb 2019 10:11:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728338AbfBXKLn (ORCPT ); Sun, 24 Feb 2019 05:11:43 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:34991 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728286AbfBXKLb (ORCPT ); Sun, 24 Feb 2019 05:11:31 -0500 Received: by mail-ed1-f68.google.com with SMTP id g19so5234976edp.2 for ; Sun, 24 Feb 2019 02:11:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=h7PMWlyKKrpUGCISt24ek3jJZkvQMgstUU3PuPifBtc=; b=ce8cZ36O4HzKGCaSXLZv0x/f0KU+e+s0mgFr4BJ+QlXJKI9xLBgYlhq1IbQP6Ig/5r Q/otrsa+k+NErlnd5M/S6hLbPO2Sk0swI5in2DZkFR/WgB3aE7/XjTBYoR5SguHmHTDF VGm5pfk5L/8BEUDOJJG0TLN9R7WAq/U/fu9EABLQmU8ivL58kGs0ML8ysZyjzhsWFNqI QSvKerTz/4ClCUdwP/1koSoFz2R3TlUJPYl6qgnjubegeUAjRbTYNbIDhMzmybSQAEip DeRYNgdTPVFEwrrH7PH5ajUEmaPjf9HqVYabNhuweepkKmz164bL9g2jldjUaPNzAHnz E+LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=h7PMWlyKKrpUGCISt24ek3jJZkvQMgstUU3PuPifBtc=; b=Dk9WSu5amzqXUJV3R5i6CuCAGs7jR6U/m8uScgCm8PwokCBTC3gHm9U8tXv1PpZyYS QVsD08DqgN+EJZRKm0HbOitSIyfCKLRbw/N5UVOgH5znZBu19cYdgTWqiLgWGfM9Yf9Y 7mZaFueZve2ANY3pkRzg4gp0RCeUZejL1ahvApICw1POpY/J8s5Z1/18z6k9D0emX4kx XZEPiD62zD4mU4OMWy4DxF1+xjHY0Qi+b4E06eAw/Msu4V0Ni9UTjSw6cC0kpqdG0u43 chzBKVLf1bO2lxZK4Eo+W/On+Pt53QokBH0I4K9Q2xUWxaEmNVFT1GIbLr99bgBk7B6j djdw== X-Gm-Message-State: AHQUAua/2iRNQ5TNqESjEp+5ohY8V/5U+uOMdZUq7V6Fmr0Al7l5Ubnm C8v/Zxx1HiAuof5r5AIdOukvCVey X-Google-Smtp-Source: AHgI3IbO714+26mTHKrSIaL/5tt9hBTBGLZwnffhJ1b7heu4ZQGAQ+y4HOb6h9+Q8rhKipUpuJwKNA== X-Received: by 2002:a17:906:a28c:: with SMTP id i12mr9029821ejz.232.1551003089858; Sun, 24 Feb 2019 02:11:29 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k15sm1855962eda.22.2019.02.24.02.11.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:29 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:29 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:06 GMT Message-Id: <64475fcde911a79fdbc207e5d47a526582a38eef.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 18/26] bisect--helper: retire `--write-terms` subcommand Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pranit Bauva The `--write-terms` subcommand is no longer used in the shell script and 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 --- 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 9cc11450f4..d6308cabd2 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 "), @@ -891,8 +890,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, @@ -905,8 +903,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, @@ -943,10 +939,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 Sun Feb 24 10:11:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27B5D1399 for ; Sun, 24 Feb 2019 10:11:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 121C82B9B2 for ; Sun, 24 Feb 2019 10:11:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 059012B9B5; Sun, 24 Feb 2019 10:11:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BED92B9B2 for ; Sun, 24 Feb 2019 10:11:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728335AbfBXKLl (ORCPT ); Sun, 24 Feb 2019 05:11:41 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:38301 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728314AbfBXKLc (ORCPT ); Sun, 24 Feb 2019 05:11:32 -0500 Received: by mail-ed1-f66.google.com with SMTP id h58so5218961edb.5 for ; Sun, 24 Feb 2019 02:11:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=tYoGZ41nrrzIjpk8aBFFoBwnTV/1q3D+4sVaC1hcBPQ=; b=KmoY9Df17QBYketBS3jQw3xwbaq1E/FzbQOyUez8MJbUq3wsv6PwnyxFS2RECUVfBq 6vgOk+el6ne+HkmWmIRiQU98IwCBuVCSvlOPxx+S2I2La7mEbl7Q01i52TqxOqztf3aj 1yMrP8fmE37LkHuvQdAaCrqoX3tYBV7Bo79Nk4TqLYfWYrHgz2YfJvd1nid3hRaDDpmZ DMZFJWlVuPp5brytgE9/ekdXiUqQQhgS77pP+vqNXWOkwdV+Pa4yiyk9DoQkYSsnxXqX YPZr7OxGDKvMXJt9EtcJpvPnL12kA1RnNcj4WFFZJ5MIKo8507tAXSReX6+FVYjyCA99 RNUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=tYoGZ41nrrzIjpk8aBFFoBwnTV/1q3D+4sVaC1hcBPQ=; b=SW4UZeVXtWKMZ3X6DaDoDPhm5mdk5lgJtosQyNJGtF3ZO1KpjUe80Ki/25eN4IrE5J w3IA8TzQ0FlTbmdEkXvbvkpzlws6HAktiZCKDL1KV9thwcn9c7sCIfUNCQ2tFOnC69NQ nD3znCEnmwJFpG+kigHEXCgtobQdq4cUP2Kz024bATO8fuMS5nAs0R2Hbvl4DMwquQ5H Tvn6q26RmMQ8BFLmAcNTt1CkStTaqE9tJm9mpMdwj1ACVKej7wmcL6skiBQdYzVU/pKm qt4lFqPbNafkEfVDW2cnPvUXxOBu52LE9Dz1PHPJf+Kf66h+HD09N+h2PPnziaEmy2db 43Rw== X-Gm-Message-State: AHQUAuZ0gffUEo2wbzYTafR3fVW0N/iAR5YGNU6lskD2mLde7LtvhQdL Bf4oeCEPzgbxH+v4LF6fzXAybGPg X-Google-Smtp-Source: AHgI3IZpvz4aBzYuPQpSP5eZ+K7J9rky1MZpziHAe1UrCs7dzIOGoyFO9RiC7HwwBznkouqv4dwmMg== X-Received: by 2002:a17:906:f05:: with SMTP id z5mr9241772eji.19.1551003090515; Sun, 24 Feb 2019 02:11:30 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x34sm1832138edm.70.2019.02.24.02.11.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:30 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:30 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:07 GMT Message-Id: <56e46dc23679b6301385df6ad63e6a5678019944.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 19/26] bisect--helper: `bisect_log` shell function in C Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. As more functions are ported, this subcommand will be retired and will be called by some other method. Mentored-by: Lars Schneider Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane --- 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 d6308cabd2..0a482d67cf 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -887,6 +887,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 { @@ -899,7 +911,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[] = { @@ -923,6 +936,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, @@ -995,6 +1010,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 Sun Feb 24 10:11:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827845 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B77F1805 for ; Sun, 24 Feb 2019 10:11:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58E282B9B1 for ; Sun, 24 Feb 2019 10:11:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D7162B9B4; Sun, 24 Feb 2019 10:11:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A29C02B9B1 for ; Sun, 24 Feb 2019 10:11:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728332AbfBXKLj (ORCPT ); Sun, 24 Feb 2019 05:11:39 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:34096 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728318AbfBXKLe (ORCPT ); Sun, 24 Feb 2019 05:11:34 -0500 Received: by mail-ed1-f66.google.com with SMTP id a16so5241311edn.1 for ; Sun, 24 Feb 2019 02:11:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=OIJHk7VSL4iQyI0dnDPtYDbapOs8CNWw2zszEvxXEKA=; b=ohMC3YU7zx1LJyBL5o6ZRZ6bnKzAFhPvbjwwFNyCivnBmCI5TdTaOhOYZtFFyuNnp1 RYT5zWBJ/FDLo2BoZIaOTtLFbab+bFEccsvl4BFIDCApT5z1REa1rnFnpLu8tDvmUynT VarxKunoI7BAWzzmi87LHFyH+RtSLpPlHg4U2Ph9xK3vY0SuPScWAOilkokISusN3ArW MaoRBp6TpMycZkVQGmpKrLXdu4ld2aFsxLSqgybcphBHYc0EP952U6Zk8nPPimhdnhdu fUA3cGWNwDZM2UIzqvkYefB9nwuZS3av6bJ5W/KfU7drGwWJT51duWR1f5cSW5E4/SRP 8XkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=OIJHk7VSL4iQyI0dnDPtYDbapOs8CNWw2zszEvxXEKA=; b=mEC3AbCwkSM7GrxyUXJJlrV77ykaj8Yjc78gD9uWX356nQ6w8W7uXqIVNMR8AjFFMr ucxu1M3z0jEWdB5zZxR5b/uZV40XZiQ9qq+rAG7rt9AwJVxrrRSHCd5Oika56Of2Zm0u rcHUVO+bRP5cgk03mV/FbDO1SR0f6YFHbGVy8cjSudmBSXegAI5cjW+UNvyuJJRbMOEM 4n2YmOJXko6MQg5iEEKLlXRoIMVif/XoCx8oFrdvHqKoofhZ3tCEL2L5duMxjQf6Z7xK NI+NChGZ3wixM4gbQnWy4n464SDPWtuH67z4r+BgJ3wnW1iVRFUx3AOF2m9X6NAMdkH/ A1JA== X-Gm-Message-State: AHQUAuYs7+FC4aJq1zV+AqMHv0jw1CB7BwILL/VxnCq7+vpHyibmLowc ylSCJB3aDDyGaIwXtgP9gO3NgcBR X-Google-Smtp-Source: AHgI3IZ1Gra1E8l87VDspz6f4gYoFp3hrPBYodvnHF796Nw2BbIZsoTmj2lcC3rc6muGfaSPxsoGYg== X-Received: by 2002:a17:906:7b0f:: with SMTP id e15mr8802875ejo.143.1551003091271; Sun, 24 Feb 2019 02:11:31 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w48sm1817780eda.88.2019.02.24.02.11.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:30 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:30 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:08 GMT Message-Id: <1e9034bb9de0e44be8ecfcc27ebc97d0dd4b44fd.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 20/26] bisect--helper: `bisect_replay` shell function in C Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. As more functions are ported, this subcommand will be retired and will be called by some other method. Mentored-by: Lars Schneider Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane --- builtin/bisect--helper.c | 123 ++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 32 +--------- 2 files changed, 123 insertions(+), 32 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 0a482d67cf..6a1920d3e7 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 }; @@ -899,6 +900,117 @@ 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 bisect_replay(struct bisect_terms *terms, const char *filename) +{ + struct strbuf line = STRBUF_INIT; + struct strbuf word = STRBUF_INIT; + FILE *fp = NULL; + int res = 0; + + if (is_empty_or_missing_file(filename)) { + error(_("cannot read file '%s' for replaying"), filename); + res = -1; + goto finish; + } + + if (bisect_reset(NULL)) { + res = -1; + goto finish; + } + + fp = fopen(filename, "r"); + if (!fp) { + res = -1; + goto finish; + } + + while (strbuf_getline(&line, fp) != EOF) { + 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)) { + res = -1; + goto finish; + } + + if (!strcmp(word.buf, "start")) { + struct argv_array argv = ARGV_ARRAY_INIT; + sq_dequote_to_argv_array(line.buf+pos, &argv); + if (bisect_start(terms, 0, argv.argv, argv.argc)) { + argv_array_clear(&argv); + res = -1; + goto finish; + } + argv_array_clear(&argv); + break; + } + + if (one_of(word.buf, terms->term_good, + terms->term_bad, "skip", NULL)) { + if (bisect_write(word.buf, line.buf+pos, terms, 0)) { + res = -1; + goto finish; + } + break; + } + + if (!strcmp(word.buf, "terms")) { + struct argv_array argv = ARGV_ARRAY_INIT; + sq_dequote_to_argv_array(line.buf+pos, &argv); + if (bisect_terms(terms, argv.argc == 1 ? argv.argv[0] : NULL)) { + argv_array_clear(&argv); + res = -1; + goto finish; + } + argv_array_clear(&argv); + break; + } + + error(_("Replay file contains rubbish (\"%s\")"), + word.buf); + res = -1; + goto finish; + } + } +finish: + if (fp) + fclose(fp); + strbuf_release(&line); + strbuf_release(&word); + if (res) + return -1; + + return bisect_auto_next(terms, NULL); +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { @@ -912,7 +1024,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[] = { @@ -938,6 +1051,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, @@ -1015,6 +1130,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 Sun Feb 24 10:11:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B5CE1399 for ; Sun, 24 Feb 2019 10:11:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09A582B9B1 for ; Sun, 24 Feb 2019 10:11:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F21742B9B4; Sun, 24 Feb 2019 10:11:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91DFD2B9B1 for ; Sun, 24 Feb 2019 10:11:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728329AbfBXKLi (ORCPT ); Sun, 24 Feb 2019 05:11:38 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:45100 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728319AbfBXKLe (ORCPT ); Sun, 24 Feb 2019 05:11:34 -0500 Received: by mail-ed1-f68.google.com with SMTP id d9so5178228edh.12 for ; Sun, 24 Feb 2019 02:11:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=/DGZbxQ0LK5qVdcc2aMZ3kSC+FWi24C6/OVtM5nKCCg=; b=hEynk5oHZnpkAqVzd+OcLDNsS2f+L9GHjzjtwFUjaAInRKdaVfJin9q6Gykfaj+NDl mswUyJuhZXoc1TW+D5eABffpwbgABMnN+ho+2Ss/qmj4LpYMIPu9RhzVDJ+a4WpEHYDH 9mZ6mbIJ/MWkoJB15BwFYVzD2xwXzYQeXSL70A8mifJj1ye6NmZDjVw7GQCU2alcj5iy O0f2WzWEFIM+DXml9//0I4GHy6dZY6vjR7TkipKN4J8U3kdv6p+Ujv3hy5B/kJFhx4Ve 3ItZjGHkema55YQnTg4myPXCfiad98grbGaREV9UULTGVRrNyEw4fNRC8jTDbNiXLxJs J0Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=/DGZbxQ0LK5qVdcc2aMZ3kSC+FWi24C6/OVtM5nKCCg=; b=k88m2IK0LlHHtHz8cHV9o7yut+9GtVuVf0RSjwSJvx1n749TMZfCnFp3oRybRsq7be nStLDEtbIS1geKXvi1KFJFWzS517N+0MGsTjzdRPC8HA5IgoTKXP1b3sclVA5I9nV/EN 9Njmb/AdMwjXpqWOI9vJI58gNhLfU+qsuURrHLsWgt+R0rfA7Ad1vuG4GwYgr1cQa+iq yXiwfSWyZUvMG6B/p28NF9NRQWSSj8JWbV8yiH5e89pWybE5g4QmxLZIOfCxlnPcxsmp /xIMym/5TAz4UtQjFZJJUhn+Wy0ZCxN0kpXK+GimsAYE1MzaeSFpLybSzmV2uGepNJhV eNiw== X-Gm-Message-State: AHQUAuZKkAuzr1XIqY6ecwyHhhhvwEOO76PwcQwWbv6xvvsPxX81JiRL bzwpRB5FBJTfOvaeTOkdnPYotRAe X-Google-Smtp-Source: AHgI3IZ9AiAS5gRvAgxsL74liEUMbh2qiNsspggY1nAV7MrJHTszr/Hs09MFAOq/Sb4dDWsroSc32A== X-Received: by 2002:a50:b646:: with SMTP id c6mr10341416ede.149.1551003092049; Sun, 24 Feb 2019 02:11:32 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f40sm1288740eda.25.2019.02.24.02.11.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:31 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:31 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:09 GMT Message-Id: In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 21/26] bisect--helper: retire `--bisect-write` subcommand Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pranit Bauva The `--bisect-write` subcommand is no longer used in the shell script and the function `bisect_write()` 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 --- builtin/bisect--helper.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 6a1920d3e7..6cd74049e8 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]"), @@ -1015,7 +1014,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, @@ -1031,8 +1029,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, @@ -1072,12 +1068,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); - 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); + res = bisect_reset(argc ? argv[0] : NULL); break; case CHECK_AND_SET_TERMS: if (argc != 3) From patchwork Sun Feb 24 10:11:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827847 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AC5D1805 for ; Sun, 24 Feb 2019 10:11:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 075EE2B9B1 for ; Sun, 24 Feb 2019 10:11:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F02E72B9B4; Sun, 24 Feb 2019 10:11:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9273D2B9B1 for ; Sun, 24 Feb 2019 10:11:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728333AbfBXKLk (ORCPT ); Sun, 24 Feb 2019 05:11:40 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:38303 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728322AbfBXKLe (ORCPT ); Sun, 24 Feb 2019 05:11:34 -0500 Received: by mail-ed1-f66.google.com with SMTP id h58so5218988edb.5 for ; Sun, 24 Feb 2019 02:11:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=lTET2oTpTgc0TvjdCTBHFo5OtJfPzLvrGW1271tCGDo=; b=IWasfszs8bFnsg6gPsqAeXNrmrlA3KP7TjbbX8VWIfa/1+PPPyIe39bYeGPYf6Rj6f amZnWH48dFLGlI3QZbq4oyJy1N78kd50foV9zMYHy4ikx+i+Z76a291+sAvo+V5zsLpK oKucu2aa/FKe0OZX16j3NZaI/Yv9wn2YN5ueVVGaCuBL7YMB2YXJOAGTW5IAfs38jLkl KL5UtWPJndDBXKRkXszZkMtEuYUhNHv16nEE6Y00yA8hDle2JYFJxYPXGzwmjNhWPgKk Whf5E/j8M3EvW5CTkNs49Q/8OTE8bULxLAfGHLuc2KM1tOArwtmqbQ5o39GEzi6buvj4 +B6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=lTET2oTpTgc0TvjdCTBHFo5OtJfPzLvrGW1271tCGDo=; b=UW9DfhY5m3n5U1f6Ap90GHW3mUFJYrKfgUwetyx2sR4yt9ejA2P91aKnAurJrbqWks u8kaFWmkGM5O06I0ZtLEFihwepP2yc7SRZeFYpLr5CQVxId7tdNWxLia4yZjqOfwfp4E hXg3jt4FjoF/vd9RFdVI9VRL8yQ9kCegrPs6bDCUcLs7BT8vicFDob3yi0mllTzL54sp dQkL5SuCjGzIhledsmAz6q3JePy2tAtu0rkYGLRP1KXkuPfSJ6k/lh++wxQciEef9pU/ nv6ipFAn0as52M26v+OSr2LTNXSdzLLsPE5BRJmMGv24pgxMv1eQPTJlVZfk4BmnkAF0 u7FQ== X-Gm-Message-State: AHQUAube2ZpF38VwDr74aik6yvk+RSAqkmk5vmcD6WyENamG13aozAI3 X0chQBqt5lITFIjZsxOttkhRxpMN X-Google-Smtp-Source: AHgI3IboWFPbE/MRXoDk9UNl89jZkh1pH9uPC4YQOZOT727ukVDeBOGKMiufk/q6kYNW71mwLo+wLQ== X-Received: by 2002:a50:86b3:: with SMTP id r48mr10361144eda.17.1551003092792; Sun, 24 Feb 2019 02:11:32 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t12sm1789756edj.61.2019.02.24.02.11.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:32 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:32 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:10 GMT Message-Id: <949c50dc7bcbba5a9bb6879678e490c274887b99.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 22/26] bisect--helper: retire `--bisect-autostart` subcommand Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pranit Bauva The `--bisect-autostart` subcommand is no longer used in the shell script and the function `bisect_autostart()` 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 --- builtin/bisect--helper.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 6cd74049e8..848401094d 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 "), @@ -1020,7 +1019,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 @@ -1041,8 +1039,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, @@ -1103,12 +1099,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 == 0) return error(_("--bisect-state requires at least one revision")); From patchwork Sun Feb 24 10:11:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827841 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A01161399 for ; Sun, 24 Feb 2019 10:11:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CA652B9B1 for ; Sun, 24 Feb 2019 10:11:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 810012B9B4; Sun, 24 Feb 2019 10:11:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10A192B9B1 for ; Sun, 24 Feb 2019 10:11:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728328AbfBXKLh (ORCPT ); Sun, 24 Feb 2019 05:11:37 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:40582 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728323AbfBXKLf (ORCPT ); Sun, 24 Feb 2019 05:11:35 -0500 Received: by mail-ed1-f68.google.com with SMTP id 10so5207272eds.7 for ; Sun, 24 Feb 2019 02:11:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=390tjtd6hStgDVrFDvt5FO6xfDfRGxtkOPFAyOHbBWM=; b=EwZdBekf65XS2t07wENbogeJQteAjlJg2PPnuCoGp+xO8Kw/BJHPS8pCq2sbm49YzV HfvcDKVuV0zFDQOPe5k8YJLAgl0GSehqUyCX/kl8kDJZ7RaTHs+vmLL2Hm6p0KrLNi6Y wRtzTrP9j+gUFA2N76gHAIlwz56Tq1ZNz93/65Y/jvqkmgqMBlFqldNlZwVCPtMc6/2l UY4Zi2sLoncKrTO9uEtEWrZG68zvc9EKyXeFpe2d+VB97DtXrTww4yTT4ZHOm8MkTtOk a/gsq6T3aVDCjLkh52TX8KAYSPie57PfkOIKQ4ut2iQ1BxUFAxjXmu51GKI7qsOfNLWt Tffg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=390tjtd6hStgDVrFDvt5FO6xfDfRGxtkOPFAyOHbBWM=; b=fQR5Zai9yTdnjb8jYdjYTnej1bfzWVB1WVqXGXuMz16URf8KyOEKdjt60vUrzKACjP 0eh9f3cZrjyG8Fn3NckyKIz3CR5VvN97PnOaTxshaII4n/HukoZUOUiXrxkwcCsrC2fm EBSZDXJaftXgbM3/p5fA2Iff+5oucc++IdcbV/VkSUAGpRUYBBz0QPM5axND+dahRz1b T97vS7AVmxf+2qo36ZNvc1Mcx89zg/kWCXNQ79B9DWb/tgAHcfd2Ow1fohjcnDoS097O dqISLeMtlD+Veqk25IpOaJaRYub/jyuGgUZgaXNs6tPOx/iis+GAY+rfuxbTJ08ChS7o +k9w== X-Gm-Message-State: AHQUAuaRkYgFph0ZfSwpVELHPcYi8WiCbXnW/f5p1RytmhlXil7yB1Bg zQXu/x2uH9pErRrDm8GkZciDyrDO X-Google-Smtp-Source: AHgI3IYe/IvwUiwofrdQYc5rEx7PF/5HZ3ahHei2gdPHoQaUS0WvqRD5m0fVOs4TGoVcleorSpbcSA== X-Received: by 2002:a50:e10f:: with SMTP id h15mr9777565edl.99.1551003093461; Sun, 24 Feb 2019 02:11:33 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t12sm1789766edj.61.2019.02.24.02.11.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:33 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:33 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:11 GMT Message-Id: <438c26ae62b48a55326dba6bc3643aeb120cc13a.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 23/26] bisect--helper: retire `--bisect-auto-next` subcommand Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pranit Bauva The `--bisect-auto-next` subcommand is no longer used in the shell script and the function `bisect_auto_next()` 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 --- builtin/bisect--helper.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 848401094d..4b4401005d 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 "), @@ -1018,7 +1017,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 @@ -1037,8 +1035,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, @@ -1093,12 +1089,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 == 0) return error(_("--bisect-state requires at least one revision")); From patchwork Sun Feb 24 10:11:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 629111399 for ; Sun, 24 Feb 2019 10:11:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F3DD2B9B1 for ; Sun, 24 Feb 2019 10:11:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4000C2B9B4; Sun, 24 Feb 2019 10:11:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C97352B9B1 for ; Sun, 24 Feb 2019 10:11:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728350AbfBXKLq (ORCPT ); Sun, 24 Feb 2019 05:11:46 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:39377 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728325AbfBXKLg (ORCPT ); Sun, 24 Feb 2019 05:11:36 -0500 Received: by mail-ed1-f68.google.com with SMTP id p27so5216148edc.6 for ; Sun, 24 Feb 2019 02:11:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=sfc7J9SZuKFabS/ta2+LHmqfazZiHP/YuVNwzg0MP00=; b=AsUx1KXo7BbZ5wUuY8YwQm0KmFb2zI7fI5y8suEUYHoy2PBjThhPD2gAAnFiHeMbqN 0EUM1hXW45tzsZGOrQ6aTkUtjefSsXZuTLCgZWYBKz+9rVafC6ZL3OK28+nI9r/TgBT6 sJCi5wVazqns8nwhjZJe7D/XItDyEfAStxRVMn6uyi14R8XBftf47G6onyF8DiGqeHmq jlM7aFL20BOLzbkB4alZRV0FA1LuKkfkmcQkw6u3nyd12VcKWk3hlYVvNHZ7qcAawXDm FSz6Obmmf+fpuJRIT10sRyi7mpDzkfj7zoB1vIcXjiieGshuIo13zZVzM38tMCLABwPf LhUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=sfc7J9SZuKFabS/ta2+LHmqfazZiHP/YuVNwzg0MP00=; b=Y2qyRfI0l5DSbFPFnDHbhI3QsVPtO1eXYEtTp+ECShkIZ9l7oLFmbr+6EjfhSOok/+ rCZQbo5IRLG+HQ99HwBO2Q2V99v5Qp1S1wNUuqOn8RkZHkoUlUMII/SG6pa+8Ze829ms YkG3VUs6qMMHmB23cry83TE06UegQTCgtbOIijh+nAjAQiCAXeKifJ6lgbolazidJLOT w/nf4efG0l6+w5YKmBVheAI6gOAHgcBtlIPea88jkr2IbxgLzqnBKwdgNIeZEpV2rFe9 cXaJupo8DaEfakC5echesMWmFokG5mj4nV7y4EkZN8sZfp7hlPmPqPPmYGXZ1jf8WKcp lKLg== X-Gm-Message-State: AHQUAuZ3vY4tNU4YOYAVb3+zGqm1+CZqOAAY3GeeTUzh5ZBq9sfN01V1 OLCIMIuU+Ub27qfAR5Qykivapsra X-Google-Smtp-Source: AHgI3IZNM+sgAkzVSfW1Dms9FNxIzpNNHK6ttQ6GnfA457v9IAv8LrJOwfSOohlem1daxpHpBIT2+w== X-Received: by 2002:a50:b4db:: with SMTP id x27mr10362802edd.90.1551003094197; Sun, 24 Feb 2019 02:11:34 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z18sm1205419ejp.44.2019.02.24.02.11.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:33 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:33 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:12 GMT Message-Id: In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 24/26] bisect--helper: remove the dequote in bisect_start() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pranit Bauva Dequoting the arguments was introduced in 25b48b5c to port the function `bisect_next()` but after the `bisect_replay()` porting, the dequoting is carried out itself when it passes the arguments to `bisect_start()` in a simpler way thus dequoting again isn't required. So remove the extra "dequoting" code introduced by the commit 25b48b5c. Mentored-by: Lars Schneider Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane --- builtin/bisect--helper.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 4b4401005d..4eb2580ba8 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -558,11 +558,6 @@ static int bisect_auto_next(struct bisect_terms *terms, const char *prefix) return 0; } -static inline char *dequote_arg(const char *arg) -{ - return arg[0] != '\'' ? xstrdup(arg) : sq_dequote(xstrdup(arg)); -} - static int bisect_start(struct bisect_terms *terms, int no_checkout, const char **argv, int argc) { @@ -583,22 +578,16 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, * Check for one bad and then some good revisions */ for (i = 0; i < argc; i++) { - char *arg = dequote_arg(argv[i]); - if (!strcmp(arg, "--")) { + if (!strcmp(argv[i], "--")) { has_double_dash = 1; - free(arg); break; } - free(arg); } for (i = 0; i < argc; i++) { - char *dequoted = dequote_arg(argv[i]); - const char *arg = dequoted; - - if (!strcmp(arg, "--")) { - free(dequoted); + const char *arg = argv[i]; + if (!strcmp(argv[i], "--")) { break; } else if (!strcmp(arg, "--no-checkout")) { no_checkout = 1; @@ -606,7 +595,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, !strcmp(arg, "--term-old")) { must_write_terms = 1; free((void *) terms->term_good); - terms->term_good = dequote_arg(argv[++i]); + terms->term_good = xstrdup(argv[++i]); } else if (skip_prefix(arg, "--term-good=", &arg) || skip_prefix(arg, "--term-old=", &arg)) { must_write_terms = 1; @@ -616,7 +605,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, !strcmp(arg, "--term-new")) { must_write_terms = 1; free((void *) terms->term_bad); - terms->term_bad = dequote_arg(argv[++i]); + terms->term_bad = xstrdup(argv[++i]); } else if (skip_prefix(arg, "--term-bad=", &arg) || skip_prefix(arg, "--term-new=", &arg)) { must_write_terms = 1; @@ -625,7 +614,6 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, } else if (starts_with(arg, "--") && !one_of(arg, "--term-good", "--term-bad", NULL)) { error(_("unrecognized option: '%s'"), arg); - free(dequoted); return -1; } else { char *commit_id = xstrfmt("%s^{commit}", arg); @@ -633,14 +621,12 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, error(_("'%s' does not appear to be a valid " "revision"), arg); free(commit_id); - free(dequoted); return -1; } string_list_append(&revs, oid_to_hex(&oid)); free(commit_id); } - free(dequoted); } pathspec_pos = i; From patchwork Sun Feb 24 10:11:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19E1D1805 for ; Sun, 24 Feb 2019 10:11:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 080D82B9B1 for ; Sun, 24 Feb 2019 10:11:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F042E2B9B4; Sun, 24 Feb 2019 10:11:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FC832B9B1 for ; Sun, 24 Feb 2019 10:11:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728305AbfBXKLu (ORCPT ); Sun, 24 Feb 2019 05:11:50 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:45008 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727943AbfBXKLh (ORCPT ); Sun, 24 Feb 2019 05:11:37 -0500 Received: by mail-ed1-f65.google.com with SMTP id b20so5190837edw.11 for ; Sun, 24 Feb 2019 02:11:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=nsFGDaUYm2we7Sy0TpieJ72cR21xwc5KcmcElxVORQE=; b=TfNn70n659gHs3axF9iBa9ZOfHNg+Q9C83lB8vLq057InKiRTnf2VDFcegQr4yw+G8 HfFEoRzOvItE9PTda1xNJJY7ZLbacnIkMsw8q3KzAHQc9wPAO6vnn7gj5BCwPKsJ1kh9 QpsvvdLKFxRV8/nWs0/J9cbgPDnqQNLfVAWQ+NupnI90oev7aa4hheeOHPVD0QxEj1Np 3fTwIQA1YIZYq7EPHx2QPOUTz1DJ4QYi7xwMJviKsYREYQHlqTsWLq5AHgWRq7fSL8hU AZ3IvCpAxtwFclNT1qfP0Cemyutr+RV5zW+y4w4ii1qWT72IVOaeOiKEd/dhSLMNhijx 6zQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=nsFGDaUYm2we7Sy0TpieJ72cR21xwc5KcmcElxVORQE=; b=MLxrWDw4mPixzSi44pEP8/hXsAes3Jt4TcyZWdu05nEhWqr1p1nNL21wH9W8mfuwmy hQlJT3+5fBt3MWAgs6doUKY0BVpQ/FKbLB1WAPgbEVjSbrNUyuMgndvbopzAgETzEJWe TEeJ57ioxsIXrU1ctSABs66sNVKWGzeq3v7I3bKyMKJZm680s0Vmig/qviCZgrUpT4N/ u7Fs0cp6CPoeaQgFL2CjRKY1OJ29GwzEYCw4P9txp0eUSq4tCpj0DQBLjAG4/JzSA9s+ MdK0E5Yrah7vGzvxdYUygDb2mz0nzWttuLM7Zvww3gJhVOw9QwcXC75QyJU2u1ce6Z+/ fq4Q== X-Gm-Message-State: AHQUAuYMqieqKNqaf1A7nM7Nel6OZC3Hvv8LJ3MXOUxoEB5oTIslvgPJ elSmQ8ScYTHaj4EQB5sBF4o7D1vH X-Google-Smtp-Source: AHgI3IYcFwBO9k713pGPEjd0AM3x/f8AptFIpIOdIS+IoHWEnnXs4NnFLnX/71Vq1YOtFrGqnfg7VA== X-Received: by 2002:a17:906:f05:: with SMTP id z5mr9241940eji.19.1551003094958; Sun, 24 Feb 2019 02:11:34 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z42sm1826021edd.29.2019.02.24.02.11.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:34 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:34 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:13 GMT Message-Id: <205efd9f60801a1b553cf3fd610f37884b99b584.1551003074.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 25/26] bisect--helper: `bisect_skip` shell function in C Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. As more functions are ported, this subcommand will be retired and will be called by some other method. Mentored-by: Lars Schneider Mentored-by: Christian Couder Mentored-by: Johannes Schindelin Signed-off-by: Pranit Bauva Signed-off-by: Tanushree Tumane --- builtin/bisect--helper.c | 45 +++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 17 +-------------- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 4eb2580ba8..0818dbf8ff 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 }; @@ -994,6 +995,41 @@ 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 { @@ -1005,7 +1041,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[] = { @@ -1027,6 +1064,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, @@ -1093,6 +1132,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 Sun Feb 24 10:11:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 10827863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 110E51399 for ; Sun, 24 Feb 2019 10:11:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2AFD2B9B1 for ; Sun, 24 Feb 2019 10:11:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E72F92B9B4; Sun, 24 Feb 2019 10:11:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 883452B9B1 for ; Sun, 24 Feb 2019 10:11:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728336AbfBXKLu (ORCPT ); Sun, 24 Feb 2019 05:11:50 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:43112 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728326AbfBXKLh (ORCPT ); Sun, 24 Feb 2019 05:11:37 -0500 Received: by mail-ed1-f68.google.com with SMTP id m35so5189872ede.10 for ; Sun, 24 Feb 2019 02:11:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=rHrKf0HyWkGAG1dPNbeHAHHAkpadTVmL0jgrmdZlU3c=; b=aMz0o6tmGg8tgcX9mPVOYPnFcW8Yy+GzfsOi9usW7o4aGO8lNYvfmAs7cp6x4jfzbl nJiQkLaACINotHzORNMqmss/OPIiFqdhx3qXYqnegd3VYmT6YSVdkPoAxQLkzQcefx27 SKUM4THpImTCvQX8iBci1FplnAEOr759sdJL514sN2ZTCx7KJDuuDQhXzySHpjxfoBbk NmzYgtmuevkB49pUhWQv65OEfYWzsvO6ORQjAJXJoq7uQOiMUGCEW6CPtzF3lRqBeEJ7 bMZIHHE/ioS62pxF5w5I55EHHA/lMGKdRe4Zn71tCiUWrH6gDNlquAR4gWL1Ws4PpWQq 29jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=rHrKf0HyWkGAG1dPNbeHAHHAkpadTVmL0jgrmdZlU3c=; b=lGB459fMouWC4/obEcSEJino6QAA1qv5SMTyuL8sTDjqrhCLCyLe0TNHHBSZjsFbPH Afs++MFyke7YpOJ/4E2LOzun9Wnx1aY8SI8pxfjzT6cUW8Hq2WbnjQZkh2CQy4XOrmR+ pAD1i5Kf0XmkDI0Ne5P0TZxeOWv849IKTmnZFvYIcRCyVy9hUwYFk701/BLZiPuAdw2J H1OVCMdK7T/3bEsdgXgUy46JnkXaloW4LJ2x9SAiAT5dd8ccGV1L3WFoWZySYH1IRFWW EkLDAwsBewAC6ngMWp8sgY53WSNm30qILa+8qNrhiOgCcuEm6SPiUO9kgspL5Em2+RnZ LI5Q== X-Gm-Message-State: AHQUAuYOn4U6rylkh6wspuhpPXI17XVDtEs12MivFkrwQSyzbugvtkXA euk2VtO5soHMyzbh43NTODqwSeIX X-Google-Smtp-Source: AHgI3IYB8hl7ywPluw8YRiFAPoHatYmKKn9qYvsnvovoSeK2GZejbs8P/YgwXAkCv+Ma3W8CSpPnuQ== X-Received: by 2002:a17:906:24ca:: with SMTP id f10mr9323920ejb.240.1551003095658; Sun, 24 Feb 2019 02:11:35 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x21sm1178356ejf.65.2019.02.24.02.11.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 02:11:35 -0800 (PST) Date: Sun, 24 Feb 2019 02:11:35 -0800 (PST) X-Google-Original-Date: Sun, 24 Feb 2019 10:11:14 GMT Message-Id: In-Reply-To: References: From: "Pranit Bauva via GitGitGadget" Subject: [PATCH 26/26] bisect--helper: retire `--check-and-set-terms` subcommand Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Pranit Bauva Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pranit Bauva The `--check-and-set-terms` subcommand is no longer used in the shell script and 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 --- builtin/bisect--helper.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 0818dbf8ff..99e2c06ae5 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}=]" @@ -1034,7 +1033,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, @@ -1048,8 +1046,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, @@ -1087,12 +1083,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"));