@@ -1053,40 +1053,35 @@ static struct commit **find_commits_for_midx_bitmap(uint32_t *indexed_commits_nr
1053
1053
return cb .commits ;
1054
1054
}
1055
1055
1056
- static int write_midx_bitmap (char * midx_name , unsigned char * midx_hash ,
1057
- struct write_midx_context * ctx ,
1056
+ static int write_midx_bitmap (const char * midx_name ,
1057
+ const unsigned char * midx_hash ,
1058
+ struct packing_data * pdata ,
1059
+ struct commit * * commits ,
1060
+ uint32_t commits_nr ,
1061
+ uint32_t * pack_order ,
1058
1062
const char * refs_snapshot ,
1059
1063
unsigned flags )
1060
1064
{
1061
- struct packing_data pdata ;
1062
- struct pack_idx_entry * * index ;
1063
- struct commit * * commits = NULL ;
1064
- uint32_t i , commits_nr ;
1065
+ int ret , i ;
1065
1066
uint16_t options = 0 ;
1066
- char * bitmap_name = xstrfmt ("%s-%s.bitmap" , midx_name , hash_to_hex (midx_hash ));
1067
- int ret ;
1068
-
1069
- if (!ctx -> entries_nr )
1070
- BUG ("cannot write a bitmap without any objects" );
1067
+ struct pack_idx_entry * * index ;
1068
+ char * bitmap_name = xstrfmt ("%s-%s.bitmap" , midx_name ,
1069
+ hash_to_hex (midx_hash ));
1071
1070
1072
1071
if (flags & MIDX_WRITE_BITMAP_HASH_CACHE )
1073
1072
options |= BITMAP_OPT_HASH_CACHE ;
1074
1073
1075
- prepare_midx_packing_data (& pdata , ctx );
1076
-
1077
- commits = find_commits_for_midx_bitmap (& commits_nr , refs_snapshot , ctx );
1078
-
1079
1074
/*
1080
1075
* Build the MIDX-order index based on pdata.objects (which is already
1081
1076
* in MIDX order; c.f., 'midx_pack_order_cmp()' for the definition of
1082
1077
* this order).
1083
1078
*/
1084
- ALLOC_ARRAY (index , pdata . nr_objects );
1085
- for (i = 0 ; i < pdata . nr_objects ; i ++ )
1086
- index [i ] = & pdata . objects [i ].idx ;
1079
+ ALLOC_ARRAY (index , pdata -> nr_objects );
1080
+ for (i = 0 ; i < pdata -> nr_objects ; i ++ )
1081
+ index [i ] = & pdata -> objects [i ].idx ;
1087
1082
1088
1083
bitmap_writer_show_progress (flags & MIDX_PROGRESS );
1089
- bitmap_writer_build_type_index (& pdata , index , pdata . nr_objects );
1084
+ bitmap_writer_build_type_index (pdata , index , pdata -> nr_objects );
1090
1085
1091
1086
/*
1092
1087
* bitmap_writer_finish expects objects in lex order, but pack_order
@@ -1101,16 +1096,16 @@ static int write_midx_bitmap(char *midx_name, unsigned char *midx_hash,
1101
1096
* happens between bitmap_writer_build_type_index() and
1102
1097
* bitmap_writer_finish().
1103
1098
*/
1104
- for (i = 0 ; i < pdata . nr_objects ; i ++ )
1105
- index [ctx -> pack_order [i ]] = & pdata . objects [i ].idx ;
1099
+ for (i = 0 ; i < pdata -> nr_objects ; i ++ )
1100
+ index [pack_order [i ]] = & pdata -> objects [i ].idx ;
1106
1101
1107
1102
bitmap_writer_select_commits (commits , commits_nr , -1 );
1108
- ret = bitmap_writer_build (& pdata );
1103
+ ret = bitmap_writer_build (pdata );
1109
1104
if (ret < 0 )
1110
1105
goto cleanup ;
1111
1106
1112
1107
bitmap_writer_set_checksum (midx_hash );
1113
- bitmap_writer_finish (index , pdata . nr_objects , bitmap_name , options );
1108
+ bitmap_writer_finish (index , pdata -> nr_objects , bitmap_name , options );
1114
1109
1115
1110
cleanup :
1116
1111
free (index );
@@ -1443,8 +1438,21 @@ static int write_midx_internal(const char *object_dir,
1443
1438
if (flags & MIDX_WRITE_REV_INDEX &&
1444
1439
git_env_bool ("GIT_TEST_MIDX_WRITE_REV" , 0 ))
1445
1440
write_midx_reverse_index (midx_name .buf , midx_hash , & ctx );
1441
+
1446
1442
if (flags & MIDX_WRITE_BITMAP ) {
1447
- if (write_midx_bitmap (midx_name .buf , midx_hash , & ctx ,
1443
+ struct packing_data pdata ;
1444
+ struct commit * * commits ;
1445
+ uint32_t commits_nr ;
1446
+
1447
+ if (!ctx .entries_nr )
1448
+ BUG ("cannot write a bitmap without any objects" );
1449
+
1450
+ prepare_midx_packing_data (& pdata , & ctx );
1451
+
1452
+ commits = find_commits_for_midx_bitmap (& commits_nr , refs_snapshot , & ctx );
1453
+
1454
+ if (write_midx_bitmap (midx_name .buf , midx_hash , & pdata ,
1455
+ commits , commits_nr , ctx .pack_order ,
1448
1456
refs_snapshot , flags ) < 0 ) {
1449
1457
error (_ ("could not write multi-pack bitmap" ));
1450
1458
result = 1 ;
0 commit comments