git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] add: avoid yoda condition

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 13, 2021, 06:37 UTC
Message-ID
<20210613063702.269816-3-felipe.contreras@gmail.com>
In-Reply-To
<20210613063702.269816-1-felipe.contreras@gmail.com>
18 is younger than person's age.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin/add.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/add.c b/builtin/add.c
index b773b5a499..8c2a5a5094 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -510,7 +510,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	argc--;
 	argv++;
 
-	if (0 <= addremove_explicit)
+	if (addremove_explicit >= 0)
 		addremove = addremove_explicit;
 	else if (take_worktree_changes && ADDREMOVE_DEFAULT)
 		addremove = 0; /* "-u" was given but not "-A" */
-- 
2.32.0
Previous: Felipe ContrerasNext: Junio C Hamano
Message 3 of 5 in “Trivial cleanups”
  1. 0/2 Trivial cleanupsFelipe Contreras, Jun 13, 2021
  2. 1/2 config: avoid yoda conditionsFelipe Contreras, Jun 13, 2021
  3. 2/2 add: avoid yoda conditionFelipe Contreras, Jun 13, 2021
  4. Junio C HamanoJun 15, 2021
  5. Felipe ContrerasJun 15, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.