diff options
author | Patrick Steinhardt <ps@pks.im> | 2019-03-29 11:41:42 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2019-03-29 12:55:17 +0100 |
commit | 25c085e6e0be04bf044ec1fb1d117af82b401ebc (patch) | |
tree | 1e01ba8fa504095b14adb8e82ec555732a384b46 /tests/repo | |
parent | fa4505e6f1e0cf29f265d3cf8dbc2534c13ad74b (diff) | |
download | libgit2-25c085e6e0be04bf044ec1fb1d117af82b401ebc.tar.gz |
tests: repo: verify that we can open repos with symlinked global config
We've got reports that users are unable to open repos when their global
configuration ("~/.gitconfig") is a symlink. Add a test to verify that
we are in fact able to do so as expected.
Diffstat (limited to 'tests/repo')
-rw-r--r-- | tests/repo/open.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/repo/open.c b/tests/repo/open.c index 06ec71bfd..5c08a388c 100644 --- a/tests/repo/open.c +++ b/tests/repo/open.c @@ -118,6 +118,36 @@ void test_repo_open__gitlinked(void) git_repository_free(repo2); } +void test_repo_open__with_symlinked_config(void) +{ +#ifndef GIT_WIN32 + git_buf path = GIT_BUF_INIT; + git_repository *repo; + git_config *cfg; + int32_t value; + + cl_git_sandbox_init("empty_standard_repo"); + + /* Setup .gitconfig as symlink */ + cl_git_pass(git_futils_mkdir_r("home", 0777)); + cl_git_mkfile("home/.gitconfig.linked", "[global]\ntest = 4567\n"); + cl_must_pass(symlink(".gitconfig.linked", "home/.gitconfig")); + cl_git_pass(git_path_prettify(&path, "home", NULL)); + cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr)); + + cl_git_pass(git_repository_open(&repo, "empty_standard_repo")); + cl_git_pass(git_config_open_default(&cfg)); + cl_git_pass(git_config_get_int32(&value, cfg, "global.test")); + cl_assert_equal_i(4567, value); + + git_config_free(cfg); + git_repository_free(repo); + cl_git_pass(git_futils_rmdir_r(git_buf_cstr(&path), NULL, GIT_RMDIR_REMOVE_FILES)); + cl_sandbox_set_search_path_defaults(); + git_buf_dispose(&path); +#endif +} + void test_repo_open__from_git_new_workdir(void) { #ifndef GIT_WIN32 |