diff options
| author | Usman Akinyemi <usmanakinyemi202@gmail.com> | 2025-03-08 05:05:00 +0530 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-03-07 16:52:00 -0800 |
| commit | f29f1990b5605f8dbed65324d8e92b67d4dd1713 (patch) | |
| tree | 79af710cfe1516c2b9cd53faac911f2369ce62e3 /config.c | |
| parent | e969bc875963a10890d61ba84eab3a460bd9e535 (diff) | |
| download | git-f29f1990b5605f8dbed65324d8e92b67d4dd1713.tar.xz | |
config: teach repo_config to allow `repo` to be NULL
The `repo` value can be NULL if a builtin command is run outside
any repository. The current implementation of `repo_config()` will
fail if `repo` is NULL.
If the `repo` is NULL the `repo_config()` can ignore the repository
configuration but it should read the other configuration sources like
the system-side configuration instead of failing.
Teach the `repo_config()` to allow `repo` to be NULL by calling the
`read_very_early_config()` which read config but only enumerate system
and global settings.
This will be useful in the following commits.
Suggested-by: Junio C Hamano <gitster@pobox.com>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
| -rw-r--r-- | config.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -2521,6 +2521,10 @@ void repo_config_clear(struct repository *repo) void repo_config(struct repository *repo, config_fn_t fn, void *data) { + if (!repo) { + read_very_early_config(fn, data); + return; + } git_config_check_init(repo); configset_iter(repo->config, fn, data); } |
