There was an error while loading. Please reload this page.
1 parent b27c41a commit 41003c5Copy full SHA for 41003c5
2 files changed
git/diff.py
@@ -574,6 +574,9 @@ def _handle_diff_line(lines_bytes: bytes, repo: "Repo", index: DiffIndex) -> Non
574
_, _, lines = lines.partition(":")
575
576
for line in lines.split("\x00:"):
577
+ if not line:
578
+ # The line data is empty, skip
579
+ continue
580
meta, _, path = line.partition("\x00")
581
path = path.rstrip("\x00")
582
a_blob_id: Optional[str]
test/test_diff.py
@@ -240,6 +240,12 @@ def test_diff_file_with_colon(self):
240
output = fixture("diff_file_with_colon")
241
res = []
242
Diff._handle_diff_line(output, None, res)
243
+ self.assertEqual(len(res), 3)
244
+
245
+ def test_empty_diff(self):
246
+ res = []
247
+ Diff._handle_diff_line(b"", None, res)
248
+ self.assertEqual(res, [])
249
250
def test_diff_initial_commit(self):
251
initial_commit = self.rorepo.commit("33ebe7acec14b25c5f84f35a664803fcab2f7781")
0 commit comments