From patchwork Sat Aug 1 17:58:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lipman X-Patchwork-Id: 11696183 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63742722 for ; Sat, 1 Aug 2020 17:58:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 415E4206E9 for ; Sat, 1 Aug 2020 17:58:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BcZieVQU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727015AbgHAR6u (ORCPT ); Sat, 1 Aug 2020 13:58:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725803AbgHAR6u (ORCPT ); Sat, 1 Aug 2020 13:58:50 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9DBCC06174A for ; Sat, 1 Aug 2020 10:58:49 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id v22so19527817qtq.8 for ; Sat, 01 Aug 2020 10:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qjBRPx+XdKmrpzi9HHohI5X7zfzm0di6w5Adgk2if64=; b=BcZieVQUCbIIBV5COZJSLZNUs3hYfTqCrerNchpq5COcsk2O083kASlUs4K8Oo/dzu +R26zJh6yf/7aIKEZFwisb2boUxa4ze/6fHOAFCR40KpJZihQlBR4BEjcAu4alFnypTX taNu31Ep/TeKV5Xtue7zZoaiTGsVr3KO85+TrT/uoijzk5mXpfadv6JacFjrw8pbMHmS 9Iq8r4UdCTF+3xgkhj4t7HxkdLRJ3jVj1dWMTZLw5LaiXcTJYTThcylYWGgnz2m1ty64 lCMDsPE04593fEhjyGlSjLjF/55XpWU/HhMnsme3jVhy3t/JlkbnQfdqqVWIkCZgNd8L yLwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qjBRPx+XdKmrpzi9HHohI5X7zfzm0di6w5Adgk2if64=; b=RqMDsdhnZNDqozCprwPIKAi/oD3Vnkv3+j2eigWjVUHaZCvJDRwdLjYCyNfwZOcezn mOtmupMD2gTO2z9YyEo7zpYkGdcYmSmaQIDLW+Qkqk4auyOfpVn3r1TnVj/Sshg2SVGR b/bwOOvWz0sLmdrJfUoX1+4T+HpA3hJKwFY/8QqOGmX2Euez4dwBxs+OVglB4T1jon7Z Vtxh5HMlaC8T9HeDThBILca5n7FHboi8Bz7drmpMmw/28mgE9Rfb6yJfodztM9iq6Aqp bsBtSecIw6nDZF/EF7e51d0WWi/yY1dqBP1ENCWafKchFziExVHiZnyX+qWClvnfctcT u0Uw== X-Gm-Message-State: AOAM533O5X9y6o26Y1wlHIbAYDL3/srb/iBxjp2T6DpC2/O7xs62xx+l jBZjTY7+hkVW9FsnvhlZXx7A8ph72fzwfw== X-Google-Smtp-Source: ABdhPJwDqb3RXEQqZQXQZv34I2vb8ntVTqBtmOVZn14qSbWATOP/zcWpM5ZP2kXlBpweShKCNyTkog== X-Received: by 2002:ac8:7181:: with SMTP id w1mr9426128qto.172.1596304728551; Sat, 01 Aug 2020 10:58:48 -0700 (PDT) Received: from localhost.localdomain (c-98-229-3-81.hsd1.vt.comcast.net. [98.229.3.81]) by smtp.gmail.com with ESMTPSA id l13sm13517405qth.77.2020.08.01.10.58.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Aug 2020 10:58:48 -0700 (PDT) From: Aaron Lipman To: git@vger.kernel.org Cc: Aaron Lipman Subject: [PATCH v3 1/4] rev-list: allow bisect and first-parent flags Date: Sat, 1 Aug 2020 13:58:37 -0400 Message-Id: <20200801175840.1877-2-alipman88@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20200801175840.1877-1-alipman88@gmail.com> References: <20200730002735.87655-1-alipman88@gmail.com> <20200801175840.1877-1-alipman88@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add first_parent_only parameter to find_bisection(), removing the barrier that prevented combining the --bisect and --first-parent flags when using git rev-list Based-on-patch-by: Tiago Botelho Signed-off-by: Aaron Lipman --- Documentation/rev-list-options.txt | 7 ++--- bisect.c | 28 ++++++++++++------- bisect.h | 2 +- builtin/rev-list.c | 2 +- revision.c | 3 -- t/t6000-rev-list-misc.sh | 4 +-- t/t6002-rev-list-bisect.sh | 45 ++++++++++++++++++++++++++++++ 7 files changed, 70 insertions(+), 21 deletions(-) diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index b01b2b6773..d3117ce51b 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -128,8 +128,7 @@ parents) and `--max-parents=-1` (negative numbers denote no upper limit). because merges into a topic branch tend to be only about adjusting to updated upstream from time to time, and this option allows you to ignore the individual commits - brought in to your history by such a merge. Cannot be - combined with --bisect. + brought in to your history by such a merge. --not:: Reverses the meaning of the '{caret}' prefix (or lack thereof) @@ -207,7 +206,7 @@ ifndef::git-rev-list[] Pretend as if the bad bisection ref `refs/bisect/bad` was listed and as if it was followed by `--not` and the good bisection refs `refs/bisect/good-*` on the command - line. Cannot be combined with --first-parent. + line. endif::git-rev-list[] --stdin:: @@ -743,7 +742,7 @@ outputs 'midpoint', the output of the two commands would be of roughly the same length. Finding the change which introduces a regression is thus reduced to a binary search: repeatedly generate and test new 'midpoint's until the commit chain is of length -one. Cannot be combined with --first-parent. +one. --bisect-vars:: This calculates the same as `--bisect`, except that refs in diff --git a/bisect.c b/bisect.c index d5e830410f..a11fdb1473 100644 --- a/bisect.c +++ b/bisect.c @@ -88,15 +88,16 @@ static inline void weight_set(struct commit_list *elem, int weight) **commit_weight_at(&commit_weight, elem->item) = weight; } -static int count_interesting_parents(struct commit *commit) +static int count_interesting_parents(struct commit *commit, int first_parent_only) { struct commit_list *p; int count; for (count = 0, p = commit->parents; p; p = p->next) { - if (p->item->object.flags & UNINTERESTING) - continue; - count++; + if (!(p->item->object.flags & UNINTERESTING)) + count++; + if (first_parent_only) + break; } return count; } @@ -259,7 +260,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n */ static struct commit_list *do_find_bisection(struct commit_list *list, int nr, int *weights, - int find_all) + int find_all, int first_parent_only) { int n, counted; struct commit_list *p; @@ -271,7 +272,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list, unsigned flags = commit->object.flags; *commit_weight_at(&commit_weight, p->item) = &weights[n++]; - switch (count_interesting_parents(commit)) { + switch (count_interesting_parents(commit, first_parent_only)) { case 0: if (!(flags & TREESAME)) { weight_set(p, 1); @@ -314,6 +315,8 @@ static struct commit_list *do_find_bisection(struct commit_list *list, continue; if (weight(p) != -2) continue; + if (first_parent_only) + BUG("shouldn't be calling count-distance in fp mode"); weight_set(p, count_distance(p)); clear_distance(list); @@ -332,7 +335,10 @@ static struct commit_list *do_find_bisection(struct commit_list *list, if (0 <= weight(p)) continue; - for (q = p->item->parents; q; q = q->next) { + + for (q = p->item->parents; + q; + q = first_parent_only ? NULL : q->next) { if (q->item->object.flags & UNINTERESTING) continue; if (0 <= weight(q)) @@ -370,7 +376,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list, } void find_bisection(struct commit_list **commit_list, int *reaches, - int *all, int find_all) + int *all, int find_all, int first_parent_only) { int nr, on_list; struct commit_list *list, *p, *best, *next, *last; @@ -406,7 +412,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches, weights = xcalloc(on_list, sizeof(*weights)); /* Do the real work of finding bisection commit. */ - best = do_find_bisection(list, nr, weights, find_all); + best = do_find_bisection(list, nr, weights, find_all, first_parent_only); if (best) { if (!find_all) { list->item = best->item; @@ -991,6 +997,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int enum bisect_error res = BISECT_OK; struct object_id *bisect_rev; char *steps_msg; + int first_parent_only = 0; /* TODO: pass --first-parent flag from git bisect start */ read_bisect_terms(&term_bad, &term_good); if (read_bisect_refs()) @@ -1001,11 +1008,12 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int return res; bisect_rev_setup(r, &revs, prefix, "%s", "^%s", 1); + revs.first_parent_only = first_parent_only; revs.limited = 1; bisect_common(&revs); - find_bisection(&revs.commits, &reaches, &all, !!skipped_revs.nr); + find_bisection(&revs.commits, &reaches, &all, !!skipped_revs.nr, first_parent_only); revs.commits = managed_skipped(revs.commits, &tried); if (!revs.commits) { diff --git a/bisect.h b/bisect.h index 8bad8d8391..a63af0505f 100644 --- a/bisect.h +++ b/bisect.h @@ -12,7 +12,7 @@ struct repository; * best commit, as chosen by `find_all`. */ void find_bisection(struct commit_list **list, int *reaches, int *all, - int find_all); + int find_all, int first_parent_only); struct commit_list *filter_skipped(struct commit_list *list, struct commit_list **tried, diff --git a/builtin/rev-list.c b/builtin/rev-list.c index f520111eda..d1a14596b2 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -638,7 +638,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) if (bisect_list) { int reaches, all; - find_bisection(&revs.commits, &reaches, &all, bisect_find_all); + find_bisection(&revs.commits, &reaches, &all, bisect_find_all, revs.first_parent_only); if (bisect_show_vars) return show_bisect_vars(&info, reaches, all); diff --git a/revision.c b/revision.c index 6aa7f4f567..f0ad2603c1 100644 --- a/revision.c +++ b/revision.c @@ -2869,9 +2869,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s if (!revs->reflog_info && revs->grep_filter.use_reflog_filter) die("cannot use --grep-reflog without --walk-reflogs"); - if (revs->first_parent_only && revs->bisect) - die(_("--first-parent is incompatible with --bisect")); - if (revs->line_level_traverse && (revs->diffopt.output_format & ~(DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT))) die(_("-L does not yet support diff formats besides -p and -s")); diff --git a/t/t6000-rev-list-misc.sh b/t/t6000-rev-list-misc.sh index 3dc1ad8f71..26e3533562 100755 --- a/t/t6000-rev-list-misc.sh +++ b/t/t6000-rev-list-misc.sh @@ -125,8 +125,8 @@ test_expect_success 'rev-list can negate index objects' ' test_cmp expect actual ' -test_expect_success '--bisect and --first-parent can not be combined' ' - test_must_fail git rev-list --bisect --first-parent HEAD +test_expect_success '--bisect and --first-parent can be combined' ' + git rev-list --bisect --first-parent HEAD ' test_expect_success '--header shows a NUL after each commit' ' diff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh index a661408038..7fc0f75ca5 100755 --- a/t/t6002-rev-list-bisect.sh +++ b/t/t6002-rev-list-bisect.sh @@ -263,4 +263,49 @@ test_expect_success 'rev-parse --bisect can default to good/bad refs' ' test_cmp expect.sorted actual.sorted ' +test_output_expect_success "--bisect --first-parent" 'git rev-list --bisect --first-parent E ^F' < expect.unsorted < expect && +git rev-list --bisect-all --first-parent E ^F > actual && +test_cmp actual expect +' + test_done From patchwork Sat Aug 1 17:58:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lipman X-Patchwork-Id: 11696189 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AEB68161F for ; Sat, 1 Aug 2020 17:58:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D1D0206E9 for ; Sat, 1 Aug 2020 17:58:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lClypt1W" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727050AbgHAR6w (ORCPT ); Sat, 1 Aug 2020 13:58:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725803AbgHAR6u (ORCPT ); Sat, 1 Aug 2020 13:58:50 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A46A1C06174A for ; Sat, 1 Aug 2020 10:58:50 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id x69so31856746qkb.1 for ; Sat, 01 Aug 2020 10:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3I/MauiJ8y5gLv3ciPrmlBUOb7Abnv4+Ewf+ZHf3Jqk=; b=lClypt1WrTtU7ruZEQOx9DG4rAQMYJcSDm0/j3a5SJF+Fk/KzmHGktuPUilq9LznZ4 mwO/+C6yXqmFzTvsh3QvN0eDzI1XmU4zBH4LGOzsBckkFn5ALBC+pTJL1hpTHuheC5DA N1rbiAGCcRksg//tl9iMfSx746QQG+eXLKdp5RUAyNrOqefK8SH/oCO+lw9+r5F8gFy0 h0jisRheGcFXB8PjkcABwMOmdY5kz214LArXUMzifV081mT6RIIJVH3bjttpU0gQi4PD qy4rv3GiLmBJOeC7wPUtHamJQE/kH1nsE8AKcEA+Tmk+zdasKpOMPlE3kDPzNzvkmWSc cIUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3I/MauiJ8y5gLv3ciPrmlBUOb7Abnv4+Ewf+ZHf3Jqk=; b=S+tZ/yreoNA1G894KIrJFzhwIEwjAN6bfus2l5J/DDVmYVVDTR/vrrTxYOlt36JZVJ MsvLD0rmUorslTwXL+0Ng/vJMmST01p2Riarzo2qR7waZrMD4W5B3XHnYYdawSd6Dl04 m+4TvlMcquMQbnLeN50F0rRxOzcLao2BvHbPWnzWVKDfsqXKtThsJ4VdMbGFQrXFnjoD Xvwrh1tDFBjy5O28ckhqCT6EUk4Mc71TV4WIaFAXWxfrVhh0cogg8wOYRrOcjrrEZMS8 J7qSgEkzoN0sEA700ue90uZMbhxLejtKRpmxhBWHzI2IdwdlVOdYBlXguvj2T13sD/+f AN2w== X-Gm-Message-State: AOAM533mtRLtqbi5ObVIOkIrOvsM+REI4pbpnolNg5Ei91LJx0pZgRHM FHhuG2QxYMGqu5jUtVXzOp8W2xJ4ytoLFw== X-Google-Smtp-Source: ABdhPJwVuJbP/ToIq7FCAYco7RfDU/sFqF/r6Kb9HEFGJhZ3gtjL0qUcFrggxeDrMUOJLVrXp8STMA== X-Received: by 2002:a05:620a:12c7:: with SMTP id e7mr9030416qkl.433.1596304729606; Sat, 01 Aug 2020 10:58:49 -0700 (PDT) Received: from localhost.localdomain (c-98-229-3-81.hsd1.vt.comcast.net. [98.229.3.81]) by smtp.gmail.com with ESMTPSA id l13sm13517405qth.77.2020.08.01.10.58.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Aug 2020 10:58:48 -0700 (PDT) From: Aaron Lipman To: git@vger.kernel.org Cc: Aaron Lipman Subject: [PATCH v3 2/4] bisect: introduce first-parent flag Date: Sat, 1 Aug 2020 13:58:38 -0400 Message-Id: <20200801175840.1877-3-alipman88@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20200801175840.1877-1-alipman88@gmail.com> References: <20200730002735.87655-1-alipman88@gmail.com> <20200801175840.1877-1-alipman88@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Upon seeing a merge commit when bisecting, this option may be used to follow only the first parent. In detecting regressions introduced through the merging of a branch, the merge commit will be identified as introduction of the bug and its ancestors will be ignored. This option is particularly useful in avoiding false positives when a merged branch contained broken or non-buildable commits, but the merge itself was OK. Signed-off-by: Aaron Lipman --- Documentation/git-bisect.txt | 13 ++++++++++++- bisect.c | 10 +++++++++- builtin/bisect--helper.c | 14 ++++++++++---- t/t6030-bisect-porcelain.sh | 18 ++++++++++++++++++ 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt index 7586c5a843..0e993e4587 100644 --- a/Documentation/git-bisect.txt +++ b/Documentation/git-bisect.txt @@ -17,7 +17,7 @@ The command takes various subcommands, and different options depending on the subcommand: git bisect start [--term-{old,good}= --term-{new,bad}=] - [--no-checkout] [ [...]] [--] [...] + [--no-checkout] [--first-parent] [ [...]] [--] [...] git bisect (bad|new|) [] git bisect (good|old|) [...] git bisect terms [--term-good | --term-bad] @@ -365,6 +365,17 @@ does not require a checked out tree. + If the repository is bare, `--no-checkout` is assumed. +--first-parent:: ++ +Follow only the first parent commit upon seeing a merge commit. ++ +In detecting regressions introduced through the merging of a branch, the merge +commit will be identified as introduction of the bug and its ancestors will be +ignored. ++ +This option is particularly useful in avoiding false positives when a merged +branch contained broken or non-buildable commits, but the merge itself was OK. + EXAMPLES -------- diff --git a/bisect.c b/bisect.c index a11fdb1473..afbb5aea32 100644 --- a/bisect.c +++ b/bisect.c @@ -460,6 +460,7 @@ static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN") static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START") static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG") static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS") +static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") static GIT_PATH_FUNC(git_path_head_name, "head-name") static void read_bisect_paths(struct argv_array *array) @@ -981,6 +982,12 @@ void read_bisect_terms(const char **read_bad, const char **read_good) fclose(fp); } +static int read_first_parent_option(void) +{ + const char *filename = git_path_bisect_first_parent(); + return !access(filename, F_OK); +} + /* * We use the convention that return BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND (-10) means * the bisection process finished successfully. @@ -997,7 +1004,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int enum bisect_error res = BISECT_OK; struct object_id *bisect_rev; char *steps_msg; - int first_parent_only = 0; /* TODO: pass --first-parent flag from git bisect start */ + int first_parent_only = read_first_parent_option(); read_bisect_terms(&term_bad, &term_good); if (read_bisect_refs()) @@ -1141,6 +1148,7 @@ int bisect_clean_state(void) unlink_or_warn(git_path_bisect_names()); unlink_or_warn(git_path_bisect_run()); unlink_or_warn(git_path_bisect_terms()); + unlink_or_warn(git_path_bisect_first_parent()); /* Cleanup head-name if it got left by an old version of git-bisect */ unlink_or_warn(git_path_head_name()); /* diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index ec4996282e..9273140f0b 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -17,6 +17,7 @@ static GIT_PATH_FUNC(git_path_bisect_head, "BISECT_HEAD") static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG") static GIT_PATH_FUNC(git_path_head_name, "head-name") static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") +static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") static const char * const git_bisect_helper_usage[] = { N_("git bisect--helper --next-all [--no-checkout]"), @@ -28,7 +29,7 @@ static const char * const git_bisect_helper_usage[] = { 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}=]" - "[--no-checkout] [ [...]] [--] [...]"), + " [--no-checkout] [--first-parent] [ [...]] [--] [...]"), NULL }; @@ -422,7 +423,7 @@ static int bisect_append_log_quoted(const char **argv) } static int bisect_start(struct bisect_terms *terms, int no_checkout, - const char **argv, int argc) + int first_parent_only, const char **argv, int argc) { int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0; int flags, pathspec_pos, res = 0; @@ -577,6 +578,9 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, */ write_file(git_path_bisect_start(), "%s\n", start_head.buf); + if (first_parent_only) + write_file(git_path_bisect_first_parent(), "\n"); + if (no_checkout) { if (get_oid(start_head.buf, &oid) < 0) { res = error(_("invalid ref: '%s'"), start_head.buf); @@ -632,7 +636,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_TERMS, BISECT_START } cmdmode = 0; - int no_checkout = 0, res = 0, nolog = 0; + int no_checkout = 0, first_parent_only = 0, res = 0, nolog = 0; struct option options[] = { OPT_CMDMODE(0, "next-all", &cmdmode, N_("perform 'git bisect next'"), NEXT_ALL), @@ -656,6 +660,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("start the bisect session"), BISECT_START), OPT_BOOL(0, "no-checkout", &no_checkout, N_("update BISECT_HEAD instead of checking out the current commit")), + OPT_BOOL(0, "first-parent", &first_parent_only, + N_("only trace the first parent of merge commits")), OPT_BOOL(0, "no-log", &nolog, N_("no log for BISECT_WRITE")), OPT_END() @@ -713,7 +719,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) break; case BISECT_START: set_terms(&terms, "bad", "good"); - res = bisect_start(&terms, no_checkout, argv, argc); + res = bisect_start(&terms, no_checkout, first_parent_only, argv, argc); break; default: return error("BUG: unknown subcommand '%d'", cmdmode); diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 36d9b2b2e4..51f5eb6ea3 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -458,6 +458,24 @@ test_expect_success 'many merge bases creation' ' grep "$SIDE_HASH5" merge_bases.txt ' +# We want to automatically find the merge that +# added "line" into hello. +test_expect_success '"git bisect run --first-parent" simple case' ' + git rev-list --first-parent $B_HASH ^$HASH4 >first_parent_chain.txt && + write_script test_script.sh <<-\EOF && + grep $(git rev-parse HEAD) first_parent_chain.txt || exit -1 + ! grep line hello >/dev/null + EOF + git bisect start --first-parent && + test_path_is_file ".git/BISECT_FIRST_PARENT" && + git bisect good $HASH4 && + git bisect bad $B_HASH && + git bisect run ./test_script.sh >my_bisect_log.txt && + grep "$B_HASH is the first bad commit" my_bisect_log.txt && + git bisect reset && + test_path_is_missing .git/BISECT_FIRST_PARENT +' + test_expect_success 'good merge bases when good and bad are siblings' ' git bisect start "$B_HASH" "$A_HASH" > my_bisect_log.txt && test_i18ngrep "merge base must be tested" my_bisect_log.txt && From patchwork Sat Aug 1 17:58:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aaron Lipman X-Patchwork-Id: 11696187 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B78FB161F for ; Sat, 1 Aug 2020 17:58:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95E5A206E9 for ; Sat, 1 Aug 2020 17:58:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pJeyeurI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727093AbgHAR6x (ORCPT ); Sat, 1 Aug 2020 13:58:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725803AbgHAR6x (ORCPT ); Sat, 1 Aug 2020 13:58:53 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B725CC06174A for ; Sat, 1 Aug 2020 10:58:52 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id d14so31800241qke.13 for ; Sat, 01 Aug 2020 10:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yNHIjH15ennrTmZK7LlS2hDxNWdMUkaH+ru2IxG0Nac=; b=pJeyeurIL8kZpmVyHEi59cwZcE/vg2v2jqTGg48TJf9JH1flr5ghnSLKuKTRG+jidv /Zl1SARbdwH83Y2Gn613iAB2w8fHA8+bnSOOWQqOVmLzDozYnDnY1BNG84Xy4Hd/sUWc vRQ7tSyAt1n1TNqySfDhUrALxTph5nCsjWqbYTSFgKsIdmfJuBK5VKt5Hr/UUpVub4ER uDny9xEYFhJzwfm1dONLMjg4oWpIiKY8iQnuC8eFKHKfVBLUzr3XYrbsM5bLXsbFdUFc SB26FEBEgTidcquauPbpGEEbNg5TWofdXkJTm0aU+qOG28nCpFwc+I/T4hONJBtfcK4Z 1/Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yNHIjH15ennrTmZK7LlS2hDxNWdMUkaH+ru2IxG0Nac=; b=buGYjiLUqVKZpyOW/cvE3V2fO0T19jedmTmPWM0mk1/YQeCp5k0kdP+cOo5MbQdvPc UZhXaMWt1ZNVMZy5mXY5o7tLt/tR1Gh0xHDRL9JEGBzMMQI6oNA7Q1RHQ583DELjAXJ5 PAUQe8jFCcR952lWQTA8laNL1wKD9nV1XHMuZOXyZZMs+1uyxbUqnaPUBB7addZz+uyV tI/q8z/MPi/wgEzRZtDRbaj1acAc7JAHKInDZP7qcFtujaEd5mzw/4GwWHmEiaCG1/VQ 5hxHYi0oJsL/yWE/46W+c8gk+cuRWHtJAsrZoBFrVVD+F3yO70Tp702DwJYedDABAwFd g9hg== X-Gm-Message-State: AOAM5335EL5umS136F/ljz848ybxxiBHFH26ujJm0mwh4ADVsdOt8C/p Gg4Y2y0oqBacVr9mocOdPioXvF3ffXBY9Q== X-Google-Smtp-Source: ABdhPJyBmc+aCh7RegNFp0oHqDamQKNYqGPRaRLV6zbjkSz2Ghh5hAakqTJmBVeBDcahBO37kM0Iyg== X-Received: by 2002:a37:a851:: with SMTP id r78mr1249894qke.419.1596304731633; Sat, 01 Aug 2020 10:58:51 -0700 (PDT) Received: from localhost.localdomain (c-98-229-3-81.hsd1.vt.comcast.net. [98.229.3.81]) by smtp.gmail.com with ESMTPSA id l13sm13517405qth.77.2020.08.01.10.58.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Aug 2020 10:58:51 -0700 (PDT) From: Aaron Lipman To: git@vger.kernel.org Cc: Aaron Lipman Subject: [PATCH v3 4/4] bisect: consistent style for git bisect run tests Date: Sat, 1 Aug 2020 13:58:40 -0400 Message-Id: <20200801175840.1877-5-alipman88@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20200801175840.1877-1-alipman88@gmail.com> References: <20200730002735.87655-1-alipman88@gmail.com> <20200801175840.1877-1-alipman88@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Enforce consistent styling for tests on "git bisect run": - Use "write_script" to abstract away platform-specific details. - Favor current whitespace conventions. --- t/t6030-bisect-porcelain.sh | 46 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 51f5eb6ea3..63661c5e3d 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -243,32 +243,30 @@ test_expect_success 'bisect skip: with commit both bad and skipped' ' ' # We want to automatically find the commit that -# introduced "Another" into hello. -test_expect_success \ - '"git bisect run" simple case' \ - 'echo "#"\!"/bin/sh" > test_script.sh && - echo "grep Another hello > /dev/null" >> test_script.sh && - echo "test \$? -ne 0" >> test_script.sh && - chmod +x test_script.sh && - git bisect start && - git bisect good $HASH1 && - git bisect bad $HASH4 && - git bisect run ./test_script.sh > my_bisect_log.txt && - grep "$HASH3 is the first bad commit" my_bisect_log.txt && - git bisect reset' +# added "Another" into hello. +test_expect_success '"git bisect run" simple case' ' + write_script test_script.sh <<-\EOF && + ! grep Another hello >/dev/null + EOF + git bisect start && + git bisect good $HASH1 && + git bisect bad $HASH4 && + git bisect run ./test_script.sh >my_bisect_log.txt && + grep "$HASH3 is the first bad commit" my_bisect_log.txt && + git bisect reset +' # We want to automatically find the commit that -# introduced "Ciao" into hello. -test_expect_success \ - '"git bisect run" with more complex "git bisect start"' \ - 'echo "#"\!"/bin/sh" > test_script.sh && - echo "grep Ciao hello > /dev/null" >> test_script.sh && - echo "test \$? -ne 0" >> test_script.sh && - chmod +x test_script.sh && - git bisect start $HASH4 $HASH1 && - git bisect run ./test_script.sh > my_bisect_log.txt && - grep "$HASH4 is the first bad commit" my_bisect_log.txt && - git bisect reset' +# added "Ciao" into hello. +test_expect_success '"git bisect run" with more complex "git bisect start"' ' + write_script test_script.sh <<-\EOF && + ! grep Ciao hello >/dev/null + EOF + git bisect start $HASH4 $HASH1 && + git bisect run ./test_script.sh >my_bisect_log.txt && + grep "$HASH4 is the first bad commit" my_bisect_log.txt && + git bisect reset +' # $HASH1 is good, $HASH5 is bad, we skip $HASH3 # but $HASH4 is good,