refs: use 'uint64_t' for 'ref_update.index'
The 'ref_update.index' variable is used to store an index for a given reference update. This index is used to order the updates in a predetermined order, while the default ordering is alphabetical as per the refname. For large repositories with millions of references, it should be safer to use 'uint64_t'. Let's do that. This also is applied for all other code sections where we store 'index' and pass it around. Reported-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Karthik Nayak committed
Jan 22, 2025 at 06:35 UTC
e7c1b9f1231e49f5e0c5250ec84c68376619f415
3 files changed
+5
-5
refs.c
+2
-2
@@ -1331,7 +1331,7 @@ static int ref_transaction_update_reflog(struct ref_transaction *transaction,
1331
const char *committer_info,
1332
unsigned int flags,
1333
const char *msg,
1334
- unsigned int index,
1334
+ uint64_t index,
1335
struct strbuf *err)
1336
{
1337
struct ref_update *update;
@@ -2813,7 +2813,7 @@ done:
2813
}
2814
2815
struct reflog_migration_data {
2816
- unsigned int index;
2816
+ uint64_t index;
2817
const char *refname;
2818
struct ref_store *old_refs;
2819
struct ref_transaction *transaction;
refs/refs-internal.h
+2
-2
@@ -120,7 +120,7 @@ struct ref_update {
120
* when migrating reflogs and we want to ensure we carry over the
121
* same order.
122
*/
123
- unsigned int index;
123
+ uint64_t index;
124
125
/*
126
* If this ref_update was split off of a symref update via
@@ -203,7 +203,7 @@ struct ref_transaction {
203
enum ref_transaction_state state;
204
void *backend_data;
205
unsigned int flags;
206
- unsigned int max_index;
206
+ uint64_t max_index;
207
};
208
209
/*
refs/reftable-backend.c
+1
-1
@@ -942,7 +942,7 @@ struct write_transaction_table_arg {
942
size_t updates_nr;
943
size_t updates_alloc;
944
size_t updates_expected;
945
- unsigned int max_index;
945
+ uint64_t max_index;
946
};
947
948
struct reftable_transaction_data {