1212
1313static const char bundle_signature [] = "# v2 git bundle\n" ;
1414
15- static void add_to_ref_list (const unsigned char * sha1 , const char * name ,
15+ static void add_to_ref_list (const struct object_id * oid , const char * name ,
1616 struct ref_list * list )
1717{
1818 ALLOC_GROW (list -> list , list -> nr + 1 , list -> alloc );
19- hashcpy ( list -> list [list -> nr ].sha1 , sha1 );
19+ oidcpy ( & list -> list [list -> nr ].oid , oid );
2020 list -> list [list -> nr ].name = xstrdup (name );
2121 list -> nr ++ ;
2222}
@@ -40,8 +40,9 @@ static int parse_bundle_header(int fd, struct bundle_header *header,
4040 /* The bundle header ends with an empty line */
4141 while (!strbuf_getwholeline_fd (& buf , fd , '\n' ) &&
4242 buf .len && buf .buf [0 ] != '\n' ) {
43- unsigned char sha1 [ 20 ] ;
43+ struct object_id oid ;
4444 int is_prereq = 0 ;
45+ const char * p ;
4546
4647 if (* buf .buf == '-' ) {
4748 is_prereq = 1 ;
@@ -54,19 +55,19 @@ static int parse_bundle_header(int fd, struct bundle_header *header,
5455 * Prerequisites have object name that is optionally
5556 * followed by SP and subject line.
5657 */
57- if (get_sha1_hex (buf .buf , sha1 ) ||
58- (buf . len > 40 && !isspace (buf . buf [ 40 ] )) ||
59- (!is_prereq && buf . len <= 40 )) {
58+ if (parse_oid_hex (buf .buf , & oid , & p ) ||
59+ (* p && !isspace (* p )) ||
60+ (!is_prereq && ! * p )) {
6061 if (report_path )
6162 error (_ ("unrecognized header: %s%s (%d)" ),
6263 (is_prereq ? "-" : "" ), buf .buf , (int )buf .len );
6364 status = -1 ;
6465 break ;
6566 } else {
6667 if (is_prereq )
67- add_to_ref_list (sha1 , "" , & header -> prerequisites );
68+ add_to_ref_list (& oid , "" , & header -> prerequisites );
6869 else
69- add_to_ref_list (sha1 , buf . buf + 41 , & header -> references );
70+ add_to_ref_list (& oid , p + 1 , & header -> references );
7071 }
7172 }
7273
@@ -115,7 +116,7 @@ static int list_refs(struct ref_list *r, int argc, const char **argv)
115116 if (j == argc )
116117 continue ;
117118 }
118- printf ("%s %s\n" , sha1_to_hex ( r -> list [i ].sha1 ),
119+ printf ("%s %s\n" , oid_to_hex ( & r -> list [i ].oid ),
119120 r -> list [i ].name );
120121 }
121122 return 0 ;
@@ -141,15 +142,15 @@ int verify_bundle(struct bundle_header *header, int verbose)
141142 init_revisions (& revs , NULL );
142143 for (i = 0 ; i < p -> nr ; i ++ ) {
143144 struct ref_list_entry * e = p -> list + i ;
144- struct object * o = parse_object (e -> sha1 );
145+ struct object * o = parse_object (e -> oid . hash );
145146 if (o ) {
146147 o -> flags |= PREREQ_MARK ;
147148 add_pending_object (& revs , o , e -> name );
148149 continue ;
149150 }
150151 if (++ ret == 1 )
151152 error ("%s" , message );
152- error ("%s %s" , sha1_to_hex ( e -> sha1 ), e -> name );
153+ error ("%s %s" , oid_to_hex ( & e -> oid ), e -> name );
153154 }
154155 if (revs .pending .nr != p -> nr )
155156 return ret ;
@@ -285,16 +286,16 @@ static int compute_and_write_prerequisites(int bundle_fd,
285286 return -1 ;
286287 rls_fout = xfdopen (rls .out , "r" );
287288 while (strbuf_getwholeline (& buf , rls_fout , '\n' ) != EOF ) {
288- unsigned char sha1 [ 20 ] ;
289+ struct object_id oid ;
289290 if (buf .len > 0 && buf .buf [0 ] == '-' ) {
290291 write_or_die (bundle_fd , buf .buf , buf .len );
291- if (!get_sha1_hex (buf .buf + 1 , sha1 )) {
292- struct object * object = parse_object_or_die (sha1 , buf .buf );
292+ if (!get_oid_hex (buf .buf + 1 , & oid )) {
293+ struct object * object = parse_object_or_die (oid . hash , buf .buf );
293294 object -> flags |= UNINTERESTING ;
294295 add_pending_object (revs , object , buf .buf );
295296 }
296- } else if (!get_sha1_hex (buf .buf , sha1 )) {
297- struct object * object = parse_object_or_die (sha1 , buf .buf );
297+ } else if (!get_oid_hex (buf .buf , & oid )) {
298+ struct object * object = parse_object_or_die (oid . hash , buf .buf );
298299 object -> flags |= SHOWN ;
299300 }
300301 }
0 commit comments