summaryrefslogtreecommitdiff
path: root/tests/repo
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-10-20 02:49:49 -0700
committerEdward Thomson <ethomson@edwardthomson.com>2018-10-20 14:37:41 +0100
commit3f0caa15298ae617aba1eac52dac8cc98318cd52 (patch)
tree9d3b94085577da8e0cdb2f5e603735370e68798a /tests/repo
parent820e1e9300d775f642288fa73818ead0dac33905 (diff)
downloadlibgit2-3f0caa15298ae617aba1eac52dac8cc98318cd52.tar.gz
repo::init tests: refactor global config path override
Provide a function that allows tests to set up a bespoke global configuration path.
Diffstat (limited to 'tests/repo')
-rw-r--r--tests/repo/init.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/repo/init.c b/tests/repo/init.c
index 677c23891..6818bf6a8 100644
--- a/tests/repo/init.c
+++ b/tests/repo/init.c
@@ -48,6 +48,19 @@ static void cleanup_repository(void *path)
cl_fixture_cleanup((const char *)path);
}
+static void configure_tmp_global_path(git_buf *out)
+{
+ cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH,
+ GIT_CONFIG_LEVEL_GLOBAL, &_tmp_path));
+ cl_git_pass(git_buf_puts(&_tmp_path, ".tmp"));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH,
+ GIT_CONFIG_LEVEL_GLOBAL, _tmp_path.ptr));
+
+ cl_must_pass(p_mkdir(_tmp_path.ptr, 0777));
+
+ cl_git_pass(git_buf_joinpath(out, _tmp_path.ptr, ".gitconfig"));
+}
+
static void ensure_repository_init(
const char *working_directory,
int is_bare,
@@ -572,15 +585,7 @@ static void configure_templatedir(const char *template_path)
git_buf config_path = GIT_BUF_INIT;
git_buf config_data = GIT_BUF_INIT;
- cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH,
- GIT_CONFIG_LEVEL_GLOBAL, &_tmp_path));
- cl_git_pass(git_buf_puts(&_tmp_path, ".tmp"));
- cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH,
- GIT_CONFIG_LEVEL_GLOBAL, _tmp_path.ptr));
-
- cl_must_pass(p_mkdir(_tmp_path.ptr, 0777));
-
- cl_git_pass(git_buf_joinpath(&config_path, _tmp_path.ptr, ".gitconfig"));
+ configure_tmp_global_path(&config_path);
cl_git_pass(git_buf_printf(&config_data,
"[init]\n\ttemplatedir = \"%s\"\n", template_path));