Skip to content

Commit b27c41a

Browse files
authored
Merge pull request #1491 from langfield/main
Fix bug where colons in paths raise a `ValueError` on `diff()` calls.
2 parents bec6157 + db392ae commit b27c41a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

git/diff.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,10 @@ def _index_from_patch_format(cls, repo: "Repo", proc: Union["Popen", "Git.AutoIn
570570
def _handle_diff_line(lines_bytes: bytes, repo: "Repo", index: DiffIndex) -> None:
571571
lines = lines_bytes.decode(defenc)
572572

573-
for line in lines.split(":")[1:]:
573+
# Discard everything before the first colon, and the colon itself.
574+
_, _, lines = lines.partition(":")
575+
576+
for line in lines.split("\x00:"):
574577
meta, _, path = line.partition("\x00")
575578
path = path.rstrip("\x00")
576579
a_blob_id: Optional[str]

test/test_diff.py

-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ def test_diff_index_raw_format(self):
236236
res[0].b_path,
237237
)
238238

239-
@unittest.skip("This currently fails and would need someone to improve diff parsing")
240239
def test_diff_file_with_colon(self):
241240
output = fixture("diff_file_with_colon")
242241
res = []

0 commit comments

Comments
 (0)