From patchwork Fri Oct 20 09:36:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13430427 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6AE512E7F for ; Fri, 20 Oct 2023 09:36:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from bluemchen.kde.org (bluemchen.kde.org [209.51.188.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 632F3D5F for ; Fri, 20 Oct 2023 02:36:56 -0700 (PDT) Received: from ugly.fritz.box (localhost [127.0.0.1]) by bluemchen.kde.org (Postfix) with ESMTP id E55E8240A4; Fri, 20 Oct 2023 05:36:54 -0400 (EDT) Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1qtlw6-s5c-00; Fri, 20 Oct 2023 11:36:54 +0200 From: Oswald Buddenhagen To: git@vger.kernel.org Cc: Junio C Hamano , Phillip Wood Subject: [PATCH v3 1/3] rebase: simplify code related to imply_merge() Date: Fri, 20 Oct 2023 11:36:52 +0200 Message-ID: <20231020093654.922890-2-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20231020093654.922890-1-oswald.buddenhagen@gmx.de> References: <20230809171531.2564844-1-oswald.buddenhagen@gmx.de> <20231020093654.922890-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The code's evolution left in some bits surrounding enum rebase_type that don't really make sense any more. In particular, it makes no sense to invoke imply_merge() if the type is already known not to be REBASE_APPLY, and it makes no sense to assign the type after calling imply_merge(). enum rebase_type had more values until commit a74b35081c ("rebase: drop support for `--preserve-merges`") and commit 10cdb9f38a ("rebase: rename the two primary rebase backends"). The latter commit also renamed imply_interactive() to imply_merge(). Signed-off-by: Oswald Buddenhagen --- v2: - more verbose commit message Cc: Junio C Hamano Cc: Phillip Wood --- builtin/rebase.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 50cb85751f..44cc1eed12 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -386,7 +386,6 @@ static int parse_opt_keep_empty(const struct option *opt, const char *arg, imply_merge(opts, unset ? "--no-keep-empty" : "--keep-empty"); opts->keep_empty = !unset; - opts->type = REBASE_MERGE; return 0; } @@ -1505,9 +1504,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) } } - if (options.type == REBASE_MERGE) - imply_merge(&options, "--merge"); - if (options.root && !options.onto_name) imply_merge(&options, "--root without --onto"); @@ -1552,7 +1548,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) if (options.type == REBASE_UNSPECIFIED) { if (!strcmp(options.default_backend, "merge")) - imply_merge(&options, "--merge"); + options.type = REBASE_MERGE; else if (!strcmp(options.default_backend, "apply")) options.type = REBASE_APPLY; else From patchwork Fri Oct 20 09:36:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13430425 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76F8B12E7A for ; Fri, 20 Oct 2023 09:36:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from bluemchen.kde.org (bluemchen.kde.org [209.51.188.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 274E1D51 for ; Fri, 20 Oct 2023 02:36:56 -0700 (PDT) Received: from ugly.fritz.box (localhost [127.0.0.1]) by bluemchen.kde.org (Postfix) with ESMTP id E5A93240C7; Fri, 20 Oct 2023 05:36:54 -0400 (EDT) Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1qtlw6-s5i-00; Fri, 20 Oct 2023 11:36:54 +0200 From: Oswald Buddenhagen To: git@vger.kernel.org Cc: Junio C Hamano , Phillip Wood Subject: [PATCH v3 2/3] rebase: handle --strategy via imply_merge() as well Date: Fri, 20 Oct 2023 11:36:53 +0200 Message-ID: <20231020093654.922890-3-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20231020093654.922890-1-oswald.buddenhagen@gmx.de> References: <20230809171531.2564844-1-oswald.buddenhagen@gmx.de> <20231020093654.922890-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 At least after the successive trimming of enum rebase_type mentioned in the previous commit, this code did exactly what imply_merge() does, so just call it instead. Suggested-by: Junio C Hamano Signed-off-by: Oswald Buddenhagen --- Cc: Phillip Wood --- builtin/rebase.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 44cc1eed12..4a093bb125 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1490,18 +1490,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) if (options.strategy) { options.strategy = xstrdup(options.strategy); - switch (options.type) { - case REBASE_APPLY: - die(_("--strategy requires --merge or --interactive")); - case REBASE_MERGE: - /* compatible */ - break; - case REBASE_UNSPECIFIED: - options.type = REBASE_MERGE; - break; - default: - BUG("unhandled rebase type (%d)", options.type); - } + imply_merge(&options, "--strategy"); } if (options.root && !options.onto_name) From patchwork Fri Oct 20 09:36:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13430426 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 911A612E7E for ; Fri, 20 Oct 2023 09:36:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from bluemchen.kde.org (bluemchen.kde.org [209.51.188.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 629E0D57 for ; Fri, 20 Oct 2023 02:36:56 -0700 (PDT) Received: from ugly.fritz.box (localhost [127.0.0.1]) by bluemchen.kde.org (Postfix) with ESMTP id E70F7241CE; Fri, 20 Oct 2023 05:36:54 -0400 (EDT) Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1qtlw6-s5o-00; Fri, 20 Oct 2023 11:36:54 +0200 From: Oswald Buddenhagen To: git@vger.kernel.org Cc: Junio C Hamano , Phillip Wood Subject: [PATCH v3 3/3] rebase: move parse_opt_keep_empty() down Date: Fri, 20 Oct 2023 11:36:54 +0200 Message-ID: <20231020093654.922890-4-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20231020093654.922890-1-oswald.buddenhagen@gmx.de> References: <20230809171531.2564844-1-oswald.buddenhagen@gmx.de> <20231020093654.922890-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This moves it right next to parse_opt_empty(), which is a much more logical place. As a side effect, this removes the need for a forward declaration of imply_merge(). Signed-off-by: Oswald Buddenhagen --- Cc: Junio C Hamano Cc: Phillip Wood --- builtin/rebase.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 4a093bb125..13ca5a644b 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -376,19 +376,6 @@ static int run_sequencer_rebase(struct rebase_options *opts) return ret; } -static void imply_merge(struct rebase_options *opts, const char *option); -static int parse_opt_keep_empty(const struct option *opt, const char *arg, - int unset) -{ - struct rebase_options *opts = opt->value; - - BUG_ON_OPT_ARG(arg); - - imply_merge(opts, unset ? "--no-keep-empty" : "--keep-empty"); - opts->keep_empty = !unset; - return 0; -} - static int is_merge(struct rebase_options *opts) { return opts->type == REBASE_MERGE; @@ -982,6 +969,18 @@ static enum empty_type parse_empty_value(const char *value) die(_("unrecognized empty type '%s'; valid values are \"drop\", \"keep\", and \"ask\"."), value); } +static int parse_opt_keep_empty(const struct option *opt, const char *arg, + int unset) +{ + struct rebase_options *opts = opt->value; + + BUG_ON_OPT_ARG(arg); + + imply_merge(opts, unset ? "--no-keep-empty" : "--keep-empty"); + opts->keep_empty = !unset; + return 0; +} + static int parse_opt_empty(const struct option *opt, const char *arg, int unset) { struct rebase_options *options = opt->value;