File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,12 @@ PyTypeObject DiffIterType = {
271271 (iternextfunc ) DiffIter_iternext , /* tp_iternext */
272272};
273273
274+ Py_ssize_t
275+ Diff_len (Diff * self )
276+ {
277+ assert (self -> list );
278+ return (Py_ssize_t )git_diff_num_deltas (self -> list );
279+ }
274280
275281PyDoc_STRVAR (Diff_patch__doc__ , "Patch diff string." );
276282
@@ -466,7 +472,7 @@ PyGetSetDef Diff_getseters[] = {
466472};
467473
468474PyMappingMethods Diff_as_mapping = {
469- 0 , /* mp_length */
475+ ( lenfunc ) Diff_len , /* mp_length */
470476 (binaryfunc )Diff_getitem , /* mp_subscript */
471477 0 , /* mp_ass_subscript */
472478};
Original file line number Diff line number Diff line change @@ -255,6 +255,7 @@ def test_diff_patch(self):
255255
256256 diff = commit_a .tree .diff_to_tree (commit_b .tree )
257257 self .assertEqual (diff .patch , PATCH )
258+ self .assertEqual (len (diff ), len ([patch for patch in diff ]))
258259
259260 def test_diff_oids (self ):
260261 commit_a = self .repo [COMMIT_SHA1_1 ]
You can’t perform that action at this time.
0 commit comments