Skip to content
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

Fix bug where colons in paths raise a ValueError on diff() calls. #1491

Merged
merged 1 commit into from
Sep 14, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,10 @@ def _index_from_patch_format(cls, repo: "Repo", proc: Union["Popen", "Git.AutoIn
def _handle_diff_line(lines_bytes: bytes, repo: "Repo", index: DiffIndex) -> None:
lines = lines_bytes.decode(defenc)

for line in lines.split(":")[1:]:
# Discard everything before the first colon, and the colon itself.
_, _, lines = lines.partition(":")

for line in lines.split("\x00:"):
meta, _, path = line.partition("\x00")
path = path.rstrip("\x00")
a_blob_id: Optional[str]
Expand Down
1 change: 0 additions & 1 deletion test/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ def test_diff_index_raw_format(self):
res[0].b_path,
)

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