File tree 3 files changed +27
-0
lines changed
3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -565,6 +565,22 @@ Diff_len(Diff *self)
565
565
return (Py_ssize_t )git_diff_num_deltas (self -> diff );
566
566
}
567
567
568
+ PyDoc_STRVAR (Diff_patchid__doc__ ,
569
+ "Corresponding patchid." );
570
+
571
+ PyObject *
572
+ Diff_patchid__get__ (Diff * self )
573
+ {
574
+ git_oid oid ;
575
+ int err ;
576
+
577
+ err = git_diff_patchid (& oid , self -> diff , NULL );
578
+ if (err < 0 )
579
+ return Error_set (err );
580
+ return git_oid_to_python (& oid );
581
+ }
582
+
583
+
568
584
PyDoc_STRVAR (Diff_deltas__doc__ , "Iterate over the diff deltas." );
569
585
570
586
PyObject *
@@ -1024,6 +1040,7 @@ PyGetSetDef Diff_getsetters[] = {
1024
1040
GETTER (Diff , deltas ),
1025
1041
GETTER (Diff , patch ),
1026
1042
GETTER (Diff , stats ),
1043
+ GETTER (Diff , patchid ),
1027
1044
{NULL }
1028
1045
};
1029
1046
Original file line number Diff line number Diff line change 35
35
36
36
PyObject * Diff_changes (Diff * self );
37
37
PyObject * Diff_patch (Diff * self );
38
+ PyObject * Diff_patchid (Diff * self );
38
39
39
40
PyObject * wrap_diff (git_diff * diff , Repository * repo );
40
41
PyObject * wrap_diff_delta (const git_diff_delta * delta );
Original file line number Diff line number Diff line change 63
63
-c/d contents
64
64
"""
65
65
66
+ PATCHID = 'f31412498a17e6c3fbc635f2c5f9aa3ef4c1a9b7'
67
+
66
68
PATCH_BINARY = """diff --git a/binary_file b/binary_file
67
69
index 86e5c10..b835d73 100644
68
70
Binary files a/binary_file and b/binary_file differ
@@ -279,6 +281,13 @@ def test_diff_ids(self):
279
281
assert delta .old_file .id .hex == '7f129fd57e31e935c6d60a0c794efe4e6927664b'
280
282
assert delta .new_file .id .hex == 'af431f20fc541ed6d5afede3e2dc7160f6f01f16'
281
283
284
+ def test_diff_patchid (self ):
285
+ commit_a = self .repo [COMMIT_SHA1_1 ]
286
+ commit_b = self .repo [COMMIT_SHA1_2 ]
287
+ diff = commit_a .tree .diff_to_tree (commit_b .tree )
288
+ assert diff .patch == PATCH
289
+ assert diff .patchid .hex == PATCHID
290
+
282
291
def test_hunk_content (self ):
283
292
commit_a = self .repo [COMMIT_SHA1_1 ]
284
293
commit_b = self .repo [COMMIT_SHA1_2 ]
You can’t perform that action at this time.
0 commit comments