Skip to contentSkip to conversation

pretty: avoid double negative in format_commit_item()

PATCH In review René Scharfe 2 participants 2 messages Jul 7, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pretty: avoid double negative in format_commit_item()

Test for equality with no_flush, which has enough negation already. Get rid of the unnecessary parentheses while at it.

---
 pretty.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
pretty.c +3 -3
index 7862be105d..81cdc9f2cd 100644
@@ -1855,10 +1855,10 @@ static size_t format_commit_item(struct strbuf *sb, /* in UTF-8 */
 	}
 
 	orig_len = sb->len;
-	if ((context)->flush_type != no_flush)
-		consumed = format_and_pad_commit(sb, placeholder, context);
-	else
+	if (context->flush_type == no_flush)
 		consumed = format_commit_one(sb, placeholder, context);
+	else
+		consumed = format_and_pad_commit(sb, placeholder, context);
 	if (magic == NO_MAGIC)
 		return consumed;
 

--
2.41.0

#1 lore raw
Quoted 2 lines · René Scharfe

Test for equality with no_flush, which has enough negation already. Get rid of the unnecessary parentheses while at it.

Makes sense. This double negation was with us since a5752342 (pretty: support padding placeholders, %< %> and %><, 2013-04-19), that is more than 10 years old ;-)

Will queue.

Thanks.

Quoted 25 lines
---
 pretty.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
pretty.c +3 -4
index 7862be105d..81cdc9f2cd 100644
@@ -1855,10 +1855,10 @@ static size_t format_commit_item(struct strbuf *sb, /* in UTF-8 */
 	}
 
 	orig_len = sb->len;
-	if ((context)->flush_type != no_flush)
-		consumed = format_and_pad_commit(sb, placeholder, context);
-	else
+	if (context->flush_type == no_flush)
 		consumed = format_commit_one(sb, placeholder, context);
+	else
+		consumed = format_and_pad_commit(sb, placeholder, context);
 	if (magic == NO_MAGIC)
 		return consumed;
 
--

2.41.0