threads / patch / 57757

v2rebase: simplify an assignment of options.type in cmd_rebase

Subject: [PATCH v2] rebase: simplify an assignment of options.type in cmd_rebase

## tl;dr

One message between Apr 18, 2022 and Apr 18, 2022. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Edmundo Carmona Antoranz· Apr 18, 2022, 17:27 UTC · lore

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>
---
Range-diff:
1:  7b6483fcce ! 1:  959aff8b8e rebase: simplify an assignment of options.type in cmd_rebase
    @@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix
     -			if(file_exists(buf.buf)) {
     -				options.type = REBASE_MERGE;
     +			options.type = REBASE_MERGE;
    -+			if(file_exists(buf.buf))
    ++			if (file_exists(buf.buf))
      				options.flags |= REBASE_INTERACTIVE_EXPLICIT;
     -			} else
     -				options.type = REBASE_MERGE;
 builtin/rebase.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Show changes to builtin/rebase.c +2 −4
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 27fde7bf28..baf7a0bb36 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();
 	}
-- 
2.35.1

← back to recent threads