@@ -106,12 +106,14 @@ static void *get_delta(struct object_entry *entry)
106106 void * buf , * base_buf , * delta_buf ;
107107 enum object_type type ;
108108
109- buf = read_sha1_file (entry -> idx .sha1 , & type , & size );
109+ buf = read_sha1_file (entry -> idx .oid . hash , & type , & size );
110110 if (!buf )
111- die ("unable to read %s" , sha1_to_hex (entry -> idx .sha1 ));
112- base_buf = read_sha1_file (entry -> delta -> idx .sha1 , & type , & base_size );
111+ die ("unable to read %s" , oid_to_hex (& entry -> idx .oid ));
112+ base_buf = read_sha1_file (entry -> delta -> idx .oid .hash , & type ,
113+ & base_size );
113114 if (!base_buf )
114- die ("unable to read %s" , sha1_to_hex (entry -> delta -> idx .sha1 ));
115+ die ("unable to read %s" ,
116+ oid_to_hex (& entry -> delta -> idx .oid ));
115117 delta_buf = diff_delta (base_buf , base_size ,
116118 buf , size , & delta_size , 0 );
117119 if (!delta_buf || delta_size != entry -> delta_size )
@@ -249,12 +251,14 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
249251 if (!usable_delta ) {
250252 if (entry -> type == OBJ_BLOB &&
251253 entry -> size > big_file_threshold &&
252- (st = open_istream (entry -> idx .sha1 , & type , & size , NULL )) != NULL )
254+ (st = open_istream (entry -> idx .oid . hash , & type , & size , NULL )) != NULL )
253255 buf = NULL ;
254256 else {
255- buf = read_sha1_file (entry -> idx .sha1 , & type , & size );
257+ buf = read_sha1_file (entry -> idx .oid .hash , & type ,
258+ & size );
256259 if (!buf )
257- die (_ ("unable to read %s" ), sha1_to_hex (entry -> idx .sha1 ));
260+ die (_ ("unable to read %s" ),
261+ oid_to_hex (& entry -> idx .oid ));
258262 }
259263 /*
260264 * make sure no cached delta data remains from a
@@ -322,7 +326,7 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
322326 return 0 ;
323327 }
324328 sha1write (f , header , hdrlen );
325- sha1write (f , entry -> delta -> idx .sha1 , 20 );
329+ sha1write (f , entry -> delta -> idx .oid . hash , 20 );
326330 hdrlen += 20 ;
327331 } else {
328332 if (limit && hdrlen + datalen + 20 >= limit ) {
@@ -334,7 +338,7 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
334338 sha1write (f , header , hdrlen );
335339 }
336340 if (st ) {
337- datalen = write_large_blob_data (st , f , entry -> idx .sha1 );
341+ datalen = write_large_blob_data (st , f , entry -> idx .oid . hash );
338342 close_istream (st );
339343 } else {
340344 sha1write (f , buf , datalen );
@@ -369,7 +373,8 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
369373 datalen = revidx [1 ].offset - offset ;
370374 if (!pack_to_stdout && p -> index_version > 1 &&
371375 check_pack_crc (p , & w_curs , offset , datalen , revidx -> nr )) {
372- error ("bad packed object CRC for %s" , sha1_to_hex (entry -> idx .sha1 ));
376+ error ("bad packed object CRC for %s" ,
377+ oid_to_hex (& entry -> idx .oid ));
373378 unuse_pack (& w_curs );
374379 return write_no_reuse_object (f , entry , limit , usable_delta );
375380 }
@@ -379,7 +384,8 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
379384
380385 if (!pack_to_stdout && p -> index_version == 1 &&
381386 check_pack_inflate (p , & w_curs , offset , datalen , entry -> size )) {
382- error ("corrupt packed object for %s" , sha1_to_hex (entry -> idx .sha1 ));
387+ error ("corrupt packed object for %s" ,
388+ oid_to_hex (& entry -> idx .oid ));
383389 unuse_pack (& w_curs );
384390 return write_no_reuse_object (f , entry , limit , usable_delta );
385391 }
@@ -404,7 +410,7 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
404410 return 0 ;
405411 }
406412 sha1write (f , header , hdrlen );
407- sha1write (f , entry -> delta -> idx .sha1 , 20 );
413+ sha1write (f , entry -> delta -> idx .oid . hash , 20 );
408414 hdrlen += 20 ;
409415 reused_delta ++ ;
410416 } else {
@@ -509,7 +515,7 @@ static enum write_one_status write_one(struct sha1file *f,
509515 recursing = (e -> idx .offset == 1 );
510516 if (recursing ) {
511517 warning ("recursive delta detected for object %s" ,
512- sha1_to_hex ( e -> idx .sha1 ));
518+ oid_to_hex ( & e -> idx .oid ));
513519 return WRITE_ONE_RECURSIVE ;
514520 } else if (e -> idx .offset || e -> preferred_base ) {
515521 /* offset is non zero if object is written already. */
@@ -1432,7 +1438,7 @@ static void check_object(struct object_entry *entry)
14321438 ofs += 1 ;
14331439 if (!ofs || MSB (ofs , 7 )) {
14341440 error ("delta base offset overflow in pack for %s" ,
1435- sha1_to_hex ( entry -> idx .sha1 ));
1441+ oid_to_hex ( & entry -> idx .oid ));
14361442 goto give_up ;
14371443 }
14381444 c = buf [used_0 ++ ];
@@ -1441,7 +1447,7 @@ static void check_object(struct object_entry *entry)
14411447 ofs = entry -> in_pack_offset - ofs ;
14421448 if (ofs <= 0 || ofs >= entry -> in_pack_offset ) {
14431449 error ("delta base offset out of bound for %s" ,
1444- sha1_to_hex ( entry -> idx .sha1 ));
1450+ oid_to_hex ( & entry -> idx .oid ));
14451451 goto give_up ;
14461452 }
14471453 if (reuse_delta && !entry -> preferred_base ) {
@@ -1498,7 +1504,7 @@ static void check_object(struct object_entry *entry)
14981504 unuse_pack (& w_curs );
14991505 }
15001506
1501- entry -> type = sha1_object_info (entry -> idx .sha1 , & entry -> size );
1507+ entry -> type = sha1_object_info (entry -> idx .oid . hash , & entry -> size );
15021508 /*
15031509 * The error condition is checked in prepare_pack(). This is
15041510 * to permit a missing preferred base object to be ignored
@@ -1514,7 +1520,7 @@ static int pack_offset_sort(const void *_a, const void *_b)
15141520
15151521 /* avoid filesystem trashing with loose objects */
15161522 if (!a -> in_pack && !b -> in_pack )
1517- return hashcmp ( a -> idx .sha1 , b -> idx .sha1 );
1523+ return oidcmp ( & a -> idx .oid , & b -> idx .oid );
15181524
15191525 if (a -> in_pack < b -> in_pack )
15201526 return -1 ;
@@ -1560,7 +1566,8 @@ static void drop_reused_delta(struct object_entry *entry)
15601566 * And if that fails, the error will be recorded in entry->type
15611567 * and dealt with in prepare_pack().
15621568 */
1563- entry -> type = sha1_object_info (entry -> idx .sha1 , & entry -> size );
1569+ entry -> type = sha1_object_info (entry -> idx .oid .hash ,
1570+ & entry -> size );
15641571 }
15651572}
15661573
@@ -1852,26 +1859,29 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
18521859 /* Load data if not already done */
18531860 if (!trg -> data ) {
18541861 read_lock ();
1855- trg -> data = read_sha1_file (trg_entry -> idx .sha1 , & type , & sz );
1862+ trg -> data = read_sha1_file (trg_entry -> idx .oid .hash , & type ,
1863+ & sz );
18561864 read_unlock ();
18571865 if (!trg -> data )
18581866 die ("object %s cannot be read" ,
1859- sha1_to_hex ( trg_entry -> idx .sha1 ));
1867+ oid_to_hex ( & trg_entry -> idx .oid ));
18601868 if (sz != trg_size )
18611869 die ("object %s inconsistent object length (%lu vs %lu)" ,
1862- sha1_to_hex (trg_entry -> idx .sha1 ), sz , trg_size );
1870+ oid_to_hex (& trg_entry -> idx .oid ), sz ,
1871+ trg_size );
18631872 * mem_usage += sz ;
18641873 }
18651874 if (!src -> data ) {
18661875 read_lock ();
1867- src -> data = read_sha1_file (src_entry -> idx .sha1 , & type , & sz );
1876+ src -> data = read_sha1_file (src_entry -> idx .oid .hash , & type ,
1877+ & sz );
18681878 read_unlock ();
18691879 if (!src -> data ) {
18701880 if (src_entry -> preferred_base ) {
18711881 static int warned = 0 ;
18721882 if (!warned ++ )
18731883 warning ("object %s cannot be read" ,
1874- sha1_to_hex ( src_entry -> idx .sha1 ));
1884+ oid_to_hex ( & src_entry -> idx .oid ));
18751885 /*
18761886 * Those objects are not included in the
18771887 * resulting pack. Be resilient and ignore
@@ -1881,11 +1891,12 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
18811891 return 0 ;
18821892 }
18831893 die ("object %s cannot be read" ,
1884- sha1_to_hex ( src_entry -> idx .sha1 ));
1894+ oid_to_hex ( & src_entry -> idx .oid ));
18851895 }
18861896 if (sz != src_size )
18871897 die ("object %s inconsistent object length (%lu vs %lu)" ,
1888- sha1_to_hex (src_entry -> idx .sha1 ), sz , src_size );
1898+ oid_to_hex (& src_entry -> idx .oid ), sz ,
1899+ src_size );
18891900 * mem_usage += sz ;
18901901 }
18911902 if (!src -> index ) {
@@ -2406,7 +2417,7 @@ static void prepare_pack(int window, int depth)
24062417 nr_deltas ++ ;
24072418 if (entry -> type < 0 )
24082419 die ("unable to get type of object %s" ,
2409- sha1_to_hex ( entry -> idx .sha1 ));
2420+ oid_to_hex ( & entry -> idx .oid ));
24102421 } else {
24112422 if (entry -> type < 0 ) {
24122423 /*
0 commit comments