summaryrefslogtreecommitdiff
path: root/git/test/test_repo.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-08-29 16:19:52 +0200
committerSebastian Thiel <byronimo@gmail.com>2015-08-29 16:20:28 +0200
commite8590424997ab1d578c777fe44bf7e4173036f93 (patch)
treeb65d2b954c878ca11439f94f42e52b40437701c7 /git/test/test_repo.py
parent6eb3af27464ffba83e3478b0a0c8b1f9ff190889 (diff)
downloadgitpython-e8590424997ab1d578c777fe44bf7e4173036f93.tar.gz
fix(repo): fail loudly if worktrees are used
As GitPython is in maintenance mode, there will be no new features. However, I believe it's good idea to explicitly state we do not support certain things if this is the case. Therefore, when worktrees are encountered, we will throw an specific exception to indicate that. The current implementation is hacky to speed up development, and increases the risk of failing due to false-positive worktree directories. Related to #344
Diffstat (limited to 'git/test/test_repo.py')
-rw-r--r--git/test/test_repo.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/git/test/test_repo.py b/git/test/test_repo.py
index c95592ea..2e44f0aa 100644
--- a/git/test/test_repo.py
+++ b/git/test/test_repo.py
@@ -33,7 +33,10 @@ from git import (
)
from git.repo.fun import touch
from git.util import join_path_native
-from git.exc import BadObject
+from git.exc import (
+ BadObject,
+ WorkTreeRepositoryUnsupported
+)
from gitdb.util import bin_to_hex
from git.compat import string_types
from gitdb.test.lib import with_rw_directory
@@ -45,6 +48,8 @@ import shutil
import itertools
from io import BytesIO
+from nose import SkipTest
+
class TestRepo(TestBase):
@@ -779,3 +784,16 @@ class TestRepo(TestBase):
self.assertFalse(repo.is_ancestor("master", c1))
for i, j in itertools.permutations([c1, 'ffffff', ''], r=2):
self.assertRaises(GitCommandError, repo.is_ancestor, i, j)
+
+ @with_rw_directory
+ def test_work_tree_unsupported(self, rw_dir):
+ git = Git(rw_dir)
+ if git.version_info[:3] < (2, 5, 1):
+ raise SkipTest("worktree feature unsupported")
+
+ rw_master = self.rorepo.clone(join_path_native(rw_dir, 'master_repo'))
+ rw_master.git.checkout('HEAD~10')
+ worktree_path = join_path_native(rw_dir, 'worktree_repo')
+ rw_master.git.worktree('add', worktree_path, 'master')
+
+ self.failUnlessRaises(WorkTreeRepositoryUnsupported, Repo, worktree_path)