@@ -120,7 +120,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
120120 * list = NULL ;
121121 for (;;) {
122122 struct ref * ref ;
123- unsigned char old_sha1 [ 20 ] ;
123+ struct object_id old_oid ;
124124 char * name ;
125125 int len , name_len ;
126126 char * buffer = packet_buffer ;
@@ -139,34 +139,36 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
139139 if (len > 4 && skip_prefix (buffer , "ERR " , & arg ))
140140 die ("remote error: %s" , arg );
141141
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 ))
144145 die ("protocol error: expected shallow sha-1, got '%s'" , arg );
145146 if (!shallow_points )
146147 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 );
148149 continue ;
149150 }
150151
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 ] != ' ' )
152154 die ("protocol error: expected sha/ref, got '%s'" , buffer );
153- name = buffer + 41 ;
155+ name = buffer + GIT_SHA1_HEXSZ + 1 ;
154156
155157 name_len = strlen (name );
156- if (len != name_len + 41 ) {
158+ if (len != name_len + GIT_SHA1_HEXSZ + 1 ) {
157159 free (server_capabilities );
158160 server_capabilities = xstrdup (name + name_len + 1 );
159161 }
160162
161163 if (extra_have && !strcmp (name , ".have" )) {
162- sha1_array_append (extra_have , old_sha1 );
164+ sha1_array_append (extra_have , old_oid . hash );
163165 continue ;
164166 }
165167
166168 if (!check_ref (name , flags ))
167169 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 );
170172 * list = ref ;
171173 list = & ref -> next ;
172174 got_at_least_one_head = 1 ;
0 commit comments