summaryrefslogtreecommitdiff
path: root/git/test
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-04-08 09:50:26 +0200
committerSebastian Thiel <byronimo@gmail.com>2015-04-08 09:50:26 +0200
commit8f043d8a1d7f4076350ff0c778bfa60f7aa2f7aa (patch)
tree4d2a80c70fc35bf69d5779347c5e6802c8b9d0c9 /git/test
parentab7c3223076306ca71f692ed5979199863cf45a7 (diff)
downloadgitpython-8f043d8a1d7f4076350ff0c778bfa60f7aa2f7aa.tar.gz
fix(index): don't write extension data by default
It turned out that the index is not actually corrupted, which is good news. What happens is that `git` writes `TREE` extension data into the index, which causes it to write out the given tree *as is* next time a `git commit` is executed. When using `git add`, this extension data is maintained automatically. However, GitPython doesn't do that ... . Usually this is no problem at all, as you are supposed to use `IndexFile.commit(...)` along with `IndexFile.add(...)`. Thanks to a shortcoming in the GitPython API, the index was automatically written out whenever files have been added, without providing control over whether or not *extension data* will be written along with it. My fix consists of an additional flag in `IndexFile.add(...)`, which causes extension data not to be written by default, so commits can be safely done via `git commit` or `IndexFile.commit(...)`. However, this might introduce new subtle bugs in case someone is relying on extension data to be written. As this can be controlled through the said flag though, a fix is easily done in that case. Fixes #265
Diffstat (limited to 'git/test')
-rw-r--r--git/test/test_index.py15
1 files changed, 0 insertions, 15 deletions
diff --git a/git/test/test_index.py b/git/test/test_index.py
index 8124ec16..63f99f10 100644
--- a/git/test/test_index.py
+++ b/git/test/test_index.py
@@ -44,11 +44,8 @@ from git.index.typ import (
BaseIndexEntry,
IndexEntry
)
-from gitdb.test.lib import with_rw_directory
from git.index.fun import hook_path
-import git
-
class TestIndex(TestBase):
@@ -768,15 +765,3 @@ class TestIndex(TestBase):
except InvalidGitRepositoryError:
asserted = True
assert asserted, "Adding using a filename is not correctly asserted."
-
- @with_rw_directory
- def test_index_add_corruption(self, rw_dir):
- # Test for https://github.com/gitpython-developers/GitPython/issues/265
- repo = git.Repo.clone_from("git://pkgs.fedoraproject.org/GitPython", rw_dir)
- assert not repo.is_dirty()
- file_path = os.path.join(rw_dir, "GitPython.spec")
- open(file_path, 'wb').close()
- assert repo.is_dirty()
- repo.index.add(['0001-GPG-signature-support-on-commit-object.patch', 'GitPython.spec', '.gitignore', 'sources'])
- repo.git.commit(m="committing file")
- assert not repo.is_dirty()