From patchwork Tue Aug 27 05:37:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11116059 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 BD5A0174A for ; Tue, 27 Aug 2019 05:37:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 986D5217F5 for ; Tue, 27 Aug 2019 05:37:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IT5YMkP2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729266AbfH0Fhw (ORCPT ); Tue, 27 Aug 2019 01:37:52 -0400 Received: from mail-io1-f53.google.com ([209.85.166.53]:36192 "EHLO mail-io1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfH0Fhw (ORCPT ); Tue, 27 Aug 2019 01:37:52 -0400 Received: by mail-io1-f53.google.com with SMTP id o9so43432835iom.3 for ; Mon, 26 Aug 2019 22:37:52 -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=aJqreQ1u4yffuKur/dcuZd7kRv6dWtyTb9G88XCHYcY=; b=IT5YMkP2gQa6QeKRlOOlOKc3JLL6PhVT94tZ4fucTpghJijkrMivy3akzyjt2R4HPj eFiPCdwtGy5k+anekR6b5tmje99TGJq2cv6FtdnJCc70D3xDKasNVPOe0j5cXxd9dw9c SU/aYwLo+wv39Hy8kw1lzgXLzHL/JbHQmICVhIN1FYhNW0lFKZamzqLoFLIhs3DrxfEO vU9Q2mEIZrX14s+6/7RoQFMJKm4qHTJtWPjehYwLkG7XSujPa9n/zlMjz0uSVP2TQRzi 9C0TlBNPgvI91sx7CpS3Oa7ZhXFis0kyRgj5pMDFxRgcybQUDPEEk3BxG/EbTOS51jCg 0gtg== 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=aJqreQ1u4yffuKur/dcuZd7kRv6dWtyTb9G88XCHYcY=; b=C2s3HWC/aLU5bO3B5xCK4EK00H08PtNfDJgcWBdX4zoFVxgMNvYNmCJw03UrGbV/nz vhDKIvE46DcfzzSXILToe4ZNfD30ywUGFeRgimApOEYzTVJLDbidwzXuyp8LFCMOTlon jNbgbbS7H4qLNh4Pco00Ky4WtvNt0CGI/5E4+3HwbLAbMyY9jwnWyT5H8F3t8QSgPRMZ mfmfcjZH72UOvVU9rDydxIFNnx3DLij9ydl1H/mH/L+LZUuBpKVMnTHyMjzNOc/GzDU9 kIP/IKKpiZrzWSQfQ0wnFfev+2IqMY0EbXVyYzq0Ec8HCovHzT8ITduIxVCJ6Y195JI0 UjOg== X-Gm-Message-State: APjAAAXe79HaCMzvOGV45O6ub+dkzCrUDsT0+/gX+rAH+EskpjMAEh0+ 4DIj7pEZF9kXy8nc5RUPZVnIO3Uy X-Google-Smtp-Source: APXvYqwPxpcVIlQq+knYMNUrxEyxlHDK8ixAYd+UV+wFeZ5q13rVOpio2EBPJxRq/LGAvjjzzN8klw== X-Received: by 2002:a5e:9244:: with SMTP id z4mr3614925iop.127.1566884271288; Mon, 26 Aug 2019 22:37:51 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.89.95]) by smtp.gmail.com with ESMTPSA id j11sm707406ioa.55.2019.08.26.22.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 22:37:50 -0700 (PDT) Date: Tue, 27 Aug 2019 01:37:49 -0400 From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine , Johannes Schindelin , Johannes Sixt , SZEDER =?iso-8859-1?q?G=E1bor?= , =?iso-8859-1?q?=C6v?= =?iso-8859-1?q?ar_Arnfj=F6r=F0?= Bjarmason , Philip Oakley , Pratyush Yadav Subject: [PATCH v10 2/9] t3432: test rebase fast-forward behavior Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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..f49af274e0 --- /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 From patchwork Tue Aug 27 05:37:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11116061 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 62F62174A for ; Tue, 27 Aug 2019 05:37:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3660C21881 for ; Tue, 27 Aug 2019 05:37:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Hla/YigR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729285AbfH0Fhz (ORCPT ); Tue, 27 Aug 2019 01:37:55 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:36369 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfH0Fhy (ORCPT ); Tue, 27 Aug 2019 01:37:54 -0400 Received: by mail-io1-f68.google.com with SMTP id o9so43433029iom.3 for ; Mon, 26 Aug 2019 22:37:54 -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:content-transfer-encoding:in-reply-to :user-agent; bh=YLd6o7LN3LqvPwEWLdfJPuaCMuppb/NlA1oVwvVSznk=; b=Hla/YigRJeuGdKYR3KdkIC9uCNFa+jqUPYyGqYHjmORkL8fbZUS9o8runxuI7iQvI3 s8jhJ6iOsm4umVl22OCrTeMPFuEWnMEW7vkpWsOMyAQOtdNEqSMbP7KDdkD6rqSiGNsE dliZRwTvVOX0YpyNL4Fj38WrM3+GiWHanTU5VDtGZRcgLihEgIKNtq+eimgBMy9E56Gu IwVsv8njYBsZ1GiuwOO3s2NbXK+MdEnMlPT26ZNBlnZacqhlPgfQ0C9NS5/D4I1sik3a 0H/cAQAYTnDkw+u3fgpizIrngMrlqd9pBeiTfdRr0IWLm5YRqF49lstPsUGD6j/GrSvU Xd6w== 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:content-transfer-encoding :in-reply-to:user-agent; bh=YLd6o7LN3LqvPwEWLdfJPuaCMuppb/NlA1oVwvVSznk=; b=JtNYpDO0mwPgVzDwT1zqqbMcEW6h3tLgu33rvNi+qALrZHHKjyTj2z03IoKX5kHKt3 CLgTBiDi+yPxDl7sUcLJ53SeO7rRVNOHZGbggGG4MkHaNPuGLeFfNIIq6pKCCelg0Vhi HMEGo2SQ0T27SU9k924E3Bfe6rDvIS9pSH3EJCZQMopH3B31l2a88JYEnGWGefor2iZo eAmb6qOurCMMYzxj7rD8hJuvlpk5se0no33yLyiNLls3H/5TI2nmr9sLX8rqBtBCe3T6 hszQe5fE/VSrJZO3Ob98nNnT3d+0bBD6Fslv1RXpSxfRhlMYnHCAwg+lccCnuzxIroCf RA1A== X-Gm-Message-State: APjAAAWgloKwBBxMdWpjKRYS/zdgn3wgd1IU11LkKIu5W8UaN/VGoI8F p+Ju8409iU4fq1N4OGN9+KSQB6lc X-Google-Smtp-Source: APXvYqyLaGy/gM+W5e2BhmDC0e0li6DAurqzQrx4DifEB6gjqCx7zHV8ZNtiEcULCRU6qG1vETR1uw== X-Received: by 2002:a02:354d:: with SMTP id y13mr19924549jae.41.1566884273721; Mon, 26 Aug 2019 22:37:53 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.89.95]) by smtp.gmail.com with ESMTPSA id y19sm12555845ioj.62.2019.08.26.22.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 22:37:53 -0700 (PDT) Date: Tue, 27 Aug 2019 01:37:51 -0400 From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine , Johannes Schindelin , Johannes Sixt , SZEDER =?iso-8859-1?q?G=E1bor?= , =?iso-8859-1?q?=C6v?= =?iso-8859-1?q?ar_Arnfj=F6r=F0?= Bjarmason , Philip Oakley , Pratyush Yadav Subject: [PATCH v10 3/9] t3432: distinguish "noop-same" v.s. "work-same" in "same head" tests Message-ID: <5c08e2b81fd65c5d4bcef1fb908987364143d181.1566884063.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ævar Arnfjörð Bjarmason Change "same head" introduced in the preceding commit to check whether the rebase.c code lands in the can_fast_forward() case in, and thus prints out an "is up to date" and aborts early. In some of these cases we make it past that and to "rewinding head", then do a rebase, only to find out there's nothing to change so HEAD stays at the same OID. These tests presumed these two cases were the same thing. In terms of where HEAD ends up they are, but we're not only interested in rebase semantics, but also whether or not we're needlessly doing work when we could avoid it entirely. I'm adding "same" and "diff" here because I'll follow-up and add --no-ff tests, where some of those will be "diff"-erent, so add the "diff" code already. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Denton Liu --- t/t3432-rebase-fast-forward.sh | 79 +++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh index f49af274e0..d9f20fa07c 100755 --- a/t/t3432-rebase-fast-forward.sh +++ b/t/t3432-rebase-fast-forward.sh @@ -18,55 +18,72 @@ test_expect_success setup ' test_rebase_same_head () { status="$1" && shift && - test_expect_$status "git rebase $* with $changes is no-op" " + what="$1" && + shift && + cmp="$1" && + shift && + test_expect_$status "git rebase $* with $changes is $what" " oldhead=\$(git rev-parse HEAD) && test_when_finished 'git reset --hard \$oldhead' && - git rebase $* && + git rebase $* >stdout && + if test $what = work + then + test_i18ngrep 'rewinding head' stdout + elif test $what = noop + then + test_i18ngrep 'is up to date' stdout + fi && newhead=\$(git rev-parse HEAD) && - test_cmp_rev \$oldhead \$newhead + if test $cmp = same + then + test_cmp_rev \$oldhead \$newhead + elif test $cmp = diff + then + ! test_cmp_rev \$oldhead \$newhead + fi " } 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_rebase_same_head success work same +test_rebase_same_head success noop same master +test_rebase_same_head success noop same --onto B B +test_rebase_same_head success noop same --onto B... B +test_rebase_same_head success noop same --onto master... master +test_rebase_same_head success noop same --no-fork-point +test_rebase_same_head success work same --fork-point master +test_rebase_same_head failure noop same --fork-point --onto B B +test_rebase_same_head failure work same --fork-point --onto B... B +test_rebase_same_head success work same --fork-point --onto master... master -test_expect_success 'add work to side' ' +test_expect_success 'add work same 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_rebase_same_head success work same +test_rebase_same_head success noop same master +test_rebase_same_head success noop same --onto B B +test_rebase_same_head success noop same --onto B... B +test_rebase_same_head success noop same --onto master... master +test_rebase_same_head success noop same --no-fork-point +test_rebase_same_head success work same --fork-point master +test_rebase_same_head failure work same --fork-point --onto B B +test_rebase_same_head failure work same --fork-point --onto B... B +test_rebase_same_head success work same --fork-point --onto master... master -test_expect_success 'add work to upstream' ' +test_expect_success 'add work same 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_rebase_same_head success noop same --onto B B +test_rebase_same_head success noop same --onto B... B +test_rebase_same_head failure work same --onto master... master +test_rebase_same_head failure work same --fork-point --onto B B +test_rebase_same_head failure work same --fork-point --onto B... B +test_rebase_same_head failure work same --fork-point --onto master... master test_done From patchwork Tue Aug 27 05:37:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11116063 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 B7EBF1398 for ; Tue, 27 Aug 2019 05:37:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8B504217F5 for ; Tue, 27 Aug 2019 05:37:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ub5RLjlc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729300AbfH0Fh5 (ORCPT ); Tue, 27 Aug 2019 01:37:57 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:46005 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfH0Fh5 (ORCPT ); Tue, 27 Aug 2019 01:37:57 -0400 Received: by mail-io1-f68.google.com with SMTP id t3so43340593ioj.12 for ; Mon, 26 Aug 2019 22:37:56 -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:content-transfer-encoding:in-reply-to :user-agent; bh=lPR2OAXYDyxgPTlUNuL3MQGfJ4o0dVgWUjdGy3VtHHY=; b=Ub5RLjlcyYOabdbjjux2AAIlSwGsW2YFh4yHMSPcqt/1KfbMqTVMtVUZFkHLyFyPhb bvNjp6LwpERakxb/JEyWfFPPVVtAkmT/EVuZTbfcbNoFsV6oBjQxqd8pzV88FI4zRC9E eu+DBpd3H+f1uwqmv5DegNM0+duDVO8DAiwY1KEBs1WWAgh9NuyQNYv8t/vFx8ufX0+f 3prbZriaQE9r6L56/iVl6DdpcZS3+6sFIOA3UbzxNpbb+sfffZtXbA4NRgsNRQBFDt2r MxaU3UnKl9PZv9pMH8Pzw6tzUuejlyUfc59Nqb/jiXrDyvTnNnKBtSACQ4f9HLl9LRX7 WFzg== 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:content-transfer-encoding :in-reply-to:user-agent; bh=lPR2OAXYDyxgPTlUNuL3MQGfJ4o0dVgWUjdGy3VtHHY=; b=bLJOGGdkTPZ/7M5uz4tTTM/a49hfqTps5g79xfzzz1557L1bpdli04cLPWEKEM/EgX I3uXpQjN4cdiXoRLjY7A1kopEGoh9BwajCkW/nG7BvBNWx8HGETwvv2qQdT6eZ6GyAaX ad0KDsFDRvPaWyrt9QxYz7w0sGHk/t5x4jvbak7c+MUieL5nw0oquKLZfiC/G4Mut7Le Ya80Big0xW0SHrigtcgDMFUdVK57+kNiYJQIe+d0hL3+PyrlX14Dp6T8P+UK3zf2JSQL 3aRlsxHeMr2m/6GrPNJ5uzSklV4C0STm/j9lXFwXaZIOOlvbPnE/lhgQRyAnZA3tJl5b e54A== X-Gm-Message-State: APjAAAVDa65j1Wk/vmDckjH0v/fdr51bFr2uD2WOloanSbCuW6vjIPIc KdpfQVIRNkdcVR8OCR7z2awMogFp X-Google-Smtp-Source: APXvYqy53U5RYwi5zkPBP+nrzZTH2OOr1lRaJQcUIIXNuk6IGDnCHH79J780U7dfzbPKM2UI3dU+3w== X-Received: by 2002:a5d:87ce:: with SMTP id q14mr14664379ios.248.1566884276167; Mon, 26 Aug 2019 22:37:56 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.89.95]) by smtp.gmail.com with ESMTPSA id t2sm27483994iod.81.2019.08.26.22.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 22:37:55 -0700 (PDT) Date: Tue, 27 Aug 2019 01:37:53 -0400 From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine , Johannes Schindelin , Johannes Sixt , SZEDER =?iso-8859-1?q?G=E1bor?= , =?iso-8859-1?q?=C6v?= =?iso-8859-1?q?ar_Arnfj=F6r=F0?= Bjarmason , Philip Oakley , Pratyush Yadav Subject: [PATCH v10 4/9] t3432: test for --no-ff's interaction with fast-forward Message-ID: <48b4e41a17d98b2f3a4254ed37c76361c3abc9ba.1566884063.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ævar Arnfjörð Bjarmason Add more stress tests for the can_fast_forward() case in rebase.c. These tests are getting rather verbose, but now we can see under --ff and --no-ff whether we skip work, or whether we're forced to run the rebase. These tests aren't supposed to endorse the status quo, just test for what we're currently doing. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Denton Liu --- t/t3432-rebase-fast-forward.sh | 83 ++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 29 deletions(-) diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh index d9f20fa07c..02b2516595 100755 --- a/t/t3432-rebase-fast-forward.sh +++ b/t/t3432-rebase-fast-forward.sh @@ -16,22 +16,47 @@ test_expect_success setup ' ' test_rebase_same_head () { + status_n="$1" && + shift && + what_n="$1" && + shift && + cmp_n="$1" && + shift && + status_f="$1" && + shift && + what_f="$1" && + shift && + cmp_f="$1" && + shift && + test_rebase_same_head_ $status_n $what_n $cmp_n "" "$*" && + test_rebase_same_head_ $status_f $what_f $cmp_f " --no-ff" "$*" +} + +test_rebase_same_head_ () { status="$1" && shift && what="$1" && shift && cmp="$1" && shift && - test_expect_$status "git rebase $* with $changes is $what" " + flag="$1" + shift && + test_expect_$status "git rebase$flag $* with $changes is $what with $cmp HEAD" " oldhead=\$(git rev-parse HEAD) && test_when_finished 'git reset --hard \$oldhead' && - git rebase $* >stdout && + git rebase$flag $* >stdout && if test $what = work then + # Must check this case first, for 'is up to + # date, rebase forced[...]rewinding head' cases test_i18ngrep 'rewinding head' stdout elif test $what = noop then - test_i18ngrep 'is up to date' stdout + test_i18ngrep 'is up to date' stdout && + ! test_i18ngrep 'rebase forced' stdout + elif test $what = noop-force + then + test_i18ngrep 'is up to date, rebase forced' stdout fi && newhead=\$(git rev-parse HEAD) && if test $cmp = same @@ -45,32 +70,32 @@ test_rebase_same_head () { } changes='no changes' -test_rebase_same_head success work same -test_rebase_same_head success noop same master -test_rebase_same_head success noop same --onto B B -test_rebase_same_head success noop same --onto B... B -test_rebase_same_head success noop same --onto master... master -test_rebase_same_head success noop same --no-fork-point -test_rebase_same_head success work same --fork-point master -test_rebase_same_head failure noop same --fork-point --onto B B -test_rebase_same_head failure work same --fork-point --onto B... B -test_rebase_same_head success work same --fork-point --onto master... master +test_rebase_same_head success work same success work same +test_rebase_same_head success noop same success noop-force same master +test_rebase_same_head success noop same success noop-force diff --onto B B +test_rebase_same_head success noop same success noop-force diff --onto B... B +test_rebase_same_head success noop same success noop-force same --onto master... master +test_rebase_same_head success noop same success noop-force same --no-fork-point +test_rebase_same_head success work same success work same --fork-point master +test_rebase_same_head failure noop same success work diff --fork-point --onto B B +test_rebase_same_head failure work same success work diff --fork-point --onto B... B +test_rebase_same_head success work same success work same --fork-point --onto master... master test_expect_success 'add work same to side' ' test_commit E ' changes='our changes' -test_rebase_same_head success work same -test_rebase_same_head success noop same master -test_rebase_same_head success noop same --onto B B -test_rebase_same_head success noop same --onto B... B -test_rebase_same_head success noop same --onto master... master -test_rebase_same_head success noop same --no-fork-point -test_rebase_same_head success work same --fork-point master -test_rebase_same_head failure work same --fork-point --onto B B -test_rebase_same_head failure work same --fork-point --onto B... B -test_rebase_same_head success work same --fork-point --onto master... master +test_rebase_same_head success work same success work same +test_rebase_same_head success noop same success noop-force same master +test_rebase_same_head success noop same success noop-force diff --onto B B +test_rebase_same_head success noop same success noop-force diff --onto B... B +test_rebase_same_head success noop same success noop-force same --onto master... master +test_rebase_same_head success noop same success noop-force same --no-fork-point +test_rebase_same_head success work same success work same --fork-point master +test_rebase_same_head failure work same success work diff --fork-point --onto B B +test_rebase_same_head failure work same success work diff --fork-point --onto B... B +test_rebase_same_head success work same success work same --fork-point --onto master... master test_expect_success 'add work same to upstream' ' git checkout master && @@ -79,11 +104,11 @@ test_expect_success 'add work same to upstream' ' ' changes='our and their changes' -test_rebase_same_head success noop same --onto B B -test_rebase_same_head success noop same --onto B... B -test_rebase_same_head failure work same --onto master... master -test_rebase_same_head failure work same --fork-point --onto B B -test_rebase_same_head failure work same --fork-point --onto B... B -test_rebase_same_head failure work same --fork-point --onto master... master +test_rebase_same_head success noop same success noop-force diff --onto B B +test_rebase_same_head success noop same success noop-force diff --onto B... B +test_rebase_same_head failure work same success work diff --onto master... master +test_rebase_same_head failure work same success work diff --fork-point --onto B B +test_rebase_same_head failure work same success work diff --fork-point --onto B... B +test_rebase_same_head failure work same success work diff --fork-point --onto master... master test_done From patchwork Tue Aug 27 05:37:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11116065 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 809D3174A for ; Tue, 27 Aug 2019 05:38:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2032021881 for ; Tue, 27 Aug 2019 05:38:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NDeXaZxM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729311AbfH0FiA (ORCPT ); Tue, 27 Aug 2019 01:38:00 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:34310 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfH0FiA (ORCPT ); Tue, 27 Aug 2019 01:38:00 -0400 Received: by mail-io1-f66.google.com with SMTP id s21so43513514ioa.1 for ; Mon, 26 Aug 2019 22:37:59 -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=QW0NShJ7fDoQCwK8HRFHmEXY/arqlqKQTi2BvHMo4Pc=; b=NDeXaZxMbC5bPG2QOhHRkscYSwlltspLX1xWqOnFr33sL6t3qwug+6DxrQX1be7jvU kvM5KK96yQooYgB14l63AwoAGdvkW0//TvTr55daUJSqdKDZd4fSB/zoo1/xoU0A7Gev yLwQUvf0SPmIg8T3gbX4TRpooLNhz7AScff13CjO8TBdj62phXFRAKKKK/0DpbOjP/Iq kfMhbzlR5Q3hYan5aqBqxWQoLmyWqtIl6KIL7JuIdLVMRxzw9FrMeKiKRLhj5oTxI2Hw 5FTwUnaFWjuEyRE7c9z2souShHiZIKiBfqikYrLNeZIyFe3preOpx+Kfe3Qt2I7TZY0U Hi9Q== 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=QW0NShJ7fDoQCwK8HRFHmEXY/arqlqKQTi2BvHMo4Pc=; b=t4hZIQ6T89gnGmW4jb1z72zKf+M3VRD2k13bwjwaBLVaxpl/lfDSoszS/mrLVdRN0F qG2psb9LdOWVrsgoZ/M2wyfHESMIAegkz/sTaESkESeeS+ArvG+UEfpoDGNnc7NGWONV Z9cAlSzjrV3WerPlANCY6bV94Cyw81hVkcByfQRHhFFYsJs0vvBoX4FA4MudocwuKIgD W9bCtb2KjS1rPzuxwz0zcIYSywBp8wS7HrCT3fWgIGg8T4J7xXbUECh5QPq5tA/4egSW 9kBIN7/W58jUli73ySiPdLoQWfqfNXzWaSnnjw54eI4QPQPVV4XRF+cXpa5Qt/++Y0ha BCWA== X-Gm-Message-State: APjAAAWuXCFisOBDl6kmzX0UM49ngZh5g8Y4DVm9Cy8uvzaVI+sVrZVO H8KIj4pm+aht5T5VdO1t1VbGX8y3 X-Google-Smtp-Source: APXvYqxKSXjzUBh3T5tP7yiWe0tIQFSM+4lji5oOfXyLQzypcK1oOJoBIeK/9Aa3vLFZwBqM99CQGw== X-Received: by 2002:a6b:6b02:: with SMTP id g2mr5184211ioc.13.1566884279064; Mon, 26 Aug 2019 22:37:59 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.89.95]) by smtp.gmail.com with ESMTPSA id t2sm27484253iod.81.2019.08.26.22.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 22:37:58 -0700 (PDT) Date: Tue, 27 Aug 2019 01:37:56 -0400 From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine , Johannes Schindelin , Johannes Sixt , SZEDER =?iso-8859-1?q?G=E1bor?= , =?iso-8859-1?q?=C6v?= =?iso-8859-1?q?ar_Arnfj=F6r=F0?= Bjarmason , Philip Oakley , Pratyush Yadav Subject: [PATCH v10 5/9] rebase: refactor can_fast_forward into goto tower Message-ID: <9acce7c911f11dbaa385f924ec8728160f990504.1566884063.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Before, can_fast_forward was written with an if-else statement. However, in the future, we may be adding more termination cases which would lead to deeply nested if statements. Refactor to use a goto tower so that future cases can be easily inserted. Signed-off-by: Denton Liu --- builtin/rebase.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 670096c065..1ddad46126 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1264,20 +1264,25 @@ static int can_fast_forward(struct commit *onto, struct object_id *head_oid, struct object_id *merge_base) { struct commit *head = lookup_commit(the_repository, head_oid); - struct commit_list *merge_bases; - int res; + struct commit_list *merge_bases = NULL; + int res = 0; if (!head) - return 0; + goto done; merge_bases = get_merge_bases(onto, head); - if (merge_bases && !merge_bases->next) { - oidcpy(merge_base, &merge_bases->item->object.oid); - res = oideq(merge_base, &onto->object.oid); - } else { + if (!merge_bases || merge_bases->next) { oidcpy(merge_base, &null_oid); - res = 0; + goto done; } + + oidcpy(merge_base, &merge_bases->item->object.oid); + if (!oideq(merge_base, &onto->object.oid)) + goto done; + + res = 1; + +done: free_commit_list(merge_bases); return res && is_linear_history(onto, head); } From patchwork Tue Aug 27 05:37: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: 11116067 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 6B91B1398 for ; Tue, 27 Aug 2019 05:38:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C2BA217F5 for ; Tue, 27 Aug 2019 05:38:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GtIgBL43" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729315AbfH0FiD (ORCPT ); Tue, 27 Aug 2019 01:38:03 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:43843 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfH0FiD (ORCPT ); Tue, 27 Aug 2019 01:38:03 -0400 Received: by mail-io1-f68.google.com with SMTP id 18so43373445ioe.10 for ; Mon, 26 Aug 2019 22:38:02 -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=KKpr0B4lGqCkK8lyinz/Ie8SCfFlUMbtdzYEIkvqLM0=; b=GtIgBL43KCQH+xf/qxyL8UUKMHOiJyJ3HoA2PEzXZmgT3dz9Yd6KO0U+yPxdZt5yhR DLSJTaCHfvEegwmxeT7YVXP3JZN9coVw023HD7oNWXVAyrqtJqvcZfdL+o1u9p5CDWU6 IucVZh5MY2zkaPPcCcvvasZgdp+84wF0+uyTgy/7wtr1s6b8S9W9byg60V6yhlw8KMxc Gji8FOUqKQ9pefykYKvQsyP+iR1mbL/ndJIuoXjX7r8HLfHewdVKdk62Cj6teAjcEjq3 Xih9hkQTPAGbD2EbDIDVmtFqgqOEER+81XKwym1OLcOrg08Fsxg7+Xi5FosEunzOleU7 H7UA== 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=KKpr0B4lGqCkK8lyinz/Ie8SCfFlUMbtdzYEIkvqLM0=; b=Td+0AHKegajmnLtjTD23W3s5HpTGVXuIM4VqPj/1S3aXuARv1iWD4QBMKIqE3WtYye mIGQ1fSWzmQT0f9Ziihj+6Q6CWvmvwPwD8pCZqnxsffJujzlzJTM+D9sCnILzF+ana/E /VMKcvltkODi/6ADBRl/ZpXJ94zdYaWHpju2STgkDN9VhQKQtgfDfvsofYUzfOiVzjA7 0BDzaeGCe+jm6YGNw9+RWWpBm1MJpWUD4KerAuuIusteMsYxClwYQluWbUgeCNBiL6oO wFWMx5pcxGtwac4OcUtImUp+8WWhTjV+YgZnFx0WqohlizQKIdBsIVntxtt5qH0D/QvI 7L9g== X-Gm-Message-State: APjAAAUnFg3Lw8R+MxhMDo/zDmF5O9JeltiQN/9cU5a5X/1Daq3WFaZF AE87B64KoYLG/+w3bayV3zNSTivc X-Google-Smtp-Source: APXvYqxNSCaGhPdoQVgvxAbzO4UQGLxetvBYZ6xvxFDP7tuLIHn9dtLBW05CPupuhAClPflJz43ooA== X-Received: by 2002:a5e:8344:: with SMTP id y4mr5087089iom.213.1566884281807; Mon, 26 Aug 2019 22:38:01 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.89.95]) by smtp.gmail.com with ESMTPSA id n21sm11572958iom.69.2019.08.26.22.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 22:38:01 -0700 (PDT) Date: Tue, 27 Aug 2019 01:37:59 -0400 From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine , Johannes Schindelin , Johannes Sixt , SZEDER =?iso-8859-1?q?G=E1bor?= , =?iso-8859-1?q?=C6v?= =?iso-8859-1?q?ar_Arnfj=F6r=F0?= Bjarmason , Philip Oakley , Pratyush Yadav Subject: [PATCH v10 6/9] rebase: fast-forward --onto in more cases Message-ID: <3f208421d672215e1f65097f87e823edfca78886.1566884063.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Before, when we had the following graph, A---B---C (master) \ D (side) running 'git rebase --onto master... master side' would result in D being always rebased, no matter what. However, the desired behavior is that rebase should notice that this is fast-forwardable and do that instead. Add detection to `can_fast_forward` so that this case can be detected and a fast-forward will be performed. First of all, rewrite the function to use gotos which simplifies the logic. Next, since the options.upstream && !oidcmp(&options.upstream->object.oid, &options.onto->object.oid) conditions were removed in `cmd_rebase`, we reintroduce a substitute in `can_fast_forward`. In particular, checking the merge bases of `upstream` and `head` fixes a failing case in t3416. The abbreviated graph for t3416 is as follows: F---G topic / A---B---C---D---E master and the failing command was git rebase --onto master...topic F topic Before, Git would see that there was one merge base (C), and the merge and onto were the same so it would incorrectly return 1, indicating that we could fast-forward. This would cause the rebased graph to be 'ABCFG' when we were expecting 'ABCG'. With the additional logic, we detect that upstream and head's merge base is F. Since onto isn't F, it means we're not rebasing the full set of commits from master..topic. Since we're excluding some commits, a fast-forward cannot be performed and so we correctly return 0. Add '-f' to test cases that failed as a result of this change because they were not expecting a fast-forward so that a rebase is forced. Helped-by: Phillip Wood Signed-off-by: Denton Liu --- builtin/rebase.c | 27 +++++++++++++++++++-------- t/t3400-rebase.sh | 2 +- t/t3404-rebase-interactive.sh | 2 +- t/t3432-rebase-fast-forward.sh | 4 ++-- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 1ddad46126..1e1406c8ba 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1260,8 +1260,8 @@ static int is_linear_history(struct commit *from, struct commit *to) return 1; } -static int can_fast_forward(struct commit *onto, struct object_id *head_oid, - struct object_id *merge_base) +static int can_fast_forward(struct commit *onto, struct commit *upstream, + struct object_id *head_oid, struct object_id *merge_base) { struct commit *head = lookup_commit(the_repository, head_oid); struct commit_list *merge_bases = NULL; @@ -1280,6 +1280,17 @@ static int can_fast_forward(struct commit *onto, struct object_id *head_oid, if (!oideq(merge_base, &onto->object.oid)) goto done; + if (!upstream) + goto done; + + free_commit_list(merge_bases); + merge_bases = get_merge_bases(upstream, head); + if (!merge_bases || merge_bases->next) + goto done; + + if (!oideq(&onto->object.oid, &merge_bases->item->object.oid)) + goto done; + res = 1; done: @@ -2027,13 +2038,13 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) /* * Check if we are already based on onto with linear history, - * but this should be done only when upstream and onto are the same - * and if this is not an interactive rebase. + * in which case we could fast-forward without replacing the commits + * with new commits recreated by replaying their changes. This + * optimization must not be done if this is an interactive rebase. */ - if (can_fast_forward(options.onto, &options.orig_head, &merge_base) && - !is_interactive(&options) && !options.restrict_revision && - options.upstream && - !oidcmp(&options.upstream->object.oid, &options.onto->object.oid)) { + if (can_fast_forward(options.onto, options.upstream, &options.orig_head, + &merge_base) && + !is_interactive(&options) && !options.restrict_revision) { int flag; if (!(options.flags & REBASE_FORCE)) { diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index 80b23fd326..d7c724bea3 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -295,7 +295,7 @@ test_expect_success 'rebase --am and --show-current-patch' ' echo two >>init.t && git commit -a -m two && git tag two && - test_must_fail git rebase --onto init HEAD^ && + test_must_fail git rebase -f --onto init HEAD^ && GIT_TRACE=1 git rebase --show-current-patch >/dev/null 2>stderr && grep "show.*$(git rev-parse two)" stderr ) diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 461dd539ff..3cc9052f10 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -1058,7 +1058,7 @@ test_expect_success C_LOCALE_OUTPUT 'rebase --edit-todo does not work on non-int git reset --hard && git checkout conflict-branch && set_fake_editor && - test_must_fail git rebase --onto HEAD~2 HEAD~ && + test_must_fail git rebase -f --onto HEAD~2 HEAD~ && test_must_fail git rebase --edit-todo && git rebase --abort ' diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh index 02b2516595..d9957e5f1e 100755 --- a/t/t3432-rebase-fast-forward.sh +++ b/t/t3432-rebase-fast-forward.sh @@ -106,9 +106,9 @@ test_expect_success 'add work same to upstream' ' changes='our and their changes' test_rebase_same_head success noop same success noop-force diff --onto B B test_rebase_same_head success noop same success noop-force diff --onto B... B -test_rebase_same_head failure work same success work diff --onto master... master +test_rebase_same_head success noop same success work diff --onto master... master test_rebase_same_head failure work same success work diff --fork-point --onto B B test_rebase_same_head failure work same success work diff --fork-point --onto B... B -test_rebase_same_head failure work same success work diff --fork-point --onto master... master +test_rebase_same_head success noop same success work diff --fork-point --onto master... master test_done From patchwork Tue Aug 27 05:38:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11116069 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 C620F1398 for ; Tue, 27 Aug 2019 05:38:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97B19217F5 for ; Tue, 27 Aug 2019 05:38:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I1iGMK8F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729324AbfH0FiF (ORCPT ); Tue, 27 Aug 2019 01:38:05 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:35769 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfH0FiF (ORCPT ); Tue, 27 Aug 2019 01:38:05 -0400 Received: by mail-io1-f65.google.com with SMTP id b10so34397940ioj.2 for ; Mon, 26 Aug 2019 22:38:04 -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:content-transfer-encoding:in-reply-to :user-agent; bh=F60fZwnt39XfVOJovpBOzsC+gIlPxSPyARZ47M61hD0=; b=I1iGMK8FTvsQlIvGDCiu8Gh/hKXNYAphCnCgT9NwBOEj7nylmrwlZaJpW+E2Mq6BWs uKf+5sy5U9PqLkSGR2IU1ZZ7pMoPW/D8qgteHA+fv5xpH5YjG0wttQy2Ap1LwwMJBCh1 Rr91YxEJghNlEfzCtJ0G70OwnltvAkvnwxoHfdOO3kV4768bibS6XGDtt5AZP0hEFcUb Uflx4GpCSGg2VhT3FjBCeTTohJa/ztlsboeuCEnNkGUQEL9VnV44XK6T0zVVEAqlJWza ZV3NkHOHPmcdQAdMwKsz7GYsfnALr5ICuElNOG/T99qfRkFp0jOKQtZV+8CBNhyQO3OD 7u1w== 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:content-transfer-encoding :in-reply-to:user-agent; bh=F60fZwnt39XfVOJovpBOzsC+gIlPxSPyARZ47M61hD0=; b=rVJC7avRk0P0cyK7yWOUhjuGz4m7W/DYdyZfQvzuFHunVVR9LN0iwXT1+UHOz9Dhaf WLgktCGEZd/Ks3QbqwTlnh8jaqwB6LMm32vVNk3Xvb5CSzrfwEHtpTJ8aQ5RvU3EUDeH 9W6stXMH2eyjPsa3cIo0g0CMLYmHBVWrc/Q8dL/ez0XMhg2jH38XTzlnpw27ATSvCL0n RRsEpk+frc3RJVMWT5CJJJg/pM9mNoBqHv61JhRvFFVoiJFwlC40a8vMBloWCBLplzyD wImG60N6Z8ArSrHMszgjMHheZ56UuUHee4qu5+5AcTxu/ueCrmHIpxsEi/6/DE5624f4 DrwA== X-Gm-Message-State: APjAAAUjjJopf4uoBak4p7698F2bc5oQpqyR6syj1Dh/M7kTzJG+0FqL zHYsDiACA84xpR3EwNnpTpgiJoZb X-Google-Smtp-Source: APXvYqxtUnAzG2ZRqw5z/pn9nTB+sGmTOo/MSGgf6PUYVaSJezn5FMfyYXJHStOYpPxCGHinb1DJ1w== X-Received: by 2002:a5d:9a01:: with SMTP id s1mr1197295iol.255.1566884284169; Mon, 26 Aug 2019 22:38:04 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.89.95]) by smtp.gmail.com with ESMTPSA id q3sm12209469ios.70.2019.08.26.22.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 22:38:03 -0700 (PDT) Date: Tue, 27 Aug 2019 01:38:01 -0400 From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine , Johannes Schindelin , Johannes Sixt , SZEDER =?iso-8859-1?q?G=E1bor?= , =?iso-8859-1?q?=C6v?= =?iso-8859-1?q?ar_Arnfj=F6r=F0?= Bjarmason , Philip Oakley , Pratyush Yadav Subject: [PATCH v10 7/9] rebase: fast-forward --fork-point in more cases Message-ID: <126c20a95d1d7afa4e0cba384fbd08a4bea43614.1566884063.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Before, when we rebased with a --fork-point invocation where the fork-point wasn't empty, we would be setting options.restrict_revision. The fast-forward logic would automatically declare that the rebase was not fast-forwardable if it was set. However, this was painting with a very broad brush. Refine the logic so that we can fast-forward in the case where the restricted revision is equal to the merge base, since we stop rebasing at the merge base anyway. Helped-by: Ævar Arnfjörð Bjarmason Signed-off-by: Denton Liu --- builtin/rebase.c | 10 +++++++--- t/t3432-rebase-fast-forward.sh | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 1e1406c8ba..7ef9095e7c 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1261,6 +1261,7 @@ static int is_linear_history(struct commit *from, struct commit *to) } static int can_fast_forward(struct commit *onto, struct commit *upstream, + struct commit *restrict_revision, struct object_id *head_oid, struct object_id *merge_base) { struct commit *head = lookup_commit(the_repository, head_oid); @@ -1280,6 +1281,9 @@ static int can_fast_forward(struct commit *onto, struct commit *upstream, if (!oideq(merge_base, &onto->object.oid)) goto done; + if (restrict_revision && !oideq(&restrict_revision->object.oid, merge_base)) + goto done; + if (!upstream) goto done; @@ -2042,9 +2046,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) * with new commits recreated by replaying their changes. This * optimization must not be done if this is an interactive rebase. */ - if (can_fast_forward(options.onto, options.upstream, &options.orig_head, - &merge_base) && - !is_interactive(&options) && !options.restrict_revision) { + if (can_fast_forward(options.onto, options.upstream, options.restrict_revision, + &options.orig_head, &merge_base) && + !is_interactive(&options)) { int flag; if (!(options.flags & REBASE_FORCE)) { diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh index d9957e5f1e..fbedfe7b4a 100755 --- a/t/t3432-rebase-fast-forward.sh +++ b/t/t3432-rebase-fast-forward.sh @@ -70,32 +70,32 @@ test_rebase_same_head_ () { } changes='no changes' -test_rebase_same_head success work same success work same +test_rebase_same_head success noop same success work same test_rebase_same_head success noop same success noop-force same master test_rebase_same_head success noop same success noop-force diff --onto B B test_rebase_same_head success noop same success noop-force diff --onto B... B test_rebase_same_head success noop same success noop-force same --onto master... master test_rebase_same_head success noop same success noop-force same --no-fork-point -test_rebase_same_head success work same success work same --fork-point master -test_rebase_same_head failure noop same success work diff --fork-point --onto B B -test_rebase_same_head failure work same success work diff --fork-point --onto B... B -test_rebase_same_head success work same success work same --fork-point --onto master... master +test_rebase_same_head success noop same success work same --fork-point master +test_rebase_same_head success noop same success work diff --fork-point --onto B B +test_rebase_same_head success noop same success work diff --fork-point --onto B... B +test_rebase_same_head success noop same success work same --fork-point --onto master... master test_expect_success 'add work same to side' ' test_commit E ' changes='our changes' -test_rebase_same_head success work same success work same +test_rebase_same_head success noop same success work same test_rebase_same_head success noop same success noop-force same master test_rebase_same_head success noop same success noop-force diff --onto B B test_rebase_same_head success noop same success noop-force diff --onto B... B test_rebase_same_head success noop same success noop-force same --onto master... master test_rebase_same_head success noop same success noop-force same --no-fork-point -test_rebase_same_head success work same success work same --fork-point master -test_rebase_same_head failure work same success work diff --fork-point --onto B B -test_rebase_same_head failure work same success work diff --fork-point --onto B... B -test_rebase_same_head success work same success work same --fork-point --onto master... master +test_rebase_same_head success noop same success work same --fork-point master +test_rebase_same_head success noop same success work diff --fork-point --onto B B +test_rebase_same_head success noop same success work diff --fork-point --onto B... B +test_rebase_same_head success noop same success work same --fork-point --onto master... master test_expect_success 'add work same to upstream' ' git checkout master && From patchwork Tue Aug 27 05:38:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11116071 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 EB93B1398 for ; Tue, 27 Aug 2019 05:38:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C763C217F5 for ; Tue, 27 Aug 2019 05:38:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NJv3qlvP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729340AbfH0FiI (ORCPT ); Tue, 27 Aug 2019 01:38:08 -0400 Received: from mail-io1-f42.google.com ([209.85.166.42]:38865 "EHLO mail-io1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfH0FiH (ORCPT ); Tue, 27 Aug 2019 01:38:07 -0400 Received: by mail-io1-f42.google.com with SMTP id p12so43496478iog.5 for ; Mon, 26 Aug 2019 22:38:07 -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:content-transfer-encoding:in-reply-to :user-agent; bh=vQ/XcDGahnhdplmjyOLvVAhEom12eBuxu/TN2N3wMX0=; b=NJv3qlvPgslO/KRVNZFPZOAF+OQQFW4xL9EDHnjyR9GrTMa3cqQlRrGUsWb3+hNrOt fAzQW0Yfm4YKyFdYMEsgahg6fKSgnGZi2Bbnq3LHQRXKJa6PMWms0xoovEBuSD316MKT mWUWG1FQPUKMm7IiWeP9M030/TxSFcOfY+JVrXfp+2harC86KkGKcOiLX0f6zHHIzSJh 7SbDUv4RfR+aJnHo/NPVhB7dpbBwuD8hUOd+PUKbFzhAIJp97owwzJ/InqHiKxbP8Odd fZccj25wql7zqgsQIeZjKtd7nj+eiGi1LYhjW3pLlq846Fy9qxlPJjFz71k4nCrMakpz y4ZQ== 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:content-transfer-encoding :in-reply-to:user-agent; bh=vQ/XcDGahnhdplmjyOLvVAhEom12eBuxu/TN2N3wMX0=; b=fQ218kU8mmGJby6rop0MJKZIAqSSksabXplUhDJH5Ep/C6kOB9zWjF5dZvCUgIuDBA 4WOtZ+/UKax5Gjsnd1+ZqOWg8Zif7LRcQZOI77Z5l4RjYlVs8Gb+8WFRxac3UrIVqLwX Zwr/JDx/o28yVOmPt+GT4wCTYszJMInLg5R4oNpvL+Ey7GSwhVeNCyoYihoDn6on+A3+ BklsI/mAcEKMBPd7/4WJ3mRDoF8V8uDQMLsrShwhHn2ssa7CRp9PawTZGi/zVuCVqDma SL9CvawYFxz8Udx8kb6ZVpEIXdU5AT8IfgUXk6EyVkddotceyw+BNP3BlmQo2cGKA+ba IKLA== X-Gm-Message-State: APjAAAUiokgeh7vWajKJ5PJOHMBts0cZyMerUZyei02TSskxggv61rGj fs7n65Gr2HA8JETCSMsvXJu44eoj X-Google-Smtp-Source: APXvYqw7fV7U2cN91/nWwVwDFw5AlMOTmJ4BIourdWr/JXjivoNBZQS2ZipbZbQWKpQUHcfdkJ9RHA== X-Received: by 2002:a02:9644:: with SMTP id c62mr10719718jai.45.1566884286604; Mon, 26 Aug 2019 22:38:06 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.89.95]) by smtp.gmail.com with ESMTPSA id s11sm12483137ioo.45.2019.08.26.22.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 22:38:06 -0700 (PDT) Date: Tue, 27 Aug 2019 01:38:04 -0400 From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine , Johannes Schindelin , Johannes Sixt , SZEDER =?iso-8859-1?q?G=E1bor?= , =?iso-8859-1?q?=C6v?= =?iso-8859-1?q?ar_Arnfj=F6r=F0?= Bjarmason , Philip Oakley , Pratyush Yadav Subject: [PATCH v10 8/9] rebase tests: test linear branch topology Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ævar Arnfjörð Bjarmason 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 Signed-off-by: Denton Liu --- 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 Tue Aug 27 05:38:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11116073 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 EB52D174A for ; Tue, 27 Aug 2019 05:38:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B3D59217F5 for ; Tue, 27 Aug 2019 05:38:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZK9OSGTu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729350AbfH0FiK (ORCPT ); Tue, 27 Aug 2019 01:38:10 -0400 Received: from mail-io1-f44.google.com ([209.85.166.44]:42579 "EHLO mail-io1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfH0FiK (ORCPT ); Tue, 27 Aug 2019 01:38:10 -0400 Received: by mail-io1-f44.google.com with SMTP id e20so43332046iob.9 for ; Mon, 26 Aug 2019 22:38:09 -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:content-transfer-encoding:in-reply-to :user-agent; bh=c/5QWT3HjTnA+rxUvWPDvvkf6RmlHqU/5wxYCEgzBC4=; b=ZK9OSGTu6FFmK0XdsoJlzHpDzHqytxDsBy/9Om3Y+aIZkA+2CtTihNSM0f7jx3nlP1 aMnCs96UkoDjVOEZdAuBBrQP06qVatyqGAzs7ls6qJTgA1fAPyIGjUiO1yfCkHQm33Z8 n0FWTmu69yKGqrqfT+NGy3k7/2B383YPTWXE1yHKmty+pl4uhcP9aLEJqTUCu9nvLQoR I4avoVEZD5nutyE5Z26YWoh/PBx7ug+NFDI4HdP2Q/C4GMi0/I2kgFeg3WcGNcsi3kCR /vc0KiQspn7B/BNckHT8taaXYs6ZFMCQv8Gz5mdRbFIA3dMl9EPvOkktQv7K8R3m0BIs cp9Q== 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:content-transfer-encoding :in-reply-to:user-agent; bh=c/5QWT3HjTnA+rxUvWPDvvkf6RmlHqU/5wxYCEgzBC4=; b=Wd2GTwQrnKH51yp7RmcHnurRJF9gpuzpESree1YpiDWTJMv4Z+R3dmnXwQXaabFKha imtOjTR1YQZHyS2Rpm+zesXrhj3hhBG6d9619G9kdrnQYbaw2WpU6sUhgAoc/kfLoPX8 Y5vI2yRbMfubNg7vT4Gs0aA/L9Ym9U6x/guHFqW9NsQdeb9YC30sowd5rPCo4adUJprg D6SHrIHBGAvbSfVJlrznAjMuVIAVqWlIZjaf1cGIC2HfLwqKQuYG0A5d2pBKwpqaIS9m fT4pIjylWCCYSDXnE+z7Op64p8qbhOBLP7pVR7gWZqtXVgbskEaw5LkVliTtmyAvlm9z 7tsA== X-Gm-Message-State: APjAAAULW3V+Z88qKiYvZ1ZDbJe1Jyai1M5VihBZ3fl6ujaLJTLA2UCl 0L4R55LPU6L8m/gzPOVM+TtakMR7 X-Google-Smtp-Source: APXvYqyWO0QgaCLVjJIJuwMnIE50q4lb5GOBAEdoKitGwU/MJ5huCWvTuPBKAR0yqd7m/lMAN1Fhww== X-Received: by 2002:a6b:fd13:: with SMTP id c19mr20458903ioi.168.1566884289008; Mon, 26 Aug 2019 22:38:09 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.89.95]) by smtp.gmail.com with ESMTPSA id a9sm11645438iod.76.2019.08.26.22.38.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 22:38:08 -0700 (PDT) Date: Tue, 27 Aug 2019 01:38:06 -0400 From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine , Johannes Schindelin , Johannes Sixt , SZEDER =?iso-8859-1?q?G=E1bor?= , =?iso-8859-1?q?=C6v?= =?iso-8859-1?q?ar_Arnfj=F6r=F0?= Bjarmason , Philip Oakley , Pratyush Yadav Subject: [PATCH v10 9/9] rebase: teach rebase --keep-base Message-ID: <6bc7423ac1e6f7d81de96cd4911ff652dc0e5a88.1566884063.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org A common scenario is if a user is working on a topic branch and they wish to make some changes to intermediate commits or autosquash, they would run something such as git rebase -i --onto master... master in order to preserve the merge base. This is useful when contributing a patch series to the Git mailing list, one often starts on top of the current 'master'. While developing the patches, 'master' is also developed further and it is sometimes not the best idea to keep rebasing on top of 'master', but to keep the base commit as-is. In addition to this, a user wishing to test individual commits in a topic branch without changing anything may run git rebase -x ./test.sh master... master Since rebasing onto the merge base of the branch and the upstream is such a common case, introduce the --keep-base option as a shortcut. This allows us to rewrite the above as git rebase -i --keep-base master and git rebase -x ./test.sh --keep-base master respectively. Add tests to ensure --keep-base works correctly in the normal case and fails when there are multiple merge bases, both in regular and interactive mode. Also, test to make sure conflicting options cause rebase to fail. While we're adding test cases, add a missing set_fake_editor call to 'rebase -i --onto master...side'. While we're documenting the --keep-base option, change an instance of "merge-base" to "merge base", which is the consistent spelling. Helped-by: Eric Sunshine Helped-by: Junio C Hamano Helped-by: Ævar Arnfjörð Bjarmason Helped-by: Johannes Schindelin Signed-off-by: Denton Liu --- Documentation/git-rebase.txt | 30 ++++++++++++-- builtin/rebase.c | 32 ++++++++++++--- contrib/completion/git-completion.bash | 2 +- t/t3416-rebase-onto-threedots.sh | 57 ++++++++++++++++++++++++++ t/t3431-rebase-fork-point.sh | 4 ++ t/t3432-rebase-fast-forward.sh | 11 +++++ 6 files changed, 126 insertions(+), 10 deletions(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 6156609cf7..3146c1592d 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -8,8 +8,8 @@ git-rebase - Reapply commits on top of another base tip SYNOPSIS -------- [verse] -'git rebase' [-i | --interactive] [] [--exec ] [--onto ] - [ []] +'git rebase' [-i | --interactive] [] [--exec ] + [--onto | --keep-base] [ []] 'git rebase' [-i | --interactive] [] [--exec ] [--onto ] --root [] 'git rebase' (--continue | --skip | --abort | --quit | --edit-todo | --show-current-patch) @@ -217,6 +217,24 @@ As a special case, you may use "A\...B" as a shortcut for the merge base of A and B if there is exactly one merge base. You can leave out at most one of A and B, in which case it defaults to HEAD. +--keep-base:: + Set the starting point at which to create the new commits to the + merge base of . Running + 'git rebase --keep-base ' is equivalent to + running 'git rebase --onto ... '. ++ +This option is useful in the case where one is developing a feature on +top of an upstream branch. While the feature is being worked on, the +upstream branch may advance and it may not be the best idea to keep +rebasing on top of the upstream but to keep the base commit as-is. ++ +Although both this option and --fork-point find the merge base between + and , this option uses the merge base as the _starting +point_ on which new commits will be created, whereas --fork-point uses +the merge base to determine the _set of commits_ which will be rebased. ++ +See also INCOMPATIBLE OPTIONS below. + :: Upstream branch to compare against. May be any valid commit, not just an existing branch name. Defaults to the configured @@ -369,6 +387,10 @@ ends up being empty, the will be used as a fallback. + If either or --root is given on the command line, then the default is `--no-fork-point`, otherwise the default is `--fork-point`. ++ +If your branch was based on but was rewound and +your branch contains commits which were dropped, this option can be used +with `--keep-base` in order to drop those commits from your branch. --ignore-whitespace:: --whitespace=