@@ -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 {
@@ -1428,7 +1429,6 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
14281429 struct reftable_log_record * logs = NULL ;
14291430 struct ident_split committer_ident = {0 };
14301431 size_t logs_nr = 0 , logs_alloc = 0 , i ;
1431- uint64_t max_update_index = ts ;
14321432 const char * committer_info ;
14331433 int ret = 0 ;
14341434
@@ -1438,7 +1438,12 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
14381438
14391439 QSORT (arg -> updates , arg -> updates_nr , transaction_update_cmp );
14401440
1441- reftable_writer_set_limits (writer , ts , ts );
1441+ /*
1442+ * During reflog migration, we add indexes for a single reflog with
1443+ * multiple entries. Each entry will contain a different update_index,
1444+ * so set the limits accordingly.
1445+ */
1446+ reftable_writer_set_limits (writer , ts , ts + arg -> max_index );
14421447
14431448 for (i = 0 ; i < arg -> updates_nr ; i ++ ) {
14441449 struct reftable_transaction_update * tx_update = & arg -> updates [i ];
@@ -1540,12 +1545,6 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
15401545 */
15411546 log -> update_index = ts + u -> index ;
15421547
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-
15491548 log -> refname = xstrdup (u -> refname );
15501549 memcpy (log -> value .update .new_hash ,
15511550 u -> new_oid .hash , GIT_MAX_RAWSZ );
@@ -1609,8 +1608,6 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
16091608 * and log blocks.
16101609 */
16111610 if (logs ) {
1612- reftable_writer_set_limits (writer , ts , max_update_index );
1613-
16141611 ret = reftable_writer_add_logs (writer , logs , logs_nr );
16151612 if (ret < 0 )
16161613 goto done ;
@@ -1631,6 +1628,9 @@ static int reftable_be_transaction_finish(struct ref_store *ref_store UNUSED,
16311628 struct reftable_transaction_data * tx_data = transaction -> backend_data ;
16321629 int ret = 0 ;
16331630
1631+ if (tx_data -> args )
1632+ tx_data -> args -> max_index = transaction -> max_index ;
1633+
16341634 for (size_t i = 0 ; i < tx_data -> args_nr ; i ++ ) {
16351635 ret = reftable_addition_add (tx_data -> args [i ].addition ,
16361636 write_transaction_table , & tx_data -> args [i ]);
0 commit comments