@@ -913,15 +913,6 @@ static int write_midx_bitmap(struct write_midx_context *ctx,
913
913
return ret ;
914
914
}
915
915
916
- static struct multi_pack_index * lookup_multi_pack_index (struct repository * r ,
917
- const char * object_dir )
918
- {
919
- struct odb_source * source = odb_find_source (r -> objects , object_dir );
920
- if (!source )
921
- die (_ ("could not find object directory matching %s" ), object_dir );
922
- return get_multi_pack_index (source );
923
- }
924
-
925
916
static int fill_packs_from_midx (struct write_midx_context * ctx ,
926
917
const char * preferred_pack_name , uint32_t flags )
927
918
{
@@ -1012,7 +1003,7 @@ static int link_midx_to_chain(struct multi_pack_index *m)
1012
1003
return ret ;
1013
1004
}
1014
1005
1015
- static void clear_midx_files (struct repository * r , const char * object_dir ,
1006
+ static void clear_midx_files (struct odb_source * source ,
1016
1007
const char * * hashes , uint32_t hashes_nr ,
1017
1008
unsigned incremental )
1018
1009
{
@@ -1031,30 +1022,31 @@ static void clear_midx_files(struct repository *r, const char *object_dir,
1031
1022
uint32_t i , j ;
1032
1023
1033
1024
for (i = 0 ; i < ARRAY_SIZE (exts ); i ++ ) {
1034
- clear_incremental_midx_files_ext (object_dir , exts [i ],
1025
+ clear_incremental_midx_files_ext (source -> path , exts [i ],
1035
1026
hashes , hashes_nr );
1036
1027
for (j = 0 ; j < hashes_nr ; j ++ )
1037
- clear_midx_files_ext (object_dir , exts [i ], hashes [j ]);
1028
+ clear_midx_files_ext (source -> path , exts [i ], hashes [j ]);
1038
1029
}
1039
1030
1040
1031
if (incremental )
1041
- get_midx_filename (r -> hash_algo , & buf , object_dir );
1032
+ get_midx_filename (source -> odb -> repo -> hash_algo , & buf , source -> path );
1042
1033
else
1043
- get_midx_chain_filename (& buf , object_dir );
1034
+ get_midx_chain_filename (& buf , source -> path );
1044
1035
1045
1036
if (unlink (buf .buf ) && errno != ENOENT )
1046
1037
die_errno (_ ("failed to clear multi-pack-index at %s" ), buf .buf );
1047
1038
1048
1039
strbuf_release (& buf );
1049
1040
}
1050
1041
1051
- static int write_midx_internal (struct repository * r , const char * object_dir ,
1042
+ static int write_midx_internal (struct odb_source * source ,
1052
1043
struct string_list * packs_to_include ,
1053
1044
struct string_list * packs_to_drop ,
1054
1045
const char * preferred_pack_name ,
1055
1046
const char * refs_snapshot ,
1056
1047
unsigned flags )
1057
1048
{
1049
+ struct repository * r = source -> odb -> repo ;
1058
1050
struct strbuf midx_name = STRBUF_INIT ;
1059
1051
unsigned char midx_hash [GIT_MAX_RAWSZ ];
1060
1052
uint32_t i , start_pack ;
@@ -1078,15 +1070,15 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1078
1070
if (ctx .incremental )
1079
1071
strbuf_addf (& midx_name ,
1080
1072
"%s/pack/multi-pack-index.d/tmp_midx_XXXXXX" ,
1081
- object_dir );
1073
+ source -> path );
1082
1074
else
1083
- get_midx_filename (r -> hash_algo , & midx_name , object_dir );
1075
+ get_midx_filename (r -> hash_algo , & midx_name , source -> path );
1084
1076
if (safe_create_leading_directories (r , midx_name .buf ))
1085
1077
die_errno (_ ("unable to create leading directories of %s" ),
1086
1078
midx_name .buf );
1087
1079
1088
1080
if (!packs_to_include || ctx .incremental ) {
1089
- struct multi_pack_index * m = lookup_multi_pack_index ( r , object_dir );
1081
+ struct multi_pack_index * m = get_multi_pack_index ( source );
1090
1082
if (m && !midx_checksum_valid (m )) {
1091
1083
warning (_ ("ignoring existing multi-pack-index; checksum mismatch" ));
1092
1084
m = NULL ;
@@ -1140,7 +1132,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1140
1132
1141
1133
ctx .to_include = packs_to_include ;
1142
1134
1143
- for_each_file_in_pack_dir (object_dir , add_pack_to_midx , & ctx );
1135
+ for_each_file_in_pack_dir (source -> path , add_pack_to_midx , & ctx );
1144
1136
stop_progress (& ctx .progress );
1145
1137
1146
1138
if ((ctx .m && ctx .nr == ctx .m -> num_packs + ctx .m -> num_packs_in_base ) &&
@@ -1160,7 +1152,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1160
1152
* corresponding bitmap (or one wasn't requested).
1161
1153
*/
1162
1154
if (!want_bitmap )
1163
- clear_midx_files_ext (object_dir , "bitmap" , NULL );
1155
+ clear_midx_files_ext (source -> path , "bitmap" , NULL );
1164
1156
goto cleanup ;
1165
1157
}
1166
1158
}
@@ -1328,7 +1320,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1328
1320
if (ctx .incremental ) {
1329
1321
struct strbuf lock_name = STRBUF_INIT ;
1330
1322
1331
- get_midx_chain_filename (& lock_name , object_dir );
1323
+ get_midx_chain_filename (& lock_name , source -> path );
1332
1324
hold_lock_file_for_update (& lk , lock_name .buf , LOCK_DIE_ON_ERROR );
1333
1325
strbuf_release (& lock_name );
1334
1326
@@ -1391,7 +1383,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1391
1383
1392
1384
if (flags & MIDX_WRITE_REV_INDEX &&
1393
1385
git_env_bool ("GIT_TEST_MIDX_WRITE_REV" , 0 ))
1394
- write_midx_reverse_index (& ctx , object_dir , midx_hash );
1386
+ write_midx_reverse_index (& ctx , source -> path , midx_hash );
1395
1387
1396
1388
if (flags & MIDX_WRITE_BITMAP ) {
1397
1389
struct packing_data pdata ;
@@ -1414,7 +1406,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1414
1406
FREE_AND_NULL (ctx .entries );
1415
1407
ctx .entries_nr = 0 ;
1416
1408
1417
- if (write_midx_bitmap (& ctx , object_dir ,
1409
+ if (write_midx_bitmap (& ctx , source -> path ,
1418
1410
midx_hash , & pdata , commits , commits_nr ,
1419
1411
flags ) < 0 ) {
1420
1412
error (_ ("could not write multi-pack bitmap" ));
@@ -1448,7 +1440,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1448
1440
return -1 ;
1449
1441
1450
1442
get_split_midx_filename_ext (r -> hash_algo , & final_midx_name ,
1451
- object_dir , midx_hash , MIDX_EXT_MIDX );
1443
+ source -> path , midx_hash , MIDX_EXT_MIDX );
1452
1444
1453
1445
if (rename_tempfile (& incr , final_midx_name .buf ) < 0 ) {
1454
1446
error_errno (_ ("unable to rename new multi-pack-index layer" ));
@@ -1481,7 +1473,7 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1481
1473
if (commit_lock_file (& lk ) < 0 )
1482
1474
die_errno (_ ("could not write multi-pack-index" ));
1483
1475
1484
- clear_midx_files (r , object_dir , keep_hashes ,
1476
+ clear_midx_files (source , keep_hashes ,
1485
1477
ctx .num_multi_pack_indexes_before + 1 ,
1486
1478
ctx .incremental );
1487
1479
@@ -1510,29 +1502,29 @@ static int write_midx_internal(struct repository *r, const char *object_dir,
1510
1502
return result ;
1511
1503
}
1512
1504
1513
- int write_midx_file (struct repository * r , const char * object_dir ,
1505
+ int write_midx_file (struct odb_source * source ,
1514
1506
const char * preferred_pack_name ,
1515
1507
const char * refs_snapshot , unsigned flags )
1516
1508
{
1517
- return write_midx_internal (r , object_dir , NULL , NULL ,
1509
+ return write_midx_internal (source , NULL , NULL ,
1518
1510
preferred_pack_name , refs_snapshot ,
1519
1511
flags );
1520
1512
}
1521
1513
1522
- int write_midx_file_only (struct repository * r , const char * object_dir ,
1514
+ int write_midx_file_only (struct odb_source * source ,
1523
1515
struct string_list * packs_to_include ,
1524
1516
const char * preferred_pack_name ,
1525
1517
const char * refs_snapshot , unsigned flags )
1526
1518
{
1527
- return write_midx_internal (r , object_dir , packs_to_include , NULL ,
1519
+ return write_midx_internal (source , packs_to_include , NULL ,
1528
1520
preferred_pack_name , refs_snapshot , flags );
1529
1521
}
1530
1522
1531
- int expire_midx_packs (struct repository * r , const char * object_dir , unsigned flags )
1523
+ int expire_midx_packs (struct odb_source * source , unsigned flags )
1532
1524
{
1533
1525
uint32_t i , * count , result = 0 ;
1534
1526
struct string_list packs_to_drop = STRING_LIST_INIT_DUP ;
1535
- struct multi_pack_index * m = lookup_multi_pack_index ( r , object_dir );
1527
+ struct multi_pack_index * m = get_multi_pack_index ( source );
1536
1528
struct progress * progress = NULL ;
1537
1529
1538
1530
if (!m )
@@ -1545,7 +1537,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
1545
1537
1546
1538
if (flags & MIDX_PROGRESS )
1547
1539
progress = start_delayed_progress (
1548
- r ,
1540
+ source -> odb -> repo ,
1549
1541
_ ("Counting referenced objects" ),
1550
1542
m -> num_objects );
1551
1543
for (i = 0 ; i < m -> num_objects ; i ++ ) {
@@ -1557,7 +1549,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
1557
1549
1558
1550
if (flags & MIDX_PROGRESS )
1559
1551
progress = start_delayed_progress (
1560
- r ,
1552
+ source -> odb -> repo ,
1561
1553
_ ("Finding and deleting unreferenced packfiles" ),
1562
1554
m -> num_packs );
1563
1555
for (i = 0 ; i < m -> num_packs ; i ++ ) {
@@ -1585,7 +1577,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
1585
1577
free (count );
1586
1578
1587
1579
if (packs_to_drop .nr )
1588
- result = write_midx_internal (r , object_dir , NULL ,
1580
+ result = write_midx_internal (source , NULL ,
1589
1581
& packs_to_drop , NULL , NULL , flags );
1590
1582
1591
1583
string_list_clear (& packs_to_drop , 0 );
@@ -1710,14 +1702,15 @@ static void fill_included_packs_batch(struct repository *r,
1710
1702
free (pack_info );
1711
1703
}
1712
1704
1713
- int midx_repack (struct repository * r , const char * object_dir , size_t batch_size , unsigned flags )
1705
+ int midx_repack (struct odb_source * source , size_t batch_size , unsigned flags )
1714
1706
{
1707
+ struct repository * r = source -> odb -> repo ;
1715
1708
int result = 0 ;
1716
1709
uint32_t i , packs_to_repack = 0 ;
1717
1710
unsigned char * include_pack ;
1718
1711
struct child_process cmd = CHILD_PROCESS_INIT ;
1719
1712
FILE * cmd_in ;
1720
- struct multi_pack_index * m = lookup_multi_pack_index ( r , object_dir );
1713
+ struct multi_pack_index * m = get_multi_pack_index ( source );
1721
1714
1722
1715
/*
1723
1716
* When updating the default for these configuration
@@ -1751,7 +1744,7 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
1751
1744
1752
1745
strvec_push (& cmd .args , "pack-objects" );
1753
1746
1754
- strvec_pushf (& cmd .args , "%s/pack/pack" , object_dir );
1747
+ strvec_pushf (& cmd .args , "%s/pack/pack" , source -> path );
1755
1748
1756
1749
if (delta_base_offset )
1757
1750
strvec_push (& cmd .args , "--delta-base-offset" );
@@ -1792,7 +1785,7 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
1792
1785
goto cleanup ;
1793
1786
}
1794
1787
1795
- result = write_midx_internal (r , object_dir , NULL , NULL , NULL , NULL ,
1788
+ result = write_midx_internal (source , NULL , NULL , NULL , NULL ,
1796
1789
flags );
1797
1790
1798
1791
cleanup :
0 commit comments