|
20 | 20 | importtime
|
21 | 21 | fromstatimport*
|
22 | 22 |
|
| 23 | +fromStringIOimportStringIO |
| 24 | +fromgitdb.baseimportIStream |
| 25 | +fromgit.objectsimportBlob |
| 26 | +fromgit.index.typimportBaseIndexEntry |
| 27 | + |
| 28 | + |
23 | 29 | classTestIndex(TestBase):
|
24 | 30 |
|
25 | 31 | def__init__(self,*args):
|
@@ -646,6 +652,34 @@ def make_paths():
|
646 | 652 | forabsfileinabsfiles:
|
647 | 653 | assertos.path.isfile(absfile)
|
648 | 654 |
|
| 655 | +@with_rw_repo('HEAD',bare=True) |
| 656 | +deftest_index_bare_add(self,rw_bare_repo): |
| 657 | +# Something is wrong after cloning to a bare repo, reading the |
| 658 | +# property rw_bare_repo.working_tree_dir will return '/tmp' |
| 659 | +# instead of throwing the Exception we are expecting. This is |
| 660 | +# a quick hack to make this test fail when expected. |
| 661 | +rw_bare_repo._working_tree_dir=None |
| 662 | +contents='This is a StringIO file' |
| 663 | +filesize=len(contents) |
| 664 | +fileobj=StringIO(contents) |
| 665 | +filename='my-imaginary-file' |
| 666 | +istream=rw_bare_repo.odb.store( |
| 667 | +IStream(Blob.type,filesize,fileobj)) |
| 668 | +entry=BaseIndexEntry((100644,istream.binsha,0,filename)) |
| 669 | +try: |
| 670 | +rw_bare_repo.index.add([entry]) |
| 671 | +exceptAssertionError,e: |
| 672 | +self.fail("Adding to the index of a bare repo is not allowed.") |
| 673 | + |
| 674 | +# Adding using a path should still require a non-bare repository. |
| 675 | +asserted=False |
| 676 | +path=os.path.join('git','test','test_index.py') |
| 677 | +try: |
| 678 | +rw_bare_repo.index.add([path]) |
| 679 | +exceptException,e: |
| 680 | +asserted="does not have a working tree"ine.message |
| 681 | +assertasserted,"Adding using a filename is not correctly asserted." |
| 682 | + |
649 | 683 |
|
650 | 684 | @with_rw_repo('HEAD')
|
651 | 685 | deftest_compare_write_tree(self,rw_repo):
|
|