From patchwork Thu Feb 21 21:40:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10824783 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 46CA215AC for ; Thu, 21 Feb 2019 21:41:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38C29323B5 for ; Thu, 21 Feb 2019 21:41:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36B82325E9; Thu, 21 Feb 2019 21:41:14 +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 C9963323B5 for ; Thu, 21 Feb 2019 21:41:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726656AbfBUVlM (ORCPT ); Thu, 21 Feb 2019 16:41:12 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37286 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbfBUVlM (ORCPT ); Thu, 21 Feb 2019 16:41:12 -0500 Received: by mail-wr1-f65.google.com with SMTP id c8so127374wrs.4 for ; Thu, 21 Feb 2019 13:41:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tLGD5GMRghrxsdvde09oPCsio/iX0+SA3TfPuUwkeTg=; b=icQCbyZD6/8s6BA4XaIw+Kh11f1+sUEgRHI8Nr7drkphbyk/xSft41HGx/jm4p9nqp +j5Air7i54FoogVBOct5nMh+H9GOnx7lsrTpPkto0nN11uxZeY5np5ZLeXaRffkTzh1a Ny3bGrrFHtomInZj7JfOGftB0KbkMHLEl3as897844TBMeyeLsXRhpMTQca8fVYvTdhk nPR6shMUsaZeC7guHJQUMXeYo0xjN8WwW3v0FZOIdhNiNGYzSw3jwYQGVvB5cVRNCTnq DmlRjxBvvF3B+0MJ0QcfSQoLIi7AG3mwuJJxNZ+qL3KHWD3l9TQgrvdlFY1MdFEFm4/m fDxg== 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=tLGD5GMRghrxsdvde09oPCsio/iX0+SA3TfPuUwkeTg=; b=cnGkjjA95ep6IEf3TXyKgKc1l+pdfJnlhammj2DuY9rC3eWi1iDYgq3p9pwmNLlgJZ O1/74qku6SH6vG8R5n5ZPTuARtmc5i4SH5Na1neWBOeVUkV4VVD8Cz5HPc6OJ74bg9im LYJqf33LJ+Oi94HWbA88Ot2kcu7G7RZTVhYST2DRxvyOabIZ0Ait2dcBID3+OrYhBI18 /hfGPLkthfy0lVov5NrlhpAAZvuQVPOyLhAWktj+pCKrao0BcxeHAm66Jw1n1pNKEby7 EhZcwKMgQkXbE/4Iu/X/9qPZERrb/K47PwNk/ZEQEKfmNgt/NCiJyyR0ONXsvW4Qiwny eM4Q== X-Gm-Message-State: AHQUAuZkqr6bKyfGbIsCEHAFp6LeMbSSS9kOopBD2aapJs5Kp4208JP8 lCQazplhmAkKuiJz2rHOBp0RGbgT2i4= X-Google-Smtp-Source: AHgI3Ia87ODGp2AZ8/M2iEAmlAbFaqPTGec1e57ntXgQiqdFIa4yr88jM2ixJb44IJCbN3B2Wkij5w== X-Received: by 2002:a5d:6703:: with SMTP id o3mr402544wru.75.1550785269416; Thu, 21 Feb 2019 13:41:09 -0800 (PST) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id k6sm17536972wrq.82.2019.02.21.13.41.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 21 Feb 2019 13:41:08 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Johannes Sixt , John Keeping , Pratik Karki , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH 1/2] rebase tests: test linear branch topology Date: Thu, 21 Feb 2019 22:40:58 +0100 Message-Id: <20190221214059.9195-2-avarab@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.258.g878e2cd30e In-Reply-To: <20190221151009.GA24309@sigill.intra.peff.net> References: <20190221151009.GA24309@sigill.intra.peff.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add tests rebasing a linear branch topology to linear rebase tests added in 2aad7cace2 ("add simple tests of consistency across rebase types", 2013-06-06). These tests are duplicates of two surrounding tests that do the same with tags pointing to the same objects. Right now there's no change in behavior being introduced, but as we'll see in a subsequent change rebase can have different behaviors when working implicitly with remote tracking branches. While I'm at it add a --fork-point test, strictly speaking this is redundant to the existing '' test, as no argument to rebase implies --fork-point. But now it's easier to grep for tests that explicitly stress --fork-point. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t3421-rebase-topology-linear.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/t/t3421-rebase-topology-linear.sh b/t/t3421-rebase-topology-linear.sh index 7274dca40b..b847064f91 100755 --- a/t/t3421-rebase-topology-linear.sh +++ b/t/t3421-rebase-topology-linear.sh @@ -31,6 +31,16 @@ test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p +test_expect_success 'setup branches and remote tracking' ' + git tag -l >tags && + for tag in $(cat tags) + do + git branch branch-$tag $tag || return 1 + done && + git remote add origin "file://$PWD" && + git fetch origin +' + test_run_rebase () { result=$1 shift @@ -57,10 +67,28 @@ test_run_rebase () { " } test_run_rebase success '' +test_run_rebase success --fork-point test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase failure -p +test_run_rebase () { + result=$1 + shift + test_expect_$result "rebase $* -f rewrites even if remote upstream is an ancestor" " + reset_rebase && + git rebase $* -f branch-b branch-e && + ! test_cmp_rev branch-e origin/branch-e && + test_cmp_rev branch-b HEAD~2 && + test_linear_range 'd e' branch-b.. + " +} +test_run_rebase success '' +test_run_rebase success --fork-point +test_run_rebase success -m +test_run_rebase success -i +test_have_prereq !REBASE_P || test_run_rebase success -p + test_run_rebase () { result=$1 shift @@ -71,6 +99,7 @@ test_run_rebase () { " } test_run_rebase success '' +test_run_rebase success --fork-point test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p From patchwork Thu Feb 21 21:40:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10824785 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 8CC2213A4 for ; Thu, 21 Feb 2019 21:41:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E26E324E0 for ; Thu, 21 Feb 2019 21:41:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C54B32529; Thu, 21 Feb 2019 21:41:16 +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 EB9953225D for ; Thu, 21 Feb 2019 21:41:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726694AbfBUVlO (ORCPT ); Thu, 21 Feb 2019 16:41:14 -0500 Received: from mail-wr1-f52.google.com ([209.85.221.52]:39925 "EHLO mail-wr1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbfBUVlN (ORCPT ); Thu, 21 Feb 2019 16:41:13 -0500 Received: by mail-wr1-f52.google.com with SMTP id l5so116199wrw.6 for ; Thu, 21 Feb 2019 13:41:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hh961CJQ1uFECSxOyL9rl5Fqv1o8hWa3t6aeioUOcmo=; b=Ss3HMXAnkqMQTr4Ie+72L6LU2rkZRDYQDgAoLKMGxmRksx7InQqW4Cpx93uZjLV4Oj 1y7PAA3yvaAFA+dR5AeQepEVjIP9jtoebPWN4y5gfbTiW9pOHetPx9QgY0TIR4oYg4sI alLiHf5/hhkaSjo2kfl3hz6gk3yf3RMB2xtApYzpc+1c3v0CZDpNHy20ipo3PY6ajtjQ cP4YO+htU+f5eN/YboaZfl0zyXAPmpOkU6nF5lxRP30rgc78oLNXJHqqjWDvvsm9fkYM rCTyH6IKnp8tZh3ZzasiGk8xvsCK0yozR4lKqRq0CvDRuiOgNmCAlDxuqg5lUjjj5T7u vb7A== 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=Hh961CJQ1uFECSxOyL9rl5Fqv1o8hWa3t6aeioUOcmo=; b=Qr4r/3zz58ngbbujvh6AdGqse6KMHaCP7KrggjSXn43TkRVE2vHJLlktZ3TSBDzJMA Ja1ynOZz6e0Ay8jsWWIXD8NyHeEGwVuE0N4vzSUjK4lVZwmRWWITuFAfauJ6qjFO6wAA g1zfgLZ4wAFNZ8CCOtukJa7VUmHo+CQXfPNg+jwjNhx9AuAROs822bvsGWKY0UO57zK5 DlBLN3hwmCm2BPZJn8DNoZDmDha3H8zgZQHgD2Q04+a6xlYW7dVU3HupP+VM45QtVQpI vw2rSoMEtmmJKLZ/xllcbA7RuE+uJ0P5CytTtWW8TazkRTeisYt02tFrsiQEDPT86EAj v/9A== X-Gm-Message-State: AHQUAuYsP0bRaO2Wb0zarYSAm4TeEC40a2plwpRTIG2D2u7ApyyoPpcy tZUIA19J0syLaOubFf5O/edlR3CxeeE= X-Google-Smtp-Source: AHgI3IYm6gbe1zr2YpwMSM6XYPkYhikGN2eNb0U1wusHH/2HcoZNI9p3BtI3CmyG0OVECj1d1WCaFA== X-Received: by 2002:a5d:4e8c:: with SMTP id e12mr401865wru.21.1550785271040; Thu, 21 Feb 2019 13:41:11 -0800 (PST) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id k6sm17536972wrq.82.2019.02.21.13.41.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 21 Feb 2019 13:41:10 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Johannes Sixt , John Keeping , Pratik Karki , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH 2/2] rebase: don't rebase linear topology with --fork-point Date: Thu, 21 Feb 2019 22:40:59 +0100 Message-Id: <20190221214059.9195-3-avarab@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.258.g878e2cd30e In-Reply-To: <20190221151009.GA24309@sigill.intra.peff.net> References: <20190221151009.GA24309@sigill.intra.peff.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix a regression introduced in 4f21454b55 ("merge-base: handle --fork-point without reflog", 2016-10-12). Before that change having a linear history on top of an upstream master would with --fork-point (aka argument-less rebase) tell us there was nothing to be done: $ git rebase Current branch master is up to date. After that change "rebase" will always redundantly find that it has work to do (it doesn't): $ git rebase First, rewinding head to replay your work on top of it... Applying: [...] Whereas equivalently running: $ git rebase @{upstream} $ git rebase $(git merge-base --fork-point @{u}) Gives us the old behavior of doing nothing. Now, why did we have this regression? Fully digging into it yields an interesting combination of causes: Way back in 1308c17b3e ("Allow rebase to run if upstream is completely merged", 2007-07-04) "rebase" learned to not do this redundant work when asked to rebase on a commit that was already an ancestor of the current commit. Then in 1e0dacdbdb ("rebase: omit patch-identical commits with --fork-point", 2014-07-16) a rebase bug was fixed for a case where the history to be rebased was divergent by entirely skipping the 2007-era logic if --fork-point was provided. But here's the critical thing, *only* if the --fork-point was divergent. At that time "git merge-base --fork-point A B" would return nothing if the two commits weren't divergent. Then in 4f21454b55 ("merge-base: handle --fork-point without reflog", 2016-10-12) which introduced the regression being fixed here, a bug fix for "git merge-base --fork-point" being run stand-alone by proxy broke this use-case git-rebase.sh was relying on, since it was still assuming that if we didn't have divergent history we'd have no output. Finally, when "rebase" was rewritten in C a combination of 9a48a615b4 ("builtin rebase: try to fast forward when possible", 2018-09-04), 103148aad8 ("merge-base --fork-point: extract libified function", 2018-09-04) and 92d0d74e8d ("builtin rebase: support `fork-point` option", 2018-09-04) faithfully re-implemented the then-buggy behavior. So let's fix this. It's easy enough, we just stop explicitly excluding --fork-point from the can_fast_forward(...) test we're doing, which as discussed above is faithfully ported over from buggy shellscript-era logic. I'm not bothering to fix this in the legacy rebase mode. As discussed in 9aea5e9286 ("rebase: fix regression in rebase.useBuiltin=false test mode", 2019-02-13) it'll be going away shortly after 2.21.0 lands. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/rebase.c | 6 ++++-- t/t3421-rebase-topology-linear.sh | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 7c7bc13e91..7a16b8051c 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1664,9 +1664,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) * and if this is not an interactive rebase. */ if (can_fast_forward(options.onto, &options.orig_head, &merge_base) && - !is_interactive(&options) && !options.restrict_revision && + !is_interactive(&options) && options.upstream && - !oidcmp(&options.upstream->object.oid, &options.onto->object.oid)) { + (options.restrict_revision + ? !oidcmp(&options.upstream->object.oid, &options.restrict_revision->object.oid) + : !oidcmp(&options.upstream->object.oid, &options.onto->object.oid))) { int flag; if (!(options.flags & REBASE_FORCE)) { diff --git a/t/t3421-rebase-topology-linear.sh b/t/t3421-rebase-topology-linear.sh index b847064f91..1754537789 100755 --- a/t/t3421-rebase-topology-linear.sh +++ b/t/t3421-rebase-topology-linear.sh @@ -55,6 +55,21 @@ test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p +test_run_rebase () { + result=$1 + shift + test_expect_$result "rebase $* is no-op if remote upstream is an ancestor" " + reset_rebase && + GIT_TEST_REBASE_USE_BUILTIN=true git rebase $* branch-b branch-e && + test_cmp_rev e HEAD + " +} +test_run_rebase success '' +test_run_rebase success --fork-point +test_run_rebase success -m +test_run_rebase success -i +test_have_prereq !REBASE_P || test_run_rebase success -p + test_run_rebase () { result=$1 shift