]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb: use size_t for object_info.sizep and the size APIs
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 15 Jun 2026 11:52:29 +0000 (11:52 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Jun 2026 14:45:41 +0000 (07:45 -0700)
When `js/objects-larger-than-4gb-on-windows` widened the streaming,
index-pack and unpack-objects code paths, in the interest of keeping the
patches somewhat reasonably-sized, it left the public ODB API still
typed in `unsigned long`. In particular `struct object_info::sizep` and
the four wrappers built on top of it (`odb_read_object`,
`odb_read_object_peeled`, `odb_read_object_info`, `odb_pretend_object`)
still return the unpacked size through `unsigned long *`, so on Windows
`cat-file -s` and the `git add` / `git status` paths for a >4 GiB blob
silently cap at 4 GiB.

Widen the field and the four wrappers. The previous commits already
widened the `unpack_entry()` cascade and pack-objects' in-core size
accessors, so most of the cascade arrives here with no further work: the
temporary shims in `packed_object_info_with_index_pos()` and in
`unpack_entry()`'s delta-base recovery path go away, the two
`SET_SIZE(entry, cast_size_t_to_ulong(canonical_size))` calls in
`check_object()` and the matching one in `drop_reused_delta()` collapse
to plain `SET_SIZE`, and `oe_get_size_slow()`'s tail
`cast_size_t_to_ulong()` is gone too.

What remains narrow are the boundaries this series does not
intend to touch: the diff, blame, textconv and fast-import machinery.

Even so, this patch is unfortunately quite large.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
65 files changed:
apply.c
archive.c
attr.c
bisect.c
blame.c
builtin/cat-file.c
builtin/difftool.c
builtin/fast-export.c
builtin/fast-import.c
builtin/fsck.c
builtin/grep.c
builtin/index-pack.c
builtin/log.c
builtin/ls-files.c
builtin/ls-tree.c
builtin/merge-tree.c
builtin/mktag.c
builtin/notes.c
builtin/pack-objects.c
builtin/repo.c
builtin/tag.c
builtin/unpack-file.c
builtin/unpack-objects.c
bundle.c
combine-diff.c
commit.c
config.c
diff.c
dir.c
entry.c
fmt-merge-msg.c
fsck.c
grep.c
http-push.c
list-objects-filter.c
mailmap.c
match-trees.c
merge-blobs.c
merge-blobs.h
merge-ort.c
notes-cache.c
notes-merge.c
notes.c
object-file.c
object.c
odb.c
odb.h
odb/source-loose.c
odb/streaming.c
pack-bitmap.c
packfile.c
path-walk.c
protocol-caps.c
read-cache.c
ref-filter.c
reflog.c
rerere.c
submodule-config.c
t/helper/test-pack-deltas.c
t/helper/test-partial-clone.c
t/unit-tests/u-odb-inmemory.c
tag.c
tree-walk.c
tree.c
xdiff-interface.c

diff --git a/apply.c b/apply.c
index 3cf544e9a966293c93d1724fbeebb3bba82055e2..5e54453f799ea2ccc736e4f213641e4bdd95a07d 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -3321,7 +3321,7 @@ static int apply_binary(struct apply_state *state,
        if (odb_has_object(the_repository->objects, &oid, 0)) {
                /* We already have the postimage */
                enum object_type type;
-               unsigned long size;
+               size_t size;
                char *result;
 
                result = odb_read_object(the_repository->objects, &oid,
@@ -3384,7 +3384,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
                strbuf_addf(buf, "Subproject commit %s\n", oid_to_hex(oid));
        } else {
                enum object_type type;
-               unsigned long sz;
+               size_t sz;
                char *result;
 
                result = odb_read_object(the_repository->objects, oid,
@@ -3611,7 +3611,7 @@ static int load_preimage(struct apply_state *state,
 
 static int resolve_to(struct image *image, const struct object_id *result_id)
 {
-       unsigned long size;
+       size_t size;
        enum object_type type;
        char *data;
 
index 51229107a57495b7b2bae34f53efa79c84f9c317..59790be98697c6eab65d4e56821d14dd736c910a 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -87,7 +87,7 @@ static void *object_file_to_archive(const struct archiver_args *args,
                                    const struct object_id *oid,
                                    unsigned int mode,
                                    enum object_type *type,
-                                   unsigned long *sizep)
+                                   size_t *sizep)
 {
        void *buffer;
        const struct commit *commit = args->convert ? args->commit : NULL;
@@ -158,7 +158,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,
        write_archive_entry_fn_t write_entry = c->write_entry;
        int err;
        const char *path_without_prefix;
-       unsigned long size;
+       size_t size;
        void *buffer;
        enum object_type type;
 
diff --git a/attr.c b/attr.c
index 75369547b306d6ee838ca81d844e47e9b9894d70..c61472a4e61e0a682aa19ec721d8687169d259fc 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -768,7 +768,7 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate,
                                              const char *path, unsigned flags)
 {
        struct object_id oid;
-       unsigned long sz;
+       size_t sz;
        enum object_type type;
        void *buf;
        unsigned short mode;
index e29d1cbc64dc44dcb6726f5c7080bfbf385c3f7d..94c7028d2a746a97196ede94ae1db7bcba1afa17 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -154,7 +154,7 @@ static void show_list(const char *debug, int counted, int nr,
                struct commit *commit = p->item;
                unsigned commit_flags = commit->object.flags;
                enum object_type type;
-               unsigned long size;
+               size_t size;
                char *buf = odb_read_object(the_repository->objects,
                                            &commit->object.oid, &type,
                                            &size);
diff --git a/blame.c b/blame.c
index 977cbb70974f8c345356c0c930223c6cd8383337..126e23241623530b57f126eaaf77e1d61bf408d2 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -1041,10 +1041,13 @@ static void fill_origin_blob(struct diff_options *opt,
                    textconv_object(opt->repo, o->path, o->mode,
                                    &o->blob_oid, 1, &file->ptr, &file_size))
                        ;
-               else
+               else {
+                       size_t file_size_st = 0;
                        file->ptr = odb_read_object(the_repository->objects,
                                                    &o->blob_oid, &type,
-                                                   &file_size);
+                                                   &file_size_st);
+                       file_size = cast_size_t_to_ulong(file_size_st);
+               }
                file->size = file_size;
 
                if (!file->ptr)
@@ -2869,10 +2872,14 @@ void setup_scoreboard(struct blame_scoreboard *sb,
                    textconv_object(sb->repo, sb->path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,
                                    &sb->final_buf_size))
                        ;
-               else
+               else {
+                       size_t final_buf_size_st = 0;
                        sb->final_buf = odb_read_object(the_repository->objects,
                                                        &o->blob_oid, &type,
-                                                       &sb->final_buf_size);
+                                                       &final_buf_size_st);
+                       sb->final_buf_size =
+                               cast_size_t_to_ulong(final_buf_size_st);
+               }
 
                if (!sb->final_buf)
                        die(_("cannot read blob %s for path %s"),
index 2b64f8f733db7b467a97e32b58f4cb335a8b2135..adb2ef51307de56662dc85129ee235130020dce7 100644 (file)
@@ -84,7 +84,7 @@ static char *replace_idents_using_mailmap(char *object_buf, size_t *size)
 
 static int filter_object(const char *path, unsigned mode,
                         const struct object_id *oid,
-                        char **buf, unsigned long *size)
+                        char **buf, size_t *size)
 {
        enum object_type type;
 
@@ -120,7 +120,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
        struct object_id oid;
        enum object_type type;
        char *buf;
-       unsigned long size;
+       size_t size;
        struct object_context obj_context = {0};
        struct object_info oi = OBJECT_INFO_INIT;
        unsigned flags = OBJECT_INFO_LOOKUP_REPLACE;
@@ -163,11 +163,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
                if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)
                        die("git cat-file: could not get object info");
 
-               if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {
-                       size_t s = size;
-                       buf = replace_idents_using_mailmap(buf, &s);
-                       size = cast_size_t_to_ulong(s);
-               }
+               if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG))
+                       buf = replace_idents_using_mailmap(buf, &size);
 
                printf("%"PRIuMAX"\n", (uintmax_t)size);
                ret = 0;
@@ -188,9 +185,15 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
                break;
 
        case 'c':
-               if (textconv_object(the_repository, path, obj_context.mode,
-                                   &oid, 1, &buf, &size))
+       {
+               unsigned long size_ul = 0;
+               int textconv_ret = textconv_object(the_repository, path,
+                                                  obj_context.mode, &oid, 1,
+                                                  &buf, &size_ul);
+               size = size_ul;
+               if (textconv_ret)
                        break;
+       }
                /* else fallthrough */
 
        case 'p':
@@ -216,11 +219,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
                if (!buf)
                        die("Cannot read object %s", obj_name);
 
-               if (use_mailmap) {
-                       size_t s = size;
-                       buf = replace_idents_using_mailmap(buf, &s);
-                       size = cast_size_t_to_ulong(s);
-               }
+               if (use_mailmap)
+                       buf = replace_idents_using_mailmap(buf, &size);
 
                /* otherwise just spit out the data */
                break;
@@ -263,11 +263,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
                buf = odb_read_object_peeled(the_repository->objects, &oid,
                                             exp_type_id, &size, NULL);
 
-               if (use_mailmap) {
-                       size_t s = size;
-                       buf = replace_idents_using_mailmap(buf, &s);
-                       size = cast_size_t_to_ulong(s);
-               }
+               if (use_mailmap)
+                       buf = replace_idents_using_mailmap(buf, &size);
                break;
        }
        default:
@@ -288,7 +285,7 @@ cleanup:
 struct expand_data {
        struct object_id oid;
        enum object_type type;
-       unsigned long size;
+       size_t size;
        unsigned short mode;
        off_t disk_size;
        const char *rest;
@@ -404,7 +401,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
                        fflush(stdout);
                if (opt->transform_mode) {
                        char *contents;
-                       unsigned long size;
+                       size_t size;
 
                        if (!data->rest)
                                die("missing path for '%s'", oid_to_hex(oid));
@@ -416,9 +413,12 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
                                            oid_to_hex(oid), data->rest);
                        } else if (opt->transform_mode == 'c') {
                                enum object_type type;
-                               if (!textconv_object(the_repository,
-                                                    data->rest, 0100644, oid,
-                                                    1, &contents, &size))
+                               unsigned long size_ul = 0;
+                               if (textconv_object(the_repository,
+                                                   data->rest, 0100644, oid,
+                                                   1, &contents, &size_ul))
+                                       size = size_ul;
+                               else
                                        contents = odb_read_object(the_repository->objects,
                                                                   oid, &type, &size);
                                if (!contents)
@@ -434,7 +434,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
        }
        else {
                enum object_type type;
-               unsigned long size;
+               size_t size;
                void *contents;
 
                contents = odb_read_object(the_repository->objects, oid,
@@ -442,11 +442,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
                if (!contents)
                        die("object %s disappeared", oid_to_hex(oid));
 
-               if (use_mailmap) {
-                       size_t s = size;
-                       contents = replace_idents_using_mailmap(contents, &s);
-                       size = cast_size_t_to_ulong(s);
-               }
+               if (use_mailmap)
+                       contents = replace_idents_using_mailmap(contents, &size);
 
                if (type != data->type)
                        die("object %s changed type!?", oid_to_hex(oid));
@@ -546,15 +543,13 @@ static void batch_object_write(const char *obj_name,
                }
 
                if (use_mailmap && (data->type == OBJ_COMMIT || data->type == OBJ_TAG)) {
-                       size_t s = data->size;
                        char *buf = NULL;
 
                        buf = odb_read_object(the_repository->objects, &data->oid,
                                              &data->type, &data->size);
                        if (!buf)
                                die(_("unable to read %s"), oid_to_hex(&data->oid));
-                       buf = replace_idents_using_mailmap(buf, &s);
-                       data->size = cast_size_t_to_ulong(s);
+                       buf = replace_idents_using_mailmap(buf, &data->size);
 
                        free(buf);
                }
index 2a21005f2ee26489d8e2a5d0b7d0d4eaa6a8bdae..26778f8515deefc835c041a69a98655718e87bb1 100644 (file)
@@ -319,7 +319,7 @@ static char *get_symlink(struct repository *repo,
                data = strbuf_detach(&link, NULL);
        } else {
                enum object_type type;
-               unsigned long size;
+               size_t size;
                data = odb_read_object(repo->objects, oid, &type, &size);
                if (!data)
                        die(_("could not read object %s for symlink %s"),
index 2eb43a28da748e19758c987c4d9e9a2d4169923b..0be43104dc0d23f9cef7e4b17a58e388ce281f31 100644 (file)
@@ -317,7 +317,10 @@ static void export_blob(const struct object_id *oid)
                object = (struct object *)lookup_blob(the_repository, oid);
                eaten = 0;
        } else {
-               buf = odb_read_object(the_repository->objects, oid, &type, &size);
+               size_t size_st = 0;
+               buf = odb_read_object(the_repository->objects, oid, &type,
+                                     &size_st);
+               size = cast_size_t_to_ulong(size_st);
                if (!buf)
                        die(_("could not read blob %s"), oid_to_hex(oid));
                if (check_object_signature(the_repository, oid, buf, size,
@@ -880,7 +883,7 @@ static char *anonymize_tag(void)
 
 static void handle_tag(const char *name, struct tag *tag)
 {
-       unsigned long size;
+       size_t size;
        enum object_type type;
        char *buf;
        const char *tagger, *tagger_end, *message;
index 3dff898c434692db670fbffb1b1368454a4a58a2..d11a2cc2c107c4f7a25a81743610f9d1b718f130 100644 (file)
@@ -1291,7 +1291,10 @@ static void load_tree(struct tree_entry *root)
                        die(_("can't load tree %s"), oid_to_hex(oid));
        } else {
                enum object_type type;
-               buf = odb_read_object(the_repository->objects, oid, &type, &size);
+               size_t size_st = 0;
+               buf = odb_read_object(the_repository->objects, oid, &type,
+                                     &size_st);
+               size = cast_size_t_to_ulong(size_st);
                if (!buf || type != OBJ_TREE)
                        die(_("can't load tree %s"), oid_to_hex(oid));
        }
@@ -2560,7 +2563,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
                        die(_("mark :%" PRIuMAX " not a commit"), commit_mark);
                oidcpy(&commit_oid, &commit_oe->idx.oid);
        } else if (!repo_get_oid(the_repository, p, &commit_oid)) {
-               unsigned long size;
+               size_t size;
                char *buf = odb_read_object_peeled(the_repository->objects,
                                                   &commit_oid, OBJ_COMMIT, &size,
                                                   &commit_oid);
@@ -2627,10 +2630,12 @@ static void parse_from_existing(struct branch *b)
                oidclr(&b->branch_tree.versions[1].oid, the_repository->hash_algo);
        } else {
                unsigned long size;
+               size_t size_st = 0;
                char *buf;
 
                buf = odb_read_object_peeled(the_repository->objects, &b->oid,
-                                            OBJ_COMMIT, &size, &b->oid);
+                                            OBJ_COMMIT, &size_st, &b->oid);
+               size = cast_size_t_to_ulong(size_st);
                parse_from_commit(b, buf, size);
                free(buf);
        }
@@ -2722,7 +2727,7 @@ static struct hash_list *parse_merge(unsigned int *count)
                                die(_("mark :%" PRIuMAX " not a commit"), idnum);
                        oidcpy(&n->oid, &oe->idx.oid);
                } else if (!repo_get_oid(the_repository, from, &n->oid)) {
-                       unsigned long size;
+                       size_t size;
                        char *buf = odb_read_object_peeled(the_repository->objects,
                                                           &n->oid, OBJ_COMMIT,
                                                           &size, &n->oid);
@@ -3330,7 +3335,10 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
        char *buf;
 
        if (!oe || oe->pack_id == MAX_PACK_ID) {
-               buf = odb_read_object(the_repository->objects, oid, &type, &size);
+               size_t size_st = 0;
+               buf = odb_read_object(the_repository->objects, oid, &type,
+                                     &size_st);
+               size = cast_size_t_to_ulong(size_st);
        } else {
                type = oe->type;
                buf = gfi_unpack_entry(oe, &size);
@@ -3438,8 +3446,10 @@ static struct object_entry *dereference(struct object_entry *oe,
                buf = gfi_unpack_entry(oe, &size);
        } else {
                enum object_type unused;
+               size_t size_st = 0;
                buf = odb_read_object(the_repository->objects, oid,
-                                     &unused, &size);
+                                     &unused, &size_st);
+               size = cast_size_t_to_ulong(size_st);
        }
        if (!buf)
                die(_("can't load object %s"), oid_to_hex(oid));
index 248f8ff5a03bc96c44b91f247faa2054923489ae..76b723f36d3dcae892b616c8c65d460d0ca62bac 100644 (file)
@@ -724,7 +724,7 @@ static int fsck_loose(const struct object_id *oid, const char *path,
        struct for_each_loose_cb *data = cb_data;
        struct object *obj;
        enum object_type type = OBJ_NONE;
-       unsigned long size;
+       size_t size;
        void *contents = NULL;
        int eaten;
        struct object_info oi = OBJECT_INFO_INIT;
index 6a09571903cd2605ba5b89f651f2d8dd2e515625..26b85479ca0d76102cd7b4d29f8311bc2f634906 100644 (file)
@@ -520,7 +520,7 @@ static int grep_submodule(struct grep_opt *opt,
                enum object_type object_type;
                struct tree_desc tree;
                void *data;
-               unsigned long size;
+               size_t size;
                struct strbuf base = STRBUF_INIT;
 
                obj_read_lock();
@@ -573,7 +573,7 @@ static int grep_cache(struct grep_opt *opt,
                        enum object_type type;
                        struct tree_desc tree;
                        void *data;
-                       unsigned long size;
+                       size_t size;
 
                        data = odb_read_object(the_repository->objects, &ce->oid,
                                               &type, &size);
@@ -666,7 +666,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
                        enum object_type type;
                        struct tree_desc sub;
                        void *data;
-                       unsigned long size;
+                       size_t size;
 
                        data = odb_read_object(the_repository->objects,
                                               &entry.oid, &type, &size);
@@ -730,7 +730,7 @@ static void collect_blob_oids_for_tree(struct repository *repo,
                        enum object_type type;
                        struct tree_desc sub_tree;
                        void *data;
-                       unsigned long size;
+                       size_t size;
 
                        data = odb_read_object(repo->objects, &entry.oid,
                                               &type, &size);
@@ -764,7 +764,7 @@ static void collect_blob_oids_for_treeish(struct grep_opt *opt,
 {
        struct tree_desc tree;
        void *data;
-       unsigned long size;
+       size_t size;
        struct strbuf base = STRBUF_INIT;
        int len;
 
@@ -841,7 +841,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
        if (obj->type == OBJ_COMMIT || obj->type == OBJ_TREE) {
                struct tree_desc tree;
                void *data;
-               unsigned long size;
+               size_t size;
                struct strbuf base;
                int hit, len;
 
index 3c4474e68113628851a26e445e01972508d15a71..78da3a6566a91a0c3f981eed4c64d15472af7944 100644 (file)
@@ -258,7 +258,7 @@ static unsigned check_object(struct object *obj)
                return 0;
 
        if (!(obj->flags & FLAG_CHECKED)) {
-               unsigned long size;
+               size_t size;
                int type = odb_read_object_info(the_repository->objects,
                                                &obj->oid, &size);
                if (type <= 0)
@@ -905,7 +905,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
        if (collision_test_needed) {
                void *has_data;
                enum object_type has_type;
-               unsigned long has_size;
+               size_t has_size;
                read_lock();
                has_type = odb_read_object_info(the_repository->objects, oid, &has_size);
                if (has_type < 0)
@@ -1515,7 +1515,7 @@ static void fix_unresolved_deltas(struct hashfile *f)
                struct ref_delta_entry *d = sorted_by_pos[i];
                enum object_type type;
                void *data;
-               unsigned long size;
+               size_t size;
 
                if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
                        continue;
index e464b30af4bcaeefcef23f480c89de5fc2cf6b75..d027ce1e0bc833a29327e133f91c18594569729e 100644 (file)
@@ -613,7 +613,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
 
 static int show_tag_object(const struct object_id *oid, struct rev_info *rev)
 {
-       unsigned long size;
+       size_t size;
        enum object_type type;
        char *buf = odb_read_object(the_repository->objects, oid, &type, &size);
        unsigned long offset = 0;
index 12d5d828ff581aeaf43124e618ac3ce25203ee8e..f30507215a01e4c9c7740d3e231d8ac236fdc314 100644 (file)
@@ -256,7 +256,7 @@ static void expand_objectsize(struct repository *repo, struct strbuf *line,
        size_t len;
 
        if (type == OBJ_BLOB) {
-               unsigned long size;
+               size_t size;
                if (odb_read_object_info(repo->objects, oid, &size) < 0)
                        die(_("could not get object info about '%s'"),
                            oid_to_hex(oid));
index 57846911ce443f3c554e5c340998c2414f65cb0d..46edaffc2e73cd079ad168ea3fc2b5d76ce3c114 100644 (file)
@@ -32,7 +32,7 @@ static void expand_objectsize(struct strbuf *line, const struct object_id *oid,
        size_t len;
 
        if (type == OBJ_BLOB) {
-               unsigned long size;
+               size_t size;
                if (odb_read_object_info(the_repository->objects, oid, &size) < 0)
                        die(_("could not get object info about '%s'"),
                            oid_to_hex(oid));
@@ -220,7 +220,7 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,
                return early;
 
        if (type == OBJ_BLOB) {
-               unsigned long size;
+               size_t size;
                if (odb_read_object_info(the_repository->objects, oid, &size) == OBJ_BAD)
                        xsnprintf(size_text, sizeof(size_text), "BAD");
                else
index 312b595d1e7ad267bec0b89b5bbdac02042fb1c4..49f41e520f1055604632fd1daf8350ee5e1c0200 100644 (file)
@@ -69,7 +69,7 @@ static const char *explanation(struct merge_list *entry)
        return "removed in remote";
 }
 
-static void *result(struct merge_list *entry, unsigned long *size)
+static void *result(struct merge_list *entry, size_t *size)
 {
        enum object_type type;
        struct blob *base, *our, *their;
@@ -96,7 +96,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
                           base, our, their, size);
 }
 
-static void *origin(struct merge_list *entry, unsigned long *size)
+static void *origin(struct merge_list *entry, size_t *size)
 {
        enum object_type type;
        while (entry) {
@@ -119,7 +119,7 @@ static int show_outf(void *priv UNUSED, mmbuffer_t *mb, int nbuf)
 
 static void show_diff(struct merge_list *entry)
 {
-       unsigned long size;
+       size_t size;
        mmfile_t src, dst;
        xpparam_t xpp;
        xdemitconf_t xecfg;
index f40264a87876f45c0dd8e38010e147cd7f026955..37c17e6beb8d933cc21579da901db45f502a5168 100644 (file)
@@ -50,7 +50,7 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)
 {
        int ret;
        enum object_type type;
-       unsigned long size;
+       size_t size;
        void *buffer;
        const struct object_id *repl;
 
index 9af602bdd7b402a32c92b8d24c232ed22d09f99f..962df867c8584331d575771f2e7548e1f0983eff 100644 (file)
@@ -150,7 +150,7 @@ static int list_each_note(const struct object_id *object_oid,
 
 static void copy_obj_to_fd(int fd, const struct object_id *oid)
 {
-       unsigned long size;
+       size_t size;
        enum object_type type;
        char *buf = odb_read_object(the_repository->objects, oid, &type, &size);
        if (buf) {
@@ -313,7 +313,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
        char *value;
        struct object_id object;
        enum object_type type;
-       unsigned long len;
+       size_t len;
 
        BUG_ON_OPT_NEG(unset);
 
@@ -721,7 +721,7 @@ static int append_edit(int argc, const char **argv, const char *prefix,
 
        if (note && !edit) {
                /* Append buf to previous note contents */
-               unsigned long size;
+               size_t size;
                enum object_type type;
                struct strbuf buf = STRBUF_INIT;
                char *prev_buf = odb_read_object(the_repository->objects, note, &type, &size);
index 961d547ef26965766a3a5ba4a8e59612036731a8..b5092d97eeb30bed6791616c71a06002de76f1ff 100644 (file)
@@ -356,14 +356,17 @@ static void *get_delta(struct object_entry *entry)
        unsigned long size, base_size, delta_size;
        void *buf, *base_buf, *delta_buf;
        enum object_type type;
+       size_t size_st = 0, base_size_st = 0;
 
        buf = odb_read_object(the_repository->objects, &entry->idx.oid,
-                             &type, &size);
+                             &type, &size_st);
+       size = cast_size_t_to_ulong(size_st);
        if (!buf)
                die(_("unable to read %s"), oid_to_hex(&entry->idx.oid));
        base_buf = odb_read_object(the_repository->objects,
                                   &DELTA(entry)->idx.oid, &type,
-                                  &base_size);
+                                  &base_size_st);
+       base_size = cast_size_t_to_ulong(base_size_st);
        if (!base_buf)
                die("unable to read %s",
                    oid_to_hex(&DELTA(entry)->idx.oid));
@@ -528,9 +531,11 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
                        type = st->type;
                        size = st->size;
                } else {
+                       size_t size_st = 0;
                        buf = odb_read_object(the_repository->objects,
                                              &entry->idx.oid, &type,
-                                             &size);
+                                             &size_st);
+                       size = cast_size_t_to_ulong(size_st);
                        if (!buf)
                                die(_("unable to read %s"),
                                    oid_to_hex(&entry->idx.oid));
@@ -1937,6 +1942,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)
        struct pbase_tree_cache *ent, *nent;
        void *data;
        unsigned long size;
+       size_t size_st = 0;
        enum object_type type;
        int neigh;
        int my_ix = pbase_tree_cache_ix(oid);
@@ -1964,7 +1970,8 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)
        /* Did not find one.  Either we got a bogus request or
         * we need to read and perhaps cache.
         */
-       data = odb_read_object(the_repository->objects, oid, &type, &size);
+       data = odb_read_object(the_repository->objects, oid, &type, &size_st);
+       size = cast_size_t_to_ulong(size_st);
        if (!data)
                return NULL;
        if (type != OBJ_TREE) {
@@ -2119,13 +2126,15 @@ static void add_preferred_base(struct object_id *oid)
        struct pbase_tree *it;
        void *data;
        unsigned long size;
+       size_t size_st = 0;
        struct object_id tree_oid;
 
        if (window <= num_preferred_base++)
                return;
 
        data = odb_read_object_peeled(the_repository->objects, oid,
-                                     OBJ_TREE, &size, &tree_oid);
+                                     OBJ_TREE, &size_st, &tree_oid);
+       size = cast_size_t_to_ulong(size_st);
        if (!data)
                return;
 
@@ -2237,7 +2246,7 @@ static void prefetch_to_pack(uint32_t object_index_start) {
 
 static void check_object(struct object_entry *entry, uint32_t object_index)
 {
-       unsigned long canonical_size;
+       size_t canonical_size;
        enum object_type type;
        struct object_info oi = {.typep = &type, .sizep = &canonical_size};
 
@@ -2436,7 +2445,7 @@ static void drop_reused_delta(struct object_entry *entry)
        unsigned *idx = &to_pack.objects[entry->delta_idx - 1].delta_child_idx;
        struct object_info oi = OBJECT_INFO_INIT;
        enum object_type type;
-       unsigned long size;
+       size_t size;
 
        while (*idx) {
                struct object_entry *oe = &to_pack.objects[*idx - 1];
@@ -2748,7 +2757,7 @@ size_t oe_get_size_slow(struct packing_data *pack,
        size_t size;
 
        if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
-               unsigned long sz;
+               size_t sz;
                packing_data_lock(&to_pack);
                if (odb_read_object_info(the_repository->objects,
                                         &e->idx.oid, &sz) < 0)
@@ -2833,10 +2842,12 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
 
        /* Load data if not already done */
        if (!trg->data) {
+               size_t sz_st = 0;
                packing_data_lock(&to_pack);
                trg->data = odb_read_object(the_repository->objects,
                                            &trg_entry->idx.oid, &type,
-                                           &sz);
+                                           &sz_st);
+               sz = cast_size_t_to_ulong(sz_st);
                packing_data_unlock(&to_pack);
                if (!trg->data)
                        die(_("object %s cannot be read"),
@@ -2848,10 +2859,12 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
                *mem_usage += sz;
        }
        if (!src->data) {
+               size_t sz_st = 0;
                packing_data_lock(&to_pack);
                src->data = odb_read_object(the_repository->objects,
                                            &src_entry->idx.oid, &type,
-                                           &sz);
+                                           &sz_st);
+               sz = cast_size_t_to_ulong(sz_st);
                packing_data_unlock(&to_pack);
                if (!src->data) {
                        if (src_entry->preferred_base) {
index 71a5c1c29c05fe4b285abe9cf313e20f555247ef..69f3626467cadf4c499a4e117c66721902204d38 100644 (file)
@@ -784,13 +784,14 @@ static int count_objects(const char *path UNUSED, struct oid_array *oids,
        for (size_t i = 0; i < oids->nr; i++) {
                struct object_info oi = OBJECT_INFO_INIT;
                unsigned long inflated;
+               size_t inflated_st = 0;
                struct commit *commit;
                struct object *obj;
                void *content;
                off_t disk;
                int eaten;
 
-               oi.sizep = &inflated;
+               oi.sizep = &inflated_st;
                oi.disk_sizep = &disk;
                oi.contentp = &content;
 
@@ -798,6 +799,7 @@ static int count_objects(const char *path UNUSED, struct oid_array *oids,
                                                  OBJECT_INFO_SKIP_FETCH_OBJECT |
                                                  OBJECT_INFO_QUICK) < 0)
                        continue;
+               inflated = cast_size_t_to_ulong(inflated_st);
 
                obj = parse_object_buffer(the_repository, &oids->oid[i], type,
                                          inflated, content, &eaten);
index d51c2e33495295a336859952fe132e60088eea07..06c125b53c88e8bb458fd0faaba11063d6e6027d 100644 (file)
@@ -238,7 +238,7 @@ static int git_tag_config(const char *var, const char *value,
 
 static void write_tag_body(int fd, const struct object_id *oid)
 {
-       unsigned long size;
+       size_t size;
        enum object_type type;
        char *buf, *sp, *orig;
        struct strbuf payload = STRBUF_INIT;
@@ -388,7 +388,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
        enum object_type type;
        struct commit *c;
        char *buf;
-       unsigned long size;
+       size_t size;
        int subject_len = 0;
        const char *subject_start;
 
index 87877a9fabc6f614e2e1d57afaea8759d8a191df..387389ed491d3369468e1e1a149974f894c8d49c 100644 (file)
@@ -12,7 +12,7 @@ static char *create_temp_file(struct object_id *oid)
        static char path[50];
        void *buf;
        enum object_type type;
-       unsigned long size;
+       size_t size;
        int fd;
 
        buf = odb_read_object(the_repository->objects, oid, &type, &size);
index e7a50c493cb3ca7a1c423ac0382b6983e0ce8a9a..f3849bb6542e621270e60483e28cf3a84fdfc147 100644 (file)
@@ -231,7 +231,7 @@ static int check_object(struct object *obj, enum object_type type,
                die("object type mismatch");
 
        if (!(obj->flags & FLAG_OPEN)) {
-               unsigned long size;
+               size_t size;
                int type = odb_read_object_info(the_repository->objects, &obj->oid, &size);
                if (type != obj->type || type <= 0)
                        die("object of unexpected type");
@@ -436,6 +436,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
 {
        void *delta_data, *base;
        unsigned long base_size;
+       size_t base_size_st = 0;
        struct object_id base_oid;
 
        if (type == OBJ_REF_DELTA) {
@@ -512,7 +513,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
                return;
 
        base = odb_read_object(the_repository->objects, &base_oid,
-                              &type, &base_size);
+                              &type, &base_size_st);
+       base_size = cast_size_t_to_ulong(base_size_st);
        if (!base) {
                error("failed to read delta-pack base object %s",
                      oid_to_hex(&base_oid));
index 42327f9739cc54659d4fc0119438c0b25d38dccb..fd2db2c837df603771418009ec38504fe3b853bb 100644 (file)
--- a/bundle.c
+++ b/bundle.c
@@ -296,7 +296,7 @@ int list_bundle_refs(struct bundle_header *header, int argc, const char **argv)
 
 static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
 {
-       unsigned long size;
+       size_t size;
        enum object_type type;
        char *buf = NULL, *line, *lineend;
        timestamp_t date;
index b7998620687ed796306c306029e6f29f2eec44c0..3ce71db8bb37085770fc57f3eafc7a21aa3159de 100644 (file)
@@ -325,7 +325,9 @@ static char *grab_blob(struct repository *r,
                *size = fill_textconv(r, textconv, df, &blob);
                free_filespec(df);
        } else {
-               blob = odb_read_object(r->objects, oid, &type, size);
+               size_t size_st = 0;
+               blob = odb_read_object(r->objects, oid, &type, &size_st);
+               *size = cast_size_t_to_ulong(size_st);
                if (!blob)
                        die(_("unable to read %s"), oid_to_hex(oid));
                if (type != OBJ_BLOB)
index fd8723502ed332958ed9f5ead62da4b4c6daa8ea..7950effc58f002e51a2592f5acd4f6d55a1d1bd0 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -395,7 +395,7 @@ const void *repo_get_commit_buffer(struct repository *r,
        const void *ret = get_cached_commit_buffer(r, commit, sizep);
        if (!ret) {
                enum object_type type;
-               unsigned long size;
+               size_t size;
                ret = odb_read_object(r->objects, &commit->object.oid, &type, &size);
                if (!ret)
                        die("cannot read commit object %s",
@@ -404,7 +404,7 @@ const void *repo_get_commit_buffer(struct repository *r,
                        die("expected commit for %s, got %s",
                            oid_to_hex(&commit->object.oid), type_name(type));
                if (sizep)
-                       *sizep = size;
+                       *sizep = cast_size_t_to_ulong(size);
        }
        return ret;
 }
@@ -437,7 +437,7 @@ static inline void set_commit_tree(struct commit *c, struct tree *t)
 static void load_tree_from_commit_contents(struct repository *r, struct commit *commit)
 {
        enum object_type type;
-       unsigned long size;
+       size_t size;
        char *buf;
        const char *p;
        struct object_id tree_oid;
@@ -604,7 +604,7 @@ int repo_parse_commit_internal(struct repository *r,
 {
        enum object_type type;
        void *buffer;
-       unsigned long size;
+       size_t size;
        struct object_info oi = {
                .typep = &type,
                .sizep = &size,
@@ -1313,7 +1313,7 @@ static void handle_signed_tag(const struct commit *parent, struct commit_extra_h
        struct merge_remote_desc *desc;
        struct commit_extra_header *mergetag;
        char *buf;
-       unsigned long size;
+       size_t size;
        enum object_type type;
        struct strbuf payload = STRBUF_INIT;
        struct strbuf signature = STRBUF_INIT;
index a1b92fe083cf435b1326529463c6a85de342886d..21b231052c71b71b59d3ac77500eacc3680e5291 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1442,7 +1442,7 @@ int git_config_from_blob_oid(config_fn_t fn,
 {
        enum object_type type;
        char *buf;
-       unsigned long size;
+       size_t size;
        int ret;
 
        buf = odb_read_object(repo->objects, oid, &type, &size);
diff --git a/diff.c b/diff.c
index 5a584fa1d569e7d5866bcd1dd47ac3d2b71540f3..816b89dc6cd1253dbcc4afc5845006f12493591e 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -4594,8 +4594,9 @@ int diff_populate_filespec(struct repository *r,
                }
        }
        else {
+               size_t size_st = 0;
                struct object_info info = {
-                       .sizep = &s->size
+                       .sizep = &size_st
                };
 
                if (!(size_only || check_binary))
@@ -4617,6 +4618,7 @@ int diff_populate_filespec(struct repository *r,
                        die("unable to read %s", oid_to_hex(&s->oid));
 
 object_read:
+               s->size = cast_size_t_to_ulong(size_st);
                if (size_only || check_binary) {
                        if (size_only)
                                return 0;
@@ -4631,6 +4633,7 @@ object_read:
                        if (odb_read_object_info_extended(r->objects, &s->oid, &info,
                                                          OBJECT_INFO_LOOKUP_REPLACE))
                                die("unable to read %s", oid_to_hex(&s->oid));
+                       s->size = cast_size_t_to_ulong(size_st);
                }
                s->should_free = 1;
        }
diff --git a/dir.c b/dir.c
index 33c81c256ee925862b9f1e9651194cfd497e6cff..b6764d98a737dec7d94b49c4da1b8b03a407370d 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -324,7 +324,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,
                        size_t *size_out, char **data_out)
 {
        enum object_type type;
-       unsigned long sz;
+       size_t sz;
        char *data;
 
        *size_out = 0;
diff --git a/entry.c b/entry.c
index 7817aee362ed9e7e14e3a2b92c9cc0ab5f013673..c444fe5a1079f1c4dc1554c2fcb7a4e0c135f803 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -92,11 +92,9 @@ static int create_file(const char *path, unsigned int mode)
 void *read_blob_entry(const struct cache_entry *ce, size_t *size)
 {
        enum object_type type;
-       unsigned long ul;
        void *blob_data = odb_read_object(the_repository->objects, &ce->oid,
-                                         &type, &ul);
+                                         &type, size);
 
-       *size = ul;
        if (blob_data) {
                if (type == OBJ_BLOB)
                        return blob_data;
index 45d8b20e9703282d1e6033a2f33a439089d7bb90..14441f23ae7b3b6f16f1a1b863e23ab9ff58f174 100644 (file)
@@ -528,11 +528,11 @@ static void fmt_merge_msg_sigs(struct strbuf *out)
        for (i = 0; i < origins.nr; i++) {
                struct object_id *oid = origins.items[i].util;
                enum object_type type;
-               unsigned long size;
+               size_t size;
                char *buf = odb_read_object(the_repository->objects, oid,
                                            &type, &size);
                char *origbuf = buf;
-               unsigned long len = size;
+               size_t len = size;
                struct signature_check sigc = { NULL };
                struct strbuf payload = STRBUF_INIT, sig = STRBUF_INIT;
 
diff --git a/fsck.c b/fsck.c
index b4ffee6a04347481abad6f0097c2be1bd480f207..94c8651c7dfa288ddd17b157108841392a6661c1 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -1328,7 +1328,7 @@ static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done,
        oidset_iter_init(blobs_found, &iter);
        while ((oid = oidset_iter_next(&iter))) {
                enum object_type type;
-               unsigned long size;
+               size_t size;
                char *buf;
 
                if (oidset_contains(blobs_done, oid))
diff --git a/grep.c b/grep.c
index a54e5d86a96cfdfd100d061a8ceb6165a7cc6b82..1d75d314211aa874e33831f7d14086f0c223da17 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -1931,9 +1931,11 @@ void grep_source_clear_data(struct grep_source *gs)
 static int grep_source_load_oid(struct grep_source *gs)
 {
        enum object_type type;
+       size_t size_st = 0;
 
        gs->buf = odb_read_object(gs->repo->objects, gs->identifier,
-                                 &type, &gs->size);
+                                 &type, &size_st);
+       gs->size = cast_size_t_to_ulong(size_st);
        if (!gs->buf)
                return error(_("'%s': unable to read %s"),
                             gs->name,
index 520d6c3b6ade1f3570db853979936ff4a82c5a8c..c61d9f7e0283730b724f1593d667ce781cc7d9df 100644 (file)
@@ -365,7 +365,7 @@ static void start_put(struct transfer_request *request)
        enum object_type type;
        char hdr[50];
        void *unpacked;
-       unsigned long len;
+       size_t len;
        int hdrlen;
        ssize_t size;
        git_zstream stream;
index 78316e7f90c8d4969e169948d9b508e6ca37484c..c912ff3079a7d7c3010cfd28242347cfe2625775 100644 (file)
@@ -280,7 +280,7 @@ static enum list_objects_filter_result filter_blobs_limit(
        void *filter_data_)
 {
        struct filter_blobs_limit_data *filter_data = filter_data_;
-       unsigned long object_length;
+       size_t object_length;
        enum object_type t;
 
        switch (filter_situation) {
index 3b2691781d8ff1131bf6d2a66d15ff6c3d3ce709..72b639e6021cf8e0c50b58b6992d9f009880b65f 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
@@ -186,7 +186,7 @@ int read_mailmap_blob(struct repository *repo, struct string_list *map,
 {
        struct object_id oid;
        char *buf;
-       unsigned long size;
+       size_t size;
        enum object_type type;
 
        if (!name)
index 4216933d06b16386d68ca6006acf0df41e82b9ff..2a43c0fa1ade8937ff073d42e27d50b4405fe0c8 100644 (file)
@@ -61,7 +61,7 @@ static void *fill_tree_desc_strict(struct repository *r,
 {
        void *buffer;
        enum object_type type;
-       unsigned long size;
+       size_t size;
 
        buffer = odb_read_object(r->objects, hash, &type, &size);
        if (!buffer)
@@ -186,7 +186,7 @@ static int splice_tree(struct repository *r,
        char *subpath;
        int toplen;
        char *buf;
-       unsigned long sz;
+       size_t sz;
        struct tree_desc desc;
        unsigned char *rewrite_here;
        const struct object_id *rewrite_with;
index 6fc279941714f63f4d2260ace310a12cc78af051..16a75bd1e302b3c0dcf8dfa0301a078e185c7600 100644 (file)
@@ -9,7 +9,7 @@
 static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
 {
        void *buf;
-       unsigned long size;
+       size_t size;
        enum object_type type;
 
        buf = odb_read_object(the_repository->objects, &obj->object.oid,
@@ -35,7 +35,7 @@ static void *three_way_filemerge(struct index_state *istate,
                                 mmfile_t *base,
                                 mmfile_t *our,
                                 mmfile_t *their,
-                                unsigned long *size)
+                                size_t *size)
 {
        enum ll_merge_result merge_status;
        mmbuffer_t res;
@@ -61,7 +61,7 @@ static void *three_way_filemerge(struct index_state *istate,
 
 void *merge_blobs(struct index_state *istate, const char *path,
                  struct blob *base, struct blob *our,
-                 struct blob *their, unsigned long *size)
+                 struct blob *their, size_t *size)
 {
        void *res = NULL;
        mmfile_t f1, f2, common;
index 13cf9669e5b2c43b34bbecd2ea71bf14d9a36d65..5797517a064e1370045b3f0f24286ff3cb63f21a 100644 (file)
@@ -6,6 +6,6 @@ struct index_state;
 
 void *merge_blobs(struct index_state *, const char *,
                  struct blob *, struct blob *,
-                 struct blob *, unsigned long *);
+                 struct blob *, size_t *);
 
 #endif /* MERGE_BLOBS_H */
index 544be9e466c9b55e12895e0da96dc535a3ac0947..4f6273bd515789af78964063364788e24dad73d3 100644 (file)
@@ -3716,7 +3716,7 @@ static int read_oid_strbuf(struct merge_options *opt,
 {
        void *buf;
        enum object_type type;
-       unsigned long size;
+       size_t size;
        buf = odb_read_object(opt->repo->objects, oid, &type, &size);
        if (!buf) {
                path_msg(opt, ERROR_OBJECT_READ_FAILED, 0,
index bf5bb1f6c13a13f0e7d3348337525c966ddb2730..74cef802bd8d9359cac8b157e94c0764565268f4 100644 (file)
@@ -82,7 +82,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,
        const struct object_id *value_oid;
        enum object_type type;
        char *value;
-       unsigned long size;
+       size_t size;
 
        value_oid = get_note(&c->tree, key_oid);
        if (!value_oid)
index b9322abbcb4863bfc2832e4e6f050e89490f3c3e..118cad2518d82eeb46d05ec34dfff6cecbf21be6 100644 (file)
@@ -339,7 +339,7 @@ static void write_note_to_worktree(const struct object_id *obj,
                                   const struct object_id *note)
 {
        enum object_type type;
-       unsigned long size;
+       size_t size;
        void *buf = odb_read_object(the_repository->objects, note, &type, &size);
 
        if (!buf)
diff --git a/notes.c b/notes.c
index 8f315e2a00d2658454309b82d4c8b8269273309b..ec9c2cb150d4e337348a8b3f4c09145e64a932fe 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -811,7 +811,8 @@ int combine_notes_concatenate(struct object_id *cur_oid,
                              const struct object_id *new_oid)
 {
        char *cur_msg = NULL, *new_msg = NULL, *buf;
-       unsigned long cur_len, new_len, buf_len;
+       unsigned long buf_len;
+       size_t cur_len, new_len;
        enum object_type cur_type, new_type;
        int ret;
 
@@ -875,7 +876,7 @@ static int string_list_add_note_lines(struct string_list *list,
                                      const struct object_id *oid)
 {
        char *data;
-       unsigned long len;
+       size_t len;
        enum object_type t;
 
        if (is_null_oid(oid))
@@ -1282,7 +1283,8 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid
        static const char utf8[] = "utf-8";
        const struct object_id *oid;
        char *msg, *msg_p;
-       unsigned long linelen, msglen;
+       unsigned long linelen;
+       size_t msglen;
        enum object_type type;
 
        if (!t)
index bce941874eb994c8dbaf391ede6c84a09fa96f56..3a21c1402786842b42b6d431b066335ddb6a6593 100644 (file)
@@ -300,7 +300,7 @@ int parse_loose_header(const char *hdr, struct object_info *oi)
        }
 
        if (oi->sizep)
-               *oi->sizep = cast_size_t_to_ulong(size);
+               *oi->sizep = size;
 
        /*
         * The length must be followed by a zero byte
@@ -931,7 +931,7 @@ int force_object_loose(struct odb_source *source,
        struct odb_source_files *files = odb_source_files_downcast(source);
        const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo;
        void *buf;
-       unsigned long len;
+       size_t len;
        struct object_info oi = OBJECT_INFO_INIT;
        struct object_id compat_oid;
        enum object_type type;
@@ -1614,7 +1614,7 @@ int read_loose_object(struct repository *repo,
        unsigned long mapsize;
        git_zstream stream;
        char hdr[MAX_HEADER_LEN];
-       unsigned long *size = oi->sizep;
+       size_t *size = oi->sizep;
 
        fd = git_open(path);
        if (fd >= 0)
index 465902ecc6dbb55ac998ec6e57b080d090371512..23b84aa7e29531a0c9bd8bf3e90e1e11b3c579c3 100644 (file)
--- a/object.c
+++ b/object.c
@@ -325,7 +325,7 @@ struct object *parse_object_with_flags(struct repository *r,
 {
        int skip_hash = !!(flags & PARSE_OBJECT_SKIP_HASH_CHECK);
        int discard_tree = !!(flags & PARSE_OBJECT_DISCARD_TREE);
-       unsigned long size;
+       size_t size;
        enum object_type type;
        int eaten;
        const struct object_id *repl = lookup_replace_object(r, oid);
diff --git a/odb.c b/odb.c
index 965ef68e4eca222bc1af9a900665916b2231068f..7d555be09feaea8932a7c58d02885d00f60a7234 100644 (file)
--- a/odb.c
+++ b/odb.c
@@ -625,7 +625,7 @@ static int oid_object_info_convert(struct repository *r,
        enum object_type type;
        struct object_id oid, delta_base_oid;
        struct object_info new_oi, *oi;
-       unsigned long size;
+       size_t size;
        void *content;
        int ret;
 
@@ -716,7 +716,7 @@ int odb_read_object_info_extended(struct object_database *odb,
 /* returns enum object_type or negative */
 int odb_read_object_info(struct object_database *odb,
                         const struct object_id *oid,
-                        unsigned long *sizep)
+                        size_t *sizep)
 {
        enum object_type type;
        struct object_info oi = OBJECT_INFO_INIT;
@@ -730,7 +730,7 @@ int odb_read_object_info(struct object_database *odb,
 }
 
 int odb_pretend_object(struct object_database *odb,
-                      void *buf, unsigned long len, enum object_type type,
+                      void *buf, size_t len, enum object_type type,
                       struct object_id *oid)
 {
        hash_object_file(odb->repo->hash_algo, buf, len, type, oid);
@@ -744,7 +744,7 @@ int odb_pretend_object(struct object_database *odb,
 void *odb_read_object(struct object_database *odb,
                      const struct object_id *oid,
                      enum object_type *type,
-                     unsigned long *size)
+                     size_t *size)
 {
        struct object_info oi = OBJECT_INFO_INIT;
        unsigned flags = OBJECT_INFO_DIE_IF_CORRUPT | OBJECT_INFO_LOOKUP_REPLACE;
@@ -762,12 +762,12 @@ void *odb_read_object(struct object_database *odb,
 void *odb_read_object_peeled(struct object_database *odb,
                             const struct object_id *oid,
                             enum object_type required_type,
-                            unsigned long *size,
+                            size_t *size,
                             struct object_id *actual_oid_return)
 {
        enum object_type type;
        void *buffer;
-       unsigned long isize;
+       size_t isize;
        struct object_id actual_oid;
 
        oidcpy(&actual_oid, oid);
diff --git a/odb.h b/odb.h
index 73553ed5a7b1ea1971f776a42e9c5780b044fa95..e2f0bbad25cb59c1b7ea4c18ee2f819cd34de0e5 100644 (file)
--- a/odb.h
+++ b/odb.h
@@ -228,12 +228,12 @@ struct odb_source *odb_add_to_alternates_memory(struct object_database *odb,
 void *odb_read_object(struct object_database *odb,
                      const struct object_id *oid,
                      enum object_type *type,
-                     unsigned long *size);
+                     size_t *size);
 
 void *odb_read_object_peeled(struct object_database *odb,
                             const struct object_id *oid,
                             enum object_type required_type,
-                            unsigned long *size,
+                            size_t *size,
                             struct object_id *oid_ret);
 
 /*
@@ -245,13 +245,13 @@ void *odb_read_object_peeled(struct object_database *odb,
  * that reference it.
  */
 int odb_pretend_object(struct object_database *odb,
-                      void *buf, unsigned long len, enum object_type type,
+                      void *buf, size_t len, enum object_type type,
                       struct object_id *oid);
 
 struct object_info {
        /* Request */
        enum object_type *typep;
-       unsigned long *sizep;
+       size_t *sizep;
        off_t *disk_sizep;
        struct object_id *delta_base_oid;
        void **contentp;
@@ -356,7 +356,7 @@ int odb_read_object_info_extended(struct object_database *odb,
  */
 int odb_read_object_info(struct object_database *odb,
                         const struct object_id *oid,
-                        unsigned long *sizep);
+                        size_t *sizep);
 
 enum odb_has_object_flags {
        /* Retry packed storage after checking packed and loose storage */
index 7d7ea2fb842537fe924e4761d5b56f8bbfde1e4d..66e6bb8d3f800451d68a9cafddd7d267754f0993 100644 (file)
@@ -72,7 +72,7 @@ static int read_object_info_from_path(struct odb_source_loose *loose,
        void *map = NULL;
        git_zstream stream, *stream_to_end = NULL;
        char hdr[MAX_HEADER_LEN];
-       unsigned long size_scratch;
+       size_t size_scratch;
        enum object_type type_scratch;
        struct stat st;
 
@@ -355,7 +355,6 @@ static int odb_source_loose_read_object_stream(struct odb_read_stream **out,
        struct object_info oi = OBJECT_INFO_INIT;
        struct odb_loose_read_stream *st;
        unsigned long mapsize;
-       unsigned long size_ul;
        void *mapped;
 
        mapped = odb_source_loose_map_object(loose, oid, &mapsize);
@@ -379,18 +378,11 @@ static int odb_source_loose_read_object_stream(struct odb_read_stream **out,
                goto error;
        }
 
-       /*
-        * object_info.sizep is unsigned long* (32-bit on Windows), but
-        * st->base.size is size_t (64-bit). Use temporary variable.
-        * Note: loose objects >4GB would still truncate here, but such
-        * large loose objects are uncommon (they'd normally be packed).
-        */
-       oi.sizep = &size_ul;
+       oi.sizep = &st->base.size;
        oi.typep = &st->base.type;
 
        if (parse_loose_header(st->hdr, &oi) < 0 || st->base.type < 0)
                goto error;
-       st->base.size = size_ul;
 
        st->mapped = mapped;
        st->mapsize = mapsize;
index 7602a8d5d87519e2d2bcb95050495dbbab191fd3..20531e864c956125f4bb4b48c4b6e1a767aef0a9 100644 (file)
@@ -157,26 +157,15 @@ static int open_istream_incore(struct odb_read_stream **out,
                .base.read = read_istream_incore,
        };
        struct odb_incore_read_stream *st;
-       unsigned long size_ul;
        int ret;
 
        oi.typep = &stream.base.type;
-       /*
-        * object_info.sizep is unsigned long* (32-bit on Windows), but
-        * stream.base.size is size_t (64-bit). We use a temporary variable
-        * because the types are incompatible. Note: this path still truncates
-        * for >4GB objects, but large objects should use pack streaming
-        * (packfile_store_read_object_stream) which handles size_t properly.
-        * This incore fallback is only used for small objects or when pack
-        * streaming is unavailable.
-        */
-       oi.sizep = &size_ul;
+       oi.sizep = &stream.base.size;
        oi.contentp = (void **)&stream.buf;
        ret = odb_read_object_info_extended(odb, oid, &oi,
                                            OBJECT_INFO_DIE_IF_CORRUPT);
        if (ret)
                return ret;
-       stream.base.size = size_ul;
 
        CALLOC_ARRAY(st, 1);
        *st = stream;
index f9af8a96bdf4eed313bb742b7b845eb88567b752..e8a82945cc319e1c71fd3079b64fc1b6ce9c7455 100644 (file)
@@ -1856,7 +1856,7 @@ static void filter_bitmap_blob_none(struct bitmap_index *bitmap_git,
 static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
                                     uint32_t pos)
 {
-       unsigned long size;
+       size_t size;
        struct object_info oi = OBJECT_INFO_INIT;
 
        oi.sizep = &size;
@@ -1891,7 +1891,7 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
                        die(_("unable to get size of %s"), oid_to_hex(&obj->oid));
        }
 
-       return size;
+       return cast_size_t_to_ulong(size);
 }
 
 static void filter_bitmap_blob_limit(struct bitmap_index *bitmap_git,
index c174982d10e79dae7d7d5d967cff65c7e3df3e5a..78c389e6f35e220e0ed09d1d9c3afe7d03b1ead6 100644 (file)
@@ -1607,13 +1607,10 @@ static int packed_object_info_with_index_pos(struct packed_git *p, off_t obj_off
         * a "real" type later if the caller is interested.
         */
        if (oi->contentp) {
-               size_t size_st = 0;
                *oi->contentp = cache_or_unpack_entry(p->repo, p, obj_offset,
-                                                     &size_st, &type);
+                                                     oi->sizep, &type);
                if (!*oi->contentp)
                        type = OBJ_BAD;
-               else if (oi->sizep)
-                       *oi->sizep = cast_size_t_to_ulong(size_st);
        } else if (oi->sizep || oi->typep || oi->delta_base_oid) {
                type = unpack_object_header(p, &w_curs, &curpos, &size);
        }
@@ -1633,7 +1630,7 @@ static int packed_object_info_with_index_pos(struct packed_git *p, off_t obj_off
                                goto out;
                        }
                }
-               *oi->sizep = (unsigned long)size;
+               *oi->sizep = size;
        }
 
        if (oi->disk_sizep || (oi->mtimep && p->is_cruft)) {
@@ -1919,7 +1916,6 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
                        struct object_id base_oid;
                        if (!(offset_to_pack_pos(p, obj_offset, &pos))) {
                                struct object_info oi = OBJECT_INFO_INIT;
-                               unsigned long bsz_ul = 0;
 
                                nth_packed_object_id(&base_oid, p,
                                                     pack_pos_to_index(p, pos));
@@ -1930,13 +1926,11 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
                                mark_bad_packed_object(p, &base_oid);
 
                                oi.typep = &type;
-                               oi.sizep = &bsz_ul;
+                               oi.sizep = &base_size;
                                oi.contentp = &base;
                                if (odb_read_object_info_extended(r->objects, &base_oid,
                                                                  &oi, 0) < 0)
                                        base = NULL;
-                               else
-                                       base_size = bsz_ul;
 
                                external_base = base;
                        }
index 94ff90bd1566b629b4660f5c3e5cdacf2a7ab24e..edc8e736d7435a71fa6bd3640d92a76a345f18dc 100644 (file)
@@ -368,7 +368,7 @@ static int walk_path(struct path_walk_context *ctx,
                struct oid_array filtered = OID_ARRAY_INIT;
 
                for (size_t i = 0; i < list->oids.nr; i++) {
-                       unsigned long size;
+                       size_t size;
 
                        if (odb_read_object_info(ctx->repo->objects,
                                                 &list->oids.oid[i],
index 35072ed60b7f4d0c2ee5ba20dcc5ef62bb9412a3..8858ea4489d71448aa71d2089aedda9badf44ea0 100644 (file)
@@ -50,7 +50,7 @@ static void send_info(struct repository *r, struct packet_writer *writer,
        for_each_string_list_item (item, oid_str_list) {
                const char *oid_str = item->string;
                struct object_id oid;
-               unsigned long object_size;
+               size_t object_size;
 
                if (get_oid_hex_algop(oid_str, &oid, r->hash_algo) < 0) {
                        packet_writer_error(
@@ -66,7 +66,8 @@ static void send_info(struct repository *r, struct packet_writer *writer,
                        if (odb_read_object_info(r->objects, &oid, &object_size) < 0) {
                                strbuf_addstr(&send_buffer, " ");
                        } else {
-                               strbuf_addf(&send_buffer, " %lu", object_size);
+                               strbuf_addf(&send_buffer, " %"PRIuMAX,
+                                           (uintmax_t)object_size);
                        }
                }
 
index 21829102ae275e124eb7b94550bc7ccf16993bac..21ca58beeaa28c86c196f8949c88c75940385c06 100644 (file)
@@ -250,7 +250,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)
 {
        int match = -1;
        void *buffer;
-       unsigned long size;
+       size_t size;
        enum object_type type;
        struct strbuf sb = STRBUF_INIT;
 
@@ -3462,7 +3462,7 @@ void *read_blob_data_from_index(struct index_state *istate,
                                const char *path, unsigned long *size)
 {
        int pos, len;
-       unsigned long sz;
+       size_t sz;
        enum object_type type;
        void *data;
 
@@ -3490,7 +3490,7 @@ void *read_blob_data_from_index(struct index_state *istate,
                return NULL;
        }
        if (size)
-               *size = sz;
+               *size = cast_size_t_to_ulong(sz);
        return data;
 }
 
index 1da4c0e60df3fa8eed3eb806e958964c90b1df3b..8ba91c72a11d39ca73a6a49dd80d84adcd0867a2 100644 (file)
@@ -86,7 +86,7 @@ struct ref_trailer_buf {
 static struct expand_data {
        struct object_id oid;
        enum object_type type;
-       unsigned long size;
+       size_t size;
        off_t disk_size;
        struct object_id delta_base_oid;
        void *content;
index 82337078d00611671df7344531360d7d8d6a2349..04edbe56707fb7fdb0aba6991a9affa2a1639a20 100644 (file)
--- a/reflog.c
+++ b/reflog.c
@@ -154,7 +154,7 @@ static int tree_is_complete(const struct object_id *oid)
 
        if (!tree->buffer) {
                enum object_type type;
-               unsigned long size;
+               size_t size;
                void *data = odb_read_object(the_repository->objects, oid,
                                             &type, &size);
                if (!data) {
index 0296700f9f448fe57d5e9561b6784b078bc5a52c..068321b24fe46457619837c83612e0cc5c900510 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -990,7 +990,7 @@ static int handle_cache(struct index_state *istate,
 
        while (pos < istate->cache_nr) {
                enum object_type type;
-               unsigned long size;
+               size_t size;
 
                ce = istate->cache[pos++];
                if (ce_namelen(ce) != len || memcmp(ce->name, path, len))
index a81897b4e069b1d491007f9c81d044f72aea4fb9..f75997402a189bc2dd531e46b84b720512886862 100644 (file)
@@ -694,7 +694,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
                enum lookup_type lookup_type)
 {
        struct strbuf rev = STRBUF_INIT;
-       unsigned long config_size;
+       size_t config_size;
        char *config = NULL;
        struct object_id oid;
        enum object_type type;
index c493b75e02a99a59bf1444787a844275193772d3..840797cf0dbabbef1d3a5f8efd3b43347bfafa34 100644 (file)
@@ -48,7 +48,8 @@ static void write_ref_delta(struct hashfile *f,
                            struct object_id *base)
 {
        unsigned char header[MAX_PACK_OBJECT_HEADER];
-       unsigned long size, base_size, delta_size, compressed_size, hdrlen;
+       unsigned long delta_size, compressed_size, hdrlen;
+       size_t size, base_size;
        enum object_type type;
        void *base_buf, *delta_buf;
        void *buf = odb_read_object(the_repository->objects,
index a7aab426d0194afca120c92e7365ff0b53985a8e..87c59108e00ccbf64ed698783637ea80d8ed78c7 100644 (file)
@@ -17,7 +17,7 @@ static void object_info(const char *gitdir, const char *oid_hex)
 {
        struct repository r;
        struct object_id oid;
-       unsigned long size;
+       size_t size;
        struct object_info oi = {.sizep = &size};
        const char *p;
 
index 482502ef4b1e11f6fa543d4efd1afa14e26af0f3..6844bfc37ccfdc9177c26bc8654c8b5693819cfe 100644 (file)
@@ -20,7 +20,7 @@ static void cl_assert_object_info(struct odb_source_inmemory *source,
                                  const char *expected_content)
 {
        enum object_type actual_type;
-       unsigned long actual_size;
+       size_t actual_size;
        void *actual_content;
        struct object_info oi = {
                .typep = &actual_type,
diff --git a/tag.c b/tag.c
index 2f12e51024ec0b717aa70996e473dd63238c8790..1a00ded6eb5f5d2cf29e8f48a1b3c7320bb3ca86 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -49,7 +49,7 @@ int gpg_verify_tag(struct repository *r, const struct object_id *oid,
 {
        enum object_type type;
        char *buf;
-       unsigned long size;
+       size_t size;
        int ret;
 
        type = odb_read_object_info(r->objects, oid, NULL);
@@ -207,7 +207,7 @@ int parse_tag(struct repository *r, struct tag *item)
 {
        enum object_type type;
        void *data;
-       unsigned long size;
+       size_t size;
        int ret;
 
        if (item->object.parsed)
index 7e1b956f2781644474c67a083cc22cbebccd3fbe..a67f06b9ebd7905ad34fdec173734cdfb3cea9b7 100644 (file)
@@ -87,7 +87,7 @@ void *fill_tree_descriptor(struct repository *r,
                           struct tree_desc *desc,
                           const struct object_id *oid)
 {
-       unsigned long size = 0;
+       size_t size = 0;
        void *buf = NULL;
 
        if (oid) {
@@ -610,7 +610,7 @@ int get_tree_entry(struct repository *r,
 {
        int retval;
        void *tree;
-       unsigned long size;
+       size_t size;
        struct object_id root;
 
        tree = odb_read_object_peeled(r->objects, tree_oid, OBJ_TREE, &size, &root);
@@ -682,7 +682,7 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,
                if (!t.buffer) {
                        void *tree;
                        struct object_id root;
-                       unsigned long size;
+                       size_t size;
                        tree = odb_read_object_peeled(r->objects, &current_tree_oid,
                                                      OBJ_TREE, &size, &root);
                        if (!tree)
@@ -778,6 +778,7 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,
                } else if (S_ISLNK(*mode)) {
                        /* Follow a symlink */
                        unsigned long link_len;
+                       size_t link_len_st = 0;
                        size_t len;
                        char *contents, *contents_start;
                        struct dir_state *parent;
@@ -797,7 +798,8 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,
 
                        contents = odb_read_object(r->objects,
                                                   &current_tree_oid, &type,
-                                                  &link_len);
+                                                  &link_len_st);
+                       link_len = cast_size_t_to_ulong(link_len_st);
 
                        if (!contents)
                                goto done;
diff --git a/tree.c b/tree.c
index d703ab97c8303a8643abbb302f99bbcff0bcbe03..53f7395e9fea09770449488963b20d4f1d1e327d 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -188,7 +188,7 @@ int repo_parse_tree_gently(struct repository *r, struct tree *item,
 {
         enum object_type type;
         void *buffer;
-        unsigned long size;
+        size_t size;
 
        if (item->object.parsed)
                return 0;
index 5ee2b96d0a756f4586d145f0ddaf8fd0906b10d4..db6938689f0a9ef5a9d630e8614d7f807758ff39 100644 (file)
@@ -179,7 +179,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
 void read_mmblob(mmfile_t *ptr, struct object_database *odb,
                 const struct object_id *oid)
 {
-       unsigned long size;
+       size_t size;
        enum object_type type;
 
        if (is_null_oid(oid)) {