@@ -3405,13 +3405,9 @@ static void read_object_list_from_stdin(void)
3405
3405
}
3406
3406
}
3407
3407
3408
- /* Remember to update object flag allocation in object.h */
3409
- #define OBJECT_ADDED (1u<<20)
3410
-
3411
3408
static void show_commit (struct commit * commit , void * data )
3412
3409
{
3413
3410
add_object_entry (& commit -> object .oid , OBJ_COMMIT , NULL , 0 );
3414
- commit -> object .flags |= OBJECT_ADDED ;
3415
3411
3416
3412
if (write_bitmap_index )
3417
3413
index_commit_for_bitmap (commit );
@@ -3424,7 +3420,6 @@ static void show_object(struct object *obj, const char *name, void *data)
3424
3420
{
3425
3421
add_preferred_base_object (name );
3426
3422
add_object_entry (& obj -> oid , obj -> type , name , 0 );
3427
- obj -> flags |= OBJECT_ADDED ;
3428
3423
3429
3424
if (use_delta_islands ) {
3430
3425
const char * p ;
@@ -3505,79 +3500,23 @@ static void show_edge(struct commit *commit)
3505
3500
add_preferred_base (& commit -> object .oid );
3506
3501
}
3507
3502
3508
- struct in_pack_object {
3509
- off_t offset ;
3510
- struct object * object ;
3511
- };
3512
-
3513
- struct in_pack {
3514
- unsigned int alloc ;
3515
- unsigned int nr ;
3516
- struct in_pack_object * array ;
3517
- };
3518
-
3519
- static void mark_in_pack_object (struct object * object , struct packed_git * p , struct in_pack * in_pack )
3520
- {
3521
- in_pack -> array [in_pack -> nr ].offset = find_pack_entry_one (object -> oid .hash , p );
3522
- in_pack -> array [in_pack -> nr ].object = object ;
3523
- in_pack -> nr ++ ;
3524
- }
3525
-
3526
- /*
3527
- * Compare the objects in the offset order, in order to emulate the
3528
- * "git rev-list --objects" output that produced the pack originally.
3529
- */
3530
- static int ofscmp (const void * a_ , const void * b_ )
3503
+ static int add_object_in_unpacked_pack (const struct object_id * oid ,
3504
+ struct packed_git * pack ,
3505
+ uint32_t pos ,
3506
+ void * _data )
3531
3507
{
3532
- struct in_pack_object * a = (struct in_pack_object * )a_ ;
3533
- struct in_pack_object * b = (struct in_pack_object * )b_ ;
3534
-
3535
- if (a -> offset < b -> offset )
3536
- return -1 ;
3537
- else if (a -> offset > b -> offset )
3538
- return 1 ;
3539
- else
3540
- return oidcmp (& a -> object -> oid , & b -> object -> oid );
3508
+ add_object_entry (oid , OBJ_NONE , "" , 0 );
3509
+ return 0 ;
3541
3510
}
3542
3511
3543
3512
static void add_objects_in_unpacked_packs (void )
3544
3513
{
3545
- struct packed_git * p ;
3546
- struct in_pack in_pack ;
3547
- uint32_t i ;
3548
-
3549
- memset (& in_pack , 0 , sizeof (in_pack ));
3550
-
3551
- for (p = get_all_packs (the_repository ); p ; p = p -> next ) {
3552
- struct object_id oid ;
3553
- struct object * o ;
3554
-
3555
- if (!p -> pack_local || p -> pack_keep || p -> pack_keep_in_core )
3556
- continue ;
3557
- if (open_pack_index (p ))
3558
- die (_ ("cannot open pack index" ));
3559
-
3560
- ALLOC_GROW (in_pack .array ,
3561
- in_pack .nr + p -> num_objects ,
3562
- in_pack .alloc );
3563
-
3564
- for (i = 0 ; i < p -> num_objects ; i ++ ) {
3565
- nth_packed_object_id (& oid , p , i );
3566
- o = lookup_unknown_object (the_repository , & oid );
3567
- if (!(o -> flags & OBJECT_ADDED ))
3568
- mark_in_pack_object (o , p , & in_pack );
3569
- o -> flags |= OBJECT_ADDED ;
3570
- }
3571
- }
3572
-
3573
- if (in_pack .nr ) {
3574
- QSORT (in_pack .array , in_pack .nr , ofscmp );
3575
- for (i = 0 ; i < in_pack .nr ; i ++ ) {
3576
- struct object * o = in_pack .array [i ].object ;
3577
- add_object_entry (& o -> oid , o -> type , "" , 0 );
3578
- }
3579
- }
3580
- free (in_pack .array );
3514
+ if (for_each_packed_object (add_object_in_unpacked_pack , NULL ,
3515
+ FOR_EACH_OBJECT_PACK_ORDER |
3516
+ FOR_EACH_OBJECT_LOCAL_ONLY |
3517
+ FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS |
3518
+ FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS ))
3519
+ die (_ ("cannot open pack index" ));
3581
3520
}
3582
3521
3583
3522
static int add_loose_object (const struct object_id * oid , const char * path ,
0 commit comments