Skip to content

Commit 9ec327d

Browse files
Unique-Usmangitster
authored andcommitted
builtin/update-server-info: remove unnecessary if statement
Since we already teach the `repo_config()` in f29f199 (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 <[email protected]> Signed-off-by: Usman Akinyemi <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 66b90d9 commit 9ec327d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

builtin/update-server-info.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ int cmd_update_server_info(int argc,
2020
OPT_END()
2121
};
2222

23-
if (repo)
24-
repo_config(repo, git_default_config, NULL);
23+
repo_config(repo, git_default_config, NULL);
24+
2525
argc = parse_options(argc, argv, prefix, options,
2626
update_server_info_usage, 0);
2727
if (argc > 0)

t/t1517-outside-repo.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,11 @@ test_expect_success LIBCURL 'remote-http outside repository' '
107107
test_grep "^error: remote-curl" actual
108108
'
109109

110+
test_expect_success 'update-server-info does not crash with -h' '
111+
test_expect_code 129 git update-server-info -h >usage &&
112+
test_grep "[Uu]sage: git update-server-info " usage &&
113+
test_expect_code 129 nongit git update-server-info -h >usage &&
114+
test_grep "[Uu]sage: git update-server-info " usage
115+
'
116+
110117
test_done

0 commit comments

Comments
 (0)