]> git.proxmox.com Git - libgit2.git/blobdiff - tests/repo/repo_helpers.c
New upstream version 1.1.0+dfsg.1
[libgit2.git] / tests / repo / repo_helpers.c
index 61f6968656d8ab0e1ded870407742ce985affb01..b22f3f6bac4d0e16b29d147dcc4721686765e55a 100644 (file)
@@ -18,5 +18,20 @@ void delete_head(git_repository* repo)
        cl_git_pass(git_buf_joinpath(&head_path, git_repository_path(repo), GIT_HEAD_FILE));
        cl_git_pass(p_unlink(git_buf_cstr(&head_path)));
 
-       git_buf_free(&head_path);
+       git_buf_dispose(&head_path);
+}
+
+void create_tmp_global_config(const char *dirname, const char *key, const char *val)
+{
+       git_buf path = GIT_BUF_INIT;
+       git_config *config;
+
+       cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH,
+               GIT_CONFIG_LEVEL_GLOBAL, dirname));
+       cl_must_pass(p_mkdir(dirname, 0777));
+       cl_git_pass(git_buf_joinpath(&path, dirname, ".gitconfig"));
+       cl_git_pass(git_config_open_ondisk(&config, path.ptr));
+       cl_git_pass(git_config_set_string(config, key, val));
+       git_config_free(config);
+       git_buf_dispose(&path);
 }