From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 427C61F45F 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?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= To: git@vger.kernel.org Cc: Junio C Hamano , Denton Liu , Eric Sunshine , Johannes Schindelin , Johannes Sixt , =?UTF-8?q?SZEDER=20G=C3=A1bor?= , =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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=