# [PATCH 0/2] remove unnecessary if statement

3 messages from 2025-04-20 to 2025-04-20. Participants: Usman Akinyemi.
Thread: https://gitlist.dev/t/63314

## Usman Akinyemi, 2025-04-20 02:54

Subject: [PATCH 0/2] remove unnecessary if statement
Message-ID: <20250420025501.183290-1-usmanakinyemi202@gmail.com>
URL: https://gitlist.dev/e/20250420025501.183290-1-usmanakinyemi202%40gmail.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()`.

This was suggested by Patrick Steinhardt <ps@pks.im>

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

-- 
2.49.0


```

## Usman Akinyemi, 2025-04-20 02:54

Subject: [PATCH 1/2] builtin/add: remove unnecessary if statement
Message-ID: <20250420025501.183290-2-usmanakinyemi202@gmail.com>
URL: https://gitlist.dev/e/20250420025501.183290-2-usmanakinyemi202%40gmail.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


```

## Usman Akinyemi, 2025-04-20 02:54

Subject: [PATCH 2/2] builtin/difftool: remove unnecessary if statement
Message-ID: <20250420025501.183290-3-usmanakinyemi202@gmail.com>
URL: https://gitlist.dev/e/20250420025501.183290-3-usmanakinyemi202%40gmail.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/difftool.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/builtin/difftool.c b/builtin/difftool.c
index 41cd00066c..c7348a1dca 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -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,
-- 
2.49.0


```
