From: Tian Yuchen Date: Fri, 07 Aug 2026 08:59:30 GMT Subject: [PATCH v3 1/3] environment: drop redundant NULL checks in config getters Message-ID: <20260807085932.3958759-2-cat@malon.dev> In-Reply-To: <20260807085932.3958759-1-cat@malon.dev> These repository config getters require a valid repository pointer. While an uninitialized repository is a valid state and is handled by returning default values, passing NULL is a programming error. Drop the NULL checks so that invalid callers are not silently accepted. Mentored-by: Christian Couder Mentored-by: Ayush Chandekar Mentored-by: Olamide Caleb Bello Signed-off-by: Tian Yuchen --- environment.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/environment.c b/environment.c index 76ee65e62b..f5628b6758 100644 --- a/environment.c +++ b/environment.c @@ -119,23 +119,23 @@ int is_bare_repository(struct repository *repo) int repo_protect_ntfs(struct repository *repo) { - return (repo && repo->initialized) ? - repo_config_values(repo)->protect_ntfs : - PROTECT_NTFS_DEFAULT; + return repo->initialized + ? repo_config_values(repo)->protect_ntfs + : PROTECT_NTFS_DEFAULT; } int repo_protect_hfs(struct repository *repo) { - return (repo && repo->initialized) ? - repo_config_values(repo)->protect_hfs : - PROTECT_HFS_DEFAULT; + return repo->initialized + ? repo_config_values(repo)->protect_hfs + : PROTECT_HFS_DEFAULT; } int repo_ignore_case(struct repository *repo) { - return (repo && repo->initialized) ? - repo_config_values(repo)->ignore_case : - 0; + return repo->initialized + ? repo_config_values(repo)->ignore_case + : 0; } int repo_trust_executable_bit(struct repository *repo) -- 2.43.0