From patchwork Mon Apr 1 20:51:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10880563 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 BB80117E1 for ; Mon, 1 Apr 2019 20:52:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A25A8286B3 for ; Mon, 1 Apr 2019 20:52:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9670C28768; Mon, 1 Apr 2019 20:52:07 +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 7326A286D5 for ; Mon, 1 Apr 2019 20:52:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727352AbfDAUwC (ORCPT ); Mon, 1 Apr 2019 16:52:02 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34343 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727065AbfDAUwB (ORCPT ); Mon, 1 Apr 2019 16:52:01 -0400 Received: by mail-pl1-f194.google.com with SMTP id y6so5087517plt.1 for ; Mon, 01 Apr 2019 13:52:01 -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=xW00cASk1Oe66ISAgQGokK/mMcbXitwScnZIEDwxwo4=; b=EwvJuohsYGt4kE3/+7SMJNnVuWETx40/totWh+2y7B7RdkxiXYnn25VG5mUmndgJLI smGI4IiWgd3pFMMDiDFenN87tA+XhXIi2sH+g/akMQwMFeP6eKJ30ryRjyM36doTVBh2 FydjYVJtQXuG15rQ4qjP4064GSr11yNFav41T/9/QOa0poVzfceiCFmszR6vymIxUfX+ J3NTnkGOhELzJc0Vnh4AalFoVPzm5bnAYmM+tY2k/eDfpsq8/M91GIlPlLtX9UTdNBH5 JU2qJu+KfdgsY9S2w6tPLLCXn7tDm6pDGhd3TqWArlNiJ9mxi+7PrimZllWGwnJUw5b2 u71w== 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=xW00cASk1Oe66ISAgQGokK/mMcbXitwScnZIEDwxwo4=; b=h1QsIOUaVRJjaOLigx8/k2r/41+LCfi83ayq2y4/nAhj5glP/KBtWZBaN96bzsjIFQ asDmfRs07MDhZjK++iBZYDAruZMRu/yLMHzGLcuesBIiHWM2F6OtianaIsklk5hEurR+ jRdIk4TzdKgJvO+EukrW2JWhtMUWuN42BnhW//Xr2+W4F3FCuW6i7YRfCghNRYyBkxk7 KxJhYB5NaVwaMC24fA7OmQc2PmoNGG0+NU80SzELU20RKurxbnApLDXVwhuLHrRbFqlw /9AweX6h15n9RJAU7lliV7Nl4WNfELeUMzZn+Hu105CnikcB35o6PtKVvt3Q3zE5AGGA Fpcg== X-Gm-Message-State: APjAAAXm0byCZTExwy55y52mAXSSz3ctKqjL9c+RMNl8UBdLw04M83O1 PeKLRpQ7WHtwXzQTOE51n74PcRS5 X-Google-Smtp-Source: APXvYqyOo+/AKLHe+yqoQGpaP25ubOISN5OaYQ7aZ2AwJVRV2RKX9YqW1aLDlqHoGbQTx0uRikkabw== X-Received: by 2002:a17:902:f089:: with SMTP id go9mr26310103plb.309.1554151920651; Mon, 01 Apr 2019 13:52:00 -0700 (PDT) Received: from dev-l ([149.28.200.39]) by smtp.gmail.com with ESMTPSA id f125sm20023797pfc.91.2019.04.01.13.51.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Apr 2019 13:52:00 -0700 (PDT) Date: Mon, 1 Apr 2019 13:51:59 -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 Subject: [PATCH v3 2/4] t3432: test rebase fast-forward behavior Message-ID: <4da2fe9b0429e10821e1cb96b79500c749fc31be.1554151449.git.liu.denton@gmail.com> References: <20190328221745.GA3941@dev-l> 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 is one case that currently does not pass. In the case 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. Mark this case as failure so we can fix it later. Signed-off-by: Denton Liu --- t/t3432-rebase-fast-forward.sh | 59 ++++++++++++++++++++++++++++++++++ 1 file changed, 59 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..3e6362dd9c --- /dev/null +++ b/t/t3432-rebase-fast-forward.sh @@ -0,0 +1,59 @@ +#!/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_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_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_done