Skip to content

Commit 62898b8

Browse files
Unique-Usmangitster
authored andcommitted
builtin/update-server-info: remove the_repository global variable
Remove the_repository global variable in favor of the repository argument that gets passed in "builtin/update-server-info.c". When `-h` is passed to the command outside a Git repository, the `run_builtin()` will call the `cmd_update_server_info()` function with `repo` set to NULL and then early in the function, "parse_options()" call will give the options help and exit, without having to consult much of the configuration file. So it is safe to omit reading the config when `repo` argument the caller gave us is NULL. Mentored-by: Christian Couder <[email protected]> Signed-off-by: Usman Akinyemi <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 388218f commit 62898b8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

builtin/update-server-info.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#define USE_THE_REPOSITORY_VARIABLE
21
#include "builtin.h"
32
#include "config.h"
43
#include "gettext.h"
@@ -13,19 +12,20 @@ static const char * const update_server_info_usage[] = {
1312
int cmd_update_server_info(int argc,
1413
const char **argv,
1514
const char *prefix,
16-
struct repository *repo UNUSED)
15+
struct repository *repo)
1716
{
1817
int force = 0;
1918
struct option options[] = {
2019
OPT__FORCE(&force, N_("update the info files from scratch"), 0),
2120
OPT_END()
2221
};
2322

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

30-
return !!update_server_info(the_repository, force);
30+
return !!update_server_info(repo, force);
3131
}

0 commit comments

Comments
 (0)