diff options
Diffstat (limited to 'git/test')
-rw-r--r-- | git/test/performance/test_commit.py | 2 | ||||
-rw-r--r-- | git/test/test_index.py | 13 | ||||
-rw-r--r-- | git/test/test_submodule.py | 33 |
3 files changed, 46 insertions, 2 deletions
diff --git a/git/test/performance/test_commit.py b/git/test/performance/test_commit.py index 7d3e87c4..b59c747e 100644 --- a/git/test/performance/test_commit.py +++ b/git/test/performance/test_commit.py @@ -76,7 +76,7 @@ class TestPerformance(TestBigRepoRW): % (nc, elapsed_time, nc / elapsed_time), file=sys.stderr) def test_commit_serialization(self): - assert_commit_serialization(self.gitrwrepo, self.gitrwrepo.head, True) + assert_commit_serialization(self.gitrwrepo, '58c78e6', True) rwrepo = self.gitrwrepo make_object = rwrepo.odb.store diff --git a/git/test/test_index.py b/git/test/test_index.py index 2fd53f65..ffc4bffe 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -18,6 +18,7 @@ from git.exc import ( ) from git import ( IndexFile, + Repo, BlobFilter, UnmergedEntriesError, Tree, @@ -45,6 +46,7 @@ from git.index.typ import ( IndexEntry ) from git.index.fun import hook_path +from gitdb.test.lib import with_rw_directory class TestIndex(TestBase): @@ -780,3 +782,14 @@ class TestIndex(TestBase): except InvalidGitRepositoryError: asserted = True assert asserted, "Adding using a filename is not correctly asserted." + + @with_rw_directory + def test_add_utf8P_path(self, rw_dir): + # NOTE: fp is not a Unicode object in python 2 (which is the source of the problem) + fp = os.path.join(rw_dir, 'ø.txt') + with open(fp, 'wb') as fs: + fs.write(u'content of ø'.encode('utf-8')) + + r = Repo.init(rw_dir) + r.index.add([fp]) + r.index.commit('Added orig and prestable') diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py index cbf38c18..17ce605a 100644 --- a/git/test/test_submodule.py +++ b/git/test/test_submodule.py @@ -661,7 +661,7 @@ class TestSubmodule(TestBase): # end for each checkout mode @with_rw_directory - def test_git_submodules(self, rwdir): + def test_git_submodules_and_add_sm_with_new_commit(self, rwdir): parent = git.Repo.init(os.path.join(rwdir, 'parent')) parent.git.submodule('add', self._small_repo_url(), 'module') parent.index.commit("added submodule") @@ -686,6 +686,37 @@ class TestSubmodule(TestBase): sm.move(sm.path + '_moved') sm2.move(sm2.path + '_moved') + parent.index.commit("moved submodules") + + smm = sm.module() + fp = os.path.join(smm.working_tree_dir, 'empty-file') + with open(fp, 'w'): + pass + smm.git.add(fp) + smm.git.commit(m="new file added") + + # submodules are retrieved from the current commit's tree, therefore we can't really get a new submodule + # object pointing to the new submodule commit + sm_too = parent.submodules['module_moved'] + assert parent.head.commit.tree[sm.path].binsha == sm.binsha + assert sm_too.binsha == sm.binsha, "cached submodule should point to the same commit as updated one" + + added_bies = parent.index.add([sm]) # addded base-index-entries + assert len(added_bies) == 1 + parent.index.commit("add same submodule entry") + commit_sm = parent.head.commit.tree[sm.path] + assert commit_sm.binsha == added_bies[0].binsha + assert commit_sm.binsha == sm.binsha + + sm_too.binsha = sm_too.module().head.commit.binsha + added_bies = parent.index.add([sm_too]) + assert len(added_bies) == 1 + parent.index.commit("add new submodule entry") + commit_sm = parent.head.commit.tree[sm.path] + assert commit_sm.binsha == added_bies[0].binsha + assert commit_sm.binsha == sm_too.binsha + assert sm_too.binsha != sm.binsha + @with_rw_directory def test_git_submodule_compatibility(self, rwdir): parent = git.Repo.init(os.path.join(rwdir, 'parent')) |