@@ -79,7 +79,7 @@ static int check_packed_git_idx(const char *path, struct packed_git *p)
79
79
size_t idx_size ;
80
80
int fd = git_open (path ), ret ;
81
81
struct stat st ;
82
- const unsigned int hashsz = the_hash_algo -> rawsz ;
82
+ const unsigned int hashsz = p -> repo -> hash_algo -> rawsz ;
83
83
84
84
if (fd < 0 )
85
85
return -1 ;
@@ -243,7 +243,7 @@ struct packed_git *parse_pack_index(struct repository *r, unsigned char *sha1,
243
243
244
244
memcpy (p -> pack_name , path , alloc ); /* includes NUL */
245
245
free (path );
246
- hashcpy (p -> hash , sha1 , the_repository -> hash_algo );
246
+ hashcpy (p -> hash , sha1 , p -> repo -> hash_algo );
247
247
if (check_packed_git_idx (idx_path , p )) {
248
248
free (p );
249
249
return NULL ;
@@ -278,7 +278,7 @@ static int unuse_one_window(struct packed_git *current)
278
278
279
279
if (current )
280
280
scan_windows (current , & lru_p , & lru_w , & lru_l );
281
- for (p = the_repository -> objects -> packed_git ; p ; p = p -> next )
281
+ for (p = current -> repo -> objects -> packed_git ; p ; p = p -> next )
282
282
scan_windows (p , & lru_p , & lru_w , & lru_l );
283
283
if (lru_p ) {
284
284
munmap (lru_w -> base , lru_w -> len );
@@ -540,7 +540,7 @@ static int open_packed_git_1(struct packed_git *p)
540
540
unsigned char hash [GIT_MAX_RAWSZ ];
541
541
unsigned char * idx_hash ;
542
542
ssize_t read_result ;
543
- const unsigned hashsz = the_hash_algo -> rawsz ;
543
+ const unsigned hashsz = p -> repo -> hash_algo -> rawsz ;
544
544
545
545
if (open_pack_index (p ))
546
546
return error ("packfile %s index unavailable" , p -> pack_name );
@@ -597,7 +597,7 @@ static int open_packed_git_1(struct packed_git *p)
597
597
if (read_result != hashsz )
598
598
return error ("packfile %s signature is unavailable" , p -> pack_name );
599
599
idx_hash = ((unsigned char * )p -> index_data ) + p -> index_size - hashsz * 2 ;
600
- if (!hasheq (hash , idx_hash , the_repository -> hash_algo ))
600
+ if (!hasheq (hash , idx_hash , p -> repo -> hash_algo ))
601
601
return error ("packfile %s does not match index" , p -> pack_name );
602
602
return 0 ;
603
603
}
@@ -637,7 +637,7 @@ unsigned char *use_pack(struct packed_git *p,
637
637
*/
638
638
if (!p -> pack_size && p -> pack_fd == -1 && open_packed_git (p ))
639
639
die ("packfile %s cannot be accessed" , p -> pack_name );
640
- if (offset > (p -> pack_size - the_hash_algo -> rawsz ))
640
+ if (offset > (p -> pack_size - p -> repo -> hash_algo -> rawsz ))
641
641
die ("offset beyond end of packfile (truncated pack?)" );
642
642
if (offset < 0 )
643
643
die (_ ("offset before end of packfile (broken .idx?)" ));
@@ -711,6 +711,7 @@ struct packed_git *add_packed_git(struct repository *r, const char *path,
711
711
struct stat st ;
712
712
size_t alloc ;
713
713
struct packed_git * p ;
714
+ struct object_id oid ;
714
715
715
716
/*
716
717
* Make sure a corresponding .pack file exists and that
@@ -751,9 +752,13 @@ struct packed_git *add_packed_git(struct repository *r, const char *path,
751
752
p -> pack_size = st .st_size ;
752
753
p -> pack_local = local ;
753
754
p -> mtime = st .st_mtime ;
754
- if (path_len < the_hash_algo -> hexsz ||
755
- get_hash_hex (path + path_len - the_hash_algo -> hexsz , p -> hash ))
756
- hashclr (p -> hash , the_repository -> hash_algo );
755
+ if (path_len < r -> hash_algo -> hexsz ||
756
+ get_oid_hex_algop (path + path_len - r -> hash_algo -> hexsz , & oid ,
757
+ r -> hash_algo ))
758
+ hashclr (p -> hash , r -> hash_algo );
759
+ else
760
+ hashcpy (p -> hash , oid .hash , r -> hash_algo );
761
+
757
762
return p ;
758
763
}
759
764
@@ -1243,9 +1248,9 @@ off_t get_delta_base(struct packed_git *p,
1243
1248
} else if (type == OBJ_REF_DELTA ) {
1244
1249
/* The base entry _must_ be in the same pack */
1245
1250
struct object_id oid ;
1246
- oidread (& oid , base_info , the_repository -> hash_algo );
1251
+ oidread (& oid , base_info , p -> repo -> hash_algo );
1247
1252
base_offset = find_pack_entry_one (& oid , p );
1248
- * curpos += the_hash_algo -> rawsz ;
1253
+ * curpos += p -> repo -> hash_algo -> rawsz ;
1249
1254
} else
1250
1255
die ("I am totally screwed" );
1251
1256
return base_offset ;
@@ -1266,7 +1271,7 @@ static int get_delta_base_oid(struct packed_git *p,
1266
1271
{
1267
1272
if (type == OBJ_REF_DELTA ) {
1268
1273
unsigned char * base = use_pack (p , w_curs , curpos , NULL );
1269
- oidread (oid , base , the_repository -> hash_algo );
1274
+ oidread (oid , base , p -> repo -> hash_algo );
1270
1275
return 0 ;
1271
1276
} else if (type == OBJ_OFS_DELTA ) {
1272
1277
uint32_t base_pos ;
@@ -1608,7 +1613,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,
1608
1613
goto out ;
1609
1614
}
1610
1615
} else
1611
- oidclr (oi -> delta_base_oid , the_repository -> hash_algo );
1616
+ oidclr (oi -> delta_base_oid , p -> repo -> hash_algo );
1612
1617
}
1613
1618
1614
1619
oi -> whence = in_delta_base_cache (p , obj_offset ) ? OI_DBCACHED :
@@ -1897,7 +1902,7 @@ int bsearch_pack(const struct object_id *oid, const struct packed_git *p, uint32
1897
1902
{
1898
1903
const unsigned char * index_fanout = p -> index_data ;
1899
1904
const unsigned char * index_lookup ;
1900
- const unsigned int hashsz = the_hash_algo -> rawsz ;
1905
+ const unsigned int hashsz = p -> repo -> hash_algo -> rawsz ;
1901
1906
int index_lookup_width ;
1902
1907
1903
1908
if (!index_fanout )
@@ -1922,7 +1927,7 @@ int nth_packed_object_id(struct object_id *oid,
1922
1927
uint32_t n )
1923
1928
{
1924
1929
const unsigned char * index = p -> index_data ;
1925
- const unsigned int hashsz = the_hash_algo -> rawsz ;
1930
+ const unsigned int hashsz = p -> repo -> hash_algo -> rawsz ;
1926
1931
if (!index ) {
1927
1932
if (open_pack_index (p ))
1928
1933
return -1 ;
@@ -1933,11 +1938,10 @@ int nth_packed_object_id(struct object_id *oid,
1933
1938
index += 4 * 256 ;
1934
1939
if (p -> index_version == 1 ) {
1935
1940
oidread (oid , index + st_add (st_mult (hashsz + 4 , n ), 4 ),
1936
- the_repository -> hash_algo );
1941
+ p -> repo -> hash_algo );
1937
1942
} else {
1938
1943
index += 8 ;
1939
- oidread (oid , index + st_mult (hashsz , n ),
1940
- the_repository -> hash_algo );
1944
+ oidread (oid , index + st_mult (hashsz , n ), p -> repo -> hash_algo );
1941
1945
}
1942
1946
return 0 ;
1943
1947
}
@@ -1959,7 +1963,7 @@ void check_pack_index_ptr(const struct packed_git *p, const void *vptr)
1959
1963
off_t nth_packed_object_offset (const struct packed_git * p , uint32_t n )
1960
1964
{
1961
1965
const unsigned char * index = p -> index_data ;
1962
- const unsigned int hashsz = the_hash_algo -> rawsz ;
1966
+ const unsigned int hashsz = p -> repo -> hash_algo -> rawsz ;
1963
1967
index += 4 * 256 ;
1964
1968
if (p -> index_version == 1 ) {
1965
1969
return ntohl (* ((uint32_t * )(index + st_mult (hashsz + 4 , n ))));
@@ -2159,7 +2163,7 @@ int for_each_object_in_pack(struct packed_git *p,
2159
2163
int r = 0 ;
2160
2164
2161
2165
if (flags & FOR_EACH_OBJECT_PACK_ORDER ) {
2162
- if (load_pack_revindex (the_repository , p ))
2166
+ if (load_pack_revindex (p -> repo , p ))
2163
2167
return -1 ;
2164
2168
}
2165
2169
@@ -2227,20 +2231,20 @@ int for_each_packed_object(each_packed_object_fn cb, void *data,
2227
2231
}
2228
2232
2229
2233
static int add_promisor_object (const struct object_id * oid ,
2230
- struct packed_git * pack UNUSED ,
2234
+ struct packed_git * pack ,
2231
2235
uint32_t pos UNUSED ,
2232
2236
void * set_ )
2233
2237
{
2234
2238
struct oidset * set = set_ ;
2235
2239
struct object * obj ;
2236
2240
int we_parsed_object ;
2237
2241
2238
- obj = lookup_object (the_repository , oid );
2242
+ obj = lookup_object (pack -> repo , oid );
2239
2243
if (obj && obj -> parsed ) {
2240
2244
we_parsed_object = 0 ;
2241
2245
} else {
2242
2246
we_parsed_object = 1 ;
2243
- obj = parse_object (the_repository , oid );
2247
+ obj = parse_object (pack -> repo , oid );
2244
2248
}
2245
2249
2246
2250
if (!obj )
0 commit comments