Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdb392ae

Browse files
committed
Fix bug where colons in paths raise aValueError ondiff() calls.
This commit introduces a potential fix for#1490 and#1483, in which an`invalid literal for int() with base 10: 'n'` exception was raisedwithin a diff operation. Within `_handle_diff_line()`, we split theoutput of `git diff-tree` on colons (`:` characters), under theassumption that there are no colons within the paths of the files beingdiffed. On POSIX systems this is not a valid assumption. The fix is tosplit on `\x00:`, since a null character always precedes the colons weactually need to split on.A test already existed for this case (`test_diff_file_with_colon()`),but it was marked as skipped.* Split on `\x00:` instead of `:` in `_handle_diff_line()`.* Unskip `test_diff_file_with_colon()`.
1 parentbec6157 commitdb392ae

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

‎git/diff.py

Lines changed: 4 additions & 1 deletion
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-
forlineinlines.split(":")[1:]:
573+
# Discard everything before the first colon, and the colon itself.
574+
_,_,lines=lines.partition(":")
575+
576+
forlineinlines.split("\x00:"):
574577
meta,_,path=line.partition("\x00")
575578
path=path.rstrip("\x00")
576579
a_blob_id:Optional[str]

‎test/test_diff.py

Lines changed: 0 additions & 1 deletion
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
deftest_diff_file_with_colon(self):
241240
output=fixture("diff_file_with_colon")
242241
res= []

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp