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

Commit1019d4c

Browse files
committed
diff: by limiting the splitcount to 5, a subtle bug was introduced as the newline at the end of the split line was not split away automatically. Added test for this, and the trivial fix
Wow, at least two people reviewd the code, but it slipped through anyway :)
1 parent600fcbc commit1019d4c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

‎lib/git/diff.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ def _index_from_raw_format(cls, repo, stream):
343343
continue
344344
# END its not a valid diff line
345345
old_mode,new_mode,a_blob_id,b_blob_id,change_type,path=line[1:].split(None,5)
346+
path=path.strip()
346347
a_path=path
347348
b_path=path
348349
deleted_file=False

‎test/git/test_diff.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,30 @@
88
fromgitimport*
99

1010
classTestDiff(TestBase):
11+
12+
def_assert_diff_format(self,diffs):
13+
# verify that the format of the diff is sane
14+
fordiffindiffs:
15+
ifdiff.a_blob:
16+
assertnotdiff.a_blob.path.endswith('\n')
17+
ifdiff.b_blob:
18+
assertnotdiff.b_blob.path.endswith('\n')
19+
# END for each diff
20+
returndiffs
1121

1222
deftest_list_from_string_new_mode(self):
1323
output=ListProcessAdapter(fixture('diff_new_mode'))
1424
diffs=Diff._index_from_patch_format(self.rorepo,output.stdout)
25+
self._assert_diff_format(diffs)
26+
1527
assert_equal(1,len(diffs))
1628
assert_equal(10,len(diffs[0].diff.splitlines()))
1729

1830
deftest_diff_with_rename(self):
1931
output=ListProcessAdapter(fixture('diff_rename'))
2032
diffs=Diff._index_from_patch_format(self.rorepo,output.stdout)
21-
33+
self._assert_diff_format(diffs)
34+
2235
assert_equal(1,len(diffs))
2336

2437
diff=diffs[0]
@@ -54,6 +67,7 @@ def test_diff_interface(self):
5467
assertisinstance(diff_index,DiffIndex)
5568

5669
ifdiff_index:
70+
self._assert_diff_format(diff_index)
5771
forctinDiffIndex.change_type:
5872
key='ct_%s'%ct
5973
assertion_map.setdefault(key,0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp