| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,5 +16,6 @@ Contributors are: | |||
| 16 | 16 | -Vincent Driessen <me _at_ nvie.com> | |
| 17 | 17 | -Phil Elson <pelson _dot_ pub _at_ gmail.com> | |
| 18 | 18 | -Bernard `Guyzmo` Pratz <guyzmo+gitpython+pub@m0g.net> | |
| 19 | + -Timothy B. Hartman <tbhartman _at_ gmail.com> | ||
| 19 | 20 | ||
| 20 | 21 | Portions derived from other open source works and are clearly marked. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -135,7 +135,7 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals | |||
| 135 | 135 | # removed. It's just cleaner. | |
| 136 | 136 | if is_git_dir(curpath): | |
| 137 | 137 | self.git_dir = curpath | |
| 138 | - self._working_tree_dir = os.path.dirname(self.git_dir) | ||
| 138 | + self._working_tree_dir = os.getenv('GIT_WORK_TREE', os.path.dirname(self.git_dir)) | ||
| 139 | 139 | break | |
| 140 | 140 | ||
| 141 | 141 | sm_gitpath = find_submodule_git_dir(osp.join(curpath, '.git')) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -925,3 +925,32 @@ def test_work_tree_unsupported(self, rw_dir): | |||
| 925 | 925 | raise AssertionError(ex, "It's ok if TC not running from `master`.") | |
| 926 | 926 | ||
| 927 | 927 | self.failUnlessRaises(InvalidGitRepositoryError, Repo, worktree_path) | |
| 928 | + | ||
| 929 | + @with_rw_directory | ||
| 930 | + def test_git_work_tree_env(self, rw_dir): | ||
| 931 | + """Check that we yield to GIT_WORK_TREE""" | ||
| 932 | + # clone a repo | ||
| 933 | + # move .git directory to a subdirectory | ||
| 934 | + # set GIT_DIR and GIT_WORK_TREE appropriately | ||
| 935 | + # check that repo.working_tree_dir == rw_dir | ||
| 936 | + git = Git(rw_dir) | ||
| 937 | + self.rorepo.clone(join_path_native(rw_dir, 'master_repo')) | ||
| 938 | + | ||
| 939 | + repo_dir = join_path_native(rw_dir, 'master_repo') | ||
| 940 | + old_git_dir = join_path_native(repo_dir, '.git') | ||
| 941 | + new_subdir = join_path_native(repo_dir, 'gitdir') | ||
| 942 | + new_git_dir = join_path_native(new_subdir, 'git') | ||
| 943 | + os.mkdir(new_subdir) | ||
| 944 | + os.rename(old_git_dir, new_git_dir) | ||
| 945 | + | ||
| 946 | + oldenv = os.environ.copy() | ||
| 947 | + os.environ['GIT_DIR'] = new_git_dir | ||
| 948 | + os.environ['GIT_WORK_TREE'] = repo_dir | ||
| 949 | + | ||
| 950 | + try: | ||
| 951 | + r = Repo() | ||
| 952 | + self.assertEqual(r.working_tree_dir, repo_dir) | ||
| 953 | + self.assertEqual(r.working_dir, repo_dir) | ||
| 954 | + finally: | ||
| 955 | + os.environ = oldenv | ||
| 956 | + | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments