@@ -1227,22 +1227,20 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi
12271227 static struct object_info blank_oi = OBJECT_INFO_INIT ;
12281228 struct pack_entry e ;
12291229 int rtype ;
1230- const unsigned char * real = (flags & OBJECT_INFO_LOOKUP_REPLACE ) ?
1231- lookup_replace_object (oid -> hash ) :
1232- oid -> hash ;
1230+ const struct object_id * real = oid ;
12331231 int already_retried = 0 ;
1234- struct object_id realoid ;
12351232
1236- hashcpy (realoid .hash , real );
1233+ if (flags & OBJECT_INFO_LOOKUP_REPLACE )
1234+ real = lookup_replace_object (oid );
12371235
1238- if (is_null_sha1 (real ))
1236+ if (is_null_oid (real ))
12391237 return -1 ;
12401238
12411239 if (!oi )
12421240 oi = & blank_oi ;
12431241
12441242 if (!(flags & OBJECT_INFO_SKIP_CACHED )) {
1245- struct cached_object * co = find_cached_object (real );
1243+ struct cached_object * co = find_cached_object (real -> hash );
12461244 if (co ) {
12471245 if (oi -> typep )
12481246 * (oi -> typep ) = co -> type ;
@@ -1262,16 +1260,16 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi
12621260 }
12631261
12641262 while (1 ) {
1265- if (find_pack_entry (real , & e ))
1263+ if (find_pack_entry (real -> hash , & e ))
12661264 break ;
12671265
12681266 /* Most likely it's a loose object. */
1269- if (!sha1_loose_object_info (real , oi , flags ))
1267+ if (!sha1_loose_object_info (real -> hash , oi , flags ))
12701268 return 0 ;
12711269
12721270 /* Not a loose object; someone else may have just packed it. */
12731271 reprepare_packed_git ();
1274- if (find_pack_entry (real , & e ))
1272+ if (find_pack_entry (real -> hash , & e ))
12751273 break ;
12761274
12771275 /* Check if it is a missing object */
@@ -1281,7 +1279,7 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi
12811279 * TODO Investigate haveing fetch_object() return
12821280 * TODO error/success and stopping the music here.
12831281 */
1284- fetch_object (repository_format_partial_clone , real );
1282+ fetch_object (repository_format_partial_clone , real -> hash );
12851283 already_retried = 1 ;
12861284 continue ;
12871285 }
@@ -1297,8 +1295,8 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi
12971295 return 0 ;
12981296 rtype = packed_object_info (e .p , e .offset , oi );
12991297 if (rtype < 0 ) {
1300- mark_bad_packed_object (e .p , real );
1301- return oid_object_info_extended (& realoid , oi , 0 );
1298+ mark_bad_packed_object (e .p , real -> hash );
1299+ return oid_object_info_extended (real , oi , 0 );
13021300 } else if (oi -> whence == OI_PACKED ) {
13031301 oi -> u .packed .offset = e .offset ;
13041302 oi -> u .packed .pack = e .p ;
@@ -1372,29 +1370,29 @@ void *read_object_file_extended(const struct object_id *oid,
13721370 const struct packed_git * p ;
13731371 const char * path ;
13741372 struct stat st ;
1375- const unsigned char * repl = lookup_replace ? lookup_replace_object (oid -> hash )
1376- : oid -> hash ;
1373+ const struct object_id * repl = lookup_replace ? lookup_replace_object (oid )
1374+ : oid ;
13771375
13781376 errno = 0 ;
1379- data = read_object (repl , type , size );
1377+ data = read_object (repl -> hash , type , size );
13801378 if (data )
13811379 return data ;
13821380
13831381 if (errno && errno != ENOENT )
13841382 die_errno ("failed to read object %s" , oid_to_hex (oid ));
13851383
13861384 /* die if we replaced an object with one that does not exist */
1387- if (repl != oid -> hash )
1385+ if (repl != oid )
13881386 die ("replacement %s not found for %s" ,
1389- sha1_to_hex (repl ), oid_to_hex (oid ));
1387+ oid_to_hex (repl ), oid_to_hex (oid ));
13901388
1391- if (!stat_sha1_file (repl , & st , & path ))
1389+ if (!stat_sha1_file (repl -> hash , & st , & path ))
13921390 die ("loose object %s (stored in %s) is corrupt" ,
1393- sha1_to_hex (repl ), path );
1391+ oid_to_hex (repl ), path );
13941392
1395- if ((p = has_packed_and_bad (repl )) != NULL )
1393+ if ((p = has_packed_and_bad (repl -> hash )) != NULL )
13961394 die ("packed object %s (stored in %s) is corrupt" ,
1397- sha1_to_hex (repl ), p -> pack_name );
1395+ oid_to_hex (repl ), p -> pack_name );
13981396
13991397 return NULL ;
14001398}
0 commit comments