@@ -448,6 +448,8 @@ struct pack_list {
448
448
uint32_t nr ;
449
449
uint32_t alloc ;
450
450
struct multi_pack_index * m ;
451
+ struct progress * progress ;
452
+ unsigned pack_paths_checked ;
451
453
};
452
454
453
455
static void add_pack_to_midx (const char * full_path , size_t full_path_len ,
@@ -456,6 +458,7 @@ static void add_pack_to_midx(const char *full_path, size_t full_path_len,
456
458
struct pack_list * packs = (struct pack_list * )data ;
457
459
458
460
if (ends_with (file_name , ".idx" )) {
461
+ display_progress (packs -> progress , ++ packs -> pack_paths_checked );
459
462
if (packs -> m && midx_contains_pack (packs -> m , file_name ))
460
463
return ;
461
464
@@ -785,7 +788,7 @@ static size_t write_midx_large_offsets(struct hashfile *f, uint32_t nr_large_off
785
788
}
786
789
787
790
static int write_midx_internal (const char * object_dir , struct multi_pack_index * m ,
788
- struct string_list * packs_to_drop )
791
+ struct string_list * packs_to_drop , unsigned flags )
789
792
{
790
793
unsigned char cur_chunk , num_chunks = 0 ;
791
794
char * midx_name ;
@@ -799,6 +802,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
799
802
uint64_t chunk_offsets [MIDX_MAX_CHUNKS + 1 ];
800
803
uint32_t nr_entries , num_large_offsets = 0 ;
801
804
struct pack_midx_entry * entries = NULL ;
805
+ struct progress * progress = NULL ;
802
806
int large_offsets_needed = 0 ;
803
807
int pack_name_concat_len = 0 ;
804
808
int dropped_packs = 0 ;
@@ -833,7 +837,14 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
833
837
}
834
838
}
835
839
840
+ packs .pack_paths_checked = 0 ;
841
+ if (flags & MIDX_PROGRESS )
842
+ packs .progress = start_progress (_ ("Adding packfiles to multi-pack-index" ), 0 );
843
+ else
844
+ packs .progress = NULL ;
845
+
836
846
for_each_file_in_pack_dir (object_dir , add_pack_to_midx , & packs );
847
+ stop_progress (& packs .progress );
837
848
838
849
if (packs .m && packs .nr == packs .m -> num_packs && !packs_to_drop )
839
850
goto cleanup ;
@@ -958,6 +969,9 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
958
969
written += MIDX_CHUNKLOOKUP_WIDTH ;
959
970
}
960
971
972
+ if (flags & MIDX_PROGRESS )
973
+ progress = start_progress (_ ("Writing chunks to multi-pack-index" ),
974
+ num_chunks );
961
975
for (i = 0 ; i < num_chunks ; i ++ ) {
962
976
if (written != chunk_offsets [i ])
963
977
BUG ("incorrect chunk offset (%" PRIu64 " != %" PRIu64 ") for chunk id %" PRIx32 ,
@@ -990,7 +1004,10 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
990
1004
BUG ("trying to write unknown chunk id %" PRIx32 ,
991
1005
chunk_ids [i ]);
992
1006
}
1007
+
1008
+ display_progress (progress , i + 1 );
993
1009
}
1010
+ stop_progress (& progress );
994
1011
995
1012
if (written != chunk_offsets [num_chunks ])
996
1013
BUG ("incorrect final offset %" PRIu64 " != %" PRIu64 ,
@@ -1018,7 +1035,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
1018
1035
1019
1036
int write_midx_file (const char * object_dir , unsigned flags )
1020
1037
{
1021
- return write_midx_internal (object_dir , NULL , NULL );
1038
+ return write_midx_internal (object_dir , NULL , NULL , flags );
1022
1039
}
1023
1040
1024
1041
void clear_midx_file (struct repository * r )
@@ -1221,7 +1238,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
1221
1238
free (count );
1222
1239
1223
1240
if (packs_to_drop .nr )
1224
- result = write_midx_internal (object_dir , m , & packs_to_drop );
1241
+ result = write_midx_internal (object_dir , m , & packs_to_drop , flags );
1225
1242
1226
1243
string_list_clear (& packs_to_drop , 0 );
1227
1244
return result ;
@@ -1370,7 +1387,7 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
1370
1387
goto cleanup ;
1371
1388
}
1372
1389
1373
- result = write_midx_internal (object_dir , m , NULL );
1390
+ result = write_midx_internal (object_dir , m , NULL , flags );
1374
1391
m = NULL ;
1375
1392
1376
1393
cleanup :
0 commit comments