@@ -942,6 +942,7 @@ struct write_transaction_table_arg {
942
942
size_t updates_nr ;
943
943
size_t updates_alloc ;
944
944
size_t updates_expected ;
945
+ unsigned int max_index ;
945
946
};
946
947
947
948
struct reftable_transaction_data {
@@ -1019,6 +1020,7 @@ static int prepare_transaction_update(struct write_transaction_table_arg **out,
1019
1020
arg -> updates_nr = 0 ;
1020
1021
arg -> updates_alloc = 0 ;
1021
1022
arg -> updates_expected = 0 ;
1023
+ arg -> max_index = 0 ;
1022
1024
}
1023
1025
1024
1026
arg -> updates_expected ++ ;
@@ -1428,7 +1430,6 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
1428
1430
struct reftable_log_record * logs = NULL ;
1429
1431
struct ident_split committer_ident = {0 };
1430
1432
size_t logs_nr = 0 , logs_alloc = 0 , i ;
1431
- uint64_t max_update_index = ts ;
1432
1433
const char * committer_info ;
1433
1434
int ret = 0 ;
1434
1435
@@ -1438,7 +1439,12 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
1438
1439
1439
1440
QSORT (arg -> updates , arg -> updates_nr , transaction_update_cmp );
1440
1441
1441
- reftable_writer_set_limits (writer , ts , ts );
1442
+ /*
1443
+ * During reflog migration, we add indexes for a single reflog with
1444
+ * multiple entries. Each entry will contain a different update_index,
1445
+ * so set the limits accordingly.
1446
+ */
1447
+ reftable_writer_set_limits (writer , ts , ts + arg -> max_index );
1442
1448
1443
1449
for (i = 0 ; i < arg -> updates_nr ; i ++ ) {
1444
1450
struct reftable_transaction_update * tx_update = & arg -> updates [i ];
@@ -1540,12 +1546,6 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
1540
1546
*/
1541
1547
log -> update_index = ts + u -> index ;
1542
1548
1543
- /*
1544
- * Note the max update_index so the limit can be set later on.
1545
- */
1546
- if (log -> update_index > max_update_index )
1547
- max_update_index = log -> update_index ;
1548
-
1549
1549
log -> refname = xstrdup (u -> refname );
1550
1550
memcpy (log -> value .update .new_hash ,
1551
1551
u -> new_oid .hash , GIT_MAX_RAWSZ );
@@ -1609,8 +1609,6 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
1609
1609
* and log blocks.
1610
1610
*/
1611
1611
if (logs ) {
1612
- reftable_writer_set_limits (writer , ts , max_update_index );
1613
-
1614
1612
ret = reftable_writer_add_logs (writer , logs , logs_nr );
1615
1613
if (ret < 0 )
1616
1614
goto done ;
@@ -1632,6 +1630,8 @@ static int reftable_be_transaction_finish(struct ref_store *ref_store UNUSED,
1632
1630
int ret = 0 ;
1633
1631
1634
1632
for (size_t i = 0 ; i < tx_data -> args_nr ; i ++ ) {
1633
+ tx_data -> args [i ].max_index = transaction -> max_index ;
1634
+
1635
1635
ret = reftable_addition_add (tx_data -> args [i ].addition ,
1636
1636
write_transaction_table , & tx_data -> args [i ]);
1637
1637
if (ret < 0 )
0 commit comments