Skip to content

Commit df71591

Browse files
KarthikNayakdscho
authored andcommitted
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 <[email protected]> Signed-off-by: Karthik Nayak <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ba9f503 commit df71591

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

refs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ static int ref_transaction_update_reflog(struct ref_transaction *transaction,
13311331
const char *committer_info,
13321332
unsigned int flags,
13331333
const char *msg,
1334-
unsigned int index,
1334+
uint64_t index,
13351335
struct strbuf *err)
13361336
{
13371337
struct ref_update *update;
@@ -2813,7 +2813,7 @@ static int migrate_one_ref(const char *refname, const char *referent UNUSED, con
28132813
}
28142814

28152815
struct reflog_migration_data {
2816-
unsigned int index;
2816+
uint64_t index;
28172817
const char *refname;
28182818
struct ref_store *old_refs;
28192819
struct ref_transaction *transaction;

refs/refs-internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ struct ref_update {
120120
* when migrating reflogs and we want to ensure we carry over the
121121
* same order.
122122
*/
123-
unsigned int index;
123+
uint64_t index;
124124

125125
/*
126126
* If this ref_update was split off of a symref update via
@@ -203,7 +203,7 @@ struct ref_transaction {
203203
enum ref_transaction_state state;
204204
void *backend_data;
205205
unsigned int flags;
206-
unsigned int max_index;
206+
uint64_t max_index;
207207
};
208208

209209
/*

refs/reftable-backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +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;
945+
uint64_t max_index;
946946
};
947947

948948
struct reftable_transaction_data {

0 commit comments

Comments
 (0)