diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2014-11-17 11:27:40 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2014-11-17 11:27:40 +0100 |
commit | ca4c1b87b3fdedd98a0b9e7a8cf02033b5aaa1c8 (patch) | |
tree | 210d461a1a498e782dc587a36a12d495b81ee697 /git/test/test_index.py | |
parent | cebda2d5941410cad07b30c4e6b3fc1823d593a4 (diff) | |
parent | 4d4138c16299ce51541cb752672da1ae467cc5ff (diff) | |
download | gitpython-ca4c1b87b3fdedd98a0b9e7a8cf02033b5aaa1c8.tar.gz |
Merge branch 'master' of https://github.com/moshevds/GitPython into moshevds-master
Fixed an issue with path_rewriter code branch, but there is more to do
Conflicts:
git/index/base.py
git/test/test_index.py
Diffstat (limited to 'git/test/test_index.py')
-rw-r--r-- | git/test/test_index.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/git/test/test_index.py b/git/test/test_index.py index 76d43cbf..a4e26977 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -20,6 +20,11 @@ import shutil import time from stat import * +from StringIO import StringIO +from gitdb.base import IStream +from git.objects import Blob +from git.index.typ import BaseIndexEntry + class TestIndex(TestBase): @@ -671,3 +676,32 @@ class TestIndex(TestBase): index = IndexFile.new(self.rorepo, *args) assert isinstance(index, IndexFile) # END for each arg tuple + + @with_rw_repo('HEAD', bare=True) + def test_index_bare_add(self, rw_bare_repo): + # Something is wrong after cloning to a bare repo, reading the + # property rw_bare_repo.working_tree_dir will return '/tmp' + # instead of throwing the Exception we are expecting. This is + # a quick hack to make this test fail when expected. + rw_bare_repo._working_tree_dir = None + contents = 'This is a StringIO file' + filesize = len(contents) + fileobj = StringIO(contents) + filename = 'my-imaginary-file' + istream = rw_bare_repo.odb.store( + IStream(Blob.type, filesize, fileobj)) + entry = BaseIndexEntry((100644, istream.binsha, 0, filename)) + try: + rw_bare_repo.index.add([entry]) + except AssertionError, e: + self.fail("Adding to the index of a bare repo is not allowed.") + + # Adding using a path should still require a non-bare repository. + asserted = False + path = os.path.join('git', 'test', 'test_index.py') + try: + rw_bare_repo.index.add([path]) + except Exception, e: + asserted = "does not have a working tree" in e.message + assert asserted, "Adding using a filename is not correctly asserted." + |