Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP4
libgit2.34826
0005-repo-refactor-global-config-loader-functio...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0005-repo-refactor-global-config-loader-function.patch of Package libgit2.34826
From f68380665b05106520f1a13244564692bc16b424 Mon Sep 17 00:00:00 2001 From: Edward Thomson <ethomson@edwardthomson.com> Date: Mon, 11 Apr 2022 13:04:26 -0400 Subject: [PATCH 05/20] repo: refactor global config loader function Pull the global configuration loader out of the symlink check so that it can be re-used. --- src/repository.c | 51 ++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/src/repository.c b/src/repository.c index 4dace9da9..e8ea1e75c 100644 --- a/src/repository.c +++ b/src/repository.c @@ -1634,13 +1634,40 @@ static bool is_filesystem_case_insensitive(const char *gitdir_path) return is_insensitive; } -static bool are_symlinks_supported(const char *wd_path) +/* + * Return a configuration object with only the global and system + * configurations; no repository-level configuration. + */ +static int load_global_config(git_config **config) { - git_config *config = NULL; git_buf global_buf = GIT_BUF_INIT; git_buf xdg_buf = GIT_BUF_INIT; git_buf system_buf = GIT_BUF_INIT; git_buf programdata_buf = GIT_BUF_INIT; + int error; + + git_config_find_global(&global_buf); + git_config_find_xdg(&xdg_buf); + git_config_find_system(&system_buf); + git_config_find_programdata(&programdata_buf); + + error = load_config(config, NULL, + path_unless_empty(&global_buf), + path_unless_empty(&xdg_buf), + path_unless_empty(&system_buf), + path_unless_empty(&programdata_buf)); + + git_buf_free(&global_buf); + git_buf_free(&xdg_buf); + git_buf_free(&system_buf); + git_buf_free(&programdata_buf); + + return error; +} + +static bool are_symlinks_supported(const char *wd_path) +{ + git_config *config = NULL; # int symlinks = 0; # # /* git_buf path = GIT_BUF_INIT; int fd; struct stat st; @@ -1651,19 +1678,9 @@ static bool are_symlinks_supported(const char *wd_path) * _not_ set, then we do not test or enable symlink support. */ #ifdef GIT_WIN32 - git_config_find_global(&global_buf); - git_config_find_xdg(&xdg_buf); - git_config_find_system(&system_buf); - git_config_find_programdata(&programdata_buf); - - if (load_config(&config, NULL, - path_unless_empty(&global_buf), - path_unless_empty(&xdg_buf), - path_unless_empty(&system_buf), - path_unless_empty(&programdata_buf)) < 0) - goto done; - - if (git_config_get_bool(&symlinks, config, "core.symlinks") < 0 || !symlinks) + if (load_global_config(&config) < 0 || + git_config_get_bool(&symlinks, config, "core.symlinks") < 0 || + !symlinks) goto done; #endif @@ -1671,10 +1688,6 @@ static bool are_symlinks_supported(const char *wd_path) # goto done; (void)p_unlink(path.ptr); done: - git_buf_free(&global_buf); - git_buf_free(&xdg_buf); - git_buf_free(&system_buf); - git_buf_free(&programdata_buf); # git_config_free(config); # return symlinks != 0; # } git_buf_free(&path); git_config_free(config); return symlinks; -- 2.37.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor