1
1
#include "builtin.h"
2
2
3
- static void flush_current_id (int patchlen , unsigned char * id , unsigned char * result )
3
+ static void flush_current_id (int patchlen , struct object_id * id , struct object_id * result )
4
4
{
5
5
char name [50 ];
6
6
7
7
if (!patchlen )
8
8
return ;
9
9
10
- memcpy (name , sha1_to_hex (id ), 41 );
11
- printf ("%s %s\n" , sha1_to_hex (result ), name );
10
+ memcpy (name , oid_to_hex (id ), GIT_SHA1_HEXSZ + 1 );
11
+ printf ("%s %s\n" , oid_to_hex (result ), name );
12
12
}
13
13
14
14
static int remove_space (char * line )
@@ -53,31 +53,31 @@ static int scan_hunk_header(const char *p, int *p_before, int *p_after)
53
53
return 1 ;
54
54
}
55
55
56
- static void flush_one_hunk (unsigned char * result , git_SHA_CTX * ctx )
56
+ static void flush_one_hunk (struct object_id * result , git_SHA_CTX * ctx )
57
57
{
58
- unsigned char hash [20 ];
58
+ unsigned char hash [GIT_SHA1_RAWSZ ];
59
59
unsigned short carry = 0 ;
60
60
int i ;
61
61
62
62
git_SHA1_Final (hash , ctx );
63
63
git_SHA1_Init (ctx );
64
64
/* 20-byte sum, with carry */
65
- for (i = 0 ; i < 20 ; ++ i ) {
66
- carry += result [i ] + hash [i ];
67
- result [i ] = carry ;
65
+ for (i = 0 ; i < GIT_SHA1_RAWSZ ; ++ i ) {
66
+ carry += result -> hash [i ] + hash [i ];
67
+ result -> hash [i ] = carry ;
68
68
carry >>= 8 ;
69
69
}
70
70
}
71
71
72
- static int get_one_patchid (unsigned char * next_sha1 , unsigned char * result ,
72
+ static int get_one_patchid (struct object_id * next_oid , struct object_id * result ,
73
73
struct strbuf * line_buf , int stable )
74
74
{
75
75
int patchlen = 0 , found_next = 0 ;
76
76
int before = -1 , after = -1 ;
77
77
git_SHA_CTX ctx ;
78
78
79
79
git_SHA1_Init (& ctx );
80
- hashclr (result );
80
+ oidclr (result );
81
81
82
82
while (strbuf_getwholeline (line_buf , stdin , '\n' ) != EOF ) {
83
83
char * line = line_buf -> buf ;
@@ -93,7 +93,7 @@ static int get_one_patchid(unsigned char *next_sha1, unsigned char *result,
93
93
else if (!memcmp (line , "\\ " , 2 ) && 12 < strlen (line ))
94
94
continue ;
95
95
96
- if (!get_sha1_hex (p , next_sha1 )) {
96
+ if (!get_oid_hex (p , next_oid )) {
97
97
found_next = 1 ;
98
98
break ;
99
99
}
@@ -143,7 +143,7 @@ static int get_one_patchid(unsigned char *next_sha1, unsigned char *result,
143
143
}
144
144
145
145
if (!found_next )
146
- hashclr ( next_sha1 );
146
+ oidclr ( next_oid );
147
147
148
148
flush_one_hunk (result , & ctx );
149
149
@@ -152,15 +152,15 @@ static int get_one_patchid(unsigned char *next_sha1, unsigned char *result,
152
152
153
153
static void generate_id_list (int stable )
154
154
{
155
- unsigned char sha1 [ 20 ] , n [ 20 ] , result [ 20 ] ;
155
+ struct object_id oid , n , result ;
156
156
int patchlen ;
157
157
struct strbuf line_buf = STRBUF_INIT ;
158
158
159
- hashclr ( sha1 );
159
+ oidclr ( & oid );
160
160
while (!feof (stdin )) {
161
- patchlen = get_one_patchid (n , result , & line_buf , stable );
162
- flush_current_id (patchlen , sha1 , result );
163
- hashcpy ( sha1 , n );
161
+ patchlen = get_one_patchid (& n , & result , & line_buf , stable );
162
+ flush_current_id (patchlen , & oid , & result );
163
+ oidcpy ( & oid , & n );
164
164
}
165
165
strbuf_release (& line_buf );
166
166
}
0 commit comments