From patchwork Wed Apr 17 18:01:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10905747 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 23882922 for ; Wed, 17 Apr 2019 18:01:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D2F028706 for ; Wed, 17 Apr 2019 18:01:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 014A228B26; Wed, 17 Apr 2019 18:01: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 8F6D828706 for ; Wed, 17 Apr 2019 18:01:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731696AbfDQSB3 (ORCPT ); Wed, 17 Apr 2019 14:01:29 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:37341 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731116AbfDQSB3 (ORCPT ); Wed, 17 Apr 2019 14:01:29 -0400 Received: by mail-pl1-f194.google.com with SMTP id w23so12390674ply.4 for ; Wed, 17 Apr 2019 11:01:28 -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=s6mCxr6PGltFjwNoWk/s4dm40wr6oDRyNZVJ+5whTFA=; b=PFJXUFpDARiDaUa7/hdAKpPtqJVCWdtm/Oc9CqCvLWRYDbe6eLmBpt8iK3GP36xKh4 HfrafnhwkXwVt5+tmWKxkhKkH29vnZmHMko3BGXhwP/neOgKyBEHFlakfogbS2J7YQzv wBLGv5BnsLneiQaJ81t7s5pDtqawEh+if50RnaaOuBJypbRYVqtThEegW1qOO67SIG6r lgktoD0vwSFjxZl8wfjvqmr3xdscY8LJJZRSHITo3BhZqVHRt0xOXvrjTY4tN9SjehMn GHI6ai0TlXAza0DUaxWsqGLyjrwudtrtev02kD/IJQ/nl2jQh3nckz3yPIUE6aoUCIHL 5raw== 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=s6mCxr6PGltFjwNoWk/s4dm40wr6oDRyNZVJ+5whTFA=; b=rbyfUXQ1tefm2CgfbR8NChabr0uX/9s7/5+xWfH+ewvmE8rR+c1AsTEno1oMz1N5po AAgACMpbOoeYmOuloW3LT4JSn+uxzsSnEJ2NucJY0EzUhkOg3f7jH88WwNLgduONBDt2 QYXVjz0hmg4GAiv5Zzjczx4IJhBlpR66Fz403l9Oiy6cCgZHJG+gIVZB70BkerrdxjKo tbqcyyi6OBlsRyqu+sLt9NKzBOHSZf0ROAnmWqMs9V8tyVlxmd0g12dVn6phwgI6O0t3 AT2utfBuFExVtGotIsII77w5D6FQL3bZlwYYI3wk1o3MRr4tlmLMNEkMkLtYsqS0+yVs 58mg== X-Gm-Message-State: APjAAAUo+S3o+TmoxWQpTalaZz3Hk/rTzZxpPVYLwcsX9AK7MmEyJuEb WapQMaSdcrp1b2x6Ym1BoTl2SlQqNsE= X-Google-Smtp-Source: APXvYqyuFKhdeG73V/tZKEXgIipNhhzV41LQHc+rTyHClOSpQjwMDpqJznhqE0Q6iilFuN24W477nw== X-Received: by 2002:a17:902:2862:: with SMTP id e89mr71705682plb.203.1555524088077; Wed, 17 Apr 2019 11:01:28 -0700 (PDT) Received: from dev-l ([149.28.200.39]) by smtp.gmail.com with ESMTPSA id b15sm76834377pgg.90.2019.04.17.11.01.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 11:01:27 -0700 (PDT) Date: Wed, 17 Apr 2019 11:01:26 -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 v6 2/6] t3432: test rebase fast-forward behavior Message-ID: <4c087ec0413880e1d3e6cbba95ff62224a4d95e6.1555523176.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) 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