@@ -79,7 +79,7 @@ static int check_packed_git_idx(const char *path, struct packed_git *p)
7979 size_t idx_size ;
8080 int fd = git_open (path ), ret ;
8181 struct stat st ;
82- const unsigned int hashsz = the_hash_algo -> rawsz ;
82+ const unsigned int hashsz = p -> repo -> hash_algo -> rawsz ;
8383
8484 if (fd < 0 )
8585 return -1 ;
@@ -243,7 +243,7 @@ struct packed_git *parse_pack_index(struct repository *r, unsigned char *sha1,
243243
244244 memcpy (p -> pack_name , path , alloc ); /* includes NUL */
245245 free (path );
246- hashcpy (p -> hash , sha1 , the_repository -> hash_algo );
246+ hashcpy (p -> hash , sha1 , p -> repo -> hash_algo );
247247 if (check_packed_git_idx (idx_path , p )) {
248248 free (p );
249249 return NULL ;
@@ -278,7 +278,7 @@ static int unuse_one_window(struct packed_git *current)
278278
279279 if (current )
280280 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 )
282282 scan_windows (p , & lru_p , & lru_w , & lru_l );
283283 if (lru_p ) {
284284 munmap (lru_w -> base , lru_w -> len );
@@ -540,7 +540,7 @@ static int open_packed_git_1(struct packed_git *p)
540540 unsigned char hash [GIT_MAX_RAWSZ ];
541541 unsigned char * idx_hash ;
542542 ssize_t read_result ;
543- const unsigned hashsz = the_hash_algo -> rawsz ;
543+ const unsigned hashsz = p -> repo -> hash_algo -> rawsz ;
544544
545545 if (open_pack_index (p ))
546546 return error ("packfile %s index unavailable" , p -> pack_name );
@@ -597,7 +597,7 @@ static int open_packed_git_1(struct packed_git *p)
597597 if (read_result != hashsz )
598598 return error ("packfile %s signature is unavailable" , p -> pack_name );
599599 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 ))
601601 return error ("packfile %s does not match index" , p -> pack_name );
602602 return 0 ;
603603}
@@ -637,7 +637,7 @@ unsigned char *use_pack(struct packed_git *p,
637637 */
638638 if (!p -> pack_size && p -> pack_fd == -1 && open_packed_git (p ))
639639 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 ))
641641 die ("offset beyond end of packfile (truncated pack?)" );
642642 if (offset < 0 )
643643 die (_ ("offset before end of packfile (broken .idx?)" ));
@@ -711,6 +711,7 @@ struct packed_git *add_packed_git(struct repository *r, const char *path,
711711 struct stat st ;
712712 size_t alloc ;
713713 struct packed_git * p ;
714+ struct object_id oid ;
714715
715716 /*
716717 * 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,
751752 p -> pack_size = st .st_size ;
752753 p -> pack_local = local ;
753754 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+
757762 return p ;
758763}
759764
@@ -1243,9 +1248,9 @@ off_t get_delta_base(struct packed_git *p,
12431248 } else if (type == OBJ_REF_DELTA ) {
12441249 /* The base entry _must_ be in the same pack */
12451250 struct object_id oid ;
1246- oidread (& oid , base_info , the_repository -> hash_algo );
1251+ oidread (& oid , base_info , p -> repo -> hash_algo );
12471252 base_offset = find_pack_entry_one (& oid , p );
1248- * curpos += the_hash_algo -> rawsz ;
1253+ * curpos += p -> repo -> hash_algo -> rawsz ;
12491254 } else
12501255 die ("I am totally screwed" );
12511256 return base_offset ;
@@ -1266,7 +1271,7 @@ static int get_delta_base_oid(struct packed_git *p,
12661271{
12671272 if (type == OBJ_REF_DELTA ) {
12681273 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 );
12701275 return 0 ;
12711276 } else if (type == OBJ_OFS_DELTA ) {
12721277 uint32_t base_pos ;
@@ -1608,7 +1613,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,
16081613 goto out ;
16091614 }
16101615 } else
1611- oidclr (oi -> delta_base_oid , the_repository -> hash_algo );
1616+ oidclr (oi -> delta_base_oid , p -> repo -> hash_algo );
16121617 }
16131618
16141619 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
18971902{
18981903 const unsigned char * index_fanout = p -> index_data ;
18991904 const unsigned char * index_lookup ;
1900- const unsigned int hashsz = the_hash_algo -> rawsz ;
1905+ const unsigned int hashsz = p -> repo -> hash_algo -> rawsz ;
19011906 int index_lookup_width ;
19021907
19031908 if (!index_fanout )
@@ -1922,7 +1927,7 @@ int nth_packed_object_id(struct object_id *oid,
19221927 uint32_t n )
19231928{
19241929 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 ;
19261931 if (!index ) {
19271932 if (open_pack_index (p ))
19281933 return -1 ;
@@ -1933,11 +1938,10 @@ int nth_packed_object_id(struct object_id *oid,
19331938 index += 4 * 256 ;
19341939 if (p -> index_version == 1 ) {
19351940 oidread (oid , index + st_add (st_mult (hashsz + 4 , n ), 4 ),
1936- the_repository -> hash_algo );
1941+ p -> repo -> hash_algo );
19371942 } else {
19381943 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 );
19411945 }
19421946 return 0 ;
19431947}
@@ -1959,7 +1963,7 @@ void check_pack_index_ptr(const struct packed_git *p, const void *vptr)
19591963off_t nth_packed_object_offset (const struct packed_git * p , uint32_t n )
19601964{
19611965 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 ;
19631967 index += 4 * 256 ;
19641968 if (p -> index_version == 1 ) {
19651969 return ntohl (* ((uint32_t * )(index + st_mult (hashsz + 4 , n ))));
@@ -2159,7 +2163,7 @@ int for_each_object_in_pack(struct packed_git *p,
21592163 int r = 0 ;
21602164
21612165 if (flags & FOR_EACH_OBJECT_PACK_ORDER ) {
2162- if (load_pack_revindex (the_repository , p ))
2166+ if (load_pack_revindex (p -> repo , p ))
21632167 return -1 ;
21642168 }
21652169
@@ -2227,20 +2231,20 @@ int for_each_packed_object(each_packed_object_fn cb, void *data,
22272231}
22282232
22292233static int add_promisor_object (const struct object_id * oid ,
2230- struct packed_git * pack UNUSED ,
2234+ struct packed_git * pack ,
22312235 uint32_t pos UNUSED ,
22322236 void * set_ )
22332237{
22342238 struct oidset * set = set_ ;
22352239 struct object * obj ;
22362240 int we_parsed_object ;
22372241
2238- obj = lookup_object (the_repository , oid );
2242+ obj = lookup_object (pack -> repo , oid );
22392243 if (obj && obj -> parsed ) {
22402244 we_parsed_object = 0 ;
22412245 } else {
22422246 we_parsed_object = 1 ;
2243- obj = parse_object (the_repository , oid );
2247+ obj = parse_object (pack -> repo , oid );
22442248 }
22452249
22462250 if (!obj )
0 commit comments