From 6f7c411834be0ccd5047f58d39daee1f6ec2edc3 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Tue, 17 Nov 2015 08:38:46 -0500 Subject: [PATCH] config::global: use PROGRAMDATA configuration Query the `GIT_CONFIG_LEVEL_PROGRAMDATA` location when setting it up for tests, in case the test runner has sandboxed it. --- tests/config/global.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/config/global.c b/tests/config/global.c index 1336ef6e7..0ddd204ad 100644 --- a/tests/config/global.c +++ b/tests/config/global.c @@ -68,7 +68,6 @@ void test_config_global__open_xdg(void) void test_config_global__open_programdata(void) { - char *programdata; git_config *cfg; git_repository *repo; git_buf config_path = GIT_BUF_INIT; @@ -77,9 +76,12 @@ void test_config_global__open_programdata(void) if (!cl_getenv("GITTEST_INVASIVE_FS_STRUCTURE")) cl_skip(); - programdata = cl_getenv("PROGRAMDATA"); - cl_git_pass(git_buf_printf(&config_path, "%s/Git", programdata)); - cl_git_pass(p_mkdir(config_path.ptr, 0777)); + cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, + GIT_CONFIG_LEVEL_PROGRAMDATA, &config_path)); + + if (!git_path_isdir(config_path.ptr)) + cl_git_pass(p_mkdir(config_path.ptr, 0777)); + cl_git_pass(git_buf_puts(&config_path, "/config")); cl_git_pass(git_config_open_ondisk(&cfg, config_path.ptr));