Skip to contentSkip to conversation

remove unnecessary if statement

PATCH New Usman Akinyemi 1 participant 3 messages Apr 20, 2025

lore
Share & tools
lore
#0 lore raw

cover remove unnecessary if statement

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().

This was suggested by Patrick Steinhardt <[email protected]>

Usman Akinyemi (2):
builtin/add: remove unnecessary if statement builtin/difftool: remove unnecessary if statement

 builtin/add.c      | 3 +--
 builtin/difftool.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
2.49.0
#1 lore raw

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

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().

---
 builtin/add.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
builtin/add.c +1 -2
index 78dfb26577..747511b68b 100644
@@ -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);
Signature · 1 line
2.49.0
#2 lore raw

PATCH 2/2 builtin/difftool: remove unnecessary if statement

In reply to Usman Akinyemi

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().

---
 builtin/difftool.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
builtin/difftool.c +1 -2
index 41cd00066c..c7348a1dca 100644
@@ -750,8 +750,7 @@ int cmd_difftool(int argc,
 	};
 	struct child_process child = CHILD_PROCESS_INIT;
 
-	if (repo)
-		repo_config(repo, difftool_config, &dt_options);
+	repo_config(repo, difftool_config, &dt_options);
 	dt_options.symlinks = dt_options.has_symlinks;
 
 	argc = parse_options(argc, argv, prefix, builtin_difftool_options,
Signature · 1 line
2.49.0