@@ -120,7 +120,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
120
120
* list = NULL ;
121
121
for (;;) {
122
122
struct ref * ref ;
123
- unsigned char old_sha1 [ 20 ] ;
123
+ struct object_id old_oid ;
124
124
char * name ;
125
125
int len , name_len ;
126
126
char * buffer = packet_buffer ;
@@ -139,34 +139,36 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
139
139
if (len > 4 && skip_prefix (buffer , "ERR " , & arg ))
140
140
die ("remote error: %s" , arg );
141
141
142
- if (len == 48 && skip_prefix (buffer , "shallow " , & arg )) {
143
- if (get_sha1_hex (arg , old_sha1 ))
142
+ if (len == GIT_SHA1_HEXSZ + strlen ("shallow " ) &&
143
+ skip_prefix (buffer , "shallow " , & arg )) {
144
+ if (get_oid_hex (arg , & old_oid ))
144
145
die ("protocol error: expected shallow sha-1, got '%s'" , arg );
145
146
if (!shallow_points )
146
147
die ("repository on the other end cannot be shallow" );
147
- sha1_array_append (shallow_points , old_sha1 );
148
+ sha1_array_append (shallow_points , old_oid . hash );
148
149
continue ;
149
150
}
150
151
151
- if (len < 42 || get_sha1_hex (buffer , old_sha1 ) || buffer [40 ] != ' ' )
152
+ if (len < GIT_SHA1_HEXSZ + 2 || get_oid_hex (buffer , & old_oid ) ||
153
+ buffer [GIT_SHA1_HEXSZ ] != ' ' )
152
154
die ("protocol error: expected sha/ref, got '%s'" , buffer );
153
- name = buffer + 41 ;
155
+ name = buffer + GIT_SHA1_HEXSZ + 1 ;
154
156
155
157
name_len = strlen (name );
156
- if (len != name_len + 41 ) {
158
+ if (len != name_len + GIT_SHA1_HEXSZ + 1 ) {
157
159
free (server_capabilities );
158
160
server_capabilities = xstrdup (name + name_len + 1 );
159
161
}
160
162
161
163
if (extra_have && !strcmp (name , ".have" )) {
162
- sha1_array_append (extra_have , old_sha1 );
164
+ sha1_array_append (extra_have , old_oid . hash );
163
165
continue ;
164
166
}
165
167
166
168
if (!check_ref (name , flags ))
167
169
continue ;
168
- ref = alloc_ref (buffer + 41 );
169
- hashcpy ( ref -> old_oid . hash , old_sha1 );
170
+ ref = alloc_ref (buffer + GIT_SHA1_HEXSZ + 1 );
171
+ oidcpy ( & ref -> old_oid , & old_oid );
170
172
* list = ref ;
171
173
list = & ref -> next ;
172
174
got_at_least_one_head = 1 ;
0 commit comments