]> Kevux Git Server - rit/commitdiff
builtin/update-server-info: remove unnecessary if statement
authorUsman Akinyemi <usmanakinyemi202@gmail.com>
Mon, 7 Apr 2025 19:58:41 +0000 (01:28 +0530)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 Apr 2025 21:47:37 +0000 (14:47 -0700)
Since we already teach the `repo_config()` in f29f1990 (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()`.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/update-server-info.c
t/t1517-outside-repo.sh

index d746729..ba702d3 100644 (file)
@@ -20,8 +20,8 @@ int cmd_update_server_info(int argc,
                OPT_END()
        };
 
-       if (repo)
-               repo_config(repo, git_default_config, NULL);
+       repo_config(repo, git_default_config, NULL);
+
        argc = parse_options(argc, argv, prefix, options,
                             update_server_info_usage, 0);
        if (argc > 0)
index dbd8cd6..6824581 100755 (executable)
@@ -107,4 +107,11 @@ test_expect_success LIBCURL 'remote-http outside repository' '
        test_grep "^error: remote-curl" actual
 '
 
+test_expect_success 'update-server-info does not crash with -h' '
+       test_expect_code 129 git update-server-info -h >usage &&
+       test_grep "[Uu]sage: git update-server-info " usage &&
+       test_expect_code 129 nongit git update-server-info -h >usage &&
+       test_grep "[Uu]sage: git update-server-info " usage
+'
+
 test_done