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=-3.8 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, SPF_HELO_NONE,SPF_NONE 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 AB7F21F461 for ; Tue, 27 Aug 2019 05:38:11 +0000 (UTC) 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?=C6var_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-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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=