diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2023-04-03 10:38:57 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2023-04-04 09:05:16 +0100 |
commit | b41c3dfce65fec1f6f5f009f050e61c54acf617c (patch) | |
tree | e94f0080aad2c8b09d382b96d4b64c1379a9ef64 /tests/libgit2 | |
parent | 54a22f536557b9a25752c6b59829dff4cbee99e0 (diff) | |
download | libgit2-b41c3dfce65fec1f6f5f009f050e61c54acf617c.tar.gz |
repo: honor GIT_WORK_TREE environment variable
When the repository is opened with `GIT_REPOSITORY_OPEN_FROM_ENV`, honor
the `GIT_WORK_TREE` environment variable.
Diffstat (limited to 'tests/libgit2')
-rw-r--r-- | tests/libgit2/repo/env.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/libgit2/repo/env.c b/tests/libgit2/repo/env.c index 790ffd40f..5f084ac00 100644 --- a/tests/libgit2/repo/env.c +++ b/tests/libgit2/repo/env.c @@ -31,6 +31,8 @@ void test_repo_env__cleanup(void) if (git_fs_path_isdir("peeled.git")) git_futils_rmdir_r("peeled.git", NULL, GIT_RMDIR_REMOVE_FILES); + cl_fixture_cleanup("test_workdir"); + clear_git_env(); } @@ -275,3 +277,21 @@ void test_repo_env__open(void) clear_git_env(); } + +void test_repo_env__work_tree(void) +{ + git_repository *repo; + const char *test_path; + + cl_fixture_sandbox("attr"); + cl_git_pass(p_rename("attr/.gitted", "attr/.git")); + + cl_must_pass(p_mkdir("test_workdir", 0777)); + test_path = cl_git_sandbox_path(1, "test_workdir", NULL); + + cl_setenv("GIT_WORK_TREE", test_path); + cl_git_pass(git_repository_open_ext(&repo, "attr", GIT_REPOSITORY_OPEN_FROM_ENV, NULL)); + cl_assert_equal_s(test_path, git_repository_workdir(repo)); + git_repository_free(repo); + cl_setenv("GIT_WORK_TREE", NULL); +} |