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

Commit85a5a8c

Browse files
committed
Fixed mode-handling in Diff creation, and added assertions to catch this in future
There is still some work todo in terms of how we handle the encoding
1 parent18caa61 commit85a5a8c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

‎git/diff.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,12 @@ def __init__(self, repo, a_path, b_path, a_blob_id, b_blob_id, a_mode,
217217
ifa_blob_idisNone:
218218
self.a_blob=None
219219
else:
220+
assertself.a_mode
220221
self.a_blob=Blob(repo,hex_to_bin(a_blob_id),mode=self.a_mode,path=a_path)
221222
ifb_blob_idisNone:
222223
self.b_blob=None
223224
else:
225+
assertself.b_mode
224226
self.b_blob=Blob(repo,hex_to_bin(b_blob_id),mode=self.b_mode,path=b_path)
225227

226228
self.new_file=new_file
@@ -313,8 +315,9 @@ def _index_from_patch_format(cls, repo, stream):
313315

314316
# Make sure the mode is set if the path is set. Otherwise the resulting blob is invalid
315317
# We just use the one mode we should have parsed
316-
index.append(Diff(repo,a_path,b_path,a_blob_id,b_blob_id,
317-
old_modeordeleted_file_modeorb_mode,new_modeornew_file_modeorb_mode,
318+
a_mode=old_modeordeleted_file_modeor (a_pathand (b_modeornew_modeornew_file_mode))
319+
b_mode=b_modeornew_modeornew_file_modeor (b_pathanda_mode)
320+
index.append(Diff(repo,a_path,b_path,a_blob_id,b_blob_id,a_mode,b_mode,
318321
new_file,deleted_file,rename_from,rename_to,None))
319322

320323
previous_header=header

‎git/test/test_diff.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_binary_diff(self):
7373
assertlen(list(res.iter_change_type('M')))==1
7474
ifres[0].diff:
7575
assertres[0].diff=="Binary files a/rps and b/rps differ\n","in patch mode, we get a diff text"
76-
assertisinstance(str(res[0]),str),"This call should just work"
76+
assertstr(res[0]),"This call should just work"
7777
# end for each method to test
7878

7979
deftest_diff_index(self):
@@ -82,6 +82,7 @@ def test_diff_index(self):
8282
assertlen(res)==6
8383
fordrinres:
8484
assertdr.diff
85+
assertstr(dr),"Diff to string conversion should be possible"
8586
# end for each diff
8687

8788
dr=res[3]
@@ -129,6 +130,9 @@ def test_diff_interface(self):
129130
assertlen(diff_set)==1
130131
assertdiff_index[0]==diff_index[0]
131132
assertnot (diff_index[0]!=diff_index[0])
133+
134+
fordrindiff_index:
135+
assertstr(dr),"Diff to string conversion should be possible"
132136
# END diff index checking
133137
# END for each patch option
134138
# END for each path option

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp