diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-10-27 21:49:46 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-10-27 21:49:46 +0200 |
commit | 0d5bfb5d6d22f8fe8c940f36e1fbe16738965d5f (patch) | |
tree | 41fceee78aadde8f909356aaf896e64696753db6 /test/git/test_index.py | |
parent | 1b6b9510e0724bfcb4250f703ddf99d1e4020bbc (diff) | |
download | gitpython-0d5bfb5d6d22f8fe8c940f36e1fbe16738965d5f.tar.gz |
index.reset: updated parameter docs, but most importantly, the method now has better testing for the use of paths during reset. The IndexFile now implements this on its own, which also allows for something equivalent to git-reset --hard -- <paths>, which is not possible in the git command for some probably very good reason
Diffstat (limited to 'test/git/test_index.py')
-rw-r--r-- | test/git/test_index.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/git/test_index.py b/test/git/test_index.py index 29ad2b5c..b5600eeb 100644 --- a/test/git/test_index.py +++ b/test/git/test_index.py @@ -599,6 +599,46 @@ class TestIndex(TestBase): for filenum in range(len(paths)): assert index.entry_key(str(filenum), 0) in index.entries + + + # TEST RESET ON PATHS + ###################### + arela = "aa" + brela = "bb" + afile = self._make_file(arela, "adata", rw_repo) + bfile = self._make_file(brela, "bdata", rw_repo) + akey = index.entry_key(arela, 0) + bkey = index.entry_key(brela, 0) + keys = (akey, bkey) + absfiles = (afile, bfile) + files = (arela, brela) + + for fkey in keys: + assert not fkey in index.entries + + index.add(files, write=True) + nc = index.commit("2 files committed", head=False) + + for fkey in keys: + assert fkey in index.entries + + # just the index + index.reset(paths=(arela, afile)) + assert not akey in index.entries + assert bkey in index.entries + + # now with working tree - files on disk as well as entries must be recreated + rw_repo.head.commit = nc + for absfile in absfiles: + os.remove(absfile) + + index.reset(working_tree=True, paths=files) + + for fkey in keys: + assert fkey in index.entries + for absfile in absfiles: + assert os.path.isfile(absfile) + @with_rw_repo('HEAD') def test_compare_write_tree(self, rw_repo): |