@@ -2444,6 +2444,9 @@ int packed_object_info(struct packed_git *p, off_t obj_offset,
24442444 hashclr (oi -> delta_base_sha1 );
24452445 }
24462446
2447+ oi -> whence = in_delta_base_cache (p , obj_offset ) ? OI_DBCACHED :
2448+ OI_PACKED ;
2449+
24472450out :
24482451 unuse_pack (& w_curs );
24492452 return type ;
@@ -2963,6 +2966,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,
29632966 if (oi -> sizep == & size_scratch )
29642967 oi -> sizep = NULL ;
29652968 strbuf_release (& hdrbuf );
2969+ oi -> whence = OI_LOOSE ;
29662970 return (status < 0 ) ? status : 0 ;
29672971}
29682972
@@ -3000,10 +3004,8 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
30003004
30013005 if (!find_pack_entry (real , & e )) {
30023006 /* Most likely it's a loose object. */
3003- if (!sha1_loose_object_info (real , oi , flags )) {
3004- oi -> whence = OI_LOOSE ;
3007+ if (!sha1_loose_object_info (real , oi , flags ))
30053008 return 0 ;
3006- }
30073009
30083010 /* Not a loose object; someone else may have just packed it. */
30093011 if (flags & OBJECT_INFO_QUICK ) {
@@ -3026,10 +3028,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
30263028 if (rtype < 0 ) {
30273029 mark_bad_packed_object (e .p , real );
30283030 return sha1_object_info_extended (real , oi , 0 );
3029- } else if (in_delta_base_cache (e .p , e .offset )) {
3030- oi -> whence = OI_DBCACHED ;
3031- } else {
3032- oi -> whence = OI_PACKED ;
3031+ } else if (oi -> whence == OI_PACKED ) {
30333032 oi -> u .packed .offset = e .offset ;
30343033 oi -> u .packed .pack = e .p ;
30353034 oi -> u .packed .is_delta = (rtype == OBJ_REF_DELTA ||
@@ -3053,30 +3052,6 @@ int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)
30533052 return type ;
30543053}
30553054
3056- static void * read_packed_sha1 (const unsigned char * sha1 ,
3057- enum object_type * type , unsigned long * size )
3058- {
3059- struct pack_entry e ;
3060- void * data ;
3061-
3062- if (!find_pack_entry (sha1 , & e ))
3063- return NULL ;
3064- data = cache_or_unpack_entry (e .p , e .offset , size , type );
3065- if (!data ) {
3066- /*
3067- * We're probably in deep shit, but let's try to fetch
3068- * the required object anyway from another pack or loose.
3069- * This should happen only in the presence of a corrupted
3070- * pack, and is better than failing outright.
3071- */
3072- error ("failed to read object %s at offset %" PRIuMAX " from %s" ,
3073- sha1_to_hex (sha1 ), (uintmax_t )e .offset , e .p -> pack_name );
3074- mark_bad_packed_object (e .p , sha1 );
3075- data = read_object (sha1 , type , size );
3076- }
3077- return data ;
3078- }
3079-
30803055int pretend_sha1_file (void * buf , unsigned long len , enum object_type type ,
30813056 unsigned char * sha1 )
30823057{
@@ -3459,7 +3434,7 @@ int force_object_loose(const unsigned char *sha1, time_t mtime)
34593434
34603435 if (has_loose_object (sha1 ))
34613436 return 0 ;
3462- buf = read_packed_sha1 (sha1 , & type , & len );
3437+ buf = read_object (sha1 , & type , & len );
34633438 if (!buf )
34643439 return error ("cannot read sha1_file for %s" , sha1_to_hex (sha1 ));
34653440 hdrlen = xsnprintf (hdr , sizeof (hdr ), "%s %lu" , typename (type ), len ) + 1 ;
0 commit comments