@@ -118,9 +118,9 @@ static void rev_list_push(struct commit *commit, int mark)
118118 }
119119}
120120
121- static int rev_list_insert_ref (const char * refname , const unsigned char * sha1 )
121+ static int rev_list_insert_ref (const char * refname , const struct object_id * oid )
122122{
123- struct object * o = deref_tag (parse_object (sha1 ), refname , 0 );
123+ struct object * o = deref_tag (parse_object (oid -> hash ), refname , 0 );
124124
125125 if (o && o -> type == OBJ_COMMIT )
126126 rev_list_push ((struct commit * )o , SEEN );
@@ -131,7 +131,7 @@ static int rev_list_insert_ref(const char *refname, const unsigned char *sha1)
131131static int rev_list_insert_ref_oid (const char * refname , const struct object_id * oid ,
132132 int flag , void * cb_data )
133133{
134- return rev_list_insert_ref (refname , oid -> hash );
134+ return rev_list_insert_ref (refname , oid );
135135}
136136
137137static int clear_marks (const char * refname , const struct object_id * oid ,
@@ -183,7 +183,7 @@ static void mark_common(struct commit *commit,
183183 Get the next rev to send, ignoring the common.
184184*/
185185
186- static const unsigned char * get_rev (void )
186+ static const struct object_id * get_rev (void )
187187{
188188 struct commit * commit = NULL ;
189189
@@ -222,7 +222,7 @@ static const unsigned char *get_rev(void)
222222 }
223223 }
224224
225- return commit -> object .oid . hash ;
225+ return & commit -> object .oid ;
226226}
227227
228228enum ack_type {
@@ -251,7 +251,7 @@ static void consume_shallow_list(struct fetch_pack_args *args, int fd)
251251 }
252252}
253253
254- static enum ack_type get_ack (int fd , unsigned char * result_sha1 )
254+ static enum ack_type get_ack (int fd , struct object_id * result_oid )
255255{
256256 int len ;
257257 char * line = packet_read_line (fd , & len );
@@ -262,7 +262,7 @@ static enum ack_type get_ack(int fd, unsigned char *result_sha1)
262262 if (!strcmp (line , "NAK" ))
263263 return NAK ;
264264 if (skip_prefix (line , "ACK " , & arg )) {
265- if (!get_sha1_hex (arg , result_sha1 )) {
265+ if (!get_oid_hex (arg , result_oid )) {
266266 arg += 40 ;
267267 len -= arg - line ;
268268 if (len < 1 )
@@ -293,7 +293,7 @@ static void send_request(struct fetch_pack_args *args,
293293
294294static void insert_one_alternate_object (struct object * obj )
295295{
296- rev_list_insert_ref (NULL , obj -> oid . hash );
296+ rev_list_insert_ref (NULL , & obj -> oid );
297297}
298298
299299#define INITIAL_FLUSH 16
@@ -317,12 +317,12 @@ static int next_flush(struct fetch_pack_args *args, int count)
317317}
318318
319319static int find_common (struct fetch_pack_args * args ,
320- int fd [2 ], unsigned char * result_sha1 ,
320+ int fd [2 ], struct object_id * result_oid ,
321321 struct ref * refs )
322322{
323323 int fetching ;
324324 int count = 0 , flushes = 0 , flush_at = INITIAL_FLUSH , retval ;
325- const unsigned char * sha1 ;
325+ const struct object_id * oid ;
326326 unsigned in_vain = 0 ;
327327 int got_continue = 0 ;
328328 int got_ready = 0 ;
@@ -340,7 +340,7 @@ static int find_common(struct fetch_pack_args *args,
340340
341341 fetching = 0 ;
342342 for ( ; refs ; refs = refs -> next ) {
343- unsigned char * remote = refs -> old_oid . hash ;
343+ struct object_id * remote = & refs -> old_oid ;
344344 const char * remote_hex ;
345345 struct object * o ;
346346
@@ -354,12 +354,12 @@ static int find_common(struct fetch_pack_args *args,
354354 * interested in the case we *know* the object is
355355 * reachable and we have already scanned it.
356356 */
357- if (((o = lookup_object (remote )) != NULL ) &&
357+ if (((o = lookup_object (remote -> hash )) != NULL ) &&
358358 (o -> flags & COMPLETE )) {
359359 continue ;
360360 }
361361
362- remote_hex = sha1_to_hex (remote );
362+ remote_hex = oid_to_hex (remote );
363363 if (!fetching ) {
364364 struct strbuf c = STRBUF_INIT ;
365365 if (multi_ack == 2 ) strbuf_addstr (& c , " multi_ack_detailed" );
@@ -410,25 +410,25 @@ static int find_common(struct fetch_pack_args *args,
410410 if (args -> deepen ) {
411411 char * line ;
412412 const char * arg ;
413- unsigned char sha1 [ 20 ] ;
413+ struct object_id oid ;
414414
415415 send_request (args , fd [1 ], & req_buf );
416416 while ((line = packet_read_line (fd [0 ], NULL ))) {
417417 if (skip_prefix (line , "shallow " , & arg )) {
418- if (get_sha1_hex (arg , sha1 ))
418+ if (get_oid_hex (arg , & oid ))
419419 die (_ ("invalid shallow line: %s" ), line );
420- register_shallow (sha1 );
420+ register_shallow (oid . hash );
421421 continue ;
422422 }
423423 if (skip_prefix (line , "unshallow " , & arg )) {
424- if (get_sha1_hex (arg , sha1 ))
424+ if (get_oid_hex (arg , & oid ))
425425 die (_ ("invalid unshallow line: %s" ), line );
426- if (!lookup_object (sha1 ))
426+ if (!lookup_object (oid . hash ))
427427 die (_ ("object not found: %s" ), line );
428428 /* make sure that it is parsed as shallow */
429- if (!parse_object (sha1 ))
429+ if (!parse_object (oid . hash ))
430430 die (_ ("error in object: %s" ), line );
431- if (unregister_shallow (sha1 ))
431+ if (unregister_shallow (oid . hash ))
432432 die (_ ("no shallow found: %s" ), line );
433433 continue ;
434434 }
@@ -447,9 +447,9 @@ static int find_common(struct fetch_pack_args *args,
447447
448448 flushes = 0 ;
449449 retval = -1 ;
450- while ((sha1 = get_rev ())) {
451- packet_buf_write (& req_buf , "have %s\n" , sha1_to_hex ( sha1 ));
452- print_verbose (args , "have %s" , sha1_to_hex ( sha1 ));
450+ while ((oid = get_rev ())) {
451+ packet_buf_write (& req_buf , "have %s\n" , oid_to_hex ( oid ));
452+ print_verbose (args , "have %s" , oid_to_hex ( oid ));
453453 in_vain ++ ;
454454 if (flush_at <= ++ count ) {
455455 int ack ;
@@ -469,10 +469,10 @@ static int find_common(struct fetch_pack_args *args,
469469
470470 consume_shallow_list (args , fd [0 ]);
471471 do {
472- ack = get_ack (fd [0 ], result_sha1 );
472+ ack = get_ack (fd [0 ], result_oid );
473473 if (ack )
474474 print_verbose (args , _ ("got %s %d %s" ), "ack" ,
475- ack , sha1_to_hex ( result_sha1 ));
475+ ack , oid_to_hex ( result_oid ));
476476 switch (ack ) {
477477 case ACK :
478478 flushes = 0 ;
@@ -483,17 +483,17 @@ static int find_common(struct fetch_pack_args *args,
483483 case ACK_ready :
484484 case ACK_continue : {
485485 struct commit * commit =
486- lookup_commit (result_sha1 );
486+ lookup_commit (result_oid -> hash );
487487 if (!commit )
488- die (_ ("invalid commit %s" ), sha1_to_hex ( result_sha1 ));
488+ die (_ ("invalid commit %s" ), oid_to_hex ( result_oid ));
489489 if (args -> stateless_rpc
490490 && ack == ACK_common
491491 && !(commit -> object .flags & COMMON )) {
492492 /* We need to replay the have for this object
493493 * on the next RPC request so the peer knows
494494 * it is in common with us.
495495 */
496- const char * hex = sha1_to_hex ( result_sha1 );
496+ const char * hex = oid_to_hex ( result_oid );
497497 packet_buf_write (& req_buf , "have %s\n" , hex );
498498 state_len = req_buf .len ;
499499 /*
@@ -538,10 +538,10 @@ static int find_common(struct fetch_pack_args *args,
538538 if (!got_ready || !no_done )
539539 consume_shallow_list (args , fd [0 ]);
540540 while (flushes || multi_ack ) {
541- int ack = get_ack (fd [0 ], result_sha1 );
541+ int ack = get_ack (fd [0 ], result_oid );
542542 if (ack ) {
543543 print_verbose (args , _ ("got %s (%d) %s" ), "ack" ,
544- ack , sha1_to_hex ( result_sha1 ));
544+ ack , oid_to_hex ( result_oid ));
545545 if (ack == ACK )
546546 return 0 ;
547547 multi_ack = 1 ;
@@ -555,9 +555,9 @@ static int find_common(struct fetch_pack_args *args,
555555
556556static struct commit_list * complete ;
557557
558- static int mark_complete (const unsigned char * sha1 )
558+ static int mark_complete (const struct object_id * oid )
559559{
560- struct object * o = parse_object (sha1 );
560+ struct object * o = parse_object (oid -> hash );
561561
562562 while (o && o -> type == OBJ_TAG ) {
563563 struct tag * t = (struct tag * ) o ;
@@ -579,7 +579,7 @@ static int mark_complete(const unsigned char *sha1)
579579static int mark_complete_oid (const char * refname , const struct object_id * oid ,
580580 int flag , void * cb_data )
581581{
582- return mark_complete (oid -> hash );
582+ return mark_complete (oid );
583583}
584584
585585static void mark_recent_complete_commits (struct fetch_pack_args * args ,
@@ -637,14 +637,15 @@ static void filter_refs(struct fetch_pack_args *args,
637637
638638 /* Append unmatched requests to the list */
639639 for (i = 0 ; i < nr_sought ; i ++ ) {
640- unsigned char sha1 [20 ];
640+ struct object_id oid ;
641+ const char * p ;
641642
642643 ref = sought [i ];
643644 if (ref -> match_status != REF_NOT_MATCHED )
644645 continue ;
645- if (get_sha1_hex (ref -> name , sha1 ) ||
646- ref -> name [ 40 ] != '\0' ||
647- hashcmp ( sha1 , ref -> old_oid . hash ))
646+ if (parse_oid_hex (ref -> name , & oid , & p ) ||
647+ * p != '\0' ||
648+ oidcmp ( & oid , & ref -> old_oid ))
648649 continue ;
649650
650651 if ((allow_unadvertised_object_request &
@@ -661,7 +662,7 @@ static void filter_refs(struct fetch_pack_args *args,
661662
662663static void mark_alternate_complete (struct object * obj )
663664{
664- mark_complete (obj -> oid . hash );
665+ mark_complete (& obj -> oid );
665666}
666667
667668static int everything_local (struct fetch_pack_args * args ,
@@ -724,17 +725,17 @@ static int everything_local(struct fetch_pack_args *args,
724725 filter_refs (args , refs , sought , nr_sought );
725726
726727 for (retval = 1 , ref = * refs ; ref ; ref = ref -> next ) {
727- const unsigned char * remote = ref -> old_oid . hash ;
728+ const struct object_id * remote = & ref -> old_oid ;
728729 struct object * o ;
729730
730- o = lookup_object (remote );
731+ o = lookup_object (remote -> hash );
731732 if (!o || !(o -> flags & COMPLETE )) {
732733 retval = 0 ;
733- print_verbose (args , "want %s (%s)" , sha1_to_hex (remote ),
734+ print_verbose (args , "want %s (%s)" , oid_to_hex (remote ),
734735 ref -> name );
735736 continue ;
736737 }
737- print_verbose (args , _ ("already have %s (%s)" ), sha1_to_hex (remote ),
738+ print_verbose (args , _ ("already have %s (%s)" ), oid_to_hex (remote ),
738739 ref -> name );
739740 }
740741 return retval ;
@@ -873,7 +874,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
873874 char * * pack_lockfile )
874875{
875876 struct ref * ref = copy_ref_list (orig_ref );
876- unsigned char sha1 [ 20 ] ;
877+ struct object_id oid ;
877878 const char * agent_feature ;
878879 int agent_len ;
879880
@@ -945,7 +946,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
945946 packet_flush (fd [1 ]);
946947 goto all_done ;
947948 }
948- if (find_common (args , fd , sha1 , ref ) < 0 )
949+ if (find_common (args , fd , & oid , ref ) < 0 )
949950 if (!args -> keep_pack )
950951 /* When cloning, it is not unusual to have
951952 * no common commit.
0 commit comments