Skip to content

Split diff line by '\t' for metadata and path #398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ def _index_from_raw_format(cls, repo, stream):
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
Expand Down
1 change: 1 addition & 0 deletions git/test/fixtures/diff_index_raw
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D
6 changes: 6 additions & 0 deletions git/test/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ def test_diff_index(self):
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
Expand Down