@@ -106,12 +106,14 @@ static void *get_delta(struct object_entry *entry)
106
106
void * buf , * base_buf , * delta_buf ;
107
107
enum object_type type ;
108
108
109
- buf = read_sha1_file (entry -> idx .sha1 , & type , & size );
109
+ buf = read_sha1_file (entry -> idx .oid . hash , & type , & size );
110
110
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 );
113
114
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 ));
115
117
delta_buf = diff_delta (base_buf , base_size ,
116
118
buf , size , & delta_size , 0 );
117
119
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
249
251
if (!usable_delta ) {
250
252
if (entry -> type == OBJ_BLOB &&
251
253
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 )
253
255
buf = NULL ;
254
256
else {
255
- buf = read_sha1_file (entry -> idx .sha1 , & type , & size );
257
+ buf = read_sha1_file (entry -> idx .oid .hash , & type ,
258
+ & size );
256
259
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 ));
258
262
}
259
263
/*
260
264
* 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
322
326
return 0 ;
323
327
}
324
328
sha1write (f , header , hdrlen );
325
- sha1write (f , entry -> delta -> idx .sha1 , 20 );
329
+ sha1write (f , entry -> delta -> idx .oid . hash , 20 );
326
330
hdrlen += 20 ;
327
331
} else {
328
332
if (limit && hdrlen + datalen + 20 >= limit ) {
@@ -334,7 +338,7 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
334
338
sha1write (f , header , hdrlen );
335
339
}
336
340
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 );
338
342
close_istream (st );
339
343
} else {
340
344
sha1write (f , buf , datalen );
@@ -369,7 +373,8 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
369
373
datalen = revidx [1 ].offset - offset ;
370
374
if (!pack_to_stdout && p -> index_version > 1 &&
371
375
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 ));
373
378
unuse_pack (& w_curs );
374
379
return write_no_reuse_object (f , entry , limit , usable_delta );
375
380
}
@@ -379,7 +384,8 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
379
384
380
385
if (!pack_to_stdout && p -> index_version == 1 &&
381
386
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 ));
383
389
unuse_pack (& w_curs );
384
390
return write_no_reuse_object (f , entry , limit , usable_delta );
385
391
}
@@ -404,7 +410,7 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
404
410
return 0 ;
405
411
}
406
412
sha1write (f , header , hdrlen );
407
- sha1write (f , entry -> delta -> idx .sha1 , 20 );
413
+ sha1write (f , entry -> delta -> idx .oid . hash , 20 );
408
414
hdrlen += 20 ;
409
415
reused_delta ++ ;
410
416
} else {
@@ -509,7 +515,7 @@ static enum write_one_status write_one(struct sha1file *f,
509
515
recursing = (e -> idx .offset == 1 );
510
516
if (recursing ) {
511
517
warning ("recursive delta detected for object %s" ,
512
- sha1_to_hex ( e -> idx .sha1 ));
518
+ oid_to_hex ( & e -> idx .oid ));
513
519
return WRITE_ONE_RECURSIVE ;
514
520
} else if (e -> idx .offset || e -> preferred_base ) {
515
521
/* offset is non zero if object is written already. */
@@ -1432,7 +1438,7 @@ static void check_object(struct object_entry *entry)
1432
1438
ofs += 1 ;
1433
1439
if (!ofs || MSB (ofs , 7 )) {
1434
1440
error ("delta base offset overflow in pack for %s" ,
1435
- sha1_to_hex ( entry -> idx .sha1 ));
1441
+ oid_to_hex ( & entry -> idx .oid ));
1436
1442
goto give_up ;
1437
1443
}
1438
1444
c = buf [used_0 ++ ];
@@ -1441,7 +1447,7 @@ static void check_object(struct object_entry *entry)
1441
1447
ofs = entry -> in_pack_offset - ofs ;
1442
1448
if (ofs <= 0 || ofs >= entry -> in_pack_offset ) {
1443
1449
error ("delta base offset out of bound for %s" ,
1444
- sha1_to_hex ( entry -> idx .sha1 ));
1450
+ oid_to_hex ( & entry -> idx .oid ));
1445
1451
goto give_up ;
1446
1452
}
1447
1453
if (reuse_delta && !entry -> preferred_base ) {
@@ -1498,7 +1504,7 @@ static void check_object(struct object_entry *entry)
1498
1504
unuse_pack (& w_curs );
1499
1505
}
1500
1506
1501
- entry -> type = sha1_object_info (entry -> idx .sha1 , & entry -> size );
1507
+ entry -> type = sha1_object_info (entry -> idx .oid . hash , & entry -> size );
1502
1508
/*
1503
1509
* The error condition is checked in prepare_pack(). This is
1504
1510
* 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)
1514
1520
1515
1521
/* avoid filesystem trashing with loose objects */
1516
1522
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 );
1518
1524
1519
1525
if (a -> in_pack < b -> in_pack )
1520
1526
return -1 ;
@@ -1560,7 +1566,8 @@ static void drop_reused_delta(struct object_entry *entry)
1560
1566
* And if that fails, the error will be recorded in entry->type
1561
1567
* and dealt with in prepare_pack().
1562
1568
*/
1563
- entry -> type = sha1_object_info (entry -> idx .sha1 , & entry -> size );
1569
+ entry -> type = sha1_object_info (entry -> idx .oid .hash ,
1570
+ & entry -> size );
1564
1571
}
1565
1572
}
1566
1573
@@ -1852,26 +1859,29 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
1852
1859
/* Load data if not already done */
1853
1860
if (!trg -> data ) {
1854
1861
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 );
1856
1864
read_unlock ();
1857
1865
if (!trg -> data )
1858
1866
die ("object %s cannot be read" ,
1859
- sha1_to_hex ( trg_entry -> idx .sha1 ));
1867
+ oid_to_hex ( & trg_entry -> idx .oid ));
1860
1868
if (sz != trg_size )
1861
1869
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 );
1863
1872
* mem_usage += sz ;
1864
1873
}
1865
1874
if (!src -> data ) {
1866
1875
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 );
1868
1878
read_unlock ();
1869
1879
if (!src -> data ) {
1870
1880
if (src_entry -> preferred_base ) {
1871
1881
static int warned = 0 ;
1872
1882
if (!warned ++ )
1873
1883
warning ("object %s cannot be read" ,
1874
- sha1_to_hex ( src_entry -> idx .sha1 ));
1884
+ oid_to_hex ( & src_entry -> idx .oid ));
1875
1885
/*
1876
1886
* Those objects are not included in the
1877
1887
* resulting pack. Be resilient and ignore
@@ -1881,11 +1891,12 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
1881
1891
return 0 ;
1882
1892
}
1883
1893
die ("object %s cannot be read" ,
1884
- sha1_to_hex ( src_entry -> idx .sha1 ));
1894
+ oid_to_hex ( & src_entry -> idx .oid ));
1885
1895
}
1886
1896
if (sz != src_size )
1887
1897
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 );
1889
1900
* mem_usage += sz ;
1890
1901
}
1891
1902
if (!src -> index ) {
@@ -2406,7 +2417,7 @@ static void prepare_pack(int window, int depth)
2406
2417
nr_deltas ++ ;
2407
2418
if (entry -> type < 0 )
2408
2419
die ("unable to get type of object %s" ,
2409
- sha1_to_hex ( entry -> idx .sha1 ));
2420
+ oid_to_hex ( & entry -> idx .oid ));
2410
2421
} else {
2411
2422
if (entry -> type < 0 ) {
2412
2423
/*
0 commit comments