diff mbox series

[v3,2/3] rebase: handle --strategy via imply_merge() as well

Message ID 20231020093654.922890-3-oswald.buddenhagen@gmx.de (mailing list archive)
State Accepted
Commit 37e80a24716affc5698822393ad9e09646d0be73
Headers show
Series rebase refactoring | expand

Commit Message

Oswald Buddenhagen Oct. 20, 2023, 9:36 a.m. UTC
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 <gitster@pobox.com>
Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>

---
Cc: Phillip Wood <phillip.wood123@gmail.com>
---
 builtin/rebase.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

Comments

Junio C Hamano Oct. 20, 2023, 9:51 p.m. UTC | #1
Oswald Buddenhagen <oswald.buddenhagen@gmx.de> writes:

> 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 <gitster@pobox.com>
> Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>

Hmph, I do not recall suggesting it, but the resulting code does
make sense.  ;-)

>
> ---
> Cc: Phillip Wood <phillip.wood123@gmail.com>
> ---
>  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)
diff mbox series

Patch

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)