summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--doc/source/changes.rst6
-rw-r--r--git/diff.py14
-rw-r--r--git/test/fixtures/diff_abbrev-40_full-index_M_raw_no-color1
-rw-r--r--git/test/test_diff.py9
5 files changed, 26 insertions, 11 deletions
diff --git a/README.md b/README.md
index 85983f0d..ad2aa4fc 100644
--- a/README.md
+++ b/README.md
@@ -18,9 +18,6 @@ The list of dependencies are listed in `./requirements.txt` and `./test-requirem
### INSTALL
-[![Latest Version](https://pypip.in/version/GitPython/badge.svg)](https://pypi.python.org/pypi/GitPython/)
-[![Supported Python Versions](https://pypip.in/py_versions/GitPython/badge.svg)](https://pypi.python.org/pypi/GitPython/)
-
If you have downloaded the source code:
python setup.py install
@@ -101,8 +98,6 @@ New BSD License. See the LICENSE file.
[![Build Status](https://travis-ci.org/gitpython-developers/GitPython.svg)](https://travis-ci.org/gitpython-developers/GitPython)
[![Code Climate](https://codeclimate.com/github/gitpython-developers/GitPython/badges/gpa.svg)](https://codeclimate.com/github/gitpython-developers/GitPython)
[![Documentation Status](https://readthedocs.org/projects/gitpython/badge/?version=stable)](https://readthedocs.org/projects/gitpython/?badge=stable)
-[![Issue Stats](http://www.issuestats.com/github/gitpython-developers/GitPython/badge/pr)](http://www.issuestats.com/github/gitpython-developers/GitPython)
-[![Issue Stats](http://www.issuestats.com/github/gitpython-developers/GitPython/badge/issue)](http://www.issuestats.com/github/gitpython-developers/GitPython)
Now that there seems to be a massive user base, this should be motivation enough to let git-python return to a proper state, which means
@@ -111,4 +106,4 @@ Now that there seems to be a massive user base, this should be motivation enough
[twitch-channel]: http://www.twitch.tv/byronimo/profile
[youtube-playlist]: https://www.youtube.com/playlist?list=PLMHbQxe1e9MnoEcLhn6Yhv5KAvpWkJbL0
-[contributing]: https://github.com/gitpython-developers/GitPython/blob/master/README.md \ No newline at end of file
+[contributing]: https://github.com/gitpython-developers/GitPython/blob/master/README.md
diff --git a/doc/source/changes.rst b/doc/source/changes.rst
index b17e7592..9f8ebb51 100644
--- a/doc/source/changes.rst
+++ b/doc/source/changes.rst
@@ -2,6 +2,12 @@
Changelog
=========
+2.0.8 - Bugfixes
+================
+
+* `DiffIndex.iter_change_type(...)` produces better results when diffing
+ an index against the working tree.
+
2.0.7 - New Features
====================
diff --git a/git/diff.py b/git/diff.py
index 06193920..fb8faaf6 100644
--- a/git/diff.py
+++ b/git/diff.py
@@ -183,7 +183,9 @@ class DiffIndex(list):
raise ValueError("Invalid change type: %s" % change_type)
for diff in self:
- if change_type == "A" and diff.new_file:
+ if diff.change_type == change_type:
+ yield diff
+ elif change_type == "A" and diff.new_file:
yield diff
elif change_type == "D" and diff.deleted_file:
yield diff
@@ -247,11 +249,12 @@ class Diff(object):
NULL_BIN_SHA = b"\0" * 20
__slots__ = ("a_blob", "b_blob", "a_mode", "b_mode", "a_rawpath", "b_rawpath",
- "new_file", "deleted_file", "raw_rename_from", "raw_rename_to", "diff")
+ "new_file", "deleted_file", "raw_rename_from", "raw_rename_to",
+ "diff", "change_type")
def __init__(self, repo, a_rawpath, b_rawpath, a_blob_id, b_blob_id, a_mode,
b_mode, new_file, deleted_file, raw_rename_from,
- raw_rename_to, diff):
+ raw_rename_to, diff, change_type):
self.a_mode = a_mode
self.b_mode = b_mode
@@ -286,6 +289,7 @@ class Diff(object):
self.raw_rename_to = raw_rename_to or None
self.diff = diff
+ self.change_type = change_type
def __eq__(self, other):
for name in self.__slots__:
@@ -435,7 +439,7 @@ class Diff(object):
new_file, deleted_file,
rename_from,
rename_to,
- None))
+ None, None))
previous_header = header
# end for each header we parse
@@ -483,7 +487,7 @@ class Diff(object):
# END add/remove handling
diff = Diff(repo, a_path, b_path, a_blob_id, b_blob_id, old_mode, new_mode,
- new_file, deleted_file, rename_from, rename_to, '')
+ new_file, deleted_file, rename_from, rename_to, '', change_type)
index.append(diff)
# END for each line
diff --git a/git/test/fixtures/diff_abbrev-40_full-index_M_raw_no-color b/git/test/fixtures/diff_abbrev-40_full-index_M_raw_no-color
new file mode 100644
index 00000000..dad85c68
--- /dev/null
+++ b/git/test/fixtures/diff_abbrev-40_full-index_M_raw_no-color
@@ -0,0 +1 @@
+:100644 100644 739bc65220ad90e9ebfa2d6af1723b97555569a4 0000000000000000000000000000000000000000 M README.md
diff --git a/git/test/test_diff.py b/git/test/test_diff.py
index ba0d2d13..9fdb26a2 100644
--- a/git/test/test_diff.py
+++ b/git/test/test_diff.py
@@ -104,6 +104,15 @@ class TestDiff(TestBase):
assert diff.rename_to == 'that'
assert len(list(diffs.iter_change_type('R'))) == 1
+ def test_diff_of_modified_files_not_added_to_the_index(self):
+ output = StringProcessAdapter(fixture('diff_abbrev-40_full-index_M_raw_no-color'))
+ diffs = Diff._index_from_raw_format(self.rorepo, output.stdout)
+
+ assert len(diffs) == 1, 'one modification'
+ assert len(list(diffs.iter_change_type('M'))) == 1, 'one modification'
+ assert diffs[0].change_type == 'M'
+ assert diffs[0].b_blob is None
+
def test_binary_diff(self):
for method, file_name in ((Diff._index_from_patch_format, 'diff_patch_binary'),
(Diff._index_from_raw_format, 'diff_raw_binary')):