diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2018-10-20 05:43:40 -0700 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2018-10-20 17:07:18 +0100 |
commit | da500cc607f1f30cea822087f3aaeb6b6727ff74 (patch) | |
tree | 277309ed61ef82926891474942c25c6c92e810a7 /tests/repo/repo_helpers.c | |
parent | 3f0caa15298ae617aba1eac52dac8cc98318cd52 (diff) | |
download | libgit2-ethomson/win_symlinks.tar.gz |
symlink tests: test symbolic links on windowsethomson/win_symlinks
Test updated symbolic link creation on Windows. Ensure that we emulate
Git for Windows behavior. Ensure that when `core.symlinks=true` is set
in a global configuration that new repositories are created without a
`core.symlinks` setting, and that when `core.symlinks` is unset that
`core.symlinks=false` in set in the repository. Further ensure that
checkout honors the expected `core.symlinks` defaults on Windows.
Diffstat (limited to 'tests/repo/repo_helpers.c')
-rw-r--r-- | tests/repo/repo_helpers.c | 28 |
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); } |