From patchwork Tue Feb 21 05:58:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 13147413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B96CC64EC7 for ; Tue, 21 Feb 2023 06:01:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232589AbjBUGBi (ORCPT ); Tue, 21 Feb 2023 01:01:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbjBUGBh (ORCPT ); Tue, 21 Feb 2023 01:01:37 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E60AE23301 for ; Mon, 20 Feb 2023 22:01:35 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id co23-20020a17090afe9700b002341fadc370so3627374pjb.1 for ; Mon, 20 Feb 2023 22:01:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ouys6+zsHtWQejzbx/I2L4sPaq4lrTjLQs3tUHk0eK0=; b=C+e+jmJxCb2jrTdvoUGiZCSMzw+B25YP686Fzacd9Or8cSUpXv/FJDRSnTubAWkK8k DAjYNSJth7ZSgNKttQrI0FV0EqztUlz0Kb+0ICsS8jxezamyPenYt5SbuDjb2jRegsIW UDKwkG7nBrdaPBhIAJEfnEGtGQxZZyxjUnTms+d5IbGfGq773yvuJ1hYqNmmSbXE0Esw kRG8v1rxFYHZZpGWiBdmkzhfdS1hBbROnva0OLIw+1LzfnaSLbYc7O5T4CPCvUkXlze7 ILXwv1Sp/R+jHE9GhFtY8ku/xKehREh7vADgFtaCuJDaAFofPO8otgdfxCHNypfXy+kl UWow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ouys6+zsHtWQejzbx/I2L4sPaq4lrTjLQs3tUHk0eK0=; b=XM2EfSbGmadjMo2c6kAXxyPywSfH25tWPpSOSwQXsX2T96rGzRrdH5cKrplt3BDbUu zEsRapGLhQ2v00iQbaF23BpTZNcf6ZvBXw6j6VGcNY4KewBXd9JXeGFsvB3tAIv3QpU1 W4xE7EHSE0d45Oato4s0mZp8Cqn+esz6aHoA19KFCWuuCouuHpynsG5/oVsx5eh8QRwQ sFsW2W/Stx5jiqLijyyk8ujPLk2ywpgXGWQYbwV5WypBLvwLVb/+E+Sl9roTOZmRa3BY aD535uukAaw4KiFBhnEfHURUtMyU6+WiVyeg7DxLSwQbMjc30BDVunlQORuYRVtGQlVg B+gg== X-Gm-Message-State: AO0yUKVpYURBEg80/CO+fvRVZ6pLBWVPxDtkAL9ZfRSS6+C0oF7qSiRG OQ9E0M71RnBbOcB1fgMUj4Gx1i3B4Ws= X-Google-Smtp-Source: AK7set/P46XH1fjqKAHpIVmF7Ga2f0yL6cUZBublXWBGUTcd4AFRmkJ/FdBI2EDKsgtB1JyfgSz2Ag== X-Received: by 2002:a17:90b:3ec4:b0:234:721e:51e5 with SMTP id rm4-20020a17090b3ec400b00234721e51e5mr5601809pjb.10.1676959295021; Mon, 20 Feb 2023 22:01:35 -0800 (PST) Received: from xavier.lan ([2607:fa18:92fe:92b::2a2]) by smtp.gmail.com with ESMTPSA id mv14-20020a17090b198e00b002308e6e645bsm993905pjb.49.2023.02.20.22.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 22:01:34 -0800 (PST) From: Alex Henrie To: git@vger.kernel.org, tao@klerks.biz, gitster@pobox.com, newren@gmail.com, phillip.wood123@gmail.com, Johannes.Schindelin@gmx.de Cc: Alex Henrie Subject: [PATCH v2 1/4] rebase: document the --no-rebase-merges option Date: Mon, 20 Feb 2023 22:58:02 -0700 Message-Id: <20230221055805.210951-1-alexhenrie24@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Alex Henrie --- Documentation/git-rebase.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 9a295bcee4..c98784a0d2 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -529,13 +529,15 @@ See also INCOMPATIBLE OPTIONS below. -r:: --rebase-merges[=(rebase-cousins|no-rebase-cousins)]:: +--no-rebase-merges:: By default, a rebase will simply drop merge commits from the todo list, and put the rebased commits into a single, linear branch. With `--rebase-merges`, the rebase will instead try to preserve the branching structure within the commits that are to be rebased, by recreating the merge commits. Any resolved merge conflicts or manual amendments in these merge commits will have to be - resolved/re-applied manually. + resolved/re-applied manually. `--no-rebase-merges` can be used to + countermand a previous `--rebase-merges`. + By default, or when `no-rebase-cousins` was specified, commits which do not have `` as direct ancestor will keep their original branch point, From patchwork Tue Feb 21 05:58:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 13147412 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B595C61DA3 for ; Tue, 21 Feb 2023 06:01:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232640AbjBUGBj (ORCPT ); Tue, 21 Feb 2023 01:01:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231806AbjBUGBh (ORCPT ); Tue, 21 Feb 2023 01:01:37 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09E0C2332A for ; Mon, 20 Feb 2023 22:01:37 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id x34so148245pjj.0 for ; Mon, 20 Feb 2023 22:01:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ADukaVmIG09urodJnbM4fEZpqZ3Ja9EWOmzSGxV3A0U=; b=cArSxQ13kbDARqvNwql3PXmm5QA6R8sExGQSvVQIMH+8BlpK9WKzLHniNuwiYb7q0E JkYLR/Hlu4D5ATpR5UEovTvhX9aFIumGPmifr8VSW5OF/xs7TYsr5R0Irou3aIw0n8iF MyUG4xESZgvWqAtvcd/YhILkgzYYiYOUXWCdQ/v9+SccIEtX9j4K/qAorbyQFJDoLW1E IktfRIoJwWj5zRqlVjWJrCu8NrUZro7CRsGApW2PsdZZnp0FncrXzphlWxbS0iihO+YG B6MWRuFPj7tmG6zLT18GcBjzmOopVZ5Cc8FMHY9eMBJ8k7SFgM/gtKfBm2QqU4lbp14N qBeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ADukaVmIG09urodJnbM4fEZpqZ3Ja9EWOmzSGxV3A0U=; b=hkkkehQFtjFPcOO0SKX8JAXNMxpeI8/ldL5JTAToL+4ozAs875zQ7Gmq6us/ZZTq1N rsKYN+G76a3Ni6PmxaPwG0Gf8fbebDUqsPqZxC8CLx5tN2XCSYr8Y4CjfBJ9qfgd0a1V yWsg2tIgBgYfzyhl5gFHIo1zWijp6LAiK+QMRObMKCdi1fZ+brchvKq0pFaUW8MHNdL0 ++xiGJfog+PFc+hVPZzAU5vcAVkv4RAmrqXd19k5oAAxyWsxzPe9BTHYruHJIn4c3AzE IOVbeUn2KHJBTCV5+v69eT8Ty/PAmPBalgA0afEo1WcbYAq0lGwwScfZ62T07XjOeGZ1 GpdA== X-Gm-Message-State: AO0yUKVQuKF00SiGPJs8ZWSZa9Nkvxv869MF1jEIUzWUfqIJOs1wcTGx nPC70IZsZJFYYwAWCjKligG4FN6hNt8= X-Google-Smtp-Source: AK7set/sDhSuUneIn/lI5DTyG25f7SzgdBZvKotX5I8MLZo4Y6M5t+nv15NCPVgvEmGpfgoidob8aA== X-Received: by 2002:a17:90a:7522:b0:22c:6bb1:55a4 with SMTP id q31-20020a17090a752200b0022c6bb155a4mr3878329pjk.45.1676959296198; Mon, 20 Feb 2023 22:01:36 -0800 (PST) Received: from xavier.lan ([2607:fa18:92fe:92b::2a2]) by smtp.gmail.com with ESMTPSA id mv14-20020a17090b198e00b002308e6e645bsm993905pjb.49.2023.02.20.22.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 22:01:35 -0800 (PST) From: Alex Henrie To: git@vger.kernel.org, tao@klerks.biz, gitster@pobox.com, newren@gmail.com, phillip.wood123@gmail.com, Johannes.Schindelin@gmx.de Cc: Alex Henrie Subject: [PATCH v2 2/4] rebase: add tests for --no-rebase-merges Date: Mon, 20 Feb 2023 22:58:03 -0700 Message-Id: <20230221055805.210951-2-alexhenrie24@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230221055805.210951-1-alexhenrie24@gmail.com> References: <20230221055805.210951-1-alexhenrie24@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Alex Henrie --- t/t3430-rebase-merges.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index fa2a06c19f..e0d910c229 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -250,6 +250,31 @@ test_expect_success 'with a branch tip that was cherry-picked already' ' EOF ' +test_expect_success 'do not rebase merges unless asked to' ' + git checkout -b rebase-merges-default E && + before="$(git rev-parse --verify HEAD)" && + test_tick && + git rebase --rebase-merges C && + test_cmp_rev HEAD $before && + test_tick && + git rebase C && + test_cmp_graph C.. <<-\EOF + * B + * D + o C + EOF +' + +test_expect_success '--no-rebase-merges countermands --rebase-merges' ' + git checkout -b no-rebase-merges E && + git rebase --rebase-merges --no-rebase-merges C && + test_cmp_graph C.. <<-\EOF + * B + * D + o C + EOF +' + test_expect_success 'do not rebase cousins unless asked for' ' git checkout -b cousins main && before="$(git rev-parse --verify HEAD)" && From patchwork Tue Feb 21 05:58:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 13147414 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71502C636D7 for ; Tue, 21 Feb 2023 06:01:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233035AbjBUGBv (ORCPT ); Tue, 21 Feb 2023 01:01:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231806AbjBUGBk (ORCPT ); Tue, 21 Feb 2023 01:01:40 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 502762332A for ; Mon, 20 Feb 2023 22:01:38 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id ky4so5029511plb.3 for ; Mon, 20 Feb 2023 22:01:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xy1IT01CTo/dcs+5t4ZdTy1e5bpLDuJ8H3Byjpbrpv0=; b=hoNZRY89jcTfdbBGZfHmxSMXhljToMgvYrLaUKcPpy9c9D5js6C7N+jHQ2uoohdexI aOqGSWkH+lF0+adD8rRtkcpAvZyOTeyHDihedOaNQz565nrXmJE9+sWpWO1DcJWZH/yc cYRcwiuzWcuG3hCqnCtKS9T/0GtqZmI2hj8kmKskLmW2wx8pux01WhARJu//5N7b88fH rtEkuIT17UsEVJswTqV248hRU+Y5fIo9Jc6IOPILY1THqJTsPKiJFerfmh5n5JCn/SNI SGy7aROVDR+J6dJl9fArlvTe4iG/V+O7VcYwpYBtBBrF8HefTbn7oP6yXxR1eAbmxkgC jz+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xy1IT01CTo/dcs+5t4ZdTy1e5bpLDuJ8H3Byjpbrpv0=; b=lMsKJ7hAnK18tvqhyOZWRyEQpJJLuWXGK2c+VOYcpMe6aApbkmhlvnq202IurSi9yv E2GHV0NakDoloO0biNBix4M0YKEA75SVhXqkk1siPEiKEan7u8YAWJUlUbcP3WTAY5vU WI26osVkn+dKW8vy9ubyAYBrOC4BvIDOYwZjQgbVOWF0jyuakCbmFDo2+WRq5G/KRljG bD/lJyOs/+t4FxHvaYZ3nA59JW6j6TPKEu2YOaza+kBLv5imkHNhnPLrCiN8/mQTNQYL fF5ub4wfNcl74DdUqqGswC963dzzc4hRQtiE3Yscf+DTauAoD8fRIRB+YTQpL1HhmIcI tDsg== X-Gm-Message-State: AO0yUKUkBugBangfQ01Xiq1Mrlh02Via6WufszxLrRkeifFLyr1W9OjI xnuDtd1kSVfihvIlnn7YrGbXBG3FECo= X-Google-Smtp-Source: AK7set92KcmoeN5y+m88Q9QhVliwegpRHsxdML2cdjifH898rFibT9fktKUDoCUaY9QCz2xvov7EwA== X-Received: by 2002:a17:90b:3847:b0:233:e9db:bd7d with SMTP id nl7-20020a17090b384700b00233e9dbbd7dmr4220554pjb.23.1676959297384; Mon, 20 Feb 2023 22:01:37 -0800 (PST) Received: from xavier.lan ([2607:fa18:92fe:92b::2a2]) by smtp.gmail.com with ESMTPSA id mv14-20020a17090b198e00b002308e6e645bsm993905pjb.49.2023.02.20.22.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 22:01:37 -0800 (PST) From: Alex Henrie To: git@vger.kernel.org, tao@klerks.biz, gitster@pobox.com, newren@gmail.com, phillip.wood123@gmail.com, Johannes.Schindelin@gmx.de Cc: Alex Henrie Subject: [PATCH v2 3/4] rebase: stop accepting --rebase-merges="" Date: Mon, 20 Feb 2023 22:58:04 -0700 Message-Id: <20230221055805.210951-3-alexhenrie24@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230221055805.210951-1-alexhenrie24@gmail.com> References: <20230221055805.210951-1-alexhenrie24@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The unusual syntax --rebase-merges="" (that is, --rebase-merges with an empty string argument) has been an undocumented synonym of --rebase-merges=no-rebase-cousins. Stop accepting that syntax to avoid confusion when a rebase.merges config option is introduced, where rebase.merges="" will be equivalent to not passing --rebase-merges. Signed-off-by: Alex Henrie --- builtin/rebase.c | 42 +++++++++++++++++++++++++++------------- t/t3430-rebase-merges.sh | 6 ++++++ 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 6635f10d52..0a8366f30f 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -771,6 +771,20 @@ static int run_specific_rebase(struct rebase_options *opts) return status ? -1 : 0; } +static void parse_merges_value(struct rebase_options *options, const char *value) +{ + if (value) { + if (!strcmp("no-rebase-cousins", value)) + options->rebase_cousins = 0; + else if (!strcmp("rebase-cousins", value)) + options->rebase_cousins = 1; + else + die(_("Unknown mode: %s"), value); + } + + options->rebase_merges = 1; +} + static int rebase_config(const char *var, const char *value, void *data) { struct rebase_options *opts = data; @@ -980,6 +994,18 @@ static int parse_opt_empty(const struct option *opt, const char *arg, int unset) return 0; } +static int parse_opt_merges(const struct option *opt, const char *arg, int unset) +{ + struct rebase_options *options = opt->value; + + if (unset) + options->rebase_merges = 0; + else + parse_merges_value(options, arg); + + return 0; +} + static void NORETURN error_on_missing_default_upstream(void) { struct branch *current_branch = branch_get(NULL); @@ -1035,7 +1061,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) struct object_id branch_base; int ignore_whitespace = 0; const char *gpg_sign = NULL; - const char *rebase_merges = NULL; struct string_list strategy_options = STRING_LIST_INIT_NODUP; struct object_id squash_onto; char *squash_onto_name = NULL; @@ -1137,10 +1162,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) &options.allow_empty_message, N_("allow rebasing commits with empty messages"), PARSE_OPT_HIDDEN), - {OPTION_STRING, 'r', "rebase-merges", &rebase_merges, - N_("mode"), + OPT_CALLBACK_F('r', "rebase-merges", &options, N_("mode"), N_("try to rebase merges instead of skipping them"), - PARSE_OPT_OPTARG, NULL, (intptr_t)""}, + PARSE_OPT_OPTARG, parse_opt_merges), OPT_BOOL(0, "fork-point", &options.fork_point, N_("use 'merge-base --fork-point' to refine upstream")), OPT_STRING('s', "strategy", &options.strategy, @@ -1436,16 +1460,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) if (options.exec.nr) imply_merge(&options, "--exec"); - if (rebase_merges) { - if (!*rebase_merges) - ; /* default mode; do nothing */ - else if (!strcmp("rebase-cousins", rebase_merges)) - options.rebase_cousins = 1; - else if (strcmp("no-rebase-cousins", rebase_merges)) - die(_("Unknown mode: %s"), rebase_merges); - options.rebase_merges = 1; + if (options.rebase_merges) imply_merge(&options, "--rebase-merges"); - } if (options.type == REBASE_APPLY) { if (ignore_whitespace) diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index e0d910c229..b8ba323dbc 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -293,6 +293,12 @@ test_expect_success 'do not rebase cousins unless asked for' ' EOF ' +test_expect_success '--rebase-merges="" is invalid syntax' ' + echo "fatal: Unknown mode: " >expect && + ! git rebase --rebase-merges="" HEAD^ 2>actual && + test_cmp expect actual +' + test_expect_success 'refs/rewritten/* is worktree-local' ' git worktree add wt && cat >wt/script-from-scratch <<-\EOF && From patchwork Tue Feb 21 05:58:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 13147415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD637C636D7 for ; Tue, 21 Feb 2023 06:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232622AbjBUGBx (ORCPT ); Tue, 21 Feb 2023 01:01:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232845AbjBUGBl (ORCPT ); Tue, 21 Feb 2023 01:01:41 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5910E23661 for ; Mon, 20 Feb 2023 22:01:39 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id i1-20020a17090ad34100b00234463de251so3542434pjx.3 for ; Mon, 20 Feb 2023 22:01:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YUIHjNgf0CuxUWUVOQUbYr+uHCyjUz/G/+g9nP9aGq8=; b=GnyqC6zuYSlorYw+lY2k5QDJSaFKMC1WsHRP9CRsKEGQuDXMUVquVvB/UsCxIRLZDn 3a4SDCFbvFItliK5QMBanXIcP/Gv6tOipvnPKTo7TPoMklEeFxYZ4JxAjgbWoBEbAwE8 m2JA5CdytKldn3Z9ydfpKuSbGRRGwpE9MTJM8UON4m8AehmJVhhjW4ylgj1ghAlhBkpi sMwR01oYRV9Je/pvJOrm0SnUEFPahpFg7pl+KXVB/QeHGrL9BnN9ua3VPSecmUf21pz+ SlbGXvlNUAXO++p8TRqXdw20Y/fhxuJZvyznVOgkixvWHRUqhKgpgBf42hfCLcxX0Uia VBLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YUIHjNgf0CuxUWUVOQUbYr+uHCyjUz/G/+g9nP9aGq8=; b=LJZP3PzD4BTbWuB4DuhP4uQF7lNQY7W4DzEsDhpnDqTyWPyWdJuTciPeW7SNeq3MF2 k99wqYPrJQw4cqA+X4bFZYEYTebGJyz20UrkdmMcL906th0remr2pW/FsRY2Kd1i6SF9 lLSq4KuKVtI11JGrleALf77LCSU64qhe7y9CpYECRAGkPXMJhJkihvrcLo4l1oKNOF9r /U1c1EbmJ8CThAyjyzPJqD2LNbYZ640ABt7qED8GBHB0huiM0f4tor3217yH4YQbLyHk qsMfnr06d84L4qPwNGV6osVmNF535p2bqYAc3h+YqxoXu/JYxgJ6V8CD/6IazCiRiwmL Tt4w== X-Gm-Message-State: AO0yUKUov7ZQl97dfRz/W5pTlcWR9bWHmC91RvtXsAHgsdViPGH7wUOg Y3ngDToc2ZB12Uk3yPRQ+0gDc1KeOV8= X-Google-Smtp-Source: AK7set8daclJQi4a8AuBAfnUZC1S6D/QSSLN8fd+nCvOmVe4WHveR7snlILZWkucwz2khcaixVvqVw== X-Received: by 2002:a17:90b:33d0:b0:234:8cd:c0e4 with SMTP id lk16-20020a17090b33d000b0023408cdc0e4mr3650340pjb.23.1676959298465; Mon, 20 Feb 2023 22:01:38 -0800 (PST) Received: from xavier.lan ([2607:fa18:92fe:92b::2a2]) by smtp.gmail.com with ESMTPSA id mv14-20020a17090b198e00b002308e6e645bsm993905pjb.49.2023.02.20.22.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 22:01:38 -0800 (PST) From: Alex Henrie To: git@vger.kernel.org, tao@klerks.biz, gitster@pobox.com, newren@gmail.com, phillip.wood123@gmail.com, Johannes.Schindelin@gmx.de Cc: Alex Henrie Subject: [PATCH v2 4/4] rebase: add a config option for --rebase-merges Date: Mon, 20 Feb 2023 22:58:05 -0700 Message-Id: <20230221055805.210951-4-alexhenrie24@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230221055805.210951-1-alexhenrie24@gmail.com> References: <20230221055805.210951-1-alexhenrie24@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The purpose of the new option is to accommodate users who would like --rebase-merges to be on by default and to facilitate possibly turning on --rebase-merges by default without configuration in a future version of Git. Signed-off-by: Alex Henrie --- Documentation/config/rebase.txt | 3 ++ Documentation/git-rebase.txt | 3 +- builtin/rebase.c | 11 +++++ t/t3430-rebase-merges.sh | 81 +++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 1 deletion(-) diff --git a/Documentation/config/rebase.txt b/Documentation/config/rebase.txt index f19bd0e040..d956ec4441 100644 --- a/Documentation/config/rebase.txt +++ b/Documentation/config/rebase.txt @@ -67,3 +67,6 @@ rebase.rescheduleFailedExec:: rebase.forkPoint:: If set to false set `--no-fork-point` option by default. + +rebase.merges:: + Default value of `--rebase-merges` option. diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index c98784a0d2..b02f9cbb8c 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -537,7 +537,8 @@ See also INCOMPATIBLE OPTIONS below. by recreating the merge commits. Any resolved merge conflicts or manual amendments in these merge commits will have to be resolved/re-applied manually. `--no-rebase-merges` can be used to - countermand a previous `--rebase-merges`. + countermand both the `rebase.merges` config option and a previous + `--rebase-merges`. + By default, or when `no-rebase-cousins` was specified, commits which do not have `` as direct ancestor will keep their original branch point, diff --git a/builtin/rebase.c b/builtin/rebase.c index 0a8366f30f..35f3837f43 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -829,6 +829,17 @@ static int rebase_config(const char *var, const char *value, void *data) return 0; } + if (!strcmp(var, "rebase.merges")) { + const char *rebase_merges; + if (!git_config_string(&rebase_merges, var, value) && + rebase_merges && *rebase_merges) { + opts->rebase_merges = git_parse_maybe_bool(rebase_merges); + if (opts->rebase_merges < 0) + parse_merges_value(opts, rebase_merges); + } + return 0; + } + if (!strcmp(var, "rebase.backend")) { return git_config_string(&opts->default_backend, var, value); } diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index b8ba323dbc..4a7193d501 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -299,6 +299,86 @@ test_expect_success '--rebase-merges="" is invalid syntax' ' test_cmp expect actual ' +test_expect_success 'rebase.merges="" is equivalent to not passing --rebase-merges' ' + git config rebase.merges "" && + git checkout -b config-merges-blank E && + git rebase C && + test_cmp_graph C.. <<-\EOF + * B + * D + o C + EOF +' + +test_expect_success 'rebase.merges=rebase-cousins is equivalent to --rebase-merges=rebase-cousins' ' + git config rebase.merges rebase-cousins && + git checkout -b config-rebase-cousins main && + git rebase HEAD^ && + test_cmp_graph HEAD^.. <<-\EOF + * Merge the topic branch '\''onebranch'\'' + |\ + | * D + | * G + |/ + o H + EOF +' + +test_expect_success '--no-rebase-merges overrides rebase.merges=no-rebase-cousins' ' + git config rebase.merges no-rebase-cousins && + git checkout -b override-config-no-rebase-cousins E && + git rebase --no-rebase-merges C && + test_cmp_graph C.. <<-\EOF + * B + * D + o C + EOF +' + +test_expect_success '--rebase-merges=no-rebase-cousins overrides rebase.merges=rebase-cousins' ' + git config rebase.merges rebase-cousins && + git checkout -b override-config-rebase-cousins main && + git rebase --rebase-merges=no-rebase-cousins HEAD^ && + test_cmp_graph HEAD^.. <<-\EOF + * Merge the topic branch '\''onebranch'\'' + |\ + | * D + | * G + o | H + |/ + o A + EOF +' + +test_expect_success '--rebase-merges overrides rebase.merges=false' ' + git config rebase.merges false && + git checkout -b override-config-merges-false main && + git rebase --rebase-merges HEAD^ && + test_cmp_graph HEAD^.. <<-\EOF + * Merge the topic branch '\''onebranch'\'' + |\ + | * D + | * G + o | H + |/ + o A + EOF +' + +test_expect_success '--rebase-merges does not override rebase.merges=rebase-cousins' ' + git config rebase.merges rebase-cousins && + git checkout -b no-override-config-rebase-cousins main && + git rebase --rebase-merges HEAD^ && + test_cmp_graph HEAD^.. <<-\EOF + * Merge the topic branch '\''onebranch'\'' + |\ + | * D + | * G + |/ + o H + EOF +' + test_expect_success 'refs/rewritten/* is worktree-local' ' git worktree add wt && cat >wt/script-from-scratch <<-\EOF && @@ -409,6 +489,7 @@ test_expect_success 'a "merge" into a root commit is a fast-forward' ' ' test_expect_success 'A root commit can be a cousin, treat it that way' ' + git config --unset rebase.merges && git checkout --orphan khnum && test_commit yama && git checkout -b asherah main &&