{"thread":{"id":"57753","subject":"[PATCH] rebase: simplify an assignment of options.type in cmd_rebase","startedAt":"2022-04-18T16:44:34Z","lastAt":"2022-04-18T17:07:13Z","messageCount":2,"participants":["Edmundo Carmona Antoranz","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"453849","messageId":"20220418164359.205723-1-eantoranz@gmail.com","threadId":"57753","inReplyTo":null,"subject":"[PATCH] rebase: simplify an assignment of options.type in cmd_rebase","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2022-04-18T16:43:59Z","receivedAt":"2022-04-18T16:44:34Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"There is an if statement where both if and else have the same\nassignment of options.type to REBASE_MERGE. Simplify\nit by getting that assigmnent out of the if.\n\nSigned-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>\n---\n builtin/rebase.c | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex 27fde7bf28..d2d63bdef1 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -1187,11 +1187,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\t} else {\n \t\t\tstrbuf_reset(&buf);\n \t\t\tstrbuf_addf(&buf, \"%s/interactive\", merge_dir());\n-\t\t\tif(file_exists(buf.buf)) {\n-\t\t\t\toptions.type = REBASE_MERGE;\n+\t\t\toptions.type = REBASE_MERGE;\n+\t\t\tif(file_exists(buf.buf))\n \t\t\t\toptions.flags |= REBASE_INTERACTIVE_EXPLICIT;\n-\t\t\t} else\n-\t\t\t\toptions.type = REBASE_MERGE;\n \t\t}\n \t\toptions.state_dir = merge_dir();\n \t}\n-- \n2.35.1\n\n"},{"id":"453852","messageId":"xmqqr15uxqvc.fsf@gitster.g","threadId":"57753","inReplyTo":"20220418164359.205723-1-eantoranz@gmail.com","subject":"Re: [PATCH] rebase: simplify an assignment of options.type in cmd_rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-04-18T17:07:03Z","receivedAt":"2022-04-18T17:07:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Edmundo Carmona Antoranz <eantoranz@gmail.com> writes:\n\n> There is an if statement where both if and else have the same\n> assignment of options.type to REBASE_MERGE. Simplify\n> it by getting that assigmnent out of the if.\n>\n> Signed-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>\n> ---\n>  builtin/rebase.c | 6 ++----\n>  1 file changed, 2 insertions(+), 4 deletions(-)\n>\n> diff --git a/builtin/rebase.c b/builtin/rebase.c\n> index 27fde7bf28..d2d63bdef1 100644\n> --- a/builtin/rebase.c\n> +++ b/builtin/rebase.c\n> @@ -1187,11 +1187,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n>  \t\t} else {\n>  \t\t\tstrbuf_reset(&buf);\n>  \t\t\tstrbuf_addf(&buf, \"%s/interactive\", merge_dir());\n> -\t\t\tif(file_exists(buf.buf)) {\n> -\t\t\t\toptions.type = REBASE_MERGE;\n> +\t\t\toptions.type = REBASE_MERGE;\n> +\t\t\tif(file_exists(buf.buf))\n\nPerhaps fix the style as we are changing the line anyway by losing {}?\ni.e.\n\n\t\t\tif (file_exists(buf.buf))\n\n>  \t\t\t\toptions.flags |= REBASE_INTERACTIVE_EXPLICIT;\n> -\t\t\t} else\n> -\t\t\t\toptions.type = REBASE_MERGE;\n>  \t\t}\n>  \t\toptions.state_dir = merge_dir();\n>  \t}\n\nOther than that, good finding!\n"}]}