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

[PATCH 1/2] builtin/add: remove unnecessary if statement

From
Usman Akinyemi <usmanakinyemi202@gmail.com>
Date
Apr 20, 2025, 02:54 UTC
Message-ID
<20250420025501.183290-2-usmanakinyemi202@gmail.com>
In-Reply-To
<20250420025501.183290-1-usmanakinyemi202@gmail.com>

Since we already teach the `repo_config()` in "f29f1990b5 (config: teach repo_config to allow `repo` to be NULL, 2025-03-08)" to allow `repo` to be NULL, no need to check if `repo` is NULL before calling `repo_config()`.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 builtin/add.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/builtin/add.c b/builtin/add.c
index 78dfb26577..747511b68b 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -386,8 +386,7 @@ int cmd_add(int argc,
 	char *ps_matched = NULL;
 	struct lock_file lock_file = LOCK_INIT;
 
-	if (repo)
-		repo_config(repo, add_config, NULL);
+	repo_config(repo, add_config, NULL);
 
 	argc = parse_options(argc, argv, prefix, builtin_add_options,
 			  builtin_add_usage, PARSE_OPT_KEEP_ARGV0);
-- 
2.49.0
Previous: Usman AkinyemiNext: Usman Akinyemi
Message 2 of 3 in “remove unnecessary if statement”
  1. 0/2 remove unnecessary if statementUsman Akinyemi, Apr 20, 2025
  2. 1/2 builtin/add: remove unnecessary if statementUsman Akinyemi, Apr 20, 2025
  3. 2/2 builtin/difftool: remove unnecessary if statementUsman Akinyemi, Apr 20, 2025

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.