]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs: use 'uint64_t' for 'ref_update.index'
authorKarthik Nayak <karthik.188@gmail.com>
Wed, 22 Jan 2025 05:35:48 +0000 (06:35 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Jan 2025 17:51:36 +0000 (09:51 -0800)
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>
refs.c
refs/refs-internal.h
refs/reftable-backend.c

diff --git a/refs.c b/refs.c
index ad6d774717150f1fe68a59c629e05e49a469693f..ef04f403a6a3a34f9156b4cf68c3daa29c9cbad6 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1331,7 +1331,7 @@ static int ref_transaction_update_reflog(struct ref_transaction *transaction,
                                         const char *committer_info,
                                         unsigned int flags,
                                         const char *msg,
-                                        unsigned int index,
+                                        uint64_t index,
                                         struct strbuf *err)
 {
        struct ref_update *update;
@@ -2813,7 +2813,7 @@ done:
 }
 
 struct reflog_migration_data {
-       unsigned int index;
+       uint64_t index;
        const char *refname;
        struct ref_store *old_refs;
        struct ref_transaction *transaction;
index aaab711bb96844755dfa600d37efdb25b30a0765..8894b43d1d1a327d404d3923c507d2d39649de19 100644 (file)
@@ -120,7 +120,7 @@ struct ref_update {
         * when migrating reflogs and we want to ensure we carry over the
         * same order.
         */
-       unsigned int index;
+       uint64_t index;
 
        /*
         * If this ref_update was split off of a symref update via
@@ -203,7 +203,7 @@ struct ref_transaction {
        enum ref_transaction_state state;
        void *backend_data;
        unsigned int flags;
-       unsigned int max_index;
+       uint64_t max_index;
 };
 
 /*
index 289496058e6eb4d3e3aef96ca70219cd4ff78eae..6814c87bc618229ac8a70b904be3f850371ad876 100644 (file)
@@ -942,7 +942,7 @@ struct write_transaction_table_arg {
        size_t updates_nr;
        size_t updates_alloc;
        size_t updates_expected;
-       unsigned int max_index;
+       uint64_t max_index;
 };
 
 struct reftable_transaction_data {