From patchwork Sun Apr 21 08:11:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10910463 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 4963F161F for ; Sun, 21 Apr 2019 08:11:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37F10288AD for ; Sun, 21 Apr 2019 08:11:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2922A288BD; Sun, 21 Apr 2019 08: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 68A39288B2 for ; Sun, 21 Apr 2019 08:11:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727175AbfDUILZ (ORCPT ); Sun, 21 Apr 2019 04:11:25 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:45241 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725940AbfDUILY (ORCPT ); Sun, 21 Apr 2019 04:11:24 -0400 Received: by mail-pg1-f193.google.com with SMTP id y3so4471639pgk.12 for ; Sun, 21 Apr 2019 01:11:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1W03mRQJZnatbdyKXVZnSz5/NReI+zKNW2yofV3vAII=; b=ACT8XyARbi1cF9GWYidAIysnNI0oF/EQ3BucOiZbKtnFLaPgw+IjkuJlMAqx2YuHxY cb1uHAObCwi7MYUM4olFK2clhH7MeaInt+0dA1swJrykdyfw689ESBa7KkY8fLgNZzOn 8rW7vwPLwo/lueB6rJnzBiT6w5PK48qL2hV1qms3CGebCCP+b4XtcA8X8rXliA8+Eza9 RQo2/gtVQxfQDc5vFFwFYzAOm+NsDybmz4vYpPPR0CauVGZOfwuQuwiwBE3pJBdrwSr7 xLryFL005WABjWxpdZk58eF8cNJOELyTjoULzcgIS/dYIgYVZPf8azwNc7kOhI0ji77F gwfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1W03mRQJZnatbdyKXVZnSz5/NReI+zKNW2yofV3vAII=; b=GO1rikEVCyRydUyrJUdffQxIc5pC4JXjj7J4g/VTV3ssva3fnvA29CTwmo9BAvvb0Y rldWMQrIsSP7jOQMR9MKqNWABk9hzrghem44E4imLtEYpXoSMmu6zn6pE3AKxeFbMx37 VXVf1QJnDToN8yJV3hZzzSHLICBe+iyNd/mEKoJnEZ8Bhe8R3eoV3sV5xJ00PdZwazcI uXLxTw3lKnUD0S3A8P9jN62flC8oYOOlbJFujdAwnVQDTjJtReJyjGp5Ah40kwKNrUOG hNK6oESYtyS4IBu2ufdw0mOJiGX+jSE5eB4CBGZYvgJwUrMrQ4uFpdFGtswQPIjnU2OO dWxA== X-Gm-Message-State: APjAAAV+tjk1kInFxsKIxxSnuQ1R51e85U1FQNsrwyE1X7qtHg1nfzQ/ KqSSA1tSj8ASw54qhIfA/5knnutC X-Google-Smtp-Source: APXvYqxlkg4dgcpvexEO3gG30ltiHxGZDpI7CUYzGZZ6m8bFKZ/j9QLToEF2mx2K2We1ksoZYeL1IQ== X-Received: by 2002:a63:5149:: with SMTP id r9mr12970111pgl.177.1555834283835; Sun, 21 Apr 2019 01:11:23 -0700 (PDT) Received: from archbookpro.localdomain ([2601:647:4b00:5d::661d]) by smtp.gmail.com with ESMTPSA id b7sm16769125pfj.67.2019.04.21.01.11.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 21 Apr 2019 01:11:23 -0700 (PDT) Date: Sun, 21 Apr 2019 01:11:21 -0700 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , =?iso-8859-1?q?=C6var_Arnfj=F6r=F0?= Bjarmason , Johannes Schindelin , Johannes Sixt , SZEDER =?iso-8859-1?q?G=E1bor?= Subject: [PATCH v7 2/6] t3432: test rebase fast-forward behavior Message-ID: <4c087ec0413880e1d3e6cbba95ff62224a4d95e6.1555832783.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When rebase is run on a branch that can be fast-forwarded, this should automatically be done. Create test to ensure this behavior happens. There are some cases that currently don't pass. The first case is where a feature and master have diverged, running "git rebase master... master" causes a full rebase to happen even though a fast-forward should happen. The second case is when we are doing "git rebase --fork-point" and a fork-point commit is found. Once again, a full rebase happens even though a fast-forward should happen. Mark these cases as failure so we can fix it later. Signed-off-by: Denton Liu --- t/t3432-rebase-fast-forward.sh | 72 ++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 t/t3432-rebase-fast-forward.sh diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh new file mode 100755 index 0000000000..4f04d67fd7 --- /dev/null +++ b/t/t3432-rebase-fast-forward.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# +# Copyright (c) 2019 Denton Liu +# + +test_description='ensure rebase fast-forwards commits when possible' + +. ./test-lib.sh + +test_expect_success setup ' + test_commit A && + test_commit B && + test_commit C && + test_commit D && + git checkout -t -b side +' + +test_rebase_same_head() { + status="$1" && + shift && + test_expect_$status "git rebase $* with $changes is no-op" " + oldhead=\$(git rev-parse HEAD) && + test_when_finished 'git reset --hard \$oldhead' && + git rebase $* && + newhead=\$(git rev-parse HEAD) && + test_cmp_rev \$oldhead \$newhead + " +} + +changes='no changes' +test_rebase_same_head success +test_rebase_same_head success master +test_rebase_same_head success --onto B B +test_rebase_same_head success --onto B... B +test_rebase_same_head success --onto master... master +test_rebase_same_head success --no-fork-point +test_rebase_same_head success --fork-point master +test_rebase_same_head failure --fork-point --onto B B +test_rebase_same_head failure --fork-point --onto B... B +test_rebase_same_head success --fork-point --onto master... master + +test_expect_success 'add work to side' ' + test_commit E +' + +changes='our changes' +test_rebase_same_head success +test_rebase_same_head success master +test_rebase_same_head success --onto B B +test_rebase_same_head success --onto B... B +test_rebase_same_head success --onto master... master +test_rebase_same_head success --no-fork-point +test_rebase_same_head success --fork-point master +test_rebase_same_head failure --fork-point --onto B B +test_rebase_same_head failure --fork-point --onto B... B +test_rebase_same_head success --fork-point --onto master... master + +test_expect_success 'add work to upstream' ' + git checkout master && + test_commit F && + git checkout side +' + +changes='our and their changes' +test_rebase_same_head success --onto B B +test_rebase_same_head success --onto B... B +test_rebase_same_head failure --onto master... master +test_rebase_same_head failure --fork-point --onto B B +test_rebase_same_head failure --fork-point --onto B... B +test_rebase_same_head failure --fork-point --onto master... master + +test_done