File tree Expand file tree Collapse file tree 2 files changed +36
-6
lines changed Expand file tree Collapse file tree 2 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -968,7 +968,7 @@ def parse_git_binary_diff(text):
968968 continue
969969 elif new_size > 0 :
970970 if base85string .match (line ):
971- assert len (line ) >= 7 and ((len (line ) - 2 ) % 5 ) ! = 0
971+ assert len (line ) >= 6 and ((len (line ) - 1 ) % 5 ) = = 0
972972 new_encoded += line [1 :]
973973 elif 0 == len (line ):
974974 decoded = base64 .b85decode (new_encoded )
@@ -992,7 +992,7 @@ def parse_git_binary_diff(text):
992992 continue
993993 elif old_size > 0 :
994994 if base85string .match (line ):
995- assert len (line ) >= 7 and ((len (line ) - 2 ) % 5 ) ! = 0
995+ assert len (line ) >= 6 and ((len (line ) - 1 ) % 5 ) = = 0
996996 old_encoded += line [1 :]
997997 elif 0 == len (line ):
998998 decoded = base64 .b85decode (old_encoded )
Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
2-
2+ import hashlib
33import os
44import time
55import unittest
@@ -1512,9 +1512,7 @@ def test_git_bin_patch(self):
15121512zo-D+utS58IOJh^YyS&Z2axbtg=}i7x*!zt+z?+dtjv0#|C#NtfGku7f+{viO<^}XH
15131513G0|Nj=Vq`=B
15141514
1515- --
1516- 2.25.1
1517- """
1515+ --"""
15181516 result = list (wtp .patch .parse_patch (text ))
15191517 assert result
15201518 assert len (result ) == 4
@@ -1538,6 +1536,38 @@ def test_git_bin_patch(self):
15381536 )
15391537 assert len (result [3 ].changes ) == 0
15401538
1539+ def test_git_bin_patch_minline (self ):
1540+ # test path with minimal line in binary diff
1541+ text = """---
1542+ 95 | Bin 94 -> 95 bytes
1543+ 1 files changed, 0 insertions(+), 0 deletions(-)
1544+
1545+ diff --git a/95 b/95
1546+ index cf104291536b187e299023ae37523f4649ca0600..edf50979da25419fbb399ffa6b93142e50dbbba7 100644
1547+ GIT binary patch
1548+ literal 95
1549+ zcmV-l0HFT>FaHM=!1loEo7=$@IDCW@J2o!_PR6;*Rs73Fmit;^XEfl3aOa~j;?1+w
1550+ z`|Sh7<pH~|jb8KHD!MpYia}Lyu+Ot@)&HI>XeZ(}tCx^}pPZlER5Jer^*}gX^QK-R
1551+ BGb8{2
1552+
1553+ literal 94
1554+ zcmV-k0HObM)Jh!P2BexYI{K1M2*Xhjg<rBg95P)btB3SD62E>3TEDprVXYw<r9s|q
1555+ z3<q^r!wu=+9KVuWwwGi0e7gXw>S|c&%Px9;9nEE3cL}-^F2dKtTQun3NbDG}SFOY=
1556+ AaR2}S
1557+
1558+ --"""
1559+ result = list (wtp .patch .parse_patch (text ))
1560+ assert result
1561+ assert len (result ) == 1
1562+ assert (
1563+ hashlib .sha1 (result [0 ].changes [0 ].line ).hexdigest ()
1564+ == "732e7e005ff8b71ab4b72398db0320f2fa012b81"
1565+ )
1566+ assert (
1567+ hashlib .sha1 (result [0 ].changes [1 ].hunk ).hexdigest ()
1568+ == "b07b94142cfce2094b5be04e9d30b653a7c63917"
1569+ )
1570+
15411571
15421572if __name__ == "__main__" :
15431573 unittest .main ()
You can’t perform that action at this time.
0 commit comments