summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus R. Brown <mrbrown@precision-mojo.com>2013-01-11 13:47:06 -0700
committerMarcus R. Brown <mrbrown@precision-mojo.com>2013-01-11 13:47:06 -0700
commit3621c06c3173bff395645bd416f0efafa20a1da6 (patch)
tree6b5b3ea91e5a177da412a76c59b19d1fc5625400
parent5991698ee2b3046bbc9cfc3bd2abd3a881f514dd (diff)
downloadgitpython-3621c06c3173bff395645bd416f0efafa20a1da6.tar.gz
Add tests for .git-file.
-rw-r--r--git/test/fixtures/git_file1
-rw-r--r--git/test/test_repo.py17
2 files changed, 18 insertions, 0 deletions
diff --git a/git/test/fixtures/git_file b/git/test/fixtures/git_file
new file mode 100644
index 00000000..2efda9f5
--- /dev/null
+++ b/git/test/fixtures/git_file
@@ -0,0 +1 @@
+gitdir: ./.real
diff --git a/git/test/test_repo.py b/git/test/test_repo.py
index 18d5c1b8..a4d148d1 100644
--- a/git/test/test_repo.py
+++ b/git/test/test_repo.py
@@ -594,6 +594,23 @@ class TestRepo(TestBase):
target_type = GitCmdObjectDB
assert isinstance(self.rorepo.odb, target_type)
+ @with_rw_repo('HEAD')
+ def test_git_file(self, rwrepo):
+ # Move the .git directory to another location and create the .git file.
+ real_path_abs = os.path.abspath(join_path_native(rwrepo.working_tree_dir, '.real'))
+ os.rename(rwrepo.git_dir, real_path_abs)
+ git_file_path = join_path_native(rwrepo.working_tree_dir, '.git')
+ open(git_file_path, 'wb').write(fixture('git_file'))
+
+ # Create a repo and make sure it's pointing to the relocated .git directory.
+ git_file_repo = Repo(rwrepo.working_tree_dir)
+ assert os.path.abspath(git_file_repo.git_dir) == real_path_abs
+
+ # Test using an absolute gitdir path in the .git file.
+ open(git_file_path, 'wb').write('gitdir: %s\n' % real_path_abs)
+ git_file_repo = Repo(rwrepo.working_tree_dir)
+ assert os.path.abspath(git_file_repo.git_dir) == real_path_abs
+
def test_submodules(self):
assert len(self.rorepo.submodules) == 1 # non-recursive
assert len(list(self.rorepo.iter_submodules())) >= 2