diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-22 22:22:00 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-22 22:22:00 +0200 |
commit | b2a14e4b96a0ffc5353733b50266b477539ef899 (patch) | |
tree | ce48feb6d2da2bed92240c0fbd2350e05f7b7519 /test/git/test_index.py | |
parent | 20c34a929a8b2871edd4fd44a38688e8977a4be6 (diff) | |
parent | ea33fe8b21d2b02f902b131aba0d14389f2f8715 (diff) | |
download | gitpython-b2a14e4b96a0ffc5353733b50266b477539ef899.tar.gz |
Merge branch 'index' into improvements
* index:
Index: Is now diffable and appears to properly implement diffing against other items as well as the working tree
default index writing now writes the index of the current repository in a fashion comparable to the native implementation
Added test for ConcurrentWriteOperation
utils: Added LockFile including test
Index now behaves more like the default index if no explicit stream is given. It will lazily read its data on first access
Diffstat (limited to 'test/git/test_index.py')
-rw-r--r-- | test/git/test_index.py | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/test/git/test_index.py b/test/git/test_index.py index 10ffb79d..257acf10 100644 --- a/test/git/test_index.py +++ b/test/git/test_index.py @@ -101,4 +101,46 @@ class TestTree(TestBase): # END for each blob assert num_blobs == len(three_way_index.entries) - + @with_rw_repo('0.1.6') + def test_from_index_and_diff(self, rw_repo): + # default Index instance points to our index + index = Index(rw_repo) + assert index.path is not None + assert len(index.entries) + + # write the file back + index.write() + + # could sha it, or check stats + + # test diff + # resetting the head will leave the index in a different state, and the + # diff will yield a few changes + cur_head_commit = rw_repo.head.commit + ref = rw_repo.head.reset(rw_repo, 'HEAD~6', index=True, working_tree=False) + + # diff against same index is 0 + diff = index.diff() + assert len(diff) == 0 + + # against HEAD as string, must be the same as it matches index + diff = index.diff('HEAD') + assert len(diff) == 0 + + # against previous head, there must be a difference + diff = index.diff(cur_head_commit) + assert len(diff) + + # we reverse the result + adiff = index.diff(str(cur_head_commit), R=True) + odiff = index.diff(cur_head_commit, R=False) # now its not reversed anymore + assert adiff != odiff + assert odiff == diff # both unreversed diffs against HEAD + + # against working copy - its still at cur_commit + wdiff = index.diff(None) + assert wdiff != adiff + assert wdiff != odiff + + # against something unusual + self.failUnlessRaises(ValueError, index.diff, int) |