@@ -942,6 +942,7 @@ struct write_transaction_table_arg {
942942 size_t updates_nr ;
943943 size_t updates_alloc ;
944944 size_t updates_expected ;
945+ unsigned int max_index ;
945946};
946947
947948struct reftable_transaction_data {
@@ -1019,6 +1020,7 @@ static int prepare_transaction_update(struct write_transaction_table_arg **out,
10191020 arg -> updates_nr = 0 ;
10201021 arg -> updates_alloc = 0 ;
10211022 arg -> updates_expected = 0 ;
1023+ arg -> max_index = 0 ;
10221024 }
10231025
10241026 arg -> updates_expected ++ ;
@@ -1428,7 +1430,6 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
14281430 struct reftable_log_record * logs = NULL ;
14291431 struct ident_split committer_ident = {0 };
14301432 size_t logs_nr = 0 , logs_alloc = 0 , i ;
1431- uint64_t max_update_index = ts ;
14321433 const char * committer_info ;
14331434 int ret = 0 ;
14341435
@@ -1438,7 +1439,12 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
14381439
14391440 QSORT (arg -> updates , arg -> updates_nr , transaction_update_cmp );
14401441
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 );
14421448
14431449 for (i = 0 ; i < arg -> updates_nr ; i ++ ) {
14441450 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
15401546 */
15411547 log -> update_index = ts + u -> index ;
15421548
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-
15491549 log -> refname = xstrdup (u -> refname );
15501550 memcpy (log -> value .update .new_hash ,
15511551 u -> new_oid .hash , GIT_MAX_RAWSZ );
@@ -1609,8 +1609,6 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
16091609 * and log blocks.
16101610 */
16111611 if (logs ) {
1612- reftable_writer_set_limits (writer , ts , max_update_index );
1613-
16141612 ret = reftable_writer_add_logs (writer , logs , logs_nr );
16151613 if (ret < 0 )
16161614 goto done ;
@@ -1632,6 +1630,8 @@ static int reftable_be_transaction_finish(struct ref_store *ref_store UNUSED,
16321630 int ret = 0 ;
16331631
16341632 for (size_t i = 0 ; i < tx_data -> args_nr ; i ++ ) {
1633+ tx_data -> args [i ].max_index = transaction -> max_index ;
1634+
16351635 ret = reftable_addition_add (tx_data -> args [i ].addition ,
16361636 write_transaction_table , & tx_data -> args [i ]);
16371637 if (ret < 0 )
0 commit comments