summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2016-03-16 19:29:15 +0100
committerSebastian Thiel <byronimo@gmail.com>2016-03-16 19:29:15 +0100
commitc877794b51f43b5fb2338bda478228883288bcdd (patch)
tree1387978ccf7637eb7a9a2ada62bec1b8a1a62b59
parentb2971489fec32160836519e66ca6b97987c33d0c (diff)
parente328ffddec722be3fba2c9b637378e31e623d58e (diff)
downloadgitpython-c877794b51f43b5fb2338bda478228883288bcdd.tar.gz
Merge pull request #398 from gitprime/master
Split diff line by '\t' for metadata and path
-rw-r--r--git/diff.py3
-rw-r--r--git/test/fixtures/diff_index_raw1
-rw-r--r--git/test/test_diff.py6
3 files changed, 9 insertions, 1 deletions
diff --git a/git/diff.py b/git/diff.py
index 9059091e..062220df 100644
--- a/git/diff.py
+++ b/git/diff.py
@@ -365,7 +365,8 @@ class Diff(object):
if not line.startswith(":"):
continue
# END its not a valid diff line
- old_mode, new_mode, a_blob_id, b_blob_id, change_type, path = line[1:].split(None, 5)
+ meta, _, path = line[1:].partition('\t')
+ old_mode, new_mode, a_blob_id, b_blob_id, change_type = meta.split(None, 4)
path = path.strip()
a_path = path
b_path = path
diff --git a/git/test/fixtures/diff_index_raw b/git/test/fixtures/diff_index_raw
new file mode 100644
index 00000000..c25f380d
--- /dev/null
+++ b/git/test/fixtures/diff_index_raw
@@ -0,0 +1 @@
+:100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D
diff --git a/git/test/test_diff.py b/git/test/test_diff.py
index 53bb65db..b0d98248 100644
--- a/git/test/test_diff.py
+++ b/git/test/test_diff.py
@@ -122,6 +122,12 @@ class TestDiff(TestBase):
dr = res[3]
assert dr.diff.endswith(b"+Binary files a/rps and b/rps differ\n")
+ def test_diff_index_raw_format(self):
+ output = StringProcessAdapter(fixture('diff_index_raw'))
+ res = Diff._index_from_raw_format(None, output.stdout)
+ assert res[0].deleted_file
+ assert res[0].b_path == ''
+
def test_diff_patch_format(self):
# test all of the 'old' format diffs for completness - it should at least
# be able to deal with it