From patchwork Sun Apr 21 08:11:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10910471 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 DFF8A161F for ; Sun, 21 Apr 2019 08:11:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCD14288A9 for ; Sun, 21 Apr 2019 08:11:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0BE6288B2; Sun, 21 Apr 2019 08:11:38 +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 8945A288A9 for ; Sun, 21 Apr 2019 08:11:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727274AbfDUILg (ORCPT ); Sun, 21 Apr 2019 04:11:36 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33159 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725940AbfDUILg (ORCPT ); Sun, 21 Apr 2019 04:11:36 -0400 Received: by mail-pl1-f194.google.com with SMTP id t16so4446111plo.0 for ; Sun, 21 Apr 2019 01:11:35 -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=FIJjFbAc1ED2nZnVPfSrkqJpuWl3onwZowjl4zcLUyg=; b=tKheTzab7xNOS2KLU5m2r9vYKtefXOQlw5AuWftnnZN5giIs/ULyaNpLuCtFxgLJB+ pUxH01XLwS4UFoURrDVpDrYTCqEsKyGwrDCfvrsA7kxd60JL1NBO1Pnq3uWUosYS2Mlh HoKA9evOivPjsTP1qCso//k2kMDYtVCL0ozwEcQNw78m/EZE9bEsc+uWeAKigAQ1Cah4 JdPt00kVfEmYSf1bO0lW+lIQBruwk4FjKibu0TLEbP+BNJfsEEh6994fRnjjjY35n07C zZE9wph5zfepRwW1nsRsBLKLTSR41uoZdQ9DhifjblE6eYZTBjx2oZvtyg315K0QFwpv mwsA== 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=FIJjFbAc1ED2nZnVPfSrkqJpuWl3onwZowjl4zcLUyg=; b=c2hCAQSW95xc8sdrfBpU2PFEr2/bFp7+bpk8BSfVurn05uuz1TvN4Op9ZA8WlozBLk 4jufKJReSD/phEtmNv4voqaVfPxq6nNR4H31PeOc3p5HS/q7y2J9g4cIy58BFi3Z0Qv8 UsSoFsv6RVbmyZByYtznBoUa63B8nApuqOPXdKYKec4/hE89CCDuAltMdeE0kH/k1TWB Pmf40NtDR5M325VgALrtHytDKCD/hpQHPuzyJUDI1lPWwZiFvbd1v4XVDolTXD3ZkB1p COVTO+/7iRglAVbVCX/Dz4MOn5wc7kZVQW1f9Rr2Namrgs40fGKbWGEtY2kw1vodtHci 4Elw== X-Gm-Message-State: APjAAAUQol2Gf9L2BbFxbW15dHTO6eDw+8BBu7cU50J2y/AooSpCgnDo w2GjOcGuyAjT0jxL9EOu2WDE+v0H X-Google-Smtp-Source: APXvYqyrsHU7F21XxIquflzCOr4lkXK7+DzfAXGvugHWNaqLkTTIISACXPtHTO01lf4BH3Uxc9LDrw== X-Received: by 2002:a17:902:e684:: with SMTP id cn4mr13506090plb.71.1555834295029; Sun, 21 Apr 2019 01:11:35 -0700 (PDT) Received: from archbookpro.localdomain ([2601:647:4b00:5d::661d]) by smtp.gmail.com with ESMTPSA id p7sm14622953pfp.70.2019.04.21.01.11.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 21 Apr 2019 01:11:34 -0700 (PDT) Date: Sun, 21 Apr 2019 01:11:32 -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 6/6] rebase: teach rebase --keep-base Message-ID: 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 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'. However, while developing the patches, 'master' is also developed further and it is sometimes not the bst idea to keep rebasing on top of 'master', but to keep the base commit as-is. Alternatively, 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 6363d674b7..569ab708d4 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 @@ -364,6 +382,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=