summaryrefslogtreecommitdiff
path: root/git/test/test_repo.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2017-02-25 11:32:28 +0100
committerSebastian Thiel <byronimo@gmail.com>2017-02-25 11:32:28 +0100
commitd3bd3c6b94c735c725f39959730de11c1cebe67a (patch)
treeaa4b1a154176b23b3cd69da3bb8148a1427b79c7 /git/test/test_repo.py
parent416daa0d11d6146e00131cf668998656186aef6a (diff)
parent8dfa1685aac22a83ba1f60d1b2d52abf5a3d842f (diff)
downloadgitpython-d3bd3c6b94c735c725f39959730de11c1cebe67a.tar.gz
Merge branch 'git_work_tree' of https://github.com/tbhartman/GitPython into tbhartman-git_work_tree
Diffstat (limited to 'git/test/test_repo.py')
-rw-r--r--git/test/test_repo.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/git/test/test_repo.py b/git/test/test_repo.py
index 9ad80ee6..5dc7bbb0 100644
--- a/git/test/test_repo.py
+++ b/git/test/test_repo.py
@@ -925,3 +925,32 @@ class TestRepo(TestBase):
raise AssertionError(ex, "It's ok if TC not running from `master`.")
self.failUnlessRaises(InvalidGitRepositoryError, Repo, worktree_path)
+
+ @with_rw_directory
+ def test_git_work_tree_env(self, rw_dir):
+ """Check that we yield to GIT_WORK_TREE"""
+ # clone a repo
+ # move .git directory to a subdirectory
+ # set GIT_DIR and GIT_WORK_TREE appropriately
+ # check that repo.working_tree_dir == rw_dir
+ git = Git(rw_dir)
+ self.rorepo.clone(join_path_native(rw_dir, 'master_repo'))
+
+ repo_dir = join_path_native(rw_dir, 'master_repo')
+ old_git_dir = join_path_native(repo_dir, '.git')
+ new_subdir = join_path_native(repo_dir, 'gitdir')
+ new_git_dir = join_path_native(new_subdir, 'git')
+ os.mkdir(new_subdir)
+ os.rename(old_git_dir, new_git_dir)
+
+ oldenv = os.environ.copy()
+ os.environ['GIT_DIR'] = new_git_dir
+ os.environ['GIT_WORK_TREE'] = repo_dir
+
+ try:
+ r = Repo()
+ self.assertEqual(r.working_tree_dir, repo_dir)
+ self.assertEqual(r.working_dir, repo_dir)
+ finally:
+ os.environ = oldenv
+