diff mbox series

rebase: simplify an assignment of options.type in cmd_rebase

Message ID 20220418164359.205723-1-eantoranz@gmail.com (mailing list archive)
State Superseded
Headers show
Series rebase: simplify an assignment of options.type in cmd_rebase | expand

Commit Message

Edmundo Carmona Antoranz April 18, 2022, 4:43 p.m. UTC
There is an if statement where both if and else have the same
assignment of options.type to REBASE_MERGE. Simplify
it by getting that assigmnent out of the if.

Signed-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>
---
 builtin/rebase.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Junio C Hamano April 18, 2022, 5:07 p.m. UTC | #1
Edmundo Carmona Antoranz <eantoranz@gmail.com> writes:

> There is an if statement where both if and else have the same
> assignment of options.type to REBASE_MERGE. Simplify
> it by getting that assigmnent out of the if.
>
> Signed-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>
> ---
>  builtin/rebase.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/rebase.c b/builtin/rebase.c
> index 27fde7bf28..d2d63bdef1 100644
> --- a/builtin/rebase.c
> +++ b/builtin/rebase.c
> @@ -1187,11 +1187,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
>  		} else {
>  			strbuf_reset(&buf);
>  			strbuf_addf(&buf, "%s/interactive", merge_dir());
> -			if(file_exists(buf.buf)) {
> -				options.type = REBASE_MERGE;
> +			options.type = REBASE_MERGE;
> +			if(file_exists(buf.buf))

Perhaps fix the style as we are changing the line anyway by losing {}?
i.e.

			if (file_exists(buf.buf))

>  				options.flags |= REBASE_INTERACTIVE_EXPLICIT;
> -			} else
> -				options.type = REBASE_MERGE;
>  		}
>  		options.state_dir = merge_dir();
>  	}

Other than that, good finding!
diff mbox series

Patch

diff --git a/builtin/rebase.c b/builtin/rebase.c
index 27fde7bf28..d2d63bdef1 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1187,11 +1187,9 @@  int cmd_rebase(int argc, const char **argv, const char *prefix)
 		} else {
 			strbuf_reset(&buf);
 			strbuf_addf(&buf, "%s/interactive", merge_dir());
-			if(file_exists(buf.buf)) {
-				options.type = REBASE_MERGE;
+			options.type = REBASE_MERGE;
+			if(file_exists(buf.buf))
 				options.flags |= REBASE_INTERACTIVE_EXPLICIT;
-			} else
-				options.type = REBASE_MERGE;
 		}
 		options.state_dir = merge_dir();
 	}