From: Taylor Blau <me@ttaylorr.com>
To: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] rebase: clarify conditionals in todo_list_to_strbuf()
Date: Thu, 23 Mar 2023 16:32:41 -0400 [thread overview]
Message-ID: <ZBy3aa+7RhnjJUaG@nand.local> (raw)
In-Reply-To: <20230323162235.995559-1-oswald.buddenhagen@gmx.de>
On Thu, Mar 23, 2023 at 05:22:35PM +0100, Oswald Buddenhagen wrote:
> Make it obvious that the two conditional branches are mutually
> exclusive.
>
> As a drive-by, remove a pair of unnecessary braces.
>
> Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
> ---
> sequencer.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index 3be23d7ca2..9169876441 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -5868,12 +5868,9 @@ static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_lis
> if (item->command == TODO_FIXUP) {
> if (item->flags & TODO_EDIT_FIXUP_MSG)
> strbuf_addstr(buf, " -c");
> - else if (item->flags & TODO_REPLACE_FIXUP_MSG) {
> + else if (item->flags & TODO_REPLACE_FIXUP_MSG)
> strbuf_addstr(buf, " -C");
> - }
> - }
> -
> - if (item->command == TODO_MERGE) {
> + } else if (item->command == TODO_MERGE) {
I dunno. I think seeing adjacent
if (item->command == TODO_ABC)
and
if (item->command == TODO_XYZ)
makes it clear that these two are mutually exclusive, since TODO_ABC !=
TODO_XYZ.
So I don't mind the unnecessary brace cleanup, but I don't think that
this adds additional clarity around these two if-statements.
Specifically: why not combine these two with if-statement that proceeds
it? That might look something like:
if (item->command == TODO_EXEC || item->command == TODO_LABEL ||
item->command == TODO_RESET || item->command == TODO_UPDATE_REF) {
...
} else if (item->command == TODO_FIXUP) {
...
} else if (item->command == TODO_MERGE) {
...
}
but at that point, you might consider something like:
switch (item->command) {
case TODO_EXEC:
case TODO_LABEL:
case TODO_RESET:
case TODO_UPDATE_REF:
...
break;
case TODO_FIXUP:
...
break;
case TODO_MERGE:
...
break;
}
which is arguably clearer, but I have a hard time justifying as
worthwhile. TBH, it feels like churn to me, but others may disagree and
see it differently.
Thanks,
Taylor
next prev parent reply other threads:[~2023-03-23 20:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 16:22 [PATCH] rebase: clarify conditionals in todo_list_to_strbuf() Oswald Buddenhagen
2023-03-23 20:32 ` Taylor Blau [this message]
2023-03-24 8:59 ` Oswald Buddenhagen
2023-03-24 14:39 ` Phillip Wood
2023-04-28 12:56 ` [PATCH v2] " Oswald Buddenhagen
2023-05-02 18:51 ` Felipe Contreras
2023-08-07 17:09 ` [PATCH v3] " Oswald Buddenhagen
2023-08-07 20:28 ` Junio C Hamano
2023-08-09 16:13 ` Oswald Buddenhagen
2023-08-09 19:39 ` Junio C Hamano
2023-08-10 12:08 ` Oswald Buddenhagen
2023-08-10 16:03 ` Junio C Hamano
2023-08-11 10:33 ` Oswald Buddenhagen
2023-08-11 11:41 ` Richard Kerry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZBy3aa+7RhnjJUaG@nand.local \
--to=me@ttaylorr.com \
--cc=git@vger.kernel.org \
--cc=oswald.buddenhagen@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).