From patchwork Wed May 8 00:12:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10933943 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 9109116C1 for ; Wed, 8 May 2019 00:13:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8028126256 for ; Wed, 8 May 2019 00:13:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 745962864E; Wed, 8 May 2019 00:13:24 +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 49EB626256 for ; Wed, 8 May 2019 00:13:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726607AbfEHANW (ORCPT ); Tue, 7 May 2019 20:13:22 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:35671 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726557AbfEHANV (ORCPT ); Tue, 7 May 2019 20:13:21 -0400 Received: by mail-wr1-f68.google.com with SMTP id w12so11209167wrp.2 for ; Tue, 07 May 2019 17:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wy5dgWcfFi+MUsCGBskQwtPCCarPq0j7KioaKN99PGw=; b=X4LbzgHUl4TdCwmwPxixs6c97dAJbEkg3E4Xk4JQzEEInQUIGHkJZe7lA1Oju86SDX A/H832Y5BFc0Een7sApaPhdsckm3joWY31NdbP2OXZSaS6uIXDgDRmtdKMfUpIdSPD5Z 7hqjClaPJ/o1/gvvbZ4Ut+svJDGQ+7cgiNmHT+sYclOxSrzbdxY9EwdMUQ9dgZRiJx4A bNWofwWV1ve3aillNbto0VC8tQWMTTcnBve2WHysgeQ/IJeiY/0Ci4yK3CfQTwZsTHTt M0d6cKA7UnWUO+JRI27Bexwkuws/J4bueH+I6GmiDuk+5l2bvWCyP4Fwg6JGGRbXLmJV A9Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wy5dgWcfFi+MUsCGBskQwtPCCarPq0j7KioaKN99PGw=; b=dvTJMHlIHe/1Gk5jWBBbuXy0sQ3FTPGtwUpyOvuapv0L12Zgg9KGB5RYa7/xqLaGD8 rYkvny1DPdNG2/Orne1EtjHpVirKqHQKN4GxI0fd0c5/2PktRbr+vIE3rJujdMG1GgHt 313f+pNhxTcqnFQ4OwlW/aVV8IEnPCCIh6CtgVPaZnNk9+bxNh8fr7fMChNQ/4sLt48L 2qKvOp7E0Lfl07AualBJ/qHlg8fwcb8OY+SR+qT0+PgT9PF33f2/T2DZ5J8wMJP+GSM7 qGTkNK3G1kBLVPMI3W12eLZXV3SOlqkRdbgtDR7MKAA2OrjIaABWbl+uS/reFD2bMckJ 9VfA== X-Gm-Message-State: APjAAAX/nSVPNqEle6kapwSG9lkjW5nhSujoKhf01Ai0Ru8yqwD1TFcD 9YXVvE/z/Z3aKLSbp2cH5U4jp2jRDcM= X-Google-Smtp-Source: APXvYqzeyOfyqOTleCITwMmN2BouqlX2kb7/AW+zaJC/RYqYVyUdhyfUoE8FeQqIZ7AGj38nVuPMhw== X-Received: by 2002:adf:f10f:: with SMTP id r15mr15158721wro.274.1557274397983; Tue, 07 May 2019 17:13:17 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n15sm5167825wrp.58.2019.05.07.17.13.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 07 May 2019 17:13:16 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Denton Liu , Eric Sunshine , Johannes Schindelin , Johannes Sixt , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [RFC WIP PATCH v8 08/13] rebase: teach rebase --keep-base Date: Wed, 8 May 2019 02:12:47 +0200 Message-Id: <20190508001252.15752-9-avarab@gmail.com> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Denton Liu 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 Signed-off-by: Junio C Hamano --- 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 f5e6ae3907..fafb7b4eb3 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=