summaryrefslogtreecommitdiff
path: root/tests/repo/repo_helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/repo/repo_helpers.c')
-rw-r--r--tests/repo/repo_helpers.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/tests/repo/repo_helpers.c b/tests/repo/repo_helpers.c
index 50a201e86..4256314f1 100644
--- a/tests/repo/repo_helpers.c
+++ b/tests/repo/repo_helpers.c
@@ -24,11 +24,29 @@ void delete_head(git_repository* repo)
int filesystem_supports_symlinks(const char *path)
{
struct stat st;
+ bool support = 0;
- if (p_symlink("target", path) < 0 ||
- p_lstat(path, &st) < 0 ||
- !(S_ISLNK(st.st_mode)))
- return 0;
+ if (p_symlink("target", path) == 0) {
+ if (p_lstat(path, &st) == 0 && S_ISLNK(st.st_mode))
+ support = 1;
- return 1;
+ p_unlink(path);
+ }
+
+ return support;
+}
+
+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);
}