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

Commit8324c4b

Browse files
committed
fix(diff): mode-assertions now deal with 0
If the file was not present, the mode seen in a diff can be legally '0',which previously caused an assertion to fail for no good reason.Now the assertion tests for None instead.Closes#323
1 parentc58887a commit8324c4b

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

‎git/diff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ def __init__(self, repo, a_path, b_path, a_blob_id, b_blob_id, a_mode,
223223
ifa_blob_idisNone:
224224
self.a_blob=None
225225
else:
226-
assertself.a_mode
226+
assertself.a_modeisnotNone
227227
self.a_blob=Blob(repo,hex_to_bin(a_blob_id),mode=self.a_mode,path=a_path)
228228
ifb_blob_idisNone:
229229
self.b_blob=None
230230
else:
231-
assertself.b_mode
231+
assertself.b_modeisnotNone
232232
self.b_blob=Blob(repo,hex_to_bin(b_blob_id),mode=self.b_mode,path=b_path)
233233

234234
self.new_file=new_file

‎git/test/test_diff.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55
# This module is part of GitPython and is released under
66
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
7+
importos
78

89
fromgit.test.libimport (
910
TestBase,
@@ -14,7 +15,11 @@
1415

1516
)
1617

18+
fromgitdb.test.libimportwith_rw_directory
19+
1720
fromgitimport (
21+
Repo,
22+
GitCommandError,
1823
Diff,
1924
DiffIndex
2025
)
@@ -37,6 +42,33 @@ def _assert_diff_format(self, diffs):
3742
# END for each diff
3843
returndiffs
3944

45+
@with_rw_directory
46+
deftest_diff_with_staged_file(self,rw_dir):
47+
# SETUP INDEX WITH MULTIPLE STAGES
48+
r=Repo.init(rw_dir)
49+
fp=os.path.join(rw_dir,'hello.txt')
50+
withopen(fp,'w')asfs:
51+
fs.write("hello world")
52+
r.git.add(fp)
53+
r.git.commit(message="init")
54+
55+
withopen(fp,'w')asfs:
56+
fs.write("Hola Mundo")
57+
r.git.commit(all=True,message="change on master")
58+
59+
r.git.checkout('HEAD~1',b='topic')
60+
withopen(fp,'w')asfs:
61+
fs.write("Hallo Welt")
62+
r.git.commit(all=True,message="change on topic branch")
63+
64+
# there must be a merge-conflict
65+
self.failUnlessRaises(GitCommandError,r.git.cherry_pick,'master')
66+
67+
# Now do the actual testing - this should just work
68+
assertlen(r.index.diff(None))==2
69+
70+
assertlen(r.index.diff(None,create_patch=True))==0,"This should work, but doesn't right now ... it's OK"
71+
4072
deftest_list_from_string_new_mode(self):
4173
output=StringProcessAdapter(fixture('diff_new_mode'))
4274
diffs=Diff._index_from_patch_format(self.rorepo,output.stdout)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp