{"thread":{"id":"49844","subject":"[PATCH/RFC v1 1/1] Use size_t instead of unsigned long","startedAt":"2018-11-17T15:12:03Z","lastAt":"2019-04-13T15:19:29Z","messageCount":13,"participants":["tboegi@web.de","Derrick Stolee","Junio C Hamano","Torsten Bögershausen","René Scharfe","Thomas Braun"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"363558","messageId":"20181117151139.22994-1-tboegi@web.de","threadId":"49844","inReplyTo":null,"subject":"[PATCH/RFC v1 1/1] Use size_t instead of unsigned long","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2018-11-17T15:11:39Z","receivedAt":"2018-11-17T15:12:03Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nCurrently Git users can not commit files >4Gib under 64 bit Windows,\nwhere \"long\" is 32 bit but size_t is 64 bit.\nImprove the code base in small steps, as small as possible.\nWhat started with a small patch to replace \"unsigned long\" with size_t\nin one file (convert.c) ended up with a change in many files.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n\nThis needs to go on top of pu, to cover all the good stuff\n  cooking here.\nI have started this series on November 1st, since that 2 or 3 rebases\n  had been done to catch up, and now it is on pu from November 15.\n\nI couldn't find a reason why changing \"unsigned ling\"\n  into \"size_t\" may break anything, any thoughts, please ?\nSide question: One thing I wondered about is why Git creates a conflict\nlike this, using git cherry-pick:\n    <<<<<<< HEAD\n    \t\tunsigned long size;\n    \t\tvoid *data = read_object_file(oid, &type, &size);\n    =======\n    \t\tsize_t size;\n    \t\tvoid *data = repo_read_object_file(the_repository, oid, &type,\n    \t\t\t\t\t\t   &size);\n    >>>>>>> 3ee0abef4c... Use size_t instead of unsigned long\n\nOne commit changed \"unsigned long size\" into \"size_t size\",\nthe other commit swapped repo_read_object_file() with read_object_file().\nBoth changed are on different lines, but Git sees a conflict here.\n\n apply.c                  | 14 ++++-----\n archive-tar.c            | 18 +++++------\n archive-zip.c            |  2 +-\n archive.c                |  2 +-\n archive.h                |  2 +-\n bisect.c                 |  2 +-\n blame.c                  |  6 ++--\n blame.h                  |  2 +-\n builtin/cat-file.c       | 10 +++---\n builtin/difftool.c       |  3 +-\n builtin/fast-export.c    |  6 ++--\n builtin/fmt-merge-msg.c  |  4 ++-\n builtin/fsck.c           |  6 ++--\n builtin/grep.c           |  8 ++---\n builtin/index-pack.c     | 27 ++++++++--------\n builtin/log.c            |  4 +--\n builtin/ls-tree.c        |  2 +-\n builtin/merge-tree.c     |  6 ++--\n builtin/mktag.c          |  5 +--\n builtin/notes.c          |  6 ++--\n builtin/pack-objects.c   | 56 +++++++++++++++++-----------------\n builtin/reflog.c         |  2 +-\n builtin/replace.c        |  2 +-\n builtin/tag.c            |  4 +--\n builtin/unpack-file.c    |  2 +-\n builtin/unpack-objects.c | 35 ++++++++++-----------\n builtin/verify-commit.c  |  4 +--\n bundle.c                 |  2 +-\n cache.h                  | 10 +++---\n combine-diff.c           | 11 ++++---\n commit.c                 | 22 +++++++-------\n commit.h                 | 10 +++---\n config.c                 |  2 +-\n convert.c                | 18 +++++------\n delta.h                  | 20 ++++++------\n diff-delta.c             |  4 +--\n diff.c                   | 30 +++++++++---------\n diff.h                   |  2 +-\n diffcore-pickaxe.c       |  4 +--\n diffcore.h               |  2 +-\n dir.c                    |  6 ++--\n dir.h                    |  2 +-\n entry.c                  |  4 +--\n fast-import.c            | 26 ++++++++--------\n fsck.c                   | 12 ++++----\n fsck.h                   |  2 +-\n fuzz-pack-headers.c      |  4 +--\n grep.h                   |  2 +-\n http-push.c              |  2 +-\n list-objects-filter.c    |  2 +-\n mailmap.c                |  2 +-\n match-trees.c            |  4 +--\n merge-blobs.c            |  6 ++--\n merge-blobs.h            |  2 +-\n merge-recursive.c        |  4 +--\n notes-cache.c            |  2 +-\n notes-merge.c            |  4 +--\n notes.c                  |  6 ++--\n object-store.h           | 20 ++++++------\n object.c                 |  4 +--\n object.h                 |  2 +-\n pack-check.c             |  2 +-\n pack-objects.h           | 14 ++++-----\n pack.h                   |  2 +-\n packfile.c               | 40 ++++++++++++------------\n packfile.h               |  8 ++---\n patch-delta.c            |  8 ++---\n range-diff.c             |  2 +-\n read-cache.c             | 48 ++++++++++++++---------------\n ref-filter.c             | 30 +++++++++---------\n remote-testsvn.c         |  4 +--\n rerere.c                 |  2 +-\n sha1-file.c              | 66 ++++++++++++++++++++--------------------\n sha1dc_git.c             |  2 +-\n sha1dc_git.h             |  2 +-\n streaming.c              | 12 ++++----\n streaming.h              |  2 +-\n submodule-config.c       |  2 +-\n t/helper/test-delta.c    |  2 +-\n tag.c                    |  6 ++--\n tag.h                    |  2 +-\n tree-walk.c              | 14 ++++-----\n tree.c                   |  2 +-\n xdiff-interface.c        |  4 +--\n xdiff-interface.h        |  4 +--\n 85 files changed, 391 insertions(+), 384 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 3703bfc8d0..5e11b85d17 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3096,7 +3096,7 @@ static int apply_binary_fragment(struct apply_state *state,\n \t\t\t\t struct patch *patch)\n {\n \tstruct fragment *fragment = patch->fragments;\n-\tunsigned long len;\n+\tsize_t len;\n \tvoid *dst;\n \n \tif (!fragment)\n@@ -3186,7 +3186,7 @@ static int apply_binary(struct apply_state *state,\n \tif (has_sha1_file(oid.hash)) {\n \t\t/* We already have the postimage */\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *result;\n \n \t\tresult = read_object_file(&oid, &type, &size);\n@@ -3248,7 +3248,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns\n \t\tstrbuf_addf(buf, \"Subproject commit %s\\n\", oid_to_hex(oid));\n \t} else {\n \t\tenum object_type type;\n-\t\tunsigned long sz;\n+\t\tsize_t sz;\n \t\tchar *result;\n \n \t\tresult = read_object_file(oid, &type, &sz);\n@@ -4277,7 +4277,7 @@ static int add_index_file(struct apply_state *state,\n \t\t\t  const char *path,\n \t\t\t  unsigned mode,\n \t\t\t  void *buf,\n-\t\t\t  unsigned long size)\n+\t\t\t  size_t size)\n {\n \tstruct stat st;\n \tstruct cache_entry *ce;\n@@ -4331,7 +4331,7 @@ static int add_index_file(struct apply_state *state,\n  */\n static int try_create_file(struct apply_state *state, const char *path,\n \t\t\t   unsigned int mode, const char *buf,\n-\t\t\t   unsigned long size)\n+\t\t\t   size_t size)\n {\n \tint fd, res;\n \tstruct strbuf nbuf = STRBUF_INIT;\n@@ -4382,7 +4382,7 @@ static int create_one_file(struct apply_state *state,\n \t\t\t   char *path,\n \t\t\t   unsigned mode,\n \t\t\t   const char *buf,\n-\t\t\t   unsigned long size)\n+\t\t\t   size_t size)\n {\n \tint res;\n \n@@ -4474,7 +4474,7 @@ static int create_file(struct apply_state *state, struct patch *patch)\n {\n \tchar *path = patch->new_name;\n \tunsigned mode = patch->new_mode;\n-\tunsigned long size = patch->resultsize;\n+\tsize_t size = patch->resultsize;\n \tchar *buf = patch->result;\n \n \tif (!mode)\ndiff --git a/archive-tar.c b/archive-tar.c\nindex a58e1a8ebf..cea52dfc0a 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -13,7 +13,7 @@\n #define BLOCKSIZE\t(RECORDSIZE * 20)\n \n static char block[BLOCKSIZE];\n-static unsigned long offset;\n+static size_t offset;\n \n static int tar_umask = 002;\n \n@@ -51,12 +51,12 @@ static void write_if_needed(void)\n  * queues up writes, so that all our write(2) calls write exactly one\n  * full block; pads writes to RECORDSIZE\n  */\n-static void do_write_blocked(const void *data, unsigned long size)\n+static void do_write_blocked(const void *data, size_t size)\n {\n \tconst char *buf = data;\n \n \tif (offset) {\n-\t\tunsigned long chunk = BLOCKSIZE - offset;\n+\t\tsize_t chunk = BLOCKSIZE - offset;\n \t\tif (size < chunk)\n \t\t\tchunk = size;\n \t\tmemcpy(block + offset, buf, chunk);\n@@ -78,7 +78,7 @@ static void do_write_blocked(const void *data, unsigned long size)\n \n static void finish_record(void)\n {\n-\tunsigned long tail;\n+\tsize_t tail;\n \ttail = offset % RECORDSIZE;\n \tif (tail)  {\n \t\tmemset(block + offset, 0, RECORDSIZE - tail);\n@@ -87,7 +87,7 @@ static void finish_record(void)\n \twrite_if_needed();\n }\n \n-static void write_blocked(const void *data, unsigned long size)\n+static void write_blocked(const void *data, size_t size)\n {\n \tdo_write_blocked(data, size);\n \tfinish_record();\n@@ -116,7 +116,7 @@ static int stream_blocked(const struct object_id *oid)\n {\n \tstruct git_istream *st;\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tchar buf[BLOCKSIZE];\n \tssize_t readlen;\n \n@@ -199,7 +199,7 @@ static size_t get_path_prefix(const char *path, size_t pathlen, size_t maxlen)\n \n static void prepare_header(struct archiver_args *args,\n \t\t\t   struct ustar_header *header,\n-\t\t\t   unsigned int mode, unsigned long size)\n+\t\t\t   unsigned int mode, size_t size)\n {\n \txsnprintf(header->mode, sizeof(header->mode), \"%07o\", mode & 07777);\n \txsnprintf(header->size, sizeof(header->size), \"%011\"PRIoMAX , S_ISREG(mode) ? (uintmax_t)size : (uintmax_t)0);\n@@ -220,7 +220,7 @@ static void prepare_header(struct archiver_args *args,\n \n static void write_extended_header(struct archiver_args *args,\n \t\t\t\t  const struct object_id *oid,\n-\t\t\t\t  const void *buffer, unsigned long size)\n+\t\t\t\t  const void *buffer, size_t size)\n {\n \tstruct ustar_header header;\n \tunsigned int mode;\n@@ -241,7 +241,7 @@ static int write_tar_entry(struct archiver_args *args,\n \tstruct ustar_header header;\n \tstruct strbuf ext_header = STRBUF_INIT;\n \tunsigned int old_mode = mode;\n-\tunsigned long size, size_in_header;\n+\tsize_t size, size_in_header;\n \tvoid *buffer;\n \tint err = 0;\n \ndiff --git a/archive-zip.c b/archive-zip.c\nindex 155ee4a779..7bc9b8d425 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -297,7 +297,7 @@ static int write_zip_entry(struct archiver_args *args,\n \tvoid *buffer;\n \tstruct git_istream *stream = NULL;\n \tunsigned long flags = 0;\n-\tunsigned long size;\n+\tsize_t size;\n \tint is_binary = -1;\n \tconst char *path_without_prefix = path + args->baselen;\n \tunsigned int creator_version = 0;\ndiff --git a/archive.c b/archive.c\nindex 180d97cf77..541d059583 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -73,7 +73,7 @@ static void format_subst(const struct commit *commit,\n void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t     const char *path, const struct object_id *oid,\n \t\t\t     unsigned int mode, enum object_type *type,\n-\t\t\t     unsigned long *sizep)\n+\t\t\t     size_t *sizep)\n {\n \tvoid *buffer;\n \tconst struct commit *commit = args->convert ? args->commit : NULL;\ndiff --git a/archive.h b/archive.h\nindex 21ac010699..5b69ee1baf 100644\n--- a/archive.h\n+++ b/archive.h\n@@ -54,6 +54,6 @@ extern int write_archive_entries(struct archiver_args *args, write_archive_entry\n extern void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t\t    const char *path, const struct object_id *oid,\n \t\t\t\t    unsigned int mode, enum object_type *type,\n-\t\t\t\t    unsigned long *sizep);\n+\t\t\t\t    size_t *sizep);\n \n #endif\t/* ARCHIVE_H */\ndiff --git a/bisect.c b/bisect.c\nindex 4c1b80bff6..73822372d0 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -137,7 +137,7 @@ static void show_list(const char *debug, int counted, int nr,\n \t\tstruct commit *commit = p->item;\n \t\tunsigned flags = commit->object.flags;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf = read_object_file(&commit->object.oid, &type,\n \t\t\t\t\t     &size);\n \t\tconst char *subject_start;\ndiff --git a/blame.c b/blame.c\nindex 43861437f7..02c412e8f4 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -222,7 +222,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,\n \t\tstruct stat st;\n \t\tconst char *read_from;\n \t\tchar *buf_ptr;\n-\t\tunsigned long buf_len;\n+\t\tsize_t buf_len;\n \n \t\tif (contents_from) {\n \t\t\tif (stat(contents_from, &st) < 0)\n@@ -319,7 +319,7 @@ static void fill_origin_blob(struct diff_options *opt,\n {\n \tif (!o->file.ptr) {\n \t\tenum object_type type;\n-\t\tunsigned long file_size;\n+\t\tsize_t file_size;\n \n \t\t(*num_read_blob)++;\n \t\tif (opt->flags.allow_textconv &&\n@@ -1651,7 +1651,7 @@ static const char *get_next_line(const char *start, const char *end)\n static int prepare_lines(struct blame_scoreboard *sb)\n {\n \tconst char *buf = sb->final_buf;\n-\tunsigned long len = sb->final_buf_size;\n+\tsize_t len = sb->final_buf_size;\n \tconst char *end = buf + len;\n \tconst char *p;\n \tint *lineno;\ndiff --git a/blame.h b/blame.h\nindex be3a895043..0ef7ff1f3f 100644\n--- a/blame.h\n+++ b/blame.h\n@@ -112,7 +112,7 @@ struct blame_scoreboard {\n \t * indexed with scoreboard.lineno[blame_entry.lno].\n \t */\n \tconst char *final_buf;\n-\tunsigned long final_buf_size;\n+\tsize_t final_buf_size;\n \n \t/* linked list of blames */\n \tstruct blame_entry *ent;\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 2ca56fd086..98dc4e6a1c 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -30,7 +30,7 @@ static const char *force_path;\n \n static int filter_object(const char *path, unsigned mode,\n \t\t\t const struct object_id *oid,\n-\t\t\t char **buf, unsigned long *size)\n+\t\t\t char **buf, size_t *size)\n {\n \tenum object_type type;\n \n@@ -63,7 +63,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tstruct object_id oid;\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_context obj_context;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tstruct strbuf sb = STRBUF_INIT;\n@@ -189,7 +189,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n struct expand_data {\n \tstruct object_id oid;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t disk_size;\n \tconst char *rest;\n \tstruct object_id delta_base_oid;\n@@ -301,7 +301,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\t\tfflush(stdout);\n \t\tif (opt->cmdmode) {\n \t\t\tchar *contents;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \n \t\t\tif (!data->rest)\n \t\t\t\tdie(\"missing path for '%s'\", oid_to_hex(oid));\n@@ -332,7 +332,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t}\n \telse {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tvoid *contents;\n \n \t\tcontents = read_object_file(oid, &type, &size);\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex 71318c26e1..f0a1ceb1f3 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -306,7 +306,8 @@ static char *get_symlink(const struct object_id *oid, const char *path)\n \t\tdata = strbuf_detach(&link, NULL);\n \t} else {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\n+\t\tsize_t size;\n \t\tdata = read_object_file(oid, &type, &size);\n \t\tif (!data)\n \t\t\tdie(_(\"could not read object %s for symlink %s\"),\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 75b5cd92a5..2e764490a0 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -227,7 +227,7 @@ static void show_progress(void)\n  * There's no need to cache this result with anonymize_mem, since\n  * we already handle blob content caching with marks.\n  */\n-static char *anonymize_blob(unsigned long *size)\n+static char *anonymize_blob(size_t *size)\n {\n \tstatic int counter;\n \tstruct strbuf out = STRBUF_INIT;\n@@ -238,7 +238,7 @@ static char *anonymize_blob(unsigned long *size)\n \n static void export_blob(const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf;\n \tstruct object *object;\n@@ -708,7 +708,7 @@ static void handle_tail(struct object_array *commits, struct rev_info *revs,\n \n static void handle_tag(const char *name, struct tag *tag)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf;\n \tconst char *tagger, *tagger_end, *message;\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex a4615587fd..9997bf2a4a 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -493,7 +493,9 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \tfor (i = 0; i < origins.nr; i++) {\n \t\tstruct object_id *oid = origins.items[i].util;\n \t\tenum object_type type;\n-\t\tunsigned long size, len;\n+\n+\t\tunsigned long len;\n+\t\tsize_t size;\n \t\tchar *buf = read_object_file(oid, &type, &size);\n \t\tstruct strbuf sig = STRBUF_INIT;\n \ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 9c4c11d0ad..011f5cd32d 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -359,7 +359,7 @@ static void check_connectivity(void)\n \t}\n }\n \n-static int fsck_obj(struct object *obj, void *buffer, unsigned long size)\n+static int fsck_obj(struct object *obj, void *buffer, size_t size)\n {\n \tint err;\n \n@@ -407,7 +407,7 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)\n }\n \n static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,\n-\t\t\t   unsigned long size, void *buffer, int *eaten)\n+\t\t\t   size_t size, void *buffer, int *eaten)\n {\n \t/*\n \t * Note, buffer may be NULL if type is OBJ_BLOB. See\n@@ -562,7 +562,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)\n {\n \tstruct object *obj;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *contents;\n \tint eaten;\n \ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex e3af50ca16..936338421a 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -294,7 +294,7 @@ static int grep_cmd_config(const char *var, const char *value, void *cb)\n \treturn st;\n }\n \n-static void *lock_and_read_oid_file(const struct object_id *oid, enum object_type *type, unsigned long *size)\n+static void *lock_and_read_oid_file(const struct object_id *oid, enum object_type *type, size_t *size)\n {\n \tvoid *data;\n \n@@ -447,7 +447,7 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,\n \t\tstruct object *object;\n \t\tstruct tree_desc tree;\n \t\tvoid *data;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tstruct strbuf base = STRBUF_INIT;\n \n \t\tobject = parse_object_or_die(oid, oid_to_hex(oid));\n@@ -575,7 +575,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\t\tenum object_type type;\n \t\t\tstruct tree_desc sub;\n \t\t\tvoid *data;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \n \t\t\tdata = lock_and_read_oid_file(entry.oid, &type, &size);\n \t\t\tif (!data)\n@@ -610,7 +610,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,\n \tif (obj->type == OBJ_COMMIT || obj->type == OBJ_TREE) {\n \t\tstruct tree_desc tree;\n \t\tvoid *data;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tstruct strbuf base;\n \t\tint hit, len;\n \ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex ac1f4ea9a7..efbed1c2d1 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -20,7 +20,7 @@ static const char index_pack_usage[] =\n \n struct object_entry {\n \tstruct pack_idx_entry idx;\n-\tunsigned long size;\n+\tsize_t size;\n \tunsigned char hdr_size;\n \tsigned char type;\n \tsigned char real_type;\n@@ -36,7 +36,7 @@ struct base_data {\n \tstruct base_data *child;\n \tstruct object_entry *obj;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ref_first, ref_last;\n \tint ofs_first, ofs_last;\n };\n@@ -198,7 +198,7 @@ static unsigned check_object(struct object *obj)\n \t\treturn 0;\n \n \tif (!(obj->flags & FLAG_CHECKED)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n@@ -412,7 +412,7 @@ static int is_delta_type(enum object_type type)\n \treturn (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA);\n }\n \n-static void *unpack_entry_data(off_t offset, unsigned long size,\n+static void *unpack_entry_data(off_t offset, size_t size,\n \t\t\t       enum object_type type, struct object_id *oid)\n {\n \tstatic char fixed_buf[8192];\n@@ -467,7 +467,8 @@ static void *unpack_raw_entry(struct object_entry *obj,\n \t\t\t      struct object_id *oid)\n {\n \tunsigned char *p;\n-\tunsigned long size, c;\n+\tunsigned long c;\n+\tsize_t size;\n \toff_t base_offset;\n \tunsigned shift;\n \tvoid *data;\n@@ -529,7 +530,7 @@ static void *unpack_raw_entry(struct object_entry *obj,\n }\n \n static void *unpack_data(struct object_entry *obj,\n-\t\t\t int (*consume)(const unsigned char *, unsigned long, void *),\n+\t\t\t int (*consume)(const unsigned char *, size_t, void *),\n \t\t\t void *cb_data)\n {\n \toff_t from = obj[0].idx.offset + obj[0].hdr_size;\n@@ -706,10 +707,10 @@ struct compare_data {\n \tstruct object_entry *entry;\n \tstruct git_istream *st;\n \tunsigned char *buf;\n-\tunsigned long buf_size;\n+\tsize_t buf_size;\n };\n \n-static int compare_objects(const unsigned char *buf, unsigned long size,\n+static int compare_objects(const unsigned char *buf, size_t size,\n \t\t\t   void *cb_data)\n {\n \tstruct compare_data *data = cb_data;\n@@ -741,7 +742,7 @@ static int check_collison(struct object_entry *entry)\n {\n \tstruct compare_data data;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tif (entry->size <= big_file_threshold || entry->type != OBJ_BLOB)\n \t\treturn -1;\n@@ -761,7 +762,7 @@ static int check_collison(struct object_entry *entry)\n }\n \n static void sha1_object(const void *data, struct object_entry *obj_entry,\n-\t\t\tunsigned long size, enum object_type type,\n+\t\t\tsize_t size, enum object_type type,\n \t\t\tconst struct object_id *oid)\n {\n \tvoid *new_data = NULL;\n@@ -785,7 +786,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \tif (collision_test_needed) {\n \t\tvoid *has_data;\n \t\tenum object_type has_type;\n-\t\tunsigned long has_size;\n+\t\tsize_t has_size;\n \t\tread_lock();\n \t\thas_type = oid_object_info(the_repository, oid, &has_size);\n \t\tif (has_type < 0)\n@@ -1288,11 +1289,11 @@ static int write_compressed(struct hashfile *f, void *in, unsigned int size)\n \n static struct object_entry *append_obj_to_pack(struct hashfile *f,\n \t\t\t       const unsigned char *sha1, void *buf,\n-\t\t\t       unsigned long size, enum object_type type)\n+\t\t\t       size_t size, enum object_type type)\n {\n \tstruct object_entry *obj = &objects[nr_objects++];\n \tunsigned char header[10];\n-\tunsigned long s = size;\n+\tsize_t s = size;\n \tint n = 0;\n \tunsigned char c = (type << 4) | (s & 15);\n \ts >>= 4;\ndiff --git a/builtin/log.c b/builtin/log.c\nindex ea15b0be4d..a2791f82a8 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -502,7 +502,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \tstruct object_id oidc;\n \tstruct object_context obj_context;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tfflush(rev->diffopt.file);\n \tif (!rev->diffopt.flags.textconv_set_via_cmdline ||\n@@ -529,7 +529,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \n static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = read_object_file(oid, &type, &size);\n \tint offset = 0;\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 7d581d6463..c662d4d318 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -94,7 +94,7 @@ static int show_tree(const struct object_id *oid, struct strbuf *base,\n \t\tif (ls_options & LS_SHOW_SIZE) {\n \t\t\tchar size_text[24];\n \t\t\tif (!strcmp(type, blob_type)) {\n-\t\t\t\tunsigned long size;\n+\t\t\t\tsize_t size;\n \t\t\t\tif (oid_object_info(the_repository, oid, &size) == OBJ_BAD)\n \t\t\t\t\txsnprintf(size_text, sizeof(size_text),\n \t\t\t\t\t\t  \"BAD\");\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 70f6fc9167..02c22e4241 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -55,7 +55,7 @@ static const char *explanation(struct merge_list *entry)\n \treturn \"removed in remote\";\n }\n \n-static void *result(struct merge_list *entry, unsigned long *size)\n+static void *result(struct merge_list *entry, size_t *size)\n {\n \tenum object_type type;\n \tstruct blob *base, *our, *their;\n@@ -79,7 +79,7 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \treturn merge_blobs(&the_index, path, base, our, their, size);\n }\n \n-static void *origin(struct merge_list *entry, unsigned long *size)\n+static void *origin(struct merge_list *entry, size_t *size)\n {\n \tenum object_type type;\n \twhile (entry) {\n@@ -101,7 +101,7 @@ static int show_outf(void *priv_, mmbuffer_t *mb, int nbuf)\n \n static void show_diff(struct merge_list *entry)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tmmfile_t src, dst;\n \txpparam_t xpp;\n \txdemitconf_t xecfg;\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 6fb7dc8578..ebc5d10621 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -24,7 +24,8 @@ static int verify_object(const struct object_id *oid, const char *expected_type)\n {\n \tint ret = -1;\n \tenum object_type type;\n-\tunsigned long size;\n+\n+\tsize_t size;\n \tvoid *buffer = read_object_file(oid, &type, &size);\n \tconst struct object_id *repl = lookup_replace_object(the_repository, oid);\n \n@@ -36,7 +37,7 @@ static int verify_object(const struct object_id *oid, const char *expected_type)\n \treturn ret;\n }\n \n-static int verify_tag(char *buffer, unsigned long size)\n+static int verify_tag(char *buffer, size_t size)\n {\n \tint typelen;\n \tchar type[20];\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 4996a670f7..be892b058b 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -122,7 +122,7 @@ static int list_each_note(const struct object_id *object_oid,\n \n static void copy_obj_to_fd(int fd, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = read_object_file(oid, &type, &size);\n \tif (buf) {\n@@ -252,7 +252,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n \tchar *buf;\n \tstruct object_id object;\n \tenum object_type type;\n-\tunsigned long len;\n+\tsize_t len;\n \n \tBUG_ON_OPT_NEG(unset);\n \n@@ -613,7 +613,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \n \tif (note && !edit) {\n \t\t/* Append buf to previous note contents */\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tenum object_type type;\n \t\tchar *prev_buf = read_object_file(note, &type, &size);\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex d0da1bed57..7f657f7937 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -142,7 +142,7 @@ static void index_commit_for_bitmap(struct commit *commit)\n \n static void *get_delta(struct object_entry *entry)\n {\n-\tunsigned long size, base_size, delta_size;\n+\tsize_t size, base_size, delta_size;\n \tvoid *buf, *base_buf, *delta_buf;\n \tenum object_type type;\n \n@@ -168,11 +168,11 @@ static void *get_delta(struct object_entry *entry)\n \treturn delta_buf;\n }\n \n-static unsigned long do_compress(void **pptr, unsigned long size)\n+static size_t do_compress(void **pptr, size_t size)\n {\n \tgit_zstream stream;\n \tvoid *in, *out;\n-\tunsigned long maxsize;\n+\tsize_t maxsize;\n \n \tgit_deflate_init(&stream, pack_compression_level);\n \tmaxsize = git_deflate_bound(&stream, size);\n@@ -193,13 +193,13 @@ static unsigned long do_compress(void **pptr, unsigned long size)\n \treturn stream.total_out;\n }\n \n-static unsigned long write_large_blob_data(struct git_istream *st, struct hashfile *f,\n+static size_t write_large_blob_data(struct git_istream *st, struct hashfile *f,\n \t\t\t\t\t   const struct object_id *oid)\n {\n \tgit_zstream stream;\n \tunsigned char ibuf[1024 * 16];\n \tunsigned char obuf[1024 * 16];\n-\tunsigned long olen = 0;\n+\tsize_t olen = 0;\n \n \tgit_deflate_init(&stream, pack_compression_level);\n \n@@ -240,7 +240,7 @@ static int check_pack_inflate(struct packed_git *p,\n \t\tstruct pack_window **w_curs,\n \t\toff_t offset,\n \t\toff_t len,\n-\t\tunsigned long expect)\n+\t\tsize_t expect)\n {\n \tgit_zstream stream;\n \tunsigned char fakebuf[4096], *in;\n@@ -282,10 +282,10 @@ static void copy_pack_data(struct hashfile *f,\n }\n \n /* Return 0 if we will bust the pack-size limit */\n-static unsigned long write_no_reuse_object(struct hashfile *f, struct object_entry *entry,\n-\t\t\t\t\t   unsigned long limit, int usable_delta)\n+static size_t write_no_reuse_object(struct hashfile *f, struct object_entry *entry,\n+\t\t\t\t\t   size_t limit, int usable_delta)\n {\n-\tunsigned long size, datalen;\n+\tsize_t size, datalen;\n \tunsigned char header[MAX_PACK_OBJECT_HEADER],\n \t\t      dheader[MAX_PACK_OBJECT_HEADER];\n \tunsigned hdrlen;\n@@ -394,7 +394,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent\n \n /* Return 0 if we will bust the pack-size limit */\n static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,\n-\t\t\t\tunsigned long limit, int usable_delta)\n+\t\t\t\tsize_t limit, int usable_delta)\n {\n \tstruct packed_git *p = IN_PACK(entry);\n \tstruct pack_window *w_curs = NULL;\n@@ -406,7 +406,7 @@ static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,\n \t\t      dheader[MAX_PACK_OBJECT_HEADER];\n \tunsigned hdrlen;\n \tconst unsigned hashsz = the_hash_algo->rawsz;\n-\tunsigned long entry_size = SIZE(entry);\n+\tsize_t entry_size = SIZE(entry);\n \n \tif (DELTA(entry))\n \t\ttype = (allow_ofs_delta && DELTA(entry)->idx.offset) ?\n@@ -477,7 +477,7 @@ static off_t write_object(struct hashfile *f,\n \t\t\t  struct object_entry *entry,\n \t\t\t  off_t write_offset)\n {\n-\tunsigned long limit;\n+\tsize_t limit;\n \toff_t len;\n \tint usable_delta, to_reuse;\n \n@@ -1208,7 +1208,7 @@ struct pbase_tree_cache {\n \tint ref;\n \tint temporary;\n \tvoid *tree_data;\n-\tunsigned long tree_size;\n+\tsize_t tree_size;\n };\n \n static struct pbase_tree_cache *(pbase_tree_cache[256]);\n@@ -1235,7 +1235,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n {\n \tstruct pbase_tree_cache *ent, *nent;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tint neigh;\n \tint my_ix = pbase_tree_cache_ix(oid);\n@@ -1418,7 +1418,7 @@ static void add_preferred_base(struct object_id *oid)\n {\n \tstruct pbase_tree *it;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_id tree_oid;\n \n \tif (window <= num_preferred_base++)\n@@ -1522,7 +1522,7 @@ static int can_reuse_delta(const unsigned char *base_sha1,\n \n static void check_object(struct object_entry *entry)\n {\n-\tunsigned long canonical_size;\n+\tsize_t canonical_size;\n \n \tif (IN_PACK(entry)) {\n \t\tstruct packed_git *p = IN_PACK(entry);\n@@ -1534,7 +1534,7 @@ static void check_object(struct object_entry *entry)\n \t\toff_t ofs;\n \t\tunsigned char *buf, c;\n \t\tenum object_type type;\n-\t\tunsigned long in_pack_size;\n+\t\tsize_t in_pack_size;\n \n \t\tbuf = use_pack(p, &w_curs, entry->in_pack_offset, &avail);\n \n@@ -1700,7 +1700,7 @@ static void drop_reused_delta(struct object_entry *entry)\n \tunsigned *idx = &to_pack.objects[entry->delta_idx - 1].delta_child_idx;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \n \twhile (*idx) {\n \t\tstruct object_entry *oe = &to_pack.objects[*idx - 1];\n@@ -1937,8 +1937,8 @@ struct unpacked {\n \tunsigned depth;\n };\n \n-static int delta_cacheable(unsigned long src_size, unsigned long trg_size,\n-\t\t\t   unsigned long delta_size)\n+static int delta_cacheable(size_t src_size, size_t trg_size,\n+\t\t\t   size_t delta_size)\n {\n \tif (max_delta_cache_size && delta_cache_size + delta_size > max_delta_cache_size)\n \t\treturn 0;\n@@ -1983,14 +1983,14 @@ static pthread_mutex_t progress_mutex;\n  * reconstruction (so non-deltas are true object sizes, but deltas\n  * return the size of the delta data).\n  */\n-unsigned long oe_get_size_slow(struct packing_data *pack,\n+size_t oe_get_size_slow(struct packing_data *pack,\n \t\t\t       const struct object_entry *e)\n {\n \tstruct packed_git *p;\n \tstruct pack_window *w_curs;\n \tunsigned char *buf;\n \tenum object_type type;\n-\tunsigned long used, size;\n+\tsize_t used, size;\n \tsize_t avail;\n \n \tif (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {\n@@ -2020,11 +2020,11 @@ unsigned long oe_get_size_slow(struct packing_data *pack,\n }\n \n static int try_delta(struct unpacked *trg, struct unpacked *src,\n-\t\t     unsigned max_depth, unsigned long *mem_usage)\n+\t\t     unsigned max_depth, size_t *mem_usage)\n {\n \tstruct object_entry *trg_entry = trg->entry;\n \tstruct object_entry *src_entry = src->entry;\n-\tunsigned long trg_size, src_size, delta_size, sizediff, max_size, sz;\n+\tsize_t trg_size, src_size, delta_size, sizediff, max_size, sz;\n \tunsigned ref_depth;\n \tenum object_type type;\n \tvoid *delta_buf;\n@@ -2180,9 +2180,9 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)\n \treturn m;\n }\n \n-static unsigned long free_unpacked(struct unpacked *n)\n+static size_t free_unpacked(struct unpacked *n)\n {\n-\tunsigned long freed_mem = sizeof_delta_index(n->index);\n+\tsize_t freed_mem = sizeof_delta_index(n->index);\n \tfree_delta_index(n->index);\n \tn->index = NULL;\n \tif (n->data) {\n@@ -2199,7 +2199,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,\n {\n \tuint32_t i, idx = 0, count = 0;\n \tstruct unpacked *array;\n-\tunsigned long mem_usage = 0;\n+\tsize_t mem_usage = 0;\n \n \tarray = xcalloc(window, sizeof(struct unpacked));\n \n@@ -2282,7 +2282,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,\n \t\t * between writes at that moment.\n \t\t */\n \t\tif (entry->delta_data && !pack_to_stdout) {\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \n \t\t\tsize = do_compress(&entry->delta_data, DELTA_SIZE(entry));\n \t\t\tif (size < (1U << OE_Z_DELTA_BITS)) {\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 64a8df4f25..11d57ccbc9 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -82,7 +82,7 @@ static int tree_is_complete(const struct object_id *oid)\n \n \tif (!tree->buffer) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tvoid *data = read_object_file(oid, &type, &size);\n \t\tif (!data) {\n \t\t\ttree->object.flags |= INCOMPLETE;\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex a58b9c6d13..473635804d 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -439,7 +439,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle)\n \tstruct commit *commit;\n \tstruct strbuf buf = STRBUF_INIT;\n \tconst char *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tif (get_oid(old_ref, &old_oid) < 0)\n \t\treturn error(_(\"not a valid object name: '%s'\"), old_ref);\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 02f6bd1279..3a76b590c1 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -165,7 +165,7 @@ static int git_tag_config(const char *var, const char *value, void *cb)\n \n static void write_tag_body(int fd, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf, *sp;\n \n@@ -286,7 +286,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \tenum object_type type;\n \tstruct commit *c;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint subject_len = 0;\n \tconst char *subject_start;\n \ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex 58652229f2..61200ed57c 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -7,7 +7,7 @@ static char *create_temp_file(struct object_id *oid)\n \tstatic char path[50];\n \tvoid *buf;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tint fd;\n \n \tbuf = read_object_file(oid, &type, &size);\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 80478808b3..13f4d1acc1 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -32,7 +32,7 @@ static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;\n  */\n struct obj_buffer {\n \tchar *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n };\n \n static struct decoration obj_decorate;\n@@ -42,7 +42,7 @@ static struct obj_buffer *lookup_object_buffer(struct object *base)\n \treturn lookup_decoration(&obj_decorate, base);\n }\n \n-static void add_object_buffer(struct object *object, char *buffer, unsigned long size)\n+static void add_object_buffer(struct object *object, char *buffer, size_t size)\n {\n \tstruct obj_buffer *obj;\n \tobj = xcalloc(1, sizeof(struct obj_buffer));\n@@ -94,7 +94,7 @@ static void use(int bytes)\n \t\tdie(_(\"pack exceeds maximum allowed size\"));\n }\n \n-static void *get_data(unsigned long size)\n+static void *get_data(size_t size)\n {\n \tgit_zstream stream;\n \tvoid *buf = xmallocz(size);\n@@ -131,7 +131,7 @@ struct delta_info {\n \tstruct object_id base_oid;\n \tunsigned nr;\n \toff_t base_offset;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *delta;\n \tstruct delta_info *next;\n };\n@@ -140,7 +140,7 @@ static struct delta_info *delta_list;\n \n static void add_delta_to_list(unsigned nr, const struct object_id *base_oid,\n \t\t\t      off_t base_offset,\n-\t\t\t      void *delta, unsigned long size)\n+\t\t\t      void *delta, size_t size)\n {\n \tstruct delta_info *info = xmalloc(sizeof(*info));\n \n@@ -199,7 +199,7 @@ static int check_object(struct object *obj, int type, void *data, struct fsck_op\n \t\tdie(\"object type mismatch\");\n \n \tif (!(obj->flags & FLAG_OPEN)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n@@ -229,7 +229,7 @@ static void write_rest(void)\n }\n \n static void added_object(unsigned nr, enum object_type type,\n-\t\t\t void *data, unsigned long size);\n+\t\t\t void *data, size_t size);\n \n /*\n  * Write out nr-th object from the list, now we know the contents\n@@ -237,7 +237,7 @@ static void added_object(unsigned nr, enum object_type type,\n  * to be checked at the end.\n  */\n static void write_object(unsigned nr, enum object_type type,\n-\t\t\t void *buf, unsigned long size)\n+\t\t\t void *buf, size_t size)\n {\n \tif (!strict) {\n \t\tif (write_object_file(buf, size, type_name(type),\n@@ -277,11 +277,11 @@ static void write_object(unsigned nr, enum object_type type,\n }\n \n static void resolve_delta(unsigned nr, enum object_type type,\n-\t\t\t  void *base, unsigned long base_size,\n-\t\t\t  void *delta, unsigned long delta_size)\n+\t\t\t  void *base, size_t base_size,\n+\t\t\t  void *delta, size_t delta_size)\n {\n \tvoid *result;\n-\tunsigned long result_size;\n+\tsize_t result_size;\n \n \tresult = patch_delta(base, base_size,\n \t\t\t     delta, delta_size,\n@@ -297,7 +297,7 @@ static void resolve_delta(unsigned nr, enum object_type type,\n  * resolve all the deltified objects that are based on it.\n  */\n static void added_object(unsigned nr, enum object_type type,\n-\t\t\t void *data, unsigned long size)\n+\t\t\t void *data, size_t size)\n {\n \tstruct delta_info **p = &delta_list;\n \tstruct delta_info *info;\n@@ -316,7 +316,7 @@ static void added_object(unsigned nr, enum object_type type,\n \t}\n }\n \n-static void unpack_non_delta_entry(enum object_type type, unsigned long size,\n+static void unpack_non_delta_entry(enum object_type type, size_t size,\n \t\t\t\t   unsigned nr)\n {\n \tvoid *buf = get_data(size);\n@@ -328,7 +328,7 @@ static void unpack_non_delta_entry(enum object_type type, unsigned long size,\n }\n \n static int resolve_against_held(unsigned nr, const struct object_id *base,\n-\t\t\t\tvoid *delta_data, unsigned long delta_size)\n+\t\t\t\tvoid *delta_data, size_t delta_size)\n {\n \tstruct object *obj;\n \tstruct obj_buffer *obj_buffer;\n@@ -343,11 +343,11 @@ static int resolve_against_held(unsigned nr, const struct object_id *base,\n \treturn 1;\n }\n \n-static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n+static void unpack_delta_entry(enum object_type type, size_t delta_size,\n \t\t\t       unsigned nr)\n {\n \tvoid *delta_data, *base;\n-\tunsigned long base_size;\n+\tsize_t base_size;\n \tstruct object_id base_oid;\n \n \tif (type == OBJ_REF_DELTA) {\n@@ -442,7 +442,8 @@ static void unpack_one(unsigned nr)\n {\n \tunsigned shift;\n \tunsigned char *pack;\n-\tunsigned long size, c;\n+\tunsigned long c;\n+\tsize_t size;\n \tenum object_type type;\n \n \tobj_list[nr].offset = consumed_bytes;\ndiff --git a/builtin/verify-commit.c b/builtin/verify-commit.c\nindex 7772c07ed7..0c25550ef1 100644\n--- a/builtin/verify-commit.c\n+++ b/builtin/verify-commit.c\n@@ -21,7 +21,7 @@ static const char * const verify_commit_usage[] = {\n \t\tNULL\n };\n \n-static int run_gpg_verify(const struct object_id *oid, const char *buf, unsigned long size, unsigned flags)\n+static int run_gpg_verify(const struct object_id *oid, const char *buf, size_t size, unsigned flags)\n {\n \tstruct signature_check signature_check;\n \tint ret;\n@@ -41,7 +41,7 @@ static int verify_commit(const char *name, unsigned flags)\n \tenum object_type type;\n \tstruct object_id oid;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tif (get_oid(name, &oid))\ndiff --git a/bundle.c b/bundle.c\nindex b94992675a..a4f1d8127b 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -217,7 +217,7 @@ int list_bundle_refs(struct bundle_header *header, int argc, const char **argv)\n \n static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = NULL, *line, *lineend;\n \ttimestamp_t date;\ndiff --git a/cache.h b/cache.h\nindex cb53380211..aba5c0034c 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -784,7 +784,7 @@ extern int chmod_index_entry(struct index_state *, struct cache_entry *ce, char\n extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);\n extern void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);\n extern int index_name_is_other(const struct index_state *, const char *, int);\n-extern void *read_blob_data_from_index(const struct index_state *, const char *, unsigned long *);\n+extern void *read_blob_data_from_index(const struct index_state *, const char *, size_t *);\n \n /* do stat comparison even if CE_VALID is true */\n #define CE_MATCH_IGNORE_VALID\t\t01\n@@ -1281,10 +1281,10 @@ extern char *xdg_cache_home(const char *filename);\n \n extern int git_open_cloexec(const char *name, int flags);\n #define git_open(name) git_open_cloexec(name, O_RDONLY)\n-extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);\n-extern int parse_sha1_header(const char *hdr, unsigned long *sizep);\n+extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, size_t mapsize, void *buffer, size_t bufsiz);\n+extern int parse_sha1_header(const char *hdr, size_t *sizep);\n \n-extern int check_object_signature(const struct object_id *oid, void *buf, unsigned long size, const char *type);\n+extern int check_object_signature(const struct object_id *oid, void *buf, size_t size, const char *type);\n \n extern int finalize_object_file(const char *tmpfile, const char *filename);\n \n@@ -1446,7 +1446,7 @@ extern int cache_name_stage_compare(const char *name1, int len1, int stage1, con\n \n extern void *read_object_with_reference(const struct object_id *oid,\n \t\t\t\t\tconst char *required_type,\n-\t\t\t\t\tunsigned long *size,\n+\t\t\t\t\tsize_t *size,\n \t\t\t\t\tstruct object_id *oid_ret);\n \n extern struct object *peel_to_type(const char *name, int namelen,\ndiff --git a/combine-diff.c b/combine-diff.c\nindex a143c00634..d782c639b1 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -287,7 +287,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,\n \n static char *grab_blob(struct repository *r,\n \t\t       const struct object_id *oid, unsigned int mode,\n-\t\t       unsigned long *size, struct userdiff_driver *textconv,\n+\t\t       size_t *size, struct userdiff_driver *textconv,\n \t\t       const char *path)\n {\n \tchar *blob;\n@@ -379,7 +379,7 @@ static void consume_hunk(void *state_,\n \tstate->sline[state->nb-1].p_lno[state->n] = state->ob;\n }\n \n-static void consume_line(void *state_, char *line, unsigned long len)\n+static void consume_line(void *state_, char *line, size_t len)\n {\n \tstruct combine_diff_state *state = state_;\n \tif (!state->lost_bucket)\n@@ -409,7 +409,7 @@ static void combine_diff(struct repository *r,\n \txdemitconf_t xecfg;\n \tmmfile_t parent_file;\n \tstruct combine_diff_state state;\n-\tunsigned long sz;\n+\tsize_t sz;\n \n \tif (result_deleted)\n \t\treturn; /* result deleted */\n@@ -979,7 +979,8 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\t    struct rev_info *rev)\n {\n \tstruct diff_options *opt = &rev->diffopt;\n-\tunsigned long result_size, cnt, lno;\n+\tunsigned long cnt, lno;\n+\tsize_t result_size;\n \tint result_deleted = 0;\n \tchar *result, *cp;\n \tstruct sline *sline; /* survived lines */\n@@ -1097,7 +1098,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\tis_binary = buffer_is_binary(result, result_size);\n \t\tfor (i = 0; !is_binary && i < num_parent; i++) {\n \t\t\tchar *buf;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\tbuf = grab_blob(opt->repo,\n \t\t\t\t\t&elem->parent[i].oid,\n \t\t\t\t\telem->parent[i].mode,\ndiff --git a/commit.c b/commit.c\nindex a5333c7ac6..b9d8793910 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -260,7 +260,7 @@ int unregister_shallow(const struct object_id *oid)\n \n struct commit_buffer {\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n };\n define_commit_slab(buffer_slab, struct commit_buffer);\n \n@@ -277,7 +277,7 @@ void free_commit_buffer_slab(struct buffer_slab *bs)\n \tfree(bs);\n }\n \n-void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer, unsigned long size)\n+void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer, size_t size)\n {\n \tstruct commit_buffer *v = buffer_slab_at(\n \t\tr->parsed_objects->buffer_slab, commit);\n@@ -285,7 +285,7 @@ void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer\n \tv->size = size;\n }\n \n-const void *get_cached_commit_buffer(struct repository *r, const struct commit *commit, unsigned long *sizep)\n+const void *get_cached_commit_buffer(struct repository *r, const struct commit *commit, size_t *sizep)\n {\n \tstruct commit_buffer *v = buffer_slab_peek(\n \t\tr->parsed_objects->buffer_slab, commit);\n@@ -301,12 +301,12 @@ const void *get_cached_commit_buffer(struct repository *r, const struct commit *\n \n const void *repo_get_commit_buffer(struct repository *r,\n \t\t\t\t   const struct commit *commit,\n-\t\t\t\t   unsigned long *sizep)\n+\t\t\t\t   size_t *sizep)\n {\n \tconst void *ret = get_cached_commit_buffer(r, commit, sizep);\n \tif (!ret) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tret = repo_read_object_file(r, &commit->object.oid, &type, &size);\n \t\tif (!ret)\n \t\t\tdie(\"cannot read commit object %s\",\n@@ -366,7 +366,7 @@ void release_commit_memory(struct parsed_object_pool *pool, struct commit *c)\n \tc->object.parsed = 0;\n }\n \n-const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n+const void *detach_commit_buffer(struct commit *commit, size_t *sizep)\n {\n \tstruct commit_buffer *v = buffer_slab_peek(\n \t\tthe_repository->parsed_objects->buffer_slab, commit);\n@@ -386,7 +386,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n \treturn ret;\n }\n \n-int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph)\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, size_t size, int check_graph)\n {\n \tconst char *tail = buffer;\n \tconst char *bufptr = buffer;\n@@ -455,7 +455,7 @@ int repo_parse_commit_internal(struct repository *r,\n {\n \tenum object_type type;\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tif (!item)\n@@ -976,7 +976,7 @@ int parse_signed_commit(const struct commit *commit,\n \t\t\tstruct strbuf *payload, struct strbuf *signature)\n {\n \n-\tunsigned long size;\n+\tsize_t size;\n \tconst char *buffer = get_commit_buffer(commit, &size);\n \tint in_signature, saw_signature = -1;\n \tconst char *line, *tail;\n@@ -1051,7 +1051,7 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header\n \tstruct merge_remote_desc *desc;\n \tstruct commit_extra_header *mergetag;\n \tchar *buf;\n-\tunsigned long size, len;\n+\tsize_t size, len;\n \tenum object_type type;\n \n \tdesc = merge_remote_util(parent);\n@@ -1158,7 +1158,7 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,\n \t\t\t\t\t\t      const char **exclude)\n {\n \tstruct commit_extra_header *extra = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \tconst char *buffer = get_commit_buffer(commit, &size);\n \textra = read_commit_extra_header_lines(buffer, size, exclude);\n \tunuse_commit_buffer(commit, buffer);\ndiff --git a/commit.h b/commit.h\nindex 42728c2906..bcf3227b85 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -79,7 +79,7 @@ struct commit *lookup_commit_reference_by_name(const char *name);\n  */\n struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);\n \n-int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph);\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, size_t size, int check_graph);\n int repo_parse_commit_internal(struct repository *r, struct commit *item,\n \t\t\t       int quiet_on_missing, int use_commit_graph);\n int repo_parse_commit_gently(struct repository *r,\n@@ -105,13 +105,13 @@ void free_commit_buffer_slab(struct buffer_slab *bs);\n  * Associate an object buffer with the commit. The ownership of the\n  * memory is handed over to the commit, and must be free()-able.\n  */\n-void set_commit_buffer(struct repository *r, struct commit *, void *buffer, unsigned long size);\n+void set_commit_buffer(struct repository *r, struct commit *, void *buffer, size_t size);\n \n /*\n  * Get any cached object buffer associated with the commit. Returns NULL\n  * if none. The resulting memory should not be freed.\n  */\n-const void *get_cached_commit_buffer(struct repository *, const struct commit *, unsigned long *size);\n+const void *get_cached_commit_buffer(struct repository *, const struct commit *, size_t *size);\n \n /*\n  * Get the commit's object contents, either from cache or by reading the object\n@@ -120,7 +120,7 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,\n  */\n const void *repo_get_commit_buffer(struct repository *r,\n \t\t\t\t   const struct commit *,\n-\t\t\t\t   unsigned long *size);\n+\t\t\t\t   size_t *size);\n #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS\n #define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s)\n #endif\n@@ -156,7 +156,7 @@ void release_commit_memory(struct parsed_object_pool *pool, struct commit *c);\n  * Disassociate any cached object buffer from the commit, but do not free it.\n  * The buffer (or NULL, if none) is returned.\n  */\n-const void *detach_commit_buffer(struct commit *, unsigned long *sizep);\n+const void *detach_commit_buffer(struct commit *, size_t *sizep);\n \n /* Find beginning and length of commit subject. */\n int find_commit_subject(const char *commit_buffer, const char **subject);\ndiff --git a/config.c b/config.c\nindex 04286f7717..69e91227a0 100644\n--- a/config.c\n+++ b/config.c\n@@ -1594,7 +1594,7 @@ int git_config_from_blob_oid(config_fn_t fn,\n {\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tbuf = read_object_file(oid, &type, &size);\ndiff --git a/convert.c b/convert.c\nindex e0848226d2..f66b23c2bf 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -43,9 +43,9 @@ struct text_stat {\n \tunsigned printable, nonprintable;\n };\n \n-static void gather_stats(const char *buf, unsigned long size, struct text_stat *stats)\n+static void gather_stats(const char *buf, size_t size, struct text_stat *stats)\n {\n-\tunsigned long i;\n+\tsize_t i;\n \n \tmemset(stats, 0, sizeof(*stats));\n \n@@ -92,7 +92,7 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *\n  * The same heuristics as diff.c::mmfile_is_binary()\n  * We treat files with bare CR as binary\n  */\n-static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n+static int convert_is_binary(size_t size, const struct text_stat *stats)\n {\n \tif (stats->lonecr)\n \t\treturn 1;\n@@ -103,7 +103,7 @@ static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n \treturn 0;\n }\n \n-static unsigned int gather_convert_stats(const char *data, unsigned long size)\n+static unsigned int gather_convert_stats(const char *data, size_t size)\n {\n \tstruct text_stat stats;\n \tint ret = 0;\n@@ -120,7 +120,7 @@ static unsigned int gather_convert_stats(const char *data, unsigned long size)\n \treturn ret;\n }\n \n-static const char *gather_convert_stats_ascii(const char *data, unsigned long size)\n+static const char *gather_convert_stats_ascii(const char *data, size_t size)\n {\n \tunsigned int convert_stats = gather_convert_stats(data, size);\n \n@@ -142,7 +142,7 @@ const char *get_cached_convert_stats_ascii(const struct index_state *istate,\n \t\t\t\t\t   const char *path)\n {\n \tconst char *ret;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tvoid *data = read_blob_data_from_index(istate, path, &sz);\n \tret = gather_convert_stats_ascii(data, sz);\n \tfree(data);\n@@ -224,7 +224,7 @@ static void check_global_conv_flags_eol(const char *path, enum crlf_action crlf_\n \n static int has_crlf_in_index(const struct index_state *istate, const char *path)\n {\n-\tunsigned long sz;\n+\tsize_t sz;\n \tvoid *data;\n \tconst char *crp;\n \tint has_crlf = 0;\n@@ -630,7 +630,7 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \n struct filter_params {\n \tconst char *src;\n-\tunsigned long size;\n+\tsize_t size;\n \tint fd;\n \tconst char *cmd;\n \tconst char *path;\n@@ -1048,7 +1048,7 @@ static int read_convert_config(const char *var, const char *value, void *cb)\n \treturn 0;\n }\n \n-static int count_ident(const char *cp, unsigned long size)\n+static int count_ident(const char *cp, size_t size)\n {\n \t/*\n \t * \"$Id: 0000000000000000000000000000000000000000 $\" <=> \"$Id$\"\ndiff --git a/delta.h b/delta.h\nindex 9b67531dfa..541171230c 100644\n--- a/delta.h\n+++ b/delta.h\n@@ -42,8 +42,8 @@ extern unsigned long sizeof_delta_index(struct delta_index *index);\n  */\n extern void *\n create_delta(const struct delta_index *index,\n-\t     const void *buf, unsigned long bufsize,\n-\t     unsigned long *delta_size, unsigned long max_delta_size);\n+\t     const void *buf, size_t bufsize,\n+\t     size_t *delta_size, size_t max_delta_size);\n \n /*\n  * diff_delta: create a delta from source buffer to target buffer\n@@ -54,9 +54,9 @@ create_delta(const struct delta_index *index,\n  * updated with its size.  The returned buffer must be freed by the caller.\n  */\n static inline void *\n-diff_delta(const void *src_buf, unsigned long src_bufsize,\n-\t   const void *trg_buf, unsigned long trg_bufsize,\n-\t   unsigned long *delta_size, unsigned long max_delta_size)\n+diff_delta(const void *src_buf, size_t src_bufsize,\n+\t   const void *trg_buf, size_t trg_bufsize,\n+\t   size_t *delta_size, size_t max_delta_size)\n {\n \tstruct delta_index *index = create_delta_index(src_buf, src_bufsize);\n \tif (index) {\n@@ -75,9 +75,9 @@ diff_delta(const void *src_buf, unsigned long src_bufsize,\n  * *trg_bufsize is updated with its size.  On failure a NULL pointer is\n  * returned.  The returned buffer must be freed by the caller.\n  */\n-extern void *patch_delta(const void *src_buf, unsigned long src_size,\n-\t\t\t const void *delta_buf, unsigned long delta_size,\n-\t\t\t unsigned long *dst_size);\n+extern void *patch_delta(const void *src_buf, size_t src_size,\n+\t\t\t const void *delta_buf, size_t delta_size,\n+\t\t\t size_t *dst_size);\n \n /* the smallest possible delta size is 4 bytes */\n #define DELTA_SIZE_MIN\t4\n@@ -86,11 +86,11 @@ extern void *patch_delta(const void *src_buf, unsigned long src_size,\n  * This must be called twice on the delta data buffer, first to get the\n  * expected source buffer size, and again to get the target buffer size.\n  */\n-static inline unsigned long get_delta_hdr_size(const unsigned char **datap,\n+static inline size_t get_delta_hdr_size(const unsigned char **datap,\n \t\t\t\t\t       const unsigned char *top)\n {\n \tconst unsigned char *data = *datap;\n-\tunsigned long cmd, size = 0;\n+\tsize_t cmd, size = 0;\n \tint i = 0;\n \tdo {\n \t\tcmd = *data++;\ndiff --git a/diff-delta.c b/diff-delta.c\nindex e49643353b..072a5ca839 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -316,8 +316,8 @@ unsigned long sizeof_delta_index(struct delta_index *index)\n \n void *\n create_delta(const struct delta_index *index,\n-\t     const void *trg_buf, unsigned long trg_size,\n-\t     unsigned long *delta_size, unsigned long max_size)\n+\t     const void *trg_buf, size_t trg_size,\n+\t     size_t *delta_size, size_t max_size)\n {\n \tunsigned int i, val;\n \toff_t outpos, moff;\ndiff --git a/diff.c b/diff.c\nindex f1e901a5fc..f78ff9778e 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2258,7 +2258,7 @@ static void find_lno(const char *line, struct emit_callback *ecbdata)\n \tecbdata->lno_in_postimage = strtol(p + 1, NULL, 10);\n }\n \n-static void fn_out_consume(void *priv, char *line, unsigned long len)\n+static void fn_out_consume(void *priv, char *line, size_t len)\n {\n \tstruct emit_callback *ecbdata = priv;\n \tconst char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);\n@@ -2461,7 +2461,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,\n \treturn x;\n }\n \n-static void diffstat_consume(void *priv, char *line, unsigned long len)\n+static void diffstat_consume(void *priv, char *line, size_t len)\n {\n \tstruct diffstat_t *diffstat = priv;\n \tstruct diffstat_file *x = diffstat->files[diffstat->nr - 1];\n@@ -3141,7 +3141,7 @@ static void checkdiff_consume_hunk(void *priv,\n \tdata->lineno = nb - 1;\n }\n \n-static void checkdiff_consume(void *priv, char *line, unsigned long len)\n+static void checkdiff_consume(void *priv, char *line, size_t len)\n {\n \tstruct checkdiff_t *data = priv;\n \tint marker_size = data->conflict_marker_size;\n@@ -3180,8 +3180,8 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)\n }\n \n static unsigned char *deflate_it(char *data,\n-\t\t\t\t unsigned long size,\n-\t\t\t\t unsigned long *result_size)\n+\t\t\t\t size_t size,\n+\t\t\t\t size_t *result_size)\n {\n \tint bound;\n \tunsigned char *deflated;\n@@ -3209,10 +3209,10 @@ static void emit_binary_diff_body(struct diff_options *o,\n \tvoid *delta;\n \tvoid *deflated;\n \tvoid *data;\n-\tunsigned long orig_size;\n-\tunsigned long delta_size;\n-\tunsigned long deflate_size;\n-\tunsigned long data_size;\n+\tsize_t orig_size;\n+\tsize_t delta_size;\n+\tsize_t deflate_size;\n+\tsize_t data_size;\n \n \t/* We could do deflated delta, or we could do just deflated two,\n \t * whichever is smaller.\n@@ -3997,7 +3997,7 @@ void diff_free_filespec_data(struct diff_filespec *s)\n static void prep_temp_blob(struct index_state *istate,\n \t\t\t   const char *path, struct diff_tempfile *temp,\n \t\t\t   void *blob,\n-\t\t\t   unsigned long size,\n+\t\t\t   size_t size,\n \t\t\t   const struct object_id *oid,\n \t\t\t   int mode)\n {\n@@ -5657,9 +5657,9 @@ struct patch_id_t {\n \tint patchlen;\n };\n \n-static int remove_space(char *line, int len)\n+static size_t remove_space(char *line, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tchar *dst = line;\n \tunsigned char c;\n \n@@ -5670,10 +5670,10 @@ static int remove_space(char *line, int len)\n \treturn dst - line;\n }\n \n-static void patch_id_consume(void *priv, char *line, unsigned long len)\n+static void patch_id_consume(void *priv, char *line, size_t len)\n {\n \tstruct patch_id_t *data = priv;\n-\tint new_len;\n+\tsize_t new_len;\n \n \tnew_len = remove_space(line, len);\n \n@@ -6434,7 +6434,7 @@ int textconv_object(struct repository *r,\n \t\t    const struct object_id *oid,\n \t\t    int oid_valid,\n \t\t    char **buf,\n-\t\t    unsigned long *buf_size)\n+\t\t    size_t *buf_size)\n {\n \tstruct diff_filespec *df;\n \tstruct userdiff_driver *textconv;\ndiff --git a/diff.h b/diff.h\nindex b512d0477a..9faeab924e 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -474,7 +474,7 @@ int textconv_object(struct repository *repo,\n \t\t    const char *path,\n \t\t    unsigned mode,\n \t\t    const struct object_id *oid, int oid_valid,\n-\t\t    char **buf, unsigned long *buf_size);\n+\t\t    char **buf, size_t *buf_size);\n \n int parse_rename_score(const char **cp_p);\n \ndiff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c\nindex ad939d2861..d78b510465 100644\n--- a/diffcore-pickaxe.c\n+++ b/diffcore-pickaxe.c\n@@ -19,7 +19,7 @@ struct diffgrep_cb {\n \tint hit;\n };\n \n-static void diffgrep_consume(void *priv, char *line, unsigned long len)\n+static void diffgrep_consume(void *priv, char *line, size_t len)\n {\n \tstruct diffgrep_cb *data = priv;\n \tregmatch_t regmatch;\n@@ -71,7 +71,7 @@ static int diff_grep(mmfile_t *one, mmfile_t *two,\n static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws)\n {\n \tunsigned int cnt;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tconst char *data;\n \n \tsz = mf->size;\ndiff --git a/diffcore.h b/diffcore.h\nindex b651061c0e..b47778dd36 100644\n--- a/diffcore.h\n+++ b/diffcore.h\n@@ -33,7 +33,7 @@ struct diff_filespec {\n \tchar *path;\n \tvoid *data;\n \tvoid *cnt_data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint count;               /* Reference count */\n \tint rename_used;         /* Count of rename users */\n \tunsigned short mode;\t /* file mode */\ndiff --git a/dir.c b/dir.c\nindex ab6477d777..8d68442040 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -183,7 +183,7 @@ static size_t common_prefix_len(const struct pathspec *pathspec)\n  */\n char *common_prefix(const struct pathspec *pathspec)\n {\n-\tunsigned long len = common_prefix_len(pathspec);\n+\tsize_t len = common_prefix_len(pathspec);\n \n \treturn len ? xmemdupz(pathspec->items[0].match, len) : NULL;\n }\n@@ -239,7 +239,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,\n \t\t\tsize_t *size_out, char **data_out)\n {\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tchar *data;\n \n \t*size_out = 0;\n@@ -2863,7 +2863,7 @@ static void load_oid_stat(struct oid_stat *oid_stat, const unsigned char *data,\n \toid_stat->valid = 1;\n }\n \n-struct untracked_cache *read_untracked_extension(const void *data, unsigned long sz)\n+struct untracked_cache *read_untracked_extension(const void *data, size_t sz)\n {\n \tstruct untracked_cache *uc;\n \tstruct read_data rd;\ndiff --git a/dir.h b/dir.h\nindex e3ec26143d..7dc741cd41 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -360,7 +360,7 @@ void untracked_cache_remove_from_index(struct index_state *, const char *);\n void untracked_cache_add_to_index(struct index_state *, const char *);\n \n void free_untracked_cache(struct untracked_cache *);\n-struct untracked_cache *read_untracked_extension(const void *data, unsigned long sz);\n+struct untracked_cache *read_untracked_extension(const void *data, size_t sz);\n void write_untracked_extension(struct strbuf *out, struct untracked_cache *untracked);\n void add_untracked_cache(struct index_state *istate);\n void remove_untracked_cache(struct index_state *istate);\ndiff --git a/entry.c b/entry.c\nindex 5f213c30fe..1dd520557a 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -83,7 +83,7 @@ static int create_file(const char *path, unsigned int mode)\n \treturn open(path, O_WRONLY | O_CREAT | O_EXCL, mode);\n }\n \n-static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size)\n+static void *read_blob_entry(const struct cache_entry *ce, size_t *size)\n {\n \tenum object_type type;\n \tvoid *blob_data = read_object_file(&ce->oid, &type, size);\n@@ -259,7 +259,7 @@ static int write_entry(struct cache_entry *ce,\n \tint fd, ret, fstat_done = 0;\n \tchar *new_blob;\n \tstruct strbuf buf = STRBUF_INIT;\n-\tunsigned long size;\n+\tsize_t size;\n \tssize_t wrote;\n \tsize_t newsize = 0;\n \tstruct stat st;\ndiff --git a/fast-import.c b/fast-import.c\nindex b7ba755c2b..adb09ef10e 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -895,7 +895,7 @@ static int store_object(\n \tstruct object_entry *e;\n \tunsigned char hdr[96];\n \tstruct object_id oid;\n-\tunsigned long hdrlen, deltalen;\n+\tsize_t hdrlen, deltalen;\n \tgit_hash_ctx c;\n \tgit_zstream s;\n \n@@ -1036,7 +1036,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)\n \tunsigned char *out_buf = xmalloc(out_sz);\n \tstruct object_entry *e;\n \tstruct object_id oid;\n-\tunsigned long hdrlen;\n+\tsize_t hdrlen;\n \toff_t offset;\n \tgit_hash_ctx c;\n \tgit_zstream s;\n@@ -1154,7 +1154,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)\n  */\n static void *gfi_unpack_entry(\n \tstruct object_entry *oe,\n-\tunsigned long *sizep)\n+\tsize_t *sizep)\n {\n \tenum object_type type;\n \tstruct packed_git *p = all_packs[oe->pack_id];\n@@ -1200,7 +1200,7 @@ static void load_tree(struct tree_entry *root)\n \tstruct object_id *oid = &root->versions[1].oid;\n \tstruct object_entry *myoe;\n \tstruct tree_content *t;\n-\tunsigned long size;\n+\tsize_t size;\n \tchar *buf;\n \tconst char *c;\n \n@@ -1873,7 +1873,7 @@ static int validate_raw_date(const char *src, struct strbuf *result)\n {\n \tconst char *orig_src = src;\n \tchar *endp;\n-\tunsigned long num;\n+\tsize_t num;\n \n \terrno = 0;\n \n@@ -2400,7 +2400,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", commit_mark);\n \t\toidcpy(&commit_oid, &commit_oe->idx.oid);\n \t} else if (!get_oid(p, &commit_oid)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf = read_object_with_reference(&commit_oid,\n \t\t\t\t\t\t       commit_type, &size,\n \t\t\t\t\t\t       &commit_oid);\n@@ -2453,7 +2453,7 @@ static void file_change_deleteall(struct branch *b)\n \tb->num_notes = 0;\n }\n \n-static void parse_from_commit(struct branch *b, char *buf, unsigned long size)\n+static void parse_from_commit(struct branch *b, char *buf, size_t size)\n {\n \tif (!buf || size < GIT_SHA1_HEXSZ + 6)\n \t\tdie(\"Not a valid commit: %s\", oid_to_hex(&b->oid));\n@@ -2470,7 +2470,7 @@ static void parse_from_existing(struct branch *b)\n \t\toidclr(&b->branch_tree.versions[0].oid);\n \t\toidclr(&b->branch_tree.versions[1].oid);\n \t} else {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf;\n \n \t\tbuf = read_object_with_reference(&b->oid, commit_type, &size,\n@@ -2507,7 +2507,7 @@ static int parse_from(struct branch *b)\n \t\tif (!oideq(&b->oid, &oe->idx.oid)) {\n \t\t\toidcpy(&b->oid, &oe->idx.oid);\n \t\t\tif (oe->pack_id != MAX_PACK_ID) {\n-\t\t\t\tunsigned long size;\n+\t\t\t\tsize_t size;\n \t\t\t\tchar *buf = gfi_unpack_entry(oe, &size);\n \t\t\t\tparse_from_commit(b, buf, size);\n \t\t\t\tfree(buf);\n@@ -2550,7 +2550,7 @@ static struct hash_list *parse_merge(unsigned int *count)\n \t\t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", idnum);\n \t\t\toidcpy(&n->oid, &oe->idx.oid);\n \t\t} else if (!get_oid(from, &n->oid)) {\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\tchar *buf = read_object_with_reference(&n->oid,\n \t\t\t\t\t\t\t       commit_type,\n \t\t\t\t\t\t\t       &size, &n->oid);\n@@ -2776,7 +2776,7 @@ static void parse_reset_branch(const char *arg)\n \t\tunread_command_buf = 1;\n }\n \n-static void cat_blob_write(const char *buf, unsigned long size)\n+static void cat_blob_write(const char *buf, size_t size)\n {\n \tif (write_in_full(cat_blob_fd, buf, size) < 0)\n \t\tdie_errno(\"Write to frontend failed\");\n@@ -2785,7 +2785,7 @@ static void cat_blob_write(const char *buf, unsigned long size)\n static void cat_blob(struct object_entry *oe, struct object_id *oid)\n {\n \tstruct strbuf line = STRBUF_INIT;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type = 0;\n \tchar *buf;\n \n@@ -2869,7 +2869,7 @@ static void parse_cat_blob(const char *p)\n static struct object_entry *dereference(struct object_entry *oe,\n \t\t\t\t\tstruct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tchar *buf = NULL;\n \tif (!oe) {\n \t\tenum object_type type = oid_object_info(the_repository, oid,\ndiff --git a/fsck.c b/fsck.c\nindex 68502ce85b..208032c693 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -850,7 +850,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,\n }\n \n static int fsck_commit(struct commit *commit, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tconst char *buffer = data ?  data : get_commit_buffer(commit, &size);\n \tint ret = fsck_commit_buffer(commit, buffer, size, options);\n@@ -860,7 +860,7 @@ static int fsck_commit(struct commit *commit, const char *data,\n }\n \n static int fsck_tag_buffer(struct tag *tag, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tstruct object_id oid;\n \tint ret = 0;\n@@ -955,7 +955,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,\n }\n \n static int fsck_tag(struct tag *tag, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tstruct object *tagged = tag->tagged;\n \n@@ -1006,7 +1006,7 @@ static int fsck_gitmodules_fn(const char *var, const char *value, void *vdata)\n }\n \n static int fsck_blob(struct blob *blob, const char *buf,\n-\t\t     unsigned long size, struct fsck_options *options)\n+\t\t     size_t size, struct fsck_options *options)\n {\n \tstruct fsck_gitmodules_data data;\n \tstruct config_options config_opts = { 0 };\n@@ -1042,7 +1042,7 @@ static int fsck_blob(struct blob *blob, const char *buf,\n \treturn data.ret;\n }\n \n-int fsck_object(struct object *obj, void *data, unsigned long size,\n+int fsck_object(struct object *obj, void *data, size_t size,\n \tstruct fsck_options *options)\n {\n \tif (!obj)\n@@ -1084,7 +1084,7 @@ int fsck_finish(struct fsck_options *options)\n \twhile ((oid = oidset_iter_next(&iter))) {\n \t\tstruct blob *blob;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf;\n \n \t\tif (oidset_contains(&gitmodules_done, oid))\ndiff --git a/fsck.h b/fsck.h\nindex b95595ae5f..939ccf856b 100644\n--- a/fsck.h\n+++ b/fsck.h\n@@ -53,7 +53,7 @@ struct fsck_options {\n  */\n int fsck_walk(struct object *obj, void *data, struct fsck_options *options);\n /* If NULL is passed for data, we assume the object is local and read it. */\n-int fsck_object(struct object *obj, void *data, unsigned long size,\n+int fsck_object(struct object *obj, void *data, size_t size,\n \tstruct fsck_options *options);\n \n /*\ndiff --git a/fuzz-pack-headers.c b/fuzz-pack-headers.c\nindex 99da1d0fd3..d04e264e23 100644\n--- a/fuzz-pack-headers.c\n+++ b/fuzz-pack-headers.c\n@@ -5,10 +5,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);\n int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)\n {\n \tenum object_type type;\n-\tunsigned long len;\n+\tsize_t len;\n \n \tunpack_object_header_buffer((const unsigned char *)data,\n-\t\t\t\t    (unsigned long)size, &type, &len);\n+\t\t\t\t    size, &type, &len);\n \n \treturn 0;\n }\ndiff --git a/grep.h b/grep.h\nindex fb04893721..5765213f4b 100644\n--- a/grep.h\n+++ b/grep.h\n@@ -209,7 +209,7 @@ struct grep_source {\n \tvoid *identifier;\n \n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tchar *path; /* for attribute lookups */\n \tstruct userdiff_driver *driver;\ndiff --git a/http-push.c b/http-push.c\nindex cd48590912..902790859e 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -359,7 +359,7 @@ static void start_put(struct transfer_request *request)\n \tenum object_type type;\n \tchar hdr[50];\n \tvoid *unpacked;\n-\tunsigned long len;\n+\tsize_t len;\n \tint hdrlen;\n \tssize_t size;\n \tgit_zstream stream;\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex a62624a1ce..ef31a7660e 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -154,7 +154,7 @@ static enum list_objects_filter_result filter_blobs_limit(\n \tvoid *filter_data_)\n {\n \tstruct filter_blobs_limit_data *filter_data = filter_data_;\n-\tunsigned long object_length;\n+\tsize_t object_length;\n \tenum object_type t;\n \n \tswitch (filter_situation) {\ndiff --git a/mailmap.c b/mailmap.c\nindex 962fd86d6d..ec7ba47eef 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -217,7 +217,7 @@ static int read_mailmap_blob(struct string_list *map,\n {\n \tstruct object_id oid;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \n \tif (!name)\ndiff --git a/match-trees.c b/match-trees.c\nindex 2b6d31ef9d..af3ded64e9 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -53,7 +53,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc,\n {\n \tvoid *buffer;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tbuffer = read_object_file(hash, &type, &size);\n \tif (!buffer)\n@@ -177,7 +177,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,\n \tchar *subpath;\n \tint toplen;\n \tchar *buf;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tstruct tree_desc desc;\n \tstruct object_id *rewrite_here;\n \tconst struct object_id *rewrite_with;\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex ee0a0e90c9..f19ee015cc 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -9,7 +9,7 @@\n static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n {\n \tvoid *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \n \tbuf = read_object_file(&obj->object.oid, &type, &size);\n@@ -34,7 +34,7 @@ static void *three_way_filemerge(struct index_state *istate,\n \t\t\t\t mmfile_t *base,\n \t\t\t\t mmfile_t *our,\n \t\t\t\t mmfile_t *their,\n-\t\t\t\t unsigned long *size)\n+\t\t\t\t size_t *size)\n {\n \tint merge_status;\n \tmmbuffer_t res;\n@@ -57,7 +57,7 @@ static void *three_way_filemerge(struct index_state *istate,\n \n void *merge_blobs(struct index_state *istate, const char *path,\n \t\t  struct blob *base, struct blob *our,\n-\t\t  struct blob *their, unsigned long *size)\n+\t\t  struct blob *their, size_t *size)\n {\n \tvoid *res = NULL;\n \tmmfile_t f1, f2, common;\ndiff --git a/merge-blobs.h b/merge-blobs.h\nindex cc31038b80..7f37952b0e 100644\n--- a/merge-blobs.h\n+++ b/merge-blobs.h\n@@ -6,6 +6,6 @@ struct index_state;\n \n extern void *merge_blobs(struct index_state *, const char *,\n \t\t\t struct blob *, struct blob *,\n-\t\t\t struct blob *, unsigned long *);\n+\t\t\t struct blob *, size_t *);\n \n #endif /* MERGE_BLOBS_H */\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex ecf8db0b71..457e748204 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -950,7 +950,7 @@ static int update_file_flags(struct merge_options *o,\n \tif (update_wd) {\n \t\tenum object_type type;\n \t\tvoid *buf;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \n \t\tif (S_ISGITLINK(mode)) {\n \t\t\t/*\n@@ -3003,7 +3003,7 @@ static int read_oid_strbuf(struct merge_options *o,\n {\n \tvoid *buf;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tbuf = read_object_file(oid, &type, &size);\n \tif (!buf)\n \t\treturn err(o, _(\"cannot read object %s\"), oid_to_hex(oid));\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 2473314d68..7914f1073f 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -76,7 +76,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \tconst struct object_id *value_oid;\n \tenum object_type type;\n \tchar *value;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tvalue_oid = get_note(&c->tree, key_oid);\n \tif (!value_oid)\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 72688d301b..5732a4cd56 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -297,7 +297,7 @@ static void check_notes_merge_worktree(struct notes_merge_options *o)\n }\n \n static void write_buf_to_worktree(const struct object_id *obj,\n-\t\t\t\t  const char *buf, unsigned long size)\n+\t\t\t\t  const char *buf, size_t size)\n {\n \tint fd;\n \tchar *path = git_pathdup(NOTES_MERGE_WORKTREE \"/%s\", oid_to_hex(obj));\n@@ -326,7 +326,7 @@ static void write_note_to_worktree(const struct object_id *obj,\n \t\t\t\t   const struct object_id *note)\n {\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *buf = read_object_file(note, &type, &size);\n \n \tif (!buf)\ndiff --git a/notes.c b/notes.c\nindex 25cdce28b7..309f856ba0 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -791,7 +791,7 @@ int combine_notes_concatenate(struct object_id *cur_oid,\n \t\t\t      const struct object_id *new_oid)\n {\n \tchar *cur_msg = NULL, *new_msg = NULL, *buf;\n-\tunsigned long cur_len, new_len, buf_len;\n+\tsize_t cur_len, new_len, buf_len;\n \tenum object_type cur_type, new_type;\n \tint ret;\n \n@@ -852,7 +852,7 @@ static int string_list_add_note_lines(struct string_list *list,\n \t\t\t\t      const struct object_id *oid)\n {\n \tchar *data;\n-\tunsigned long len;\n+\tsize_t len;\n \tenum object_type t;\n \n \tif (is_null_oid(oid))\n@@ -1206,7 +1206,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n \tstatic const char utf8[] = \"utf-8\";\n \tconst struct object_id *oid;\n \tchar *msg, *msg_p;\n-\tunsigned long linelen, msglen;\n+\tsize_t linelen, msglen;\n \tenum object_type type;\n \n \tif (!t)\ndiff --git a/object-store.h b/object-store.h\nindex 8dceed0f31..886c81d9c8 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -155,16 +155,16 @@ void raw_object_store_clear(struct raw_object_store *o);\n  */\n const char *loose_object_path(struct repository *r, struct strbuf *buf, const unsigned char *sha1);\n \n-void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size);\n+void *map_sha1_file(struct repository *r, const unsigned char *sha1, size_t *size);\n \n extern void *read_object_file_extended(struct repository *r,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       enum object_type *type,\n-\t\t\t\t       unsigned long *size, int lookup_replace);\n+\t\t\t\t       size_t *size, int lookup_replace);\n static inline void *repo_read_object_file(struct repository *r,\n \t\t\t\t\t  const struct object_id *oid,\n \t\t\t\t\t  enum object_type *type,\n-\t\t\t\t\t  unsigned long *size)\n+\t\t\t\t\t  size_t *size)\n {\n \treturn read_object_file_extended(r, oid, type, size, 1);\n }\n@@ -173,19 +173,19 @@ static inline void *repo_read_object_file(struct repository *r,\n #endif\n \n /* Read and unpack an object file into memory, write memory to an object file */\n-int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);\n+int oid_object_info(struct repository *r, const struct object_id *, size_t *);\n \n-extern int hash_object_file(const void *buf, unsigned long len,\n+extern int hash_object_file(const void *buf, size_t len,\n \t\t\t    const char *type, struct object_id *oid);\n \n-extern int write_object_file(const void *buf, unsigned long len,\n+extern int write_object_file(const void *buf, size_t len,\n \t\t\t     const char *type, struct object_id *oid);\n \n-extern int hash_object_file_literally(const void *buf, unsigned long len,\n+extern int hash_object_file_literally(const void *buf, size_t len,\n \t\t\t\t      const char *type, struct object_id *oid,\n \t\t\t\t      unsigned flags);\n \n-extern int pretend_object_file(void *, unsigned long, enum object_type,\n+extern int pretend_object_file(void *, size_t, enum object_type,\n \t\t\t       struct object_id *oid);\n \n extern int force_object_loose(const struct object_id *oid, time_t mtime);\n@@ -200,7 +200,7 @@ extern int force_object_loose(const struct object_id *oid, time_t mtime);\n int read_loose_object(const char *path,\n \t\t      const struct object_id *expected_oid,\n \t\t      enum object_type *type,\n-\t\t      unsigned long *size,\n+\t\t      size_t *size,\n \t\t      void **contents);\n \n /*\n@@ -242,7 +242,7 @@ extern void assert_oid_type(const struct object_id *oid, enum object_type expect\n struct object_info {\n \t/* Request */\n \tenum object_type *typep;\n-\tunsigned long *sizep;\n+\tsize_t *sizep;\n \toff_t *disk_sizep;\n \tunsigned char *delta_base_sha1;\n \tstruct strbuf *type_name;\ndiff --git a/object.c b/object.c\nindex c29a97a7e9..ad8c09c041 100644\n--- a/object.c\n+++ b/object.c\n@@ -186,7 +186,7 @@ struct object *lookup_unknown_object(const unsigned char *sha1)\n \treturn obj;\n }\n \n-struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)\n+struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, size_t size, void *buffer, int *eaten_p)\n {\n \tstruct object *obj;\n \t*eaten_p = 0;\n@@ -248,7 +248,7 @@ struct object *parse_object_or_die(const struct object_id *oid,\n \n struct object *parse_object(struct repository *r, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tint eaten;\n \tconst struct object_id *repl = lookup_replace_object(r, oid);\ndiff --git a/object.h b/object.h\nindex 796792cb32..b97a625882 100644\n--- a/object.h\n+++ b/object.h\n@@ -140,7 +140,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name\n  * parsing it.  eaten_p indicates if the object has a borrowed copy\n  * of buffer and the caller should not free() it.\n  */\n-struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);\n+struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, size_t size, void *buffer, int *eaten_p);\n \n /** Returns the object, with potentially excess memory allocated. **/\n struct object *lookup_unknown_object(const unsigned  char *sha1);\ndiff --git a/pack-check.c b/pack-check.c\nindex 4ff725a89c..b86a5e17b5 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -108,7 +108,7 @@ static int verify_packfile(struct repository *r,\n \tfor (i = 0; i < nr_objects; i++) {\n \t\tvoid *data;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\toff_t curpos;\n \t\tint data_valid;\n \ndiff --git a/pack-objects.h b/pack-objects.h\nindex 3fda9da83a..24937553bb 100644\n--- a/pack-objects.h\n+++ b/pack-objects.h\n@@ -320,9 +320,9 @@ static inline void oe_set_delta_sibling(struct packing_data *pack,\n \t\te->delta_sibling_idx = 0;\n }\n \n-unsigned long oe_get_size_slow(struct packing_data *pack,\n+size_t oe_get_size_slow(struct packing_data *pack,\n \t\t\t       const struct object_entry *e);\n-static inline unsigned long oe_size(struct packing_data *pack,\n+static inline size_t oe_size(struct packing_data *pack,\n \t\t\t\t    const struct object_entry *e)\n {\n \tif (e->size_valid)\n@@ -333,7 +333,7 @@ static inline unsigned long oe_size(struct packing_data *pack,\n \n static inline int oe_size_less_than(struct packing_data *pack,\n \t\t\t\t    const struct object_entry *lhs,\n-\t\t\t\t    unsigned long rhs)\n+\t\t\t\t    size_t rhs)\n {\n \tif (lhs->size_valid)\n \t\treturn lhs->size_ < rhs;\n@@ -344,7 +344,7 @@ static inline int oe_size_less_than(struct packing_data *pack,\n \n static inline int oe_size_greater_than(struct packing_data *pack,\n \t\t\t\t       const struct object_entry *lhs,\n-\t\t\t\t       unsigned long rhs)\n+\t\t\t\t       size_t rhs)\n {\n \tif (lhs->size_valid)\n \t\treturn lhs->size_ > rhs;\n@@ -355,7 +355,7 @@ static inline int oe_size_greater_than(struct packing_data *pack,\n \n static inline void oe_set_size(struct packing_data *pack,\n \t\t\t       struct object_entry *e,\n-\t\t\t       unsigned long size)\n+\t\t\t       size_t size)\n {\n \tif (size < pack->oe_size_limit) {\n \t\te->size_ = size;\n@@ -367,7 +367,7 @@ static inline void oe_set_size(struct packing_data *pack,\n \t}\n }\n \n-static inline unsigned long oe_delta_size(struct packing_data *pack,\n+static inline size_t oe_delta_size(struct packing_data *pack,\n \t\t\t\t\t  const struct object_entry *e)\n {\n \tif (e->delta_size_valid)\n@@ -386,7 +386,7 @@ static inline unsigned long oe_delta_size(struct packing_data *pack,\n \n static inline void oe_set_delta_size(struct packing_data *pack,\n \t\t\t\t     struct object_entry *e,\n-\t\t\t\t     unsigned long size)\n+\t\t\t\t     size_t size)\n {\n \tif (size < pack->oe_delta_size_limit) {\n \t\te->delta_size_ = size;\ndiff --git a/pack.h b/pack.h\nindex da99fdd1d2..6f61f83485 100644\n--- a/pack.h\n+++ b/pack.h\n@@ -77,7 +77,7 @@ struct pack_idx_entry {\n \n struct progress;\n /* Note, the data argument could be NULL if object type is blob */\n-typedef int (*verify_fn)(const struct object_id *, enum object_type, unsigned long, void*, int*);\n+typedef int (*verify_fn)(const struct object_id *, enum object_type, size_t, void*, int*);\n \n extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, const struct pack_idx_option *, const unsigned char *sha1);\n extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off_t offset, off_t len, unsigned int nr);\ndiff --git a/packfile.c b/packfile.c\nindex 373adbc8a6..672b6aca4a 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -163,8 +163,8 @@ int load_idx(const char *path, const unsigned int hashsz, void *idx_map,\n \t\t * variable sized table containing 8-byte entries\n \t\t * for offsets larger than 2^31.\n \t\t */\n-\t\tunsigned long min_size = 8 + 4*256 + nr*(hashsz + 4 + 4) + hashsz + hashsz;\n-\t\tunsigned long max_size = min_size;\n+\t\tsize_t min_size = 8 + 4*256 + nr*(hashsz + 4 + 4) + hashsz + hashsz;\n+\t\tsize_t max_size = min_size;\n \t\tif (nr)\n \t\t\tmax_size += (nr - 1)*8;\n \t\tif (idx_size < min_size || idx_size > max_size)\n@@ -1047,12 +1047,12 @@ struct list_head *get_packed_git_mru(struct repository *r)\n \treturn &r->objects->packed_git_mru;\n }\n \n-unsigned long unpack_object_header_buffer(const unsigned char *buf,\n-\t\tunsigned long len, enum object_type *type, unsigned long *sizep)\n+size_t unpack_object_header_buffer(const unsigned char *buf,\n+\t\tsize_t len, enum object_type *type, size_t *sizep)\n {\n \tunsigned shift;\n-\tunsigned long size, c;\n-\tunsigned long used = 0;\n+\tsize_t size, c;\n+\tsize_t used = 0;\n \n \tc = buf[used++];\n \t*type = (c >> 4) & 7;\n@@ -1072,7 +1072,7 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,\n \treturn used;\n }\n \n-unsigned long get_size_from_delta(struct packed_git *p,\n+size_t get_size_from_delta(struct packed_git *p,\n \t\t\t\t  struct pack_window **w_curs,\n \t\t\t\t  off_t curpos)\n {\n@@ -1114,11 +1114,11 @@ unsigned long get_size_from_delta(struct packed_git *p,\n int unpack_object_header(struct packed_git *p,\n \t\t\t struct pack_window **w_curs,\n \t\t\t off_t *curpos,\n-\t\t\t unsigned long *sizep)\n+\t\t\t size_t *sizep)\n {\n \tunsigned char *base;\n \tsize_t left;\n-\tunsigned long used;\n+\tsize_t used;\n \tenum object_type type;\n \n \t/* use_pack() assures us we have [base, base + 20) available\n@@ -1269,7 +1269,7 @@ static enum object_type packed_to_object_type(struct repository *r,\n \n \twhile (type == OBJ_OFS_DELTA || type == OBJ_REF_DELTA) {\n \t\toff_t base_offset;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\t/* Push the object we're going to leave behind */\n \t\tif (poi_stack_nr >= poi_stack_alloc && poi_stack == small_poi_stack) {\n \t\t\tpoi_stack_alloc = alloc_nr(poi_stack_nr);\n@@ -1339,7 +1339,7 @@ struct delta_base_cache_entry {\n \tstruct delta_base_cache_key key;\n \tstruct list_head lru;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n };\n \n@@ -1404,7 +1404,7 @@ static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)\n }\n \n static void *cache_or_unpack_entry(struct repository *r, struct packed_git *p,\n-\t\t\t\t   off_t base_offset, unsigned long *base_size,\n+\t\t\t\t   off_t base_offset, size_t *base_size,\n \t\t\t\t   enum object_type *type)\n {\n \tstruct delta_base_cache_entry *ent;\n@@ -1437,7 +1437,7 @@ void clear_delta_base_cache(void)\n }\n \n static void add_delta_base_cache(struct packed_git *p, off_t base_offset,\n-\tvoid *base, unsigned long base_size, enum object_type type)\n+\tvoid *base, size_t base_size, enum object_type type)\n {\n \tstruct delta_base_cache_entry *ent = xmalloc(sizeof(*ent));\n \tstruct list_head *lru, *tmp;\n@@ -1469,7 +1469,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,\n \t\t       off_t obj_offset, struct object_info *oi)\n {\n \tstruct pack_window *w_curs = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t curpos = obj_offset;\n \tenum object_type type;\n \n@@ -1554,7 +1554,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,\n static void *unpack_compressed_entry(struct packed_git *p,\n \t\t\t\t    struct pack_window **w_curs,\n \t\t\t\t    off_t curpos,\n-\t\t\t\t    unsigned long size)\n+\t\t\t\t    size_t size)\n {\n \tint st;\n \tgit_zstream stream;\n@@ -1601,13 +1601,13 @@ int do_check_packed_object_crc;\n struct unpack_entry_stack_ent {\n \toff_t obj_offset;\n \toff_t curpos;\n-\tunsigned long size;\n+\tsize_t size;\n };\n \n static void *read_object(struct repository *r,\n \t\t\t const struct object_id *oid,\n \t\t\t enum object_type *type,\n-\t\t\t unsigned long *size)\n+\t\t\t size_t *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tvoid *content;\n@@ -1621,12 +1621,12 @@ static void *read_object(struct repository *r,\n }\n \n void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n-\t\t   enum object_type *final_type, unsigned long *final_size)\n+\t\t   enum object_type *final_type, size_t *final_size)\n {\n \tstruct pack_window *w_curs = NULL;\n \toff_t curpos = obj_offset;\n \tvoid *data = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tstruct unpack_entry_stack_ent small_delta_stack[UNPACK_ENTRY_STACK_PREALLOC];\n \tstruct unpack_entry_stack_ent *delta_stack = small_delta_stack;\n@@ -1726,7 +1726,7 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n \t\tvoid *delta_data;\n \t\tvoid *base = data;\n \t\tvoid *external_base = NULL;\n-\t\tunsigned long delta_size, base_size = size;\n+\t\tsize_t delta_size, base_size = size;\n \t\tint i;\n \n \t\tdata = NULL;\ndiff --git a/packfile.h b/packfile.h\nindex 7384b4a201..25459f7e96 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -131,10 +131,10 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);\n extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);\n \n extern int is_pack_valid(struct packed_git *);\n-extern void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object_type *, unsigned long *);\n-extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);\n-extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n-extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);\n+extern void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object_type *, size_t *);\n+extern size_t unpack_object_header_buffer(const unsigned char *buf, size_t len, enum object_type *type, size_t *sizep);\n+extern size_t get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n+extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, size_t *);\n \n extern void release_pack_memory(size_t);\n \ndiff --git a/patch-delta.c b/patch-delta.c\nindex b5c8594db6..42199fa956 100644\n--- a/patch-delta.c\n+++ b/patch-delta.c\n@@ -12,13 +12,13 @@\n #include \"git-compat-util.h\"\n #include \"delta.h\"\n \n-void *patch_delta(const void *src_buf, unsigned long src_size,\n-\t\t  const void *delta_buf, unsigned long delta_size,\n-\t\t  unsigned long *dst_size)\n+void *patch_delta(const void *src_buf, size_t src_size,\n+\t\t  const void *delta_buf, size_t delta_size,\n+\t\t  size_t *dst_size)\n {\n \tconst unsigned char *data, *top;\n \tunsigned char *dst_buf, *out, cmd;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tif (delta_size < DELTA_SIZE_MIN)\n \t\treturn NULL;\ndiff --git a/range-diff.c b/range-diff.c\nindex 767af8c5bb..dcb189f40d 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -192,7 +192,7 @@ static void find_exact_matches(struct string_list *a, struct string_list *b)\n \thashmap_free(&map, 0);\n }\n \n-static void diffsize_consume(void *data, char *line, unsigned long len)\n+static void diffsize_consume(void *data, char *line, size_t len)\n {\n \t(*(int *)data)++;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex f68f40824c..483432972c 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -229,7 +229,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)\n {\n \tint match = -1;\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tstruct strbuf sb = STRBUF_INIT;\n \n@@ -1676,7 +1676,7 @@ int verify_index_checksum;\n /* Allow fsck to force verification of the cache entry order. */\n int verify_ce_order;\n \n-static int verify_hdr(const struct cache_header *hdr, unsigned long size)\n+static int verify_hdr(const struct cache_header *hdr, size_t size)\n {\n \tgit_hash_ctx c;\n \tunsigned char hash[GIT_MAX_RAWSZ];\n@@ -1700,7 +1700,7 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)\n }\n \n static int read_index_extension(struct index_state *istate,\n-\t\t\t\tconst char *ext, const char *data, unsigned long sz)\n+\t\t\t\tconst char *ext, const char *data, size_t sz)\n {\n \tswitch (CACHE_EXT(ext)) {\n \tcase CACHE_EXT_TREE:\n@@ -1746,7 +1746,7 @@ int read_index(struct index_state *istate)\n static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,\n \t\t\t\t\t    unsigned int version,\n \t\t\t\t\t    struct ondisk_cache_entry *ondisk,\n-\t\t\t\t\t    unsigned long *ent_size,\n+\t\t\t\t\t    size_t *ent_size,\n \t\t\t\t\t    const struct cache_entry *previous_ce)\n {\n \tstruct cache_entry *ce;\n@@ -1937,13 +1937,13 @@ struct load_index_extensions\n \tstruct index_state *istate;\n \tconst char *mmap;\n \tsize_t mmap_size;\n-\tunsigned long src_offset;\n+\tsize_t src_offset;\n };\n \n static void *load_index_extensions(void *_data)\n {\n \tstruct load_index_extensions *p = _data;\n-\tunsigned long src_offset = p->src_offset;\n+\tsize_t src_offset = p->src_offset;\n \n \twhile (src_offset <= p->mmap_size - the_hash_algo->rawsz - 8) {\n \t\t/* After an array of active_nr index entries,\n@@ -1971,17 +1971,17 @@ static void *load_index_extensions(void *_data)\n  * A helper function that will load the specified range of cache entries\n  * from the memory mapped file and add them to the given index.\n  */\n-static unsigned long load_cache_entry_block(struct index_state *istate,\n+static size_t load_cache_entry_block(struct index_state *istate,\n \t\t\tstruct mem_pool *ce_mem_pool, int offset, int nr, const char *mmap,\n-\t\t\tunsigned long start_offset, const struct cache_entry *previous_ce)\n+\t\t\tsize_t start_offset, const struct cache_entry *previous_ce)\n {\n \tint i;\n-\tunsigned long src_offset = start_offset;\n+\tsize_t src_offset = start_offset;\n \n \tfor (i = offset; i < offset + nr; i++) {\n \t\tstruct ondisk_cache_entry *disk_ce;\n \t\tstruct cache_entry *ce;\n-\t\tunsigned long consumed;\n+\t\tsize_t consumed;\n \n \t\tdisk_ce = (struct ondisk_cache_entry *)(mmap + src_offset);\n \t\tce = create_from_disk(ce_mem_pool, istate->version, disk_ce, &consumed, previous_ce);\n@@ -1993,10 +1993,10 @@ static unsigned long load_cache_entry_block(struct index_state *istate,\n \treturn src_offset - start_offset;\n }\n \n-static unsigned long load_all_cache_entries(struct index_state *istate,\n-\t\t\tconst char *mmap, size_t mmap_size, unsigned long src_offset)\n+static size_t load_all_cache_entries(struct index_state *istate,\n+\t\t\tconst char *mmap, size_t mmap_size, size_t src_offset)\n {\n-\tunsigned long consumed;\n+\tsize_t consumed;\n \n \tif (istate->version == 4) {\n \t\tmem_pool_init(&istate->ce_mem_pool,\n@@ -2030,7 +2030,7 @@ struct load_cache_entries_thread_data\n \tstruct index_entry_offset_table *ieot;\n \tint ieot_start;\t\t/* starting index into the ieot array */\n \tint ieot_blocks;\t/* count of ieot entries to process */\n-\tunsigned long consumed;\t/* return # of bytes in index file processed */\n+\tsize_t consumed;\t/* return # of bytes in index file processed */\n };\n \n /*\n@@ -2051,12 +2051,12 @@ static void *load_cache_entries_thread(void *_data)\n \treturn NULL;\n }\n \n-static unsigned long load_cache_entries_threaded(struct index_state *istate, const char *mmap, size_t mmap_size,\n-\t\t\tunsigned long src_offset, int nr_threads, struct index_entry_offset_table *ieot)\n+static size_t load_cache_entries_threaded(struct index_state *istate, const char *mmap, size_t mmap_size,\n+\t\t\tsize_t src_offset, int nr_threads, struct index_entry_offset_table *ieot)\n {\n \tint i, offset, ieot_blocks, ieot_start, err;\n \tstruct load_cache_entries_thread_data *data;\n-\tunsigned long consumed = 0;\n+\tsize_t consumed = 0;\n \n \t/* a little sanity checking */\n \tif (istate->name_hash_initialized)\n@@ -2127,7 +2127,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n {\n \tint fd;\n \tstruct stat st;\n-\tunsigned long src_offset;\n+\tsize_t src_offset;\n \tconst struct cache_header *hdr;\n \tconst char *mmap;\n \tsize_t mmap_size;\n@@ -2414,7 +2414,7 @@ int index_has_changes(struct index_state *istate,\n \n #define WRITE_BUFFER_SIZE 8192\n static unsigned char write_buffer[WRITE_BUFFER_SIZE];\n-static unsigned long write_buffer_len;\n+static size_t write_buffer_len;\n \n static int ce_write_flush(git_hash_ctx *context, int fd)\n {\n@@ -2999,9 +2999,9 @@ static int write_split_index(struct index_state *istate,\n \n static const char *shared_index_expire = \"2.weeks.ago\";\n \n-static unsigned long get_shared_index_expire_date(void)\n+static size_t get_shared_index_expire_date(void)\n {\n-\tstatic unsigned long shared_index_expire_date;\n+\tstatic size_t shared_index_expire_date;\n \tstatic int shared_index_expire_date_prepared;\n \n \tif (!shared_index_expire_date_prepared) {\n@@ -3017,7 +3017,7 @@ static unsigned long get_shared_index_expire_date(void)\n static int should_delete_shared_index(const char *shared_index_path)\n {\n \tstruct stat st;\n-\tunsigned long expiration;\n+\tsize_t expiration;\n \n \t/* Check timestamp */\n \texpiration = get_shared_index_expire_date();\n@@ -3249,10 +3249,10 @@ int index_name_is_other(const struct index_state *istate, const char *name,\n }\n \n void *read_blob_data_from_index(const struct index_state *istate,\n-\t\t\t\tconst char *path, unsigned long *size)\n+\t\t\t\tconst char *path, size_t *size)\n {\n \tint pos, len;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tenum object_type type;\n \tvoid *data;\n \ndiff --git a/ref-filter.c b/ref-filter.c\nindex be61586033..f8375e8884 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -68,7 +68,7 @@ struct refname_atom {\n static struct expand_data {\n \tstruct object_id oid;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t disk_size;\n \tstruct object_id delta_base_oid;\n \tvoid *content;\n@@ -934,7 +934,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_\n }\n \n /* See grab_values */\n-static void grab_tag_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_tag_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tstruct tag *tag = (struct tag *) obj;\n@@ -956,7 +956,7 @@ static void grab_tag_values(struct atom_value *val, int deref, struct object *ob\n }\n \n /* See grab_values */\n-static void grab_commit_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_commit_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tstruct commit *commit = (struct commit *) obj;\n@@ -989,7 +989,7 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object\n \t}\n }\n \n-static const char *find_wholine(const char *who, int wholen, const char *buf, unsigned long sz)\n+static const char *find_wholine(const char *who, int wholen, const char *buf, size_t sz)\n {\n \tconst char *eol;\n \twhile (*buf) {\n@@ -1035,7 +1035,7 @@ static const char *copy_email(const char *buf)\n \treturn xmemdupz(email, eoemail + 1 - email);\n }\n \n-static char *copy_subject(const char *buf, unsigned long len)\n+static char *copy_subject(const char *buf, size_t len)\n {\n \tchar *r = xmemdupz(buf, len);\n \tint i;\n@@ -1085,7 +1085,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam\n }\n \n /* See grab_values */\n-static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tint wholen = strlen(who);\n@@ -1144,11 +1144,11 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru\n \t}\n }\n \n-static void find_subpos(const char *buf, unsigned long sz,\n-\t\t\tconst char **sub, unsigned long *sublen,\n-\t\t\tconst char **body, unsigned long *bodylen,\n-\t\t\tunsigned long *nonsiglen,\n-\t\t\tconst char **sig, unsigned long *siglen)\n+static void find_subpos(const char *buf, size_t sz,\n+\t\t\tconst char **sub, size_t *sublen,\n+\t\t\tconst char **body, size_t *bodylen,\n+\t\t\tsize_t *nonsiglen,\n+\t\t\tconst char **sig, size_t *siglen)\n {\n \tconst char *eol;\n \t/* skip past header until we hit empty line */\n@@ -1192,7 +1192,7 @@ static void find_subpos(const char *buf, unsigned long sz,\n  * If 'lines' is greater than 0, append that many lines from the given\n  * 'buf' of length 'size' to the given strbuf.\n  */\n-static void append_lines(struct strbuf *out, const char *buf, unsigned long size, int lines)\n+static void append_lines(struct strbuf *out, const char *buf, size_t size, int lines)\n {\n \tint i;\n \tconst char *sp, *eol;\n@@ -1213,11 +1213,11 @@ static void append_lines(struct strbuf *out, const char *buf, unsigned long size\n }\n \n /* See grab_values */\n-static void grab_sub_body_contents(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_sub_body_contents(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tconst char *subpos = NULL, *bodypos = NULL, *sigpos = NULL;\n-\tunsigned long sublen = 0, bodylen = 0, nonsiglen = 0, siglen = 0;\n+\tsize_t sublen = 0, bodylen = 0, nonsiglen = 0, siglen = 0;\n \n \tfor (i = 0; i < used_atom_cnt; i++) {\n \t\tstruct used_atom *atom = &used_atom[i];\n@@ -1286,7 +1286,7 @@ static void fill_missing_values(struct atom_value *val)\n  * pointed at by the ref itself; otherwise it is the object the\n  * ref (which is a tag) refers to.\n  */\n-static void grab_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tswitch (obj->type) {\n \tcase OBJ_TAG:\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex 3af708c5b6..38f79aaf8a 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -56,7 +56,7 @@ static char *read_ref_note(const struct object_id *oid)\n {\n \tconst struct object_id *note_oid;\n \tchar *msg = NULL;\n-\tunsigned long msglen;\n+\tsize_t msglen;\n \tenum object_type type;\n \n \tinit_notes(NULL, notes_ref, NULL, 0);\n@@ -105,7 +105,7 @@ static int note2mark_cb(const struct object_id *object_oid,\n {\n \tFILE *file = (FILE *)cb_data;\n \tchar *msg;\n-\tunsigned long msglen;\n+\tsize_t msglen;\n \tenum object_type type;\n \tstruct rev_note note;\n \ndiff --git a/rerere.c b/rerere.c\nindex 13624038e6..8e0e590227 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -973,7 +973,7 @@ static int handle_cache(struct index_state *istate,\n \n \twhile (pos < istate->cache_nr) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \n \t\tce = istate->cache[pos++];\n \t\tif (ce_namelen(ce) != len || memcmp(ce->name, path, len))\ndiff --git a/sha1-file.c b/sha1-file.c\nindex 5d2acbda88..643a0e9be8 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -200,7 +200,7 @@ static struct cached_object {\n \tstruct object_id oid;\n \tenum object_type type;\n \tvoid *buf;\n-\tunsigned long size;\n+\tsize_t size;\n } *cached_objects;\n static int cached_object_nr, cached_object_alloc;\n \n@@ -871,7 +871,7 @@ void *xmmap(void *start, size_t length,\n  * the streaming interface and rehash it to do the same.\n  */\n int check_object_signature(const struct object_id *oid, void *map,\n-\t\t\t   unsigned long size, const char *type)\n+\t\t\t   size_t size, const char *type)\n {\n \tstruct object_id real_oid;\n \tenum object_type obj_type;\n@@ -1012,7 +1012,7 @@ static int quick_has_loose(struct repository *r,\n  * searching for a loose object named \"sha1\".\n  */\n static void *map_sha1_file_1(struct repository *r, const char *path,\n-\t\t\t     const unsigned char *sha1, unsigned long *size)\n+\t\t\t     const unsigned char *sha1, size_t *size)\n {\n \tvoid *map;\n \tint fd;\n@@ -1040,14 +1040,14 @@ static void *map_sha1_file_1(struct repository *r, const char *path,\n }\n \n void *map_sha1_file(struct repository *r,\n-\t\t    const unsigned char *sha1, unsigned long *size)\n+\t\t    const unsigned char *sha1, size_t *size)\n {\n \treturn map_sha1_file_1(r, NULL, sha1, size);\n }\n \n static int unpack_sha1_short_header(git_zstream *stream,\n-\t\t\t\t    unsigned char *map, unsigned long mapsize,\n-\t\t\t\t    void *buffer, unsigned long bufsiz)\n+\t\t\t\t    unsigned char *map, size_t mapsize,\n+\t\t\t\t    void *buffer, size_t bufsiz)\n {\n \t/* Get the data stream */\n \tmemset(stream, 0, sizeof(*stream));\n@@ -1061,8 +1061,8 @@ static int unpack_sha1_short_header(git_zstream *stream,\n }\n \n int unpack_sha1_header(git_zstream *stream,\n-\t\t       unsigned char *map, unsigned long mapsize,\n-\t\t       void *buffer, unsigned long bufsiz)\n+\t\t       unsigned char *map, size_t mapsize,\n+\t\t       void *buffer, size_t bufsiz)\n {\n \tint status = unpack_sha1_short_header(stream, map, mapsize,\n \t\t\t\t\t      buffer, bufsiz);\n@@ -1077,8 +1077,8 @@ int unpack_sha1_header(git_zstream *stream,\n }\n \n static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,\n-\t\t\t\t\tunsigned long mapsize, void *buffer,\n-\t\t\t\t\tunsigned long bufsiz, struct strbuf *header)\n+\t\t\t\t\tsize_t mapsize, void *buffer,\n+\t\t\t\t\tsize_t bufsiz, struct strbuf *header)\n {\n \tint status;\n \n@@ -1112,11 +1112,11 @@ static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,\n \treturn -1;\n }\n \n-static void *unpack_sha1_rest(git_zstream *stream, void *buffer, unsigned long size, const unsigned char *sha1)\n+static void *unpack_sha1_rest(git_zstream *stream, void *buffer, size_t size, const unsigned char *sha1)\n {\n \tint bytes = strlen(buffer) + 1;\n \tunsigned char *buf = xmallocz(size);\n-\tunsigned long n;\n+\tsize_t n;\n \tint status = Z_OK;\n \n \tn = stream->total_out - bytes;\n@@ -1166,7 +1166,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,\n \t\t\t       unsigned int flags)\n {\n \tconst char *type_buf = hdr;\n-\tunsigned long size;\n+\tsize_t size;\n \tint type, type_len = 0;\n \n \t/*\n@@ -1206,7 +1206,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,\n \t\treturn -1;\n \tif (size) {\n \t\tfor (;;) {\n-\t\t\tunsigned long c = *hdr - '0';\n+\t\t\tsize_t c = *hdr - '0';\n \t\t\tif (c > 9)\n \t\t\t\tbreak;\n \t\t\thdr++;\n@@ -1223,7 +1223,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,\n \treturn *hdr ? -1 : type;\n }\n \n-int parse_sha1_header(const char *hdr, unsigned long *sizep)\n+int parse_sha1_header(const char *hdr, size_t *sizep)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \n@@ -1236,12 +1236,12 @@ static int sha1_loose_object_info(struct repository *r,\n \t\t\t\t  struct object_info *oi, int flags)\n {\n \tint status = 0;\n-\tunsigned long mapsize;\n+\tsize_t mapsize;\n \tvoid *map;\n \tgit_zstream stream;\n \tchar hdr[MAX_HEADER_LEN];\n \tstruct strbuf hdrbuf = STRBUF_INIT;\n-\tunsigned long size_scratch;\n+\tsize_t size_scratch;\n \n \tif (oi->delta_base_sha1)\n \t\thashclr(oi->delta_base_sha1);\n@@ -1409,7 +1409,7 @@ int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n /* returns enum object_type or negative */\n int oid_object_info(struct repository *r,\n \t\t    const struct object_id *oid,\n-\t\t    unsigned long *sizep)\n+\t\t    size_t *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n@@ -1425,7 +1425,7 @@ int oid_object_info(struct repository *r,\n static void *read_object(struct repository *r,\n \t\t\t const unsigned char *sha1,\n \t\t\t enum object_type *type,\n-\t\t\t unsigned long *size)\n+\t\t\t size_t *size)\n {\n \tstruct object_id oid;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n@@ -1441,7 +1441,7 @@ static void *read_object(struct repository *r,\n \treturn content;\n }\n \n-int pretend_object_file(void *buf, unsigned long len, enum object_type type,\n+int pretend_object_file(void *buf, size_t len, enum object_type type,\n \t\t\tstruct object_id *oid)\n {\n \tstruct cached_object *co;\n@@ -1467,7 +1467,7 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type,\n void *read_object_file_extended(struct repository *r,\n \t\t\t\tconst struct object_id *oid,\n \t\t\t\tenum object_type *type,\n-\t\t\t\tunsigned long *size,\n+\t\t\t\tsize_t *size,\n \t\t\t\tint lookup_replace)\n {\n \tvoid *data;\n@@ -1503,12 +1503,12 @@ void *read_object_file_extended(struct repository *r,\n \n void *read_object_with_reference(const struct object_id *oid,\n \t\t\t\t const char *required_type_name,\n-\t\t\t\t unsigned long *size,\n+\t\t\t\t size_t *size,\n \t\t\t\t struct object_id *actual_oid_return)\n {\n \tenum object_type type, required_type;\n \tvoid *buffer;\n-\tunsigned long isize;\n+\tsize_t isize;\n \tstruct object_id actual_oid;\n \n \trequired_type = type_from_string(required_type_name);\n@@ -1549,7 +1549,7 @@ void *read_object_with_reference(const struct object_id *oid,\n \t}\n }\n \n-static void write_object_file_prepare(const void *buf, unsigned long len,\n+static void write_object_file_prepare(const void *buf, size_t len,\n \t\t\t\t      const char *type, struct object_id *oid,\n \t\t\t\t      char *hdr, int *hdrlen)\n {\n@@ -1615,7 +1615,7 @@ static int write_buffer(int fd, const void *buf, size_t len)\n \treturn 0;\n }\n \n-int hash_object_file(const void *buf, unsigned long len, const char *type,\n+int hash_object_file(const void *buf, size_t len, const char *type,\n \t\t     struct object_id *oid)\n {\n \tchar hdr[MAX_HEADER_LEN];\n@@ -1679,7 +1679,7 @@ static int create_tmpfile(struct strbuf *tmp, const char *filename)\n }\n \n static int write_loose_object(const struct object_id *oid, char *hdr,\n-\t\t\t      int hdrlen, const void *buf, unsigned long len,\n+\t\t\t      int hdrlen, const void *buf, size_t len,\n \t\t\t      time_t mtime)\n {\n \tint fd, ret;\n@@ -1769,7 +1769,7 @@ static int freshen_packed_object(const struct object_id *oid)\n \treturn 1;\n }\n \n-int write_object_file(const void *buf, unsigned long len, const char *type,\n+int write_object_file(const void *buf, size_t len, const char *type,\n \t\t      struct object_id *oid)\n {\n \tchar hdr[MAX_HEADER_LEN];\n@@ -1784,7 +1784,7 @@ int write_object_file(const void *buf, unsigned long len, const char *type,\n \treturn write_loose_object(oid, hdr, hdrlen, buf, len, 0);\n }\n \n-int hash_object_file_literally(const void *buf, unsigned long len,\n+int hash_object_file_literally(const void *buf, size_t len,\n \t\t\t       const char *type, struct object_id *oid,\n \t\t\t       unsigned flags)\n {\n@@ -1810,7 +1810,7 @@ int hash_object_file_literally(const void *buf, unsigned long len,\n int force_object_loose(const struct object_id *oid, time_t mtime)\n {\n \tvoid *buf;\n-\tunsigned long len;\n+\tsize_t len;\n \tenum object_type type;\n \tchar hdr[MAX_HEADER_LEN];\n \tint hdrlen;\n@@ -2247,14 +2247,14 @@ void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)\n \n static int check_stream_sha1(git_zstream *stream,\n \t\t\t     const char *hdr,\n-\t\t\t     unsigned long size,\n+\t\t\t     size_t size,\n \t\t\t     const char *path,\n \t\t\t     const unsigned char *expected_sha1)\n {\n \tgit_hash_ctx c;\n \tunsigned char real_sha1[GIT_MAX_RAWSZ];\n \tunsigned char buf[4096];\n-\tunsigned long total_read;\n+\tsize_t total_read;\n \tint status = Z_OK;\n \n \tthe_hash_algo->init_fn(&c);\n@@ -2306,12 +2306,12 @@ static int check_stream_sha1(git_zstream *stream,\n int read_loose_object(const char *path,\n \t\t      const struct object_id *expected_oid,\n \t\t      enum object_type *type,\n-\t\t      unsigned long *size,\n+\t\t      size_t *size,\n \t\t      void **contents)\n {\n \tint ret = -1;\n \tvoid *map = NULL;\n-\tunsigned long mapsize;\n+\tsize_t mapsize;\n \tgit_zstream stream;\n \tchar hdr[MAX_HEADER_LEN];\n \ndiff --git a/sha1dc_git.c b/sha1dc_git.c\nindex e0cc9d988c..b24fc9af55 100644\n--- a/sha1dc_git.c\n+++ b/sha1dc_git.c\n@@ -25,7 +25,7 @@ void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)\n /*\n  * Same as SHA1DCUpdate, but adjust types to match git's usual interface.\n  */\n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, size_t len)\n {\n \tconst char *data = vdata;\n \t/* We expect an unsigned long, but sha1dc only takes an int */\ndiff --git a/sha1dc_git.h b/sha1dc_git.h\nindex 41e1c3fd3f..847b38fb4b 100644\n--- a/sha1dc_git.h\n+++ b/sha1dc_git.h\n@@ -15,7 +15,7 @@ void git_SHA1DCInit(SHA1_CTX *);\n #endif\n \n void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *);\n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, unsigned long len);\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, size_t len);\n \n #define platform_SHA_CTX SHA1_CTX\n #define platform_SHA1_Init git_SHA1DCInit\ndiff --git a/streaming.c b/streaming.c\nindex 891f82f51a..1e7a656738 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -69,19 +69,19 @@ struct filtered_istream {\n \n struct git_istream {\n \tconst struct stream_vtbl *vtbl;\n-\tunsigned long size; /* inflated size of full object */\n+\tsize_t size; /* inflated size of full object */\n \tgit_zstream z;\n \tenum { z_unused, z_used, z_done, z_error } z_state;\n \n \tunion {\n \t\tstruct {\n \t\t\tchar *buf; /* from read_object() */\n-\t\t\tunsigned long read_ptr;\n+\t\t\tsize_t read_ptr;\n \t\t} incore;\n \n \t\tstruct {\n \t\t\tvoid *mapped;\n-\t\t\tunsigned long mapsize;\n+\t\t\tsize_t mapsize;\n \t\t\tchar hdr[32];\n \t\t\tint hdr_avail;\n \t\t\tint hdr_used;\n@@ -112,7 +112,7 @@ static enum input_source istream_source(const struct object_id *oid,\n \t\t\t\t\tenum object_type *type,\n \t\t\t\t\tstruct object_info *oi)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tint status;\n \n \toi->typep = type;\n@@ -135,7 +135,7 @@ static enum input_source istream_source(const struct object_id *oid,\n \n struct git_istream *open_istream(const struct object_id *oid,\n \t\t\t\t enum object_type *type,\n-\t\t\t\t unsigned long *size,\n+\t\t\t\t size_t *size,\n \t\t\t\t struct stream_filter *filter)\n {\n \tstruct git_istream *st;\n@@ -516,7 +516,7 @@ int stream_blob_to_fd(int fd, const struct object_id *oid, struct stream_filter\n {\n \tstruct git_istream *st;\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tssize_t kept = 0;\n \tint result = -1;\n \ndiff --git a/streaming.h b/streaming.h\nindex 32f4626771..552eb1d7c5 100644\n--- a/streaming.h\n+++ b/streaming.h\n@@ -8,7 +8,7 @@\n /* opaque */\n struct git_istream;\n \n-extern struct git_istream *open_istream(const struct object_id *, enum object_type *, unsigned long *, struct stream_filter *);\n+extern struct git_istream *open_istream(const struct object_id *, enum object_type *, size_t *, struct stream_filter *);\n extern int close_istream(struct git_istream *);\n extern ssize_t read_istream(struct git_istream *, void *, size_t);\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex 52702c62d9..b9444318fd 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -527,7 +527,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,\n \t\tenum lookup_type lookup_type)\n {\n \tstruct strbuf rev = STRBUF_INIT;\n-\tunsigned long config_size;\n+\tsize_t config_size;\n \tchar *config = NULL;\n \tstruct object_id oid;\n \tenum object_type type;\ndiff --git a/t/helper/test-delta.c b/t/helper/test-delta.c\nindex e749a49c88..b613cd0216 100644\n--- a/t/helper/test-delta.c\n+++ b/t/helper/test-delta.c\n@@ -21,7 +21,7 @@ int cmd__delta(int argc, const char **argv)\n \tint fd;\n \tstruct stat st;\n \tvoid *from_buf, *data_buf, *out_buf;\n-\tunsigned long from_size, data_size, out_size;\n+\tsize_t from_size, data_size, out_size;\n \n \tif (argc != 5 || (strcmp(argv[1], \"-d\") && strcmp(argv[1], \"-p\"))) {\n \t\tfprintf(stderr, \"usage: %s\\n\", usage_str);\ndiff --git a/tag.c b/tag.c\nindex 7445b8f6ea..a6c07419dc 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -41,7 +41,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n {\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \ttype = oid_object_info(the_repository, oid, NULL);\n@@ -132,7 +132,7 @@ void release_tag_memory(struct tag *t)\n \tt->date = 0;\n }\n \n-int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size)\n+int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, size_t size)\n {\n \tstruct object_id oid;\n \tchar type[20];\n@@ -195,7 +195,7 @@ int parse_tag(struct tag *item)\n {\n \tenum object_type type;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tif (item->object.parsed)\ndiff --git a/tag.h b/tag.h\nindex e669c3e497..b540b100ef 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -12,7 +12,7 @@ struct tag {\n \ttimestamp_t date;\n };\n extern struct tag *lookup_tag(struct repository *r, const struct object_id *oid);\n-extern int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size);\n+extern int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, size_t size);\n extern int parse_tag(struct tag *item);\n extern void release_tag_memory(struct tag *t);\n extern struct object *deref_tag(struct repository *r, struct object *, const char *, int);\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 79bafbd1a2..aefd189e46 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -82,7 +82,7 @@ int init_tree_desc_gently(struct tree_desc *desc, const void *buffer, unsigned l\n \n void *fill_tree_descriptor(struct tree_desc *desc, const struct object_id *oid)\n {\n-\tunsigned long size = 0;\n+\tsize_t size = 0;\n \tvoid *buf = NULL;\n \n \tif (oid) {\n@@ -108,8 +108,8 @@ static int update_tree_entry_internal(struct tree_desc *desc, struct strbuf *err\n {\n \tconst void *buf = desc->buffer;\n \tconst unsigned char *end = desc->entry.oid->hash + the_hash_algo->rawsz;\n-\tunsigned long size = desc->size;\n-\tunsigned long len = end - (const unsigned char *)buf;\n+\tsize_t size = desc->size;\n+\tsize_t len = end - (const unsigned char *)buf;\n \n \tif (size < len)\n \t\tdie(_(\"too-short tree file\"));\n@@ -489,7 +489,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)\n \n struct dir_state {\n \tvoid *tree;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_id oid;\n };\n \n@@ -532,7 +532,7 @@ int get_tree_entry(const struct object_id *tree_oid, const char *name, struct ob\n {\n \tint retval;\n \tvoid *tree;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_id root;\n \n \ttree = read_object_with_reference(tree_oid, tree_type, &size, &root);\n@@ -601,7 +601,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(struct object_id *tre\n \t\tif (!t.buffer) {\n \t\t\tvoid *tree;\n \t\t\tstruct object_id root;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\ttree = read_object_with_reference(&current_tree_oid,\n \t\t\t\t\t\t\t  tree_type, &size,\n \t\t\t\t\t\t\t  &root);\n@@ -697,7 +697,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(struct object_id *tre\n \t\t\tgoto done;\n \t\t} else if (S_ISLNK(*mode)) {\n \t\t\t/* Follow a symlink */\n-\t\t\tunsigned long link_len;\n+\t\t\tsize_t link_len;\n \t\t\tsize_t len;\n \t\t\tchar *contents, *contents_start;\n \t\t\tstruct dir_state *parent;\ndiff --git a/tree.c b/tree.c\nindex 215d3fdc7c..817d952531 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -217,7 +217,7 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)\n {\n \t enum object_type type;\n \t void *buffer;\n-\t unsigned long size;\n+\t size_t size;\n \n \tif (item->object.parsed)\n \t\treturn 0;\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 80f060d278..cd24e6c6fe 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -169,7 +169,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename)\n \n void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \n \tif (oideq(oid, &null_oid)) {\n@@ -185,7 +185,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n }\n \n #define FIRST_FEW_BYTES 8000\n-int buffer_is_binary(const char *ptr, unsigned long size)\n+int buffer_is_binary(const char *ptr, size_t size)\n {\n \tif (FIRST_FEW_BYTES < size)\n \t\tsize = FIRST_FEW_BYTES;\ndiff --git a/xdiff-interface.h b/xdiff-interface.h\nindex 2d41fffd4c..6c99f8d047 100644\n--- a/xdiff-interface.h\n+++ b/xdiff-interface.h\n@@ -11,7 +11,7 @@\n  */\n #define MAX_XDIFF_SIZE (1024UL * 1024 * 1023)\n \n-typedef void (*xdiff_emit_line_fn)(void *, char *, unsigned long);\n+typedef void (*xdiff_emit_line_fn)(void *, char *, size_t);\n typedef void (*xdiff_emit_hunk_fn)(void *data,\n \t\t\t\t   long old_begin, long old_nr,\n \t\t\t\t   long new_begin, long new_nr,\n@@ -25,7 +25,7 @@ int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,\n \t\t  xpparam_t const *xpp, xdemitconf_t const *xecfg);\n int read_mmfile(mmfile_t *ptr, const char *filename);\n void read_mmblob(mmfile_t *ptr, const struct object_id *oid);\n-int buffer_is_binary(const char *ptr, unsigned long size);\n+int buffer_is_binary(const char *ptr, size_t size);\n \n extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags);\n extern void xdiff_clear_find_func(xdemitconf_t *xecfg);\n-- \n2.19.0.271.gfe8321ec05\n\n"},{"id":"363597","messageId":"c09938cf-7631-ef89-d8fc-d952f9b121c8@gmail.com","threadId":"49844","inReplyTo":"20181117151139.22994-1-tboegi@web.de","subject":"Re: [PATCH/RFC v1 1/1] Use size_t instead of unsigned long","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-11-18T20:18:52Z","receivedAt":"2018-11-18T20:18:57Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 11/17/2018 10:11 AM, tboegi@web.de wrote:\n> From: Torsten Bögershausen <tboegi@web.de>\n>\n> Currently Git users can not commit files >4Gib under 64 bit Windows,\n> where \"long\" is 32 bit but size_t is 64 bit.\n> Improve the code base in small steps, as small as possible.\n> What started with a small patch to replace \"unsigned long\" with size_t\n> in one file (convert.c) ended up with a change in many files.\n>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n>\n> This needs to go on top of pu, to cover all the good stuff\n>    cooking here.\n\nBetter to work on top of 'master', as the work in 'pu' will be rewritten \nseveral times, probably.\n\n> I have started this series on November 1st, since that 2 or 3 rebases\n>    had been done to catch up, and now it is on pu from November 15.\n>\n> I couldn't find a reason why changing \"unsigned ling\"\n>    into \"size_t\" may break anything, any thoughts, please ?\n\nIIRC, the blocker for why we haven't done this already is that \"size_t\", \n\"timestamp_t\" and \"off_t\" are all 64-bit types that give more implied \nmeaning, so we should swap types specifically to these as we want. One \nexample series does a specific, small change [1].\n\nIf we wanted to do a single swap that removes 'unsigned long' with an \nunambiguously 64-bit type, I would recommend \"uint64_t\". Later \nreplacements to size_t, off_t, and timestamp_t could happen on a \ncase-by-case basis for type clarity.\n\nIt may benefit reviewers to split this change into multiple patches, \nstarting at the lowest levels of the call stack (so higher 'unsigned \nlong's can up-cast to the 64-bit types when calling a function) and \nfocusing the changes to one or two files at a time (X.c and X.h, \npreferrably).\n\nSince you are talking about the benefits for Git for Windows to accept \n4GB files, I wonder if we can add a test that verifies such a file will \nwork. If you have such a test, then I could help verify that the test \nfails before the change and succeeds afterward.\n\nFinally, it may be good to add a coccinelle script that replaces \n'unsigned long' with 'uint64_t' so we can easily fix any new \nintroductions that happen in the future.\n\nThanks! I do think we should make this change, but we must be careful. \nIt may be disruptive to topics in flight.\n\n-Stolee\n\n[1] https://public-inbox.org/git/20181112084031.11769-1-carenas@gmail.com/\n\n"},{"id":"363603","messageId":"xmqqwopadkf9.fsf@gitster-ct.c.googlers.com","threadId":"49844","inReplyTo":"c09938cf-7631-ef89-d8fc-d952f9b121c8@gmail.com","subject":"Re: [PATCH/RFC v1 1/1] Use size_t instead of unsigned long","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-18T23:40:10Z","receivedAt":"2018-11-18T23:40:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Derrick Stolee <stolee@gmail.com> writes:\n\n>> This needs to go on top of pu, to cover all the good stuff\n>>    cooking here.\n>\n> Better to work on top of 'master', as the work in 'pu' will be\n> rewritten several times, probably.\n\nWe may not be able to find any good moment to update some codepaths\nwith deep callchains that reaches a basic API function that take\nulong that way, as things are always in motion, but hopefully a lot\nof areas that need changes are rather isolated.  \n\nFor example, the changes I see around \"offset\" (which is \"ulong\" and\nthe patch wants to change it to \"size_t\") in archive-tar.c in the\npatch do not have any interaction with the changes in this patch\noutside that single file, and I do not think any topic in-flight\nwould interact with this change badly, either.  I didn't carefully\nlook at the remainder of the patches, but I have a feeling that many\ncan be separated out into independent and focused set of smaller\npatches that can be evaluated on their own.\n\n"},{"id":"363619","messageId":"f0c0e2e8-717d-9973-5533-8b806474e119@web.de","threadId":"49844","inReplyTo":"xmqqwopadkf9.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH/RFC v1 1/1] Use size_t instead of unsigned long","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2018-11-19T05:33:30Z","receivedAt":"2018-11-19T05:33:38Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 2018-11-19 00:40, Junio C Hamano wrote:\n> Derrick Stolee <stolee@gmail.com> writes:\n> \n>>> This needs to go on top of pu, to cover all the good stuff\n>>>    cooking here.\n>>\n>> Better to work on top of 'master', as the work in 'pu' will be\n>> rewritten several times, probably.\n> \n> We may not be able to find any good moment to update some codepaths\n> with deep callchains that reaches a basic API function that take\n> ulong that way, as things are always in motion, but hopefully a lot\n> of areas that need changes are rather isolated.  \n> \n> For example, the changes I see around \"offset\" (which is \"ulong\" and\n> the patch wants to change it to \"size_t\") in archive-tar.c in the\n> patch do not have any interaction with the changes in this patch\n> outside that single file, and I do not think any topic in-flight\n> would interact with this change badly, either.  I didn't carefully\n> look at the remainder of the patches, but I have a feeling that many\n> can be separated out into independent and focused set of smaller\n> patches that can be evaluated on their own.\n> \n\nThe archive-tar.c is actually a good example, why a step-by-step update\nis not ideal (the code would not work any more on Win64).\n\nIf we look here:\n\nstatic int stream_blocked(const struct object_id *oid)\n{\n\tstruct git_istream *st;\n\tenum object_type type;\n\tsize_t sz;\n\tchar buf[BLOCKSIZE];\n\tssize_t readlen;\n\n\tst = open_istream(oid, &type, &sz, NULL);\n                                      ^^^^^\n\tif (!st)\n\t\treturn error(_(\"cannot stream blob %s\"), oid_to_hex(oid));\n\tfor (;;) {\n\nThe sz variable must follow whatever open_istream() uses, so if we start\nwith archive-tar.c, we must use either size_t or ulong, whatever\nopen_istream() needs. Otherwise things will break:\narchive-tar.c uses ulong, open_istream() size_t, but we are passing pointers\naround, and here &ulong != &size_t\n\nIf we only update open_istream(), but not archive-tar.c, then\nthings are not better:\n&size_t != &ulong.\n\nI don't have a good idea how to split the patch.\nHowever, \"add a coccinelle script\" may be a solution.\n"},{"id":"363649","messageId":"20181119163323.GA15913@tor.lan","threadId":"49844","inReplyTo":"c09938cf-7631-ef89-d8fc-d952f9b121c8@gmail.com","subject":"Re: [PATCH/RFC v1 1/1] Use size_t instead of unsigned long","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2018-11-19T16:33:23Z","receivedAt":"2018-11-19T18:04:29Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Sun, Nov 18, 2018 at 03:18:52PM -0500, Derrick Stolee wrote:\n> On 11/17/2018 10:11 AM, tboegi@web.de wrote:\n> >From: Torsten Bögershausen <tboegi@web.de>\n> >\n> >Currently Git users can not commit files >4Gib under 64 bit Windows,\n> >where \"long\" is 32 bit but size_t is 64 bit.\n> >Improve the code base in small steps, as small as possible.\n> >What started with a small patch to replace \"unsigned long\" with size_t\n> >in one file (convert.c) ended up with a change in many files.\n> >\n> >Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> >---\n> >\n> >This needs to go on top of pu, to cover all the good stuff\n> >   cooking here.\n> \n> Better to work on top of 'master', as the work in 'pu' will be rewritten\n> several times, probably.\n> \n> >I have started this series on November 1st, since that 2 or 3 rebases\n> >   had been done to catch up, and now it is on pu from November 15.\n> >\n> >I couldn't find a reason why changing \"unsigned ling\"\n> >   into \"size_t\" may break anything, any thoughts, please ?\n> \n> IIRC, the blocker for why we haven't done this already is that \"size_t\",\n> \"timestamp_t\" and \"off_t\" are all 64-bit types that give more implied\n> meaning, so we should swap types specifically to these as we want. One\n> example series does a specific, small change [1].\n> \n> If we wanted to do a single swap that removes 'unsigned long' with an\n> unambiguously 64-bit type, I would recommend \"uint64_t\". Later replacements\n> to size_t, off_t, and timestamp_t could happen on a case-by-case basis for\n> type clarity.\n> \n> It may benefit reviewers to split this change into multiple patches,\n> starting at the lowest levels of the call stack (so higher 'unsigned long's\n> can up-cast to the 64-bit types when calling a function) and focusing the\n> changes to one or two files at a time (X.c and X.h, preferrably).\n> \n> Since you are talking about the benefits for Git for Windows to accept 4GB\n> files, I wonder if we can add a test that verifies such a file will work. If\n> you have such a test, then I could help verify that the test fails before\n> the change and succeeds afterward.\n> \n> Finally, it may be good to add a coccinelle script that replaces 'unsigned\n> long' with 'uint64_t' so we can easily fix any new introductions that happen\n> in the future.\n\nThe plan was never to change \"unsigned long\" to a 64 bit value in general.\nThe usage of \"unsigned long\" (instead of size_t) was (and is) still good\nfor 32bit systems, where both are 32 bit. (at least all system I am aware of).\n\nFor 64 bit systems like Linux or Mac OS it is the same, both are 64 bit.\n\nThe only problematic system is Win64, where \"unsigned long\" is 32 bit,\nand therefore we must use size_t to address data in memory.\nThis is not to be confused with off_t, which is used for \"data on disk\"\n(and nothing else) or timestamp_t which is used for timestamps (and nothing else).\n\nI haven't followed the \"coccinelle script\" development at all, if someone\nmakes a patch do replace \"unsigned long\" with size_t, that could replace\nmy whole patch. (Some of them may be downgraded to \"unsigned int\" ?)\n\nHowever, as we need to let  tb/print-size-t-with-uintmax-format make it to\nmaster, otherwise we are not able to print the variables in a portable way. \n\n\n> Thanks! I do think we should make this change, but we must be careful. It\n> may be disruptive to topics in flight.\n> \n> -Stolee\n> \n> [1] https://public-inbox.org/git/20181112084031.11769-1-carenas@gmail.com/\n> \n"},{"id":"363650","messageId":"0e38e87d-0b8a-054d-1ae0-37a225845e3b@web.de","threadId":"49844","inReplyTo":"f0c0e2e8-717d-9973-5533-8b806474e119@web.de","subject":"Re: [PATCH/RFC v1 1/1] Use size_t instead of unsigned long","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2018-11-19T18:15:42Z","receivedAt":"2018-11-19T18:15:52Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 19.11.2018 um 06:33 schrieb Torsten Bögershausen:\n> The archive-tar.c is actually a good example, why a step-by-step update\n> is not ideal (the code would not work any more on Win64).\n> \n> If we look here:\n> \n> static int stream_blocked(const struct object_id *oid)\n> {\n> \tstruct git_istream *st;\n> \tenum object_type type;\n> \tsize_t sz;\n> \tchar buf[BLOCKSIZE];\n> \tssize_t readlen;\n> \n> \tst = open_istream(oid, &type, &sz, NULL);\n>                                       ^^^^^\n> \tif (!st)\n> \t\treturn error(_(\"cannot stream blob %s\"), oid_to_hex(oid));\n> \tfor (;;) {\n> \n> The sz variable must follow whatever open_istream() uses, so if we start\n> with archive-tar.c, we must use either size_t or ulong, whatever\n> open_istream() needs. Otherwise things will break:\n> archive-tar.c uses ulong, open_istream() size_t, but we are passing pointers\n> around, and here &ulong != &size_t\n> \n> If we only update open_istream(), but not archive-tar.c, then\n> things are not better:\n> &size_t != &ulong.\n> \n> I don't have a good idea how to split the patch.\n\nsz is not actually used later in that function; this change can\nbe done independently of any other ulong/size_t conversion in that\nfile.\n\nHmm, looking at that call I wonder why open_istream() doesn't return\ntype and size in the struct git_istream.  To make it match\nread_object_file(), I suppose.  Perhaps it's an opportunity to\nimprove its interface?\n\nRené\n"},{"id":"363690","messageId":"xmqqin0scyxh.fsf@gitster-ct.c.googlers.com","threadId":"49844","inReplyTo":"20181119163323.GA15913@tor.lan","subject":"Re: [PATCH/RFC v1 1/1] Use size_t instead of unsigned long","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-20T01:36:42Z","receivedAt":"2018-11-20T01:36:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Torsten Bögershausen <tboegi@web.de> writes:\n\n> The only problematic system is Win64, where \"unsigned long\" is 32 bit,\n> and therefore we must use size_t to address data in memory.\n> This is not to be confused with off_t, which is used for \"data on disk\"\n> (and nothing else) or timestamp_t which is used for timestamps (and nothing else).\n>\n> I haven't followed the \"coccinelle script\" development at all, if someone\n> makes a patch do replace \"unsigned long\" with size_t, that could replace\n> my whole patch. (Some of them may be downgraded to \"unsigned int\" ?)\n\nThis paragraph makes it sound as if this patch is s/ulong/size_t/,\nbut that contradicts with the previous paragraph, no?  It is much\nbetter to leave a ulong that is not about the size of a memory\nregion as-is, to be turned into appropriate and correct type later,\nthan changing it into another wrong type (size_t).\n\nIn short, we could do ulong to size_t with Coccinelle, but I do not\nthink we want to blindly rewrite all.\n\n"},{"id":"363697","messageId":"20181120050456.16715-1-tboegi@web.de","threadId":"49844","inReplyTo":"20181117151139.22994-1-tboegi@web.de","subject":"[PATCH v2 1/1] Use size_t instead of 'unsigned long' for data in memory","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2018-11-20T05:04:56Z","receivedAt":"2018-11-20T05:05:14Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nCurrently the length of data which is stored in memory is stored\nin \"unsigned long\" at many places in the code base.\nThis is OK when both \"unsigned long\" and size_t are 32 bits,\n(and is OK when both are 64 bits).\nOn a 64 bit Windows system am \"unsigned long\" is 32 bit, and\nthat may be too short to measure the size of objects in memory,\na size_t is the natural choice.\n\nImprove the code base in \"small steps\", as small as possible.\nThe smallest step seems to be much bigger than expected.\nSee this code-snippet from convert.c:\n\n        const char *ret;\n\tunsigned long sz;\n\tvoid *data = read_blob_data_from_index(istate, path, &sz);\n\tret = gather_convert_stats_ascii(data, sz);\n\nThe corrected version looks like this:\n        const char *ret;\n\tsize_t sz;\n\tvoid *data = read_blob_data_from_index(istate, path, &sz);\n\tret = gather_convert_stats_ascii(data, sz);\n\nHowever, when the Git code base is compiled with a compiler that\ncomplains that \"unsigned long\" is different from size_t, we end\nup in this huge patch, before the code base cleanly compiles.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n\nThanks for all the comments on V1.\nChanges since V1:\n- Make the motivation somewhat clearer in the commit message\n- Rebase to the November 19 pu\n\nWhat we really need for this patch to fly are this branches:\nmk/use-size-t-in-zlib\ntb/print-size-t-with-uintmax-format\n\nAnd then it is rebased on top of all cooking stuff, too many branches\nto be mentioned here.\n\nIt may be usefull to examine all \"unsigned long\" which are left after\nthis patch and turn them into (what ? unsigned int? size_t? uint32_t ?).\nAnd once they are settled, re-do this patch with help of a coccinelle script.\nI don't know.\nI probably will rebase it until Junio says stop or someone else comes with\na better solution.\n\napply.c                  | 14 ++++-----\n archive-tar.c            | 18 +++++------\n archive-zip.c            |  2 +-\n archive.c                |  2 +-\n archive.h                |  2 +-\n bisect.c                 |  2 +-\n blame.c                  |  6 ++--\n blame.h                  |  2 +-\n builtin/cat-file.c       | 10 +++---\n builtin/difftool.c       |  2 +-\n builtin/fast-export.c    |  6 ++--\n builtin/fmt-merge-msg.c  |  3 +-\n builtin/fsck.c           |  6 ++--\n builtin/grep.c           |  8 ++---\n builtin/index-pack.c     | 27 ++++++++--------\n builtin/log.c            |  4 +--\n builtin/ls-tree.c        |  2 +-\n builtin/merge-tree.c     |  6 ++--\n builtin/mktag.c          |  4 +--\n builtin/notes.c          |  6 ++--\n builtin/pack-objects.c   | 56 +++++++++++++++++-----------------\n builtin/reflog.c         |  2 +-\n builtin/replace.c        |  2 +-\n builtin/tag.c            |  4 +--\n builtin/unpack-file.c    |  2 +-\n builtin/unpack-objects.c | 35 ++++++++++-----------\n builtin/verify-commit.c  |  4 +--\n bundle.c                 |  2 +-\n cache.h                  | 10 +++---\n combine-diff.c           | 11 ++++---\n commit.c                 | 22 +++++++-------\n commit.h                 | 10 +++---\n config.c                 |  2 +-\n convert.c                | 18 +++++------\n delta.h                  | 20 ++++++------\n diff-delta.c             |  4 +--\n diff.c                   | 30 +++++++++---------\n diff.h                   |  2 +-\n diffcore-pickaxe.c       |  4 +--\n diffcore.h               |  2 +-\n dir.c                    |  6 ++--\n dir.h                    |  2 +-\n entry.c                  |  4 +--\n fast-import.c            | 26 ++++++++--------\n fsck.c                   | 12 ++++----\n fsck.h                   |  2 +-\n fuzz-pack-headers.c      |  4 +--\n grep.h                   |  2 +-\n http-push.c              |  2 +-\n list-objects-filter.c    |  2 +-\n mailmap.c                |  2 +-\n match-trees.c            |  4 +--\n merge-blobs.c            |  6 ++--\n merge-blobs.h            |  2 +-\n merge-recursive.c        |  4 +--\n notes-cache.c            |  2 +-\n notes-merge.c            |  4 +--\n notes.c                  |  6 ++--\n object-store.h           | 20 ++++++------\n object.c                 |  4 +--\n object.h                 |  2 +-\n pack-check.c             |  2 +-\n pack-objects.h           | 14 ++++-----\n pack.h                   |  2 +-\n packfile.c               | 40 ++++++++++++------------\n packfile.h               |  8 ++---\n patch-delta.c            |  8 ++---\n range-diff.c             |  2 +-\n read-cache.c             | 48 ++++++++++++++---------------\n ref-filter.c             | 30 +++++++++---------\n remote-testsvn.c         |  4 +--\n rerere.c                 |  2 +-\n sha1-file.c              | 66 ++++++++++++++++++++--------------------\n sha1dc_git.c             |  2 +-\n sha1dc_git.h             |  2 +-\n streaming.c              | 12 ++++----\n streaming.h              |  2 +-\n submodule-config.c       |  2 +-\n t/helper/test-delta.c    |  2 +-\n tag.c                    |  6 ++--\n tag.h                    |  2 +-\n tree-walk.c              | 14 ++++-----\n tree.c                   |  2 +-\n xdiff-interface.c        |  4 +--\n xdiff-interface.h        |  4 +--\n 85 files changed, 388 insertions(+), 384 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex f814a92660..890f36dc74 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3096,7 +3096,7 @@ static int apply_binary_fragment(struct apply_state *state,\n \t\t\t\t struct patch *patch)\n {\n \tstruct fragment *fragment = patch->fragments;\n-\tunsigned long len;\n+\tsize_t len;\n \tvoid *dst;\n \n \tif (!fragment)\n@@ -3186,7 +3186,7 @@ static int apply_binary(struct apply_state *state,\n \tif (repo_has_sha1_file(the_repository, oid.hash)) {\n \t\t/* We already have the postimage */\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *result;\n \n \t\tresult = repo_read_object_file(the_repository, &oid, &type,\n@@ -3249,7 +3249,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns\n \t\tstrbuf_addf(buf, \"Subproject commit %s\\n\", oid_to_hex(oid));\n \t} else {\n \t\tenum object_type type;\n-\t\tunsigned long sz;\n+\t\tsize_t sz;\n \t\tchar *result;\n \n \t\tresult = repo_read_object_file(the_repository, oid, &type,\n@@ -4279,7 +4279,7 @@ static int add_index_file(struct apply_state *state,\n \t\t\t  const char *path,\n \t\t\t  unsigned mode,\n \t\t\t  void *buf,\n-\t\t\t  unsigned long size)\n+\t\t\t  size_t size)\n {\n \tstruct stat st;\n \tstruct cache_entry *ce;\n@@ -4333,7 +4333,7 @@ static int add_index_file(struct apply_state *state,\n  */\n static int try_create_file(struct apply_state *state, const char *path,\n \t\t\t   unsigned int mode, const char *buf,\n-\t\t\t   unsigned long size)\n+\t\t\t   size_t size)\n {\n \tint fd, res;\n \tstruct strbuf nbuf = STRBUF_INIT;\n@@ -4384,7 +4384,7 @@ static int create_one_file(struct apply_state *state,\n \t\t\t   char *path,\n \t\t\t   unsigned mode,\n \t\t\t   const char *buf,\n-\t\t\t   unsigned long size)\n+\t\t\t   size_t size)\n {\n \tint res;\n \n@@ -4476,7 +4476,7 @@ static int create_file(struct apply_state *state, struct patch *patch)\n {\n \tchar *path = patch->new_name;\n \tunsigned mode = patch->new_mode;\n-\tunsigned long size = patch->resultsize;\n+\tsize_t size = patch->resultsize;\n \tchar *buf = patch->result;\n \n \tif (!mode)\ndiff --git a/archive-tar.c b/archive-tar.c\nindex a58e1a8ebf..cea52dfc0a 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -13,7 +13,7 @@\n #define BLOCKSIZE\t(RECORDSIZE * 20)\n \n static char block[BLOCKSIZE];\n-static unsigned long offset;\n+static size_t offset;\n \n static int tar_umask = 002;\n \n@@ -51,12 +51,12 @@ static void write_if_needed(void)\n  * queues up writes, so that all our write(2) calls write exactly one\n  * full block; pads writes to RECORDSIZE\n  */\n-static void do_write_blocked(const void *data, unsigned long size)\n+static void do_write_blocked(const void *data, size_t size)\n {\n \tconst char *buf = data;\n \n \tif (offset) {\n-\t\tunsigned long chunk = BLOCKSIZE - offset;\n+\t\tsize_t chunk = BLOCKSIZE - offset;\n \t\tif (size < chunk)\n \t\t\tchunk = size;\n \t\tmemcpy(block + offset, buf, chunk);\n@@ -78,7 +78,7 @@ static void do_write_blocked(const void *data, unsigned long size)\n \n static void finish_record(void)\n {\n-\tunsigned long tail;\n+\tsize_t tail;\n \ttail = offset % RECORDSIZE;\n \tif (tail)  {\n \t\tmemset(block + offset, 0, RECORDSIZE - tail);\n@@ -87,7 +87,7 @@ static void finish_record(void)\n \twrite_if_needed();\n }\n \n-static void write_blocked(const void *data, unsigned long size)\n+static void write_blocked(const void *data, size_t size)\n {\n \tdo_write_blocked(data, size);\n \tfinish_record();\n@@ -116,7 +116,7 @@ static int stream_blocked(const struct object_id *oid)\n {\n \tstruct git_istream *st;\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tchar buf[BLOCKSIZE];\n \tssize_t readlen;\n \n@@ -199,7 +199,7 @@ static size_t get_path_prefix(const char *path, size_t pathlen, size_t maxlen)\n \n static void prepare_header(struct archiver_args *args,\n \t\t\t   struct ustar_header *header,\n-\t\t\t   unsigned int mode, unsigned long size)\n+\t\t\t   unsigned int mode, size_t size)\n {\n \txsnprintf(header->mode, sizeof(header->mode), \"%07o\", mode & 07777);\n \txsnprintf(header->size, sizeof(header->size), \"%011\"PRIoMAX , S_ISREG(mode) ? (uintmax_t)size : (uintmax_t)0);\n@@ -220,7 +220,7 @@ static void prepare_header(struct archiver_args *args,\n \n static void write_extended_header(struct archiver_args *args,\n \t\t\t\t  const struct object_id *oid,\n-\t\t\t\t  const void *buffer, unsigned long size)\n+\t\t\t\t  const void *buffer, size_t size)\n {\n \tstruct ustar_header header;\n \tunsigned int mode;\n@@ -241,7 +241,7 @@ static int write_tar_entry(struct archiver_args *args,\n \tstruct ustar_header header;\n \tstruct strbuf ext_header = STRBUF_INIT;\n \tunsigned int old_mode = mode;\n-\tunsigned long size, size_in_header;\n+\tsize_t size, size_in_header;\n \tvoid *buffer;\n \tint err = 0;\n \ndiff --git a/archive-zip.c b/archive-zip.c\nindex 155ee4a779..7bc9b8d425 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -297,7 +297,7 @@ static int write_zip_entry(struct archiver_args *args,\n \tvoid *buffer;\n \tstruct git_istream *stream = NULL;\n \tunsigned long flags = 0;\n-\tunsigned long size;\n+\tsize_t size;\n \tint is_binary = -1;\n \tconst char *path_without_prefix = path + args->baselen;\n \tunsigned int creator_version = 0;\ndiff --git a/archive.c b/archive.c\nindex 4d03134fd2..eb3613d2fe 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -74,7 +74,7 @@ static void format_subst(const struct commit *commit,\n void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t     const char *path, const struct object_id *oid,\n \t\t\t     unsigned int mode, enum object_type *type,\n-\t\t\t     unsigned long *sizep)\n+\t\t\t     size_t *sizep)\n {\n \tvoid *buffer;\n \tconst struct commit *commit = args->convert ? args->commit : NULL;\ndiff --git a/archive.h b/archive.h\nindex 21ac010699..5b69ee1baf 100644\n--- a/archive.h\n+++ b/archive.h\n@@ -54,6 +54,6 @@ extern int write_archive_entries(struct archiver_args *args, write_archive_entry\n extern void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t\t    const char *path, const struct object_id *oid,\n \t\t\t\t    unsigned int mode, enum object_type *type,\n-\t\t\t\t    unsigned long *sizep);\n+\t\t\t\t    size_t *sizep);\n \n #endif\t/* ARCHIVE_H */\ndiff --git a/bisect.c b/bisect.c\nindex cd9214f7ea..c7e7639b0c 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -137,7 +137,7 @@ static void show_list(const char *debug, int counted, int nr,\n \t\tstruct commit *commit = p->item;\n \t\tunsigned flags = commit->object.flags;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf = repo_read_object_file(the_repository,\n \t\t\t\t\t\t  &commit->object.oid, &type,\n \t\t\t\t\t\t  &size);\ndiff --git a/blame.c b/blame.c\nindex e6e8220044..2711cef2a4 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -222,7 +222,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,\n \t\tstruct stat st;\n \t\tconst char *read_from;\n \t\tchar *buf_ptr;\n-\t\tunsigned long buf_len;\n+\t\tsize_t buf_len;\n \n \t\tif (contents_from) {\n \t\t\tif (stat(contents_from, &st) < 0)\n@@ -319,7 +319,7 @@ static void fill_origin_blob(struct diff_options *opt,\n {\n \tif (!o->file.ptr) {\n \t\tenum object_type type;\n-\t\tunsigned long file_size;\n+\t\tsize_t file_size;\n \n \t\t(*num_read_blob)++;\n \t\tif (opt->flags.allow_textconv &&\n@@ -1652,7 +1652,7 @@ static const char *get_next_line(const char *start, const char *end)\n static int prepare_lines(struct blame_scoreboard *sb)\n {\n \tconst char *buf = sb->final_buf;\n-\tunsigned long len = sb->final_buf_size;\n+\tsize_t len = sb->final_buf_size;\n \tconst char *end = buf + len;\n \tconst char *p;\n \tint *lineno;\ndiff --git a/blame.h b/blame.h\nindex be3a895043..0ef7ff1f3f 100644\n--- a/blame.h\n+++ b/blame.h\n@@ -112,7 +112,7 @@ struct blame_scoreboard {\n \t * indexed with scoreboard.lineno[blame_entry.lno].\n \t */\n \tconst char *final_buf;\n-\tunsigned long final_buf_size;\n+\tsize_t final_buf_size;\n \n \t/* linked list of blames */\n \tstruct blame_entry *ent;\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 787f91aadf..1676f30aea 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -30,7 +30,7 @@ static const char *force_path;\n \n static int filter_object(const char *path, unsigned mode,\n \t\t\t const struct object_id *oid,\n-\t\t\t char **buf, unsigned long *size)\n+\t\t\t char **buf, size_t *size)\n {\n \tenum object_type type;\n \n@@ -63,7 +63,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tstruct object_id oid;\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_context obj_context;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tstruct strbuf sb = STRBUF_INIT;\n@@ -192,7 +192,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n struct expand_data {\n \tstruct object_id oid;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t disk_size;\n \tconst char *rest;\n \tstruct object_id delta_base_oid;\n@@ -304,7 +304,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\t\tfflush(stdout);\n \t\tif (opt->cmdmode) {\n \t\t\tchar *contents;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \n \t\t\tif (!data->rest)\n \t\t\t\tdie(\"missing path for '%s'\", oid_to_hex(oid));\n@@ -336,7 +336,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t}\n \telse {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tvoid *contents;\n \n \t\tcontents = repo_read_object_file(the_repository, oid, &type,\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex 5e61162d08..8e118743e1 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -306,7 +306,7 @@ static char *get_symlink(const struct object_id *oid, const char *path)\n \t\tdata = strbuf_detach(&link, NULL);\n \t} else {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tdata = repo_read_object_file(the_repository, oid, &type,\n \t\t\t\t\t     &size);\n \t\tif (!data)\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex b8c2b3eec0..e1d806b134 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -226,7 +226,7 @@ static void show_progress(void)\n  * There's no need to cache this result with anonymize_mem, since\n  * we already handle blob content caching with marks.\n  */\n-static char *anonymize_blob(unsigned long *size)\n+static char *anonymize_blob(size_t *size)\n {\n \tstatic int counter;\n \tstruct strbuf out = STRBUF_INIT;\n@@ -237,7 +237,7 @@ static char *anonymize_blob(unsigned long *size)\n \n static void export_blob(const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf;\n \tstruct object *object;\n@@ -707,7 +707,7 @@ static void handle_tail(struct object_array *commits, struct rev_info *revs,\n \n static void handle_tag(const char *name, struct tag *tag)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf;\n \tconst char *tagger, *tagger_end, *message;\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 05cbcba230..f17dd237d3 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -494,7 +494,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \tfor (i = 0; i < origins.nr; i++) {\n \t\tstruct object_id *oid = origins.items[i].util;\n \t\tenum object_type type;\n-\t\tunsigned long size, len;\n+\t\tunsigned long len;\n+\t\tsize_t size;\n \t\tchar *buf = repo_read_object_file(the_repository, oid, &type,\n \t\t\t\t\t\t  &size);\n \t\tstruct strbuf sig = STRBUF_INIT;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex f6be6cf0a3..0f41d4eeda 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -359,7 +359,7 @@ static void check_connectivity(void)\n \t}\n }\n \n-static int fsck_obj(struct object *obj, void *buffer, unsigned long size)\n+static int fsck_obj(struct object *obj, void *buffer, size_t size)\n {\n \tint err;\n \n@@ -407,7 +407,7 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)\n }\n \n static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,\n-\t\t\t   unsigned long size, void *buffer, int *eaten)\n+\t\t\t   size_t size, void *buffer, int *eaten)\n {\n \t/*\n \t * Note, buffer may be NULL if type is OBJ_BLOB. See\n@@ -562,7 +562,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)\n {\n \tstruct object *obj;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *contents;\n \tint eaten;\n \ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 19eb6b7935..15568c5ab2 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -294,7 +294,7 @@ static int grep_cmd_config(const char *var, const char *value, void *cb)\n \treturn st;\n }\n \n-static void *lock_and_read_oid_file(const struct object_id *oid, enum object_type *type, unsigned long *size)\n+static void *lock_and_read_oid_file(const struct object_id *oid, enum object_type *type, size_t *size)\n {\n \tvoid *data;\n \n@@ -447,7 +447,7 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,\n \t\tstruct object *object;\n \t\tstruct tree_desc tree;\n \t\tvoid *data;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tstruct strbuf base = STRBUF_INIT;\n \n \t\tobject = parse_object_or_die(oid, oid_to_hex(oid));\n@@ -576,7 +576,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\t\tenum object_type type;\n \t\t\tstruct tree_desc sub;\n \t\t\tvoid *data;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \n \t\t\tdata = lock_and_read_oid_file(entry.oid, &type, &size);\n \t\t\tif (!data)\n@@ -611,7 +611,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,\n \tif (obj->type == OBJ_COMMIT || obj->type == OBJ_TREE) {\n \t\tstruct tree_desc tree;\n \t\tvoid *data;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tstruct strbuf base;\n \t\tint hit, len;\n \ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 67f685fbcb..b49225416d 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -20,7 +20,7 @@ static const char index_pack_usage[] =\n \n struct object_entry {\n \tstruct pack_idx_entry idx;\n-\tunsigned long size;\n+\tsize_t size;\n \tunsigned char hdr_size;\n \tsigned char type;\n \tsigned char real_type;\n@@ -36,7 +36,7 @@ struct base_data {\n \tstruct base_data *child;\n \tstruct object_entry *obj;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ref_first, ref_last;\n \tint ofs_first, ofs_last;\n };\n@@ -198,7 +198,7 @@ static unsigned check_object(struct object *obj)\n \t\treturn 0;\n \n \tif (!(obj->flags & FLAG_CHECKED)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n@@ -412,7 +412,7 @@ static int is_delta_type(enum object_type type)\n \treturn (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA);\n }\n \n-static void *unpack_entry_data(off_t offset, unsigned long size,\n+static void *unpack_entry_data(off_t offset, size_t size,\n \t\t\t       enum object_type type, struct object_id *oid)\n {\n \tstatic char fixed_buf[8192];\n@@ -467,7 +467,8 @@ static void *unpack_raw_entry(struct object_entry *obj,\n \t\t\t      struct object_id *oid)\n {\n \tunsigned char *p;\n-\tunsigned long size, c;\n+\tunsigned long c;\n+\tsize_t size;\n \toff_t base_offset;\n \tunsigned shift;\n \tvoid *data;\n@@ -529,7 +530,7 @@ static void *unpack_raw_entry(struct object_entry *obj,\n }\n \n static void *unpack_data(struct object_entry *obj,\n-\t\t\t int (*consume)(const unsigned char *, unsigned long, void *),\n+\t\t\t int (*consume)(const unsigned char *, size_t, void *),\n \t\t\t void *cb_data)\n {\n \toff_t from = obj[0].idx.offset + obj[0].hdr_size;\n@@ -706,10 +707,10 @@ struct compare_data {\n \tstruct object_entry *entry;\n \tstruct git_istream *st;\n \tunsigned char *buf;\n-\tunsigned long buf_size;\n+\tsize_t buf_size;\n };\n \n-static int compare_objects(const unsigned char *buf, unsigned long size,\n+static int compare_objects(const unsigned char *buf, size_t size,\n \t\t\t   void *cb_data)\n {\n \tstruct compare_data *data = cb_data;\n@@ -741,7 +742,7 @@ static int check_collison(struct object_entry *entry)\n {\n \tstruct compare_data data;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tif (entry->size <= big_file_threshold || entry->type != OBJ_BLOB)\n \t\treturn -1;\n@@ -761,7 +762,7 @@ static int check_collison(struct object_entry *entry)\n }\n \n static void sha1_object(const void *data, struct object_entry *obj_entry,\n-\t\t\tunsigned long size, enum object_type type,\n+\t\t\tsize_t size, enum object_type type,\n \t\t\tconst struct object_id *oid)\n {\n \tvoid *new_data = NULL;\n@@ -785,7 +786,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \tif (collision_test_needed) {\n \t\tvoid *has_data;\n \t\tenum object_type has_type;\n-\t\tunsigned long has_size;\n+\t\tsize_t has_size;\n \t\tread_lock();\n \t\thas_type = oid_object_info(the_repository, oid, &has_size);\n \t\tif (has_type < 0)\n@@ -1289,11 +1290,11 @@ static int write_compressed(struct hashfile *f, void *in, unsigned int size)\n \n static struct object_entry *append_obj_to_pack(struct hashfile *f,\n \t\t\t       const unsigned char *sha1, void *buf,\n-\t\t\t       unsigned long size, enum object_type type)\n+\t\t\t       size_t size, enum object_type type)\n {\n \tstruct object_entry *obj = &objects[nr_objects++];\n \tunsigned char header[10];\n-\tunsigned long s = size;\n+\tsize_t s = size;\n \tint n = 0;\n \tunsigned char c = (type << 4) | (s & 15);\n \ts >>= 4;\ndiff --git a/builtin/log.c b/builtin/log.c\nindex a619fdc6cf..71a4b40981 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -502,7 +502,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \tstruct object_id oidc;\n \tstruct object_context obj_context;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tfflush(rev->diffopt.file);\n \tif (!rev->diffopt.flags.textconv_set_via_cmdline ||\n@@ -529,7 +529,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \n static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n \tint offset = 0;\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 7cad3f24eb..b4ceca9e25 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -94,7 +94,7 @@ static int show_tree(const struct object_id *oid, struct strbuf *base,\n \t\tif (ls_options & LS_SHOW_SIZE) {\n \t\t\tchar size_text[24];\n \t\t\tif (!strcmp(type, blob_type)) {\n-\t\t\t\tunsigned long size;\n+\t\t\t\tsize_t size;\n \t\t\t\tif (oid_object_info(the_repository, oid, &size) == OBJ_BAD)\n \t\t\t\t\txsnprintf(size_text, sizeof(size_text),\n \t\t\t\t\t\t  \"BAD\");\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 5ad9330c5a..2384fc9e82 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -55,7 +55,7 @@ static const char *explanation(struct merge_list *entry)\n \treturn \"removed in remote\";\n }\n \n-static void *result(struct merge_list *entry, unsigned long *size)\n+static void *result(struct merge_list *entry, size_t *size)\n {\n \tenum object_type type;\n \tstruct blob *base, *our, *their;\n@@ -81,7 +81,7 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \treturn merge_blobs(&the_index, path, base, our, their, size);\n }\n \n-static void *origin(struct merge_list *entry, unsigned long *size)\n+static void *origin(struct merge_list *entry, size_t *size)\n {\n \tenum object_type type;\n \twhile (entry) {\n@@ -104,7 +104,7 @@ static int show_outf(void *priv_, mmbuffer_t *mb, int nbuf)\n \n static void show_diff(struct merge_list *entry)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tmmfile_t src, dst;\n \txpparam_t xpp;\n \txdemitconf_t xecfg;\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex be4366b03f..0e98682bfb 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -24,7 +24,7 @@ static int verify_object(const struct object_id *oid, const char *expected_type)\n {\n \tint ret = -1;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *buffer = repo_read_object_file(the_repository, oid, &type,\n \t\t\t\t\t     &size);\n \tconst struct object_id *repl = lookup_replace_object(the_repository, oid);\n@@ -37,7 +37,7 @@ static int verify_object(const struct object_id *oid, const char *expected_type)\n \treturn ret;\n }\n \n-static int verify_tag(char *buffer, unsigned long size)\n+static int verify_tag(char *buffer, size_t size)\n {\n \tint typelen;\n \tchar type[20];\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 218baa1038..3b60ba40a4 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -122,7 +122,7 @@ static int list_each_note(const struct object_id *object_oid,\n \n static void copy_obj_to_fd(int fd, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n \tif (buf) {\n@@ -252,7 +252,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n \tchar *buf;\n \tstruct object_id object;\n \tenum object_type type;\n-\tunsigned long len;\n+\tsize_t len;\n \n \tBUG_ON_OPT_NEG(unset);\n \n@@ -613,7 +613,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \n \tif (note && !edit) {\n \t\t/* Append buf to previous note contents */\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tenum object_type type;\n \t\tchar *prev_buf = repo_read_object_file(the_repository, note,\n \t\t\t\t\t\t       &type, &size);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 04290124f4..d05622ad2c 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -142,7 +142,7 @@ static void index_commit_for_bitmap(struct commit *commit)\n \n static void *get_delta(struct object_entry *entry)\n {\n-\tunsigned long size, base_size, delta_size;\n+\tsize_t size, base_size, delta_size;\n \tvoid *buf, *base_buf, *delta_buf;\n \tenum object_type type;\n \n@@ -170,11 +170,11 @@ static void *get_delta(struct object_entry *entry)\n \treturn delta_buf;\n }\n \n-static unsigned long do_compress(void **pptr, unsigned long size)\n+static size_t do_compress(void **pptr, size_t size)\n {\n \tgit_zstream stream;\n \tvoid *in, *out;\n-\tunsigned long maxsize;\n+\tsize_t maxsize;\n \n \tgit_deflate_init(&stream, pack_compression_level);\n \tmaxsize = git_deflate_bound(&stream, size);\n@@ -195,13 +195,13 @@ static unsigned long do_compress(void **pptr, unsigned long size)\n \treturn stream.total_out;\n }\n \n-static unsigned long write_large_blob_data(struct git_istream *st, struct hashfile *f,\n+static size_t write_large_blob_data(struct git_istream *st, struct hashfile *f,\n \t\t\t\t\t   const struct object_id *oid)\n {\n \tgit_zstream stream;\n \tunsigned char ibuf[1024 * 16];\n \tunsigned char obuf[1024 * 16];\n-\tunsigned long olen = 0;\n+\tsize_t olen = 0;\n \n \tgit_deflate_init(&stream, pack_compression_level);\n \n@@ -242,7 +242,7 @@ static int check_pack_inflate(struct packed_git *p,\n \t\tstruct pack_window **w_curs,\n \t\toff_t offset,\n \t\toff_t len,\n-\t\tunsigned long expect)\n+\t\tsize_t expect)\n {\n \tgit_zstream stream;\n \tunsigned char fakebuf[4096], *in;\n@@ -284,10 +284,10 @@ static void copy_pack_data(struct hashfile *f,\n }\n \n /* Return 0 if we will bust the pack-size limit */\n-static unsigned long write_no_reuse_object(struct hashfile *f, struct object_entry *entry,\n-\t\t\t\t\t   unsigned long limit, int usable_delta)\n+static size_t write_no_reuse_object(struct hashfile *f, struct object_entry *entry,\n+\t\t\t\t\t   size_t limit, int usable_delta)\n {\n-\tunsigned long size, datalen;\n+\tsize_t size, datalen;\n \tunsigned char header[MAX_PACK_OBJECT_HEADER],\n \t\t      dheader[MAX_PACK_OBJECT_HEADER];\n \tunsigned hdrlen;\n@@ -398,7 +398,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent\n \n /* Return 0 if we will bust the pack-size limit */\n static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,\n-\t\t\t\tunsigned long limit, int usable_delta)\n+\t\t\t\tsize_t limit, int usable_delta)\n {\n \tstruct packed_git *p = IN_PACK(entry);\n \tstruct pack_window *w_curs = NULL;\n@@ -410,7 +410,7 @@ static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,\n \t\t      dheader[MAX_PACK_OBJECT_HEADER];\n \tunsigned hdrlen;\n \tconst unsigned hashsz = the_hash_algo->rawsz;\n-\tunsigned long entry_size = SIZE(entry);\n+\tsize_t entry_size = SIZE(entry);\n \n \tif (DELTA(entry))\n \t\ttype = (allow_ofs_delta && DELTA(entry)->idx.offset) ?\n@@ -481,7 +481,7 @@ static off_t write_object(struct hashfile *f,\n \t\t\t  struct object_entry *entry,\n \t\t\t  off_t write_offset)\n {\n-\tunsigned long limit;\n+\tsize_t limit;\n \toff_t len;\n \tint usable_delta, to_reuse;\n \n@@ -1212,7 +1212,7 @@ struct pbase_tree_cache {\n \tint ref;\n \tint temporary;\n \tvoid *tree_data;\n-\tunsigned long tree_size;\n+\tsize_t tree_size;\n };\n \n static struct pbase_tree_cache *(pbase_tree_cache[256]);\n@@ -1239,7 +1239,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n {\n \tstruct pbase_tree_cache *ent, *nent;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tint neigh;\n \tint my_ix = pbase_tree_cache_ix(oid);\n@@ -1422,7 +1422,7 @@ static void add_preferred_base(struct object_id *oid)\n {\n \tstruct pbase_tree *it;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_id tree_oid;\n \n \tif (window <= num_preferred_base++)\n@@ -1526,7 +1526,7 @@ static int can_reuse_delta(const unsigned char *base_sha1,\n \n static void check_object(struct object_entry *entry)\n {\n-\tunsigned long canonical_size;\n+\tsize_t canonical_size;\n \n \tif (IN_PACK(entry)) {\n \t\tstruct packed_git *p = IN_PACK(entry);\n@@ -1538,7 +1538,7 @@ static void check_object(struct object_entry *entry)\n \t\toff_t ofs;\n \t\tunsigned char *buf, c;\n \t\tenum object_type type;\n-\t\tunsigned long in_pack_size;\n+\t\tsize_t in_pack_size;\n \n \t\tbuf = use_pack(p, &w_curs, entry->in_pack_offset, &avail);\n \n@@ -1704,7 +1704,7 @@ static void drop_reused_delta(struct object_entry *entry)\n \tunsigned *idx = &to_pack.objects[entry->delta_idx - 1].delta_child_idx;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \n \twhile (*idx) {\n \t\tstruct object_entry *oe = &to_pack.objects[*idx - 1];\n@@ -1941,8 +1941,8 @@ struct unpacked {\n \tunsigned depth;\n };\n \n-static int delta_cacheable(unsigned long src_size, unsigned long trg_size,\n-\t\t\t   unsigned long delta_size)\n+static int delta_cacheable(size_t src_size, size_t trg_size,\n+\t\t\t   size_t delta_size)\n {\n \tif (max_delta_cache_size && delta_cache_size + delta_size > max_delta_cache_size)\n \t\treturn 0;\n@@ -1987,14 +1987,14 @@ static pthread_mutex_t progress_mutex;\n  * reconstruction (so non-deltas are true object sizes, but deltas\n  * return the size of the delta data).\n  */\n-unsigned long oe_get_size_slow(struct packing_data *pack,\n+size_t oe_get_size_slow(struct packing_data *pack,\n \t\t\t       const struct object_entry *e)\n {\n \tstruct packed_git *p;\n \tstruct pack_window *w_curs;\n \tunsigned char *buf;\n \tenum object_type type;\n-\tunsigned long used, size;\n+\tsize_t used, size;\n \tsize_t avail;\n \n \tif (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {\n@@ -2024,11 +2024,11 @@ unsigned long oe_get_size_slow(struct packing_data *pack,\n }\n \n static int try_delta(struct unpacked *trg, struct unpacked *src,\n-\t\t     unsigned max_depth, unsigned long *mem_usage)\n+\t\t     unsigned max_depth, size_t *mem_usage)\n {\n \tstruct object_entry *trg_entry = trg->entry;\n \tstruct object_entry *src_entry = src->entry;\n-\tunsigned long trg_size, src_size, delta_size, sizediff, max_size, sz;\n+\tsize_t trg_size, src_size, delta_size, sizediff, max_size, sz;\n \tunsigned ref_depth;\n \tenum object_type type;\n \tvoid *delta_buf;\n@@ -2188,9 +2188,9 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)\n \treturn m;\n }\n \n-static unsigned long free_unpacked(struct unpacked *n)\n+static size_t free_unpacked(struct unpacked *n)\n {\n-\tunsigned long freed_mem = sizeof_delta_index(n->index);\n+\tsize_t freed_mem = sizeof_delta_index(n->index);\n \tfree_delta_index(n->index);\n \tn->index = NULL;\n \tif (n->data) {\n@@ -2207,7 +2207,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,\n {\n \tuint32_t i, idx = 0, count = 0;\n \tstruct unpacked *array;\n-\tunsigned long mem_usage = 0;\n+\tsize_t mem_usage = 0;\n \n \tarray = xcalloc(window, sizeof(struct unpacked));\n \n@@ -2290,7 +2290,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,\n \t\t * between writes at that moment.\n \t\t */\n \t\tif (entry->delta_data && !pack_to_stdout) {\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \n \t\t\tsize = do_compress(&entry->delta_data, DELTA_SIZE(entry));\n \t\t\tif (size < (1U << OE_Z_DELTA_BITS)) {\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 7868026ade..babbd4ce0c 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -82,7 +82,7 @@ static int tree_is_complete(const struct object_id *oid)\n \n \tif (!tree->buffer) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tvoid *data = repo_read_object_file(the_repository, oid, &type,\n \t\t\t\t\t\t   &size);\n \t\tif (!data) {\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 1fad5f9502..b0def39a17 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -439,7 +439,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle)\n \tstruct commit *commit;\n \tstruct strbuf buf = STRBUF_INIT;\n \tconst char *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tif (get_oid(old_ref, &old_oid) < 0)\n \t\treturn error(_(\"not a valid object name: '%s'\"), old_ref);\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 1011e17234..b1fe2f46af 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -165,7 +165,7 @@ static int git_tag_config(const char *var, const char *value, void *cb)\n \n static void write_tag_body(int fd, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf, *sp;\n \n@@ -286,7 +286,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \tenum object_type type;\n \tstruct commit *c;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint subject_len = 0;\n \tconst char *subject_start;\n \ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex df4a47bae7..289839ad01 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -7,7 +7,7 @@ static char *create_temp_file(struct object_id *oid)\n \tstatic char path[50];\n \tvoid *buf;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tint fd;\n \n \tbuf = repo_read_object_file(the_repository, oid, &type, &size);\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex e27b21e9c2..7f2cac3037 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -32,7 +32,7 @@ static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;\n  */\n struct obj_buffer {\n \tchar *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n };\n \n static struct decoration obj_decorate;\n@@ -42,7 +42,7 @@ static struct obj_buffer *lookup_object_buffer(struct object *base)\n \treturn lookup_decoration(&obj_decorate, base);\n }\n \n-static void add_object_buffer(struct object *object, char *buffer, unsigned long size)\n+static void add_object_buffer(struct object *object, char *buffer, size_t size)\n {\n \tstruct obj_buffer *obj;\n \tobj = xcalloc(1, sizeof(struct obj_buffer));\n@@ -94,7 +94,7 @@ static void use(int bytes)\n \t\tdie(_(\"pack exceeds maximum allowed size\"));\n }\n \n-static void *get_data(unsigned long size)\n+static void *get_data(size_t size)\n {\n \tgit_zstream stream;\n \tvoid *buf = xmallocz(size);\n@@ -131,7 +131,7 @@ struct delta_info {\n \tstruct object_id base_oid;\n \tunsigned nr;\n \toff_t base_offset;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *delta;\n \tstruct delta_info *next;\n };\n@@ -140,7 +140,7 @@ static struct delta_info *delta_list;\n \n static void add_delta_to_list(unsigned nr, const struct object_id *base_oid,\n \t\t\t      off_t base_offset,\n-\t\t\t      void *delta, unsigned long size)\n+\t\t\t      void *delta, size_t size)\n {\n \tstruct delta_info *info = xmalloc(sizeof(*info));\n \n@@ -199,7 +199,7 @@ static int check_object(struct object *obj, int type, void *data, struct fsck_op\n \t\tdie(\"object type mismatch\");\n \n \tif (!(obj->flags & FLAG_OPEN)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n@@ -229,7 +229,7 @@ static void write_rest(void)\n }\n \n static void added_object(unsigned nr, enum object_type type,\n-\t\t\t void *data, unsigned long size);\n+\t\t\t void *data, size_t size);\n \n /*\n  * Write out nr-th object from the list, now we know the contents\n@@ -237,7 +237,7 @@ static void added_object(unsigned nr, enum object_type type,\n  * to be checked at the end.\n  */\n static void write_object(unsigned nr, enum object_type type,\n-\t\t\t void *buf, unsigned long size)\n+\t\t\t void *buf, size_t size)\n {\n \tif (!strict) {\n \t\tif (write_object_file(buf, size, type_name(type),\n@@ -277,11 +277,11 @@ static void write_object(unsigned nr, enum object_type type,\n }\n \n static void resolve_delta(unsigned nr, enum object_type type,\n-\t\t\t  void *base, unsigned long base_size,\n-\t\t\t  void *delta, unsigned long delta_size)\n+\t\t\t  void *base, size_t base_size,\n+\t\t\t  void *delta, size_t delta_size)\n {\n \tvoid *result;\n-\tunsigned long result_size;\n+\tsize_t result_size;\n \n \tresult = patch_delta(base, base_size,\n \t\t\t     delta, delta_size,\n@@ -297,7 +297,7 @@ static void resolve_delta(unsigned nr, enum object_type type,\n  * resolve all the deltified objects that are based on it.\n  */\n static void added_object(unsigned nr, enum object_type type,\n-\t\t\t void *data, unsigned long size)\n+\t\t\t void *data, size_t size)\n {\n \tstruct delta_info **p = &delta_list;\n \tstruct delta_info *info;\n@@ -316,7 +316,7 @@ static void added_object(unsigned nr, enum object_type type,\n \t}\n }\n \n-static void unpack_non_delta_entry(enum object_type type, unsigned long size,\n+static void unpack_non_delta_entry(enum object_type type, size_t size,\n \t\t\t\t   unsigned nr)\n {\n \tvoid *buf = get_data(size);\n@@ -328,7 +328,7 @@ static void unpack_non_delta_entry(enum object_type type, unsigned long size,\n }\n \n static int resolve_against_held(unsigned nr, const struct object_id *base,\n-\t\t\t\tvoid *delta_data, unsigned long delta_size)\n+\t\t\t\tvoid *delta_data, size_t delta_size)\n {\n \tstruct object *obj;\n \tstruct obj_buffer *obj_buffer;\n@@ -343,11 +343,11 @@ static int resolve_against_held(unsigned nr, const struct object_id *base,\n \treturn 1;\n }\n \n-static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n+static void unpack_delta_entry(enum object_type type, size_t delta_size,\n \t\t\t       unsigned nr)\n {\n \tvoid *delta_data, *base;\n-\tunsigned long base_size;\n+\tsize_t base_size;\n \tstruct object_id base_oid;\n \n \tif (type == OBJ_REF_DELTA) {\n@@ -443,7 +443,8 @@ static void unpack_one(unsigned nr)\n {\n \tunsigned shift;\n \tunsigned char *pack;\n-\tunsigned long size, c;\n+\tunsigned long c;\n+\tsize_t size;\n \tenum object_type type;\n \n \tobj_list[nr].offset = consumed_bytes;\ndiff --git a/builtin/verify-commit.c b/builtin/verify-commit.c\nindex 3caa6cf8e9..1dc8104f3a 100644\n--- a/builtin/verify-commit.c\n+++ b/builtin/verify-commit.c\n@@ -21,7 +21,7 @@ static const char * const verify_commit_usage[] = {\n \t\tNULL\n };\n \n-static int run_gpg_verify(const struct object_id *oid, const char *buf, unsigned long size, unsigned flags)\n+static int run_gpg_verify(const struct object_id *oid, const char *buf, size_t size, unsigned flags)\n {\n \tstruct signature_check signature_check;\n \tint ret;\n@@ -41,7 +41,7 @@ static int verify_commit(const char *name, unsigned flags)\n \tenum object_type type;\n \tstruct object_id oid;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tif (get_oid(name, &oid))\ndiff --git a/bundle.c b/bundle.c\nindex 1babd65ea9..b24dcf6279 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -217,7 +217,7 @@ int list_bundle_refs(struct bundle_header *header, int argc, const char **argv)\n \n static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = NULL, *line, *lineend;\n \ttimestamp_t date;\ndiff --git a/cache.h b/cache.h\nindex cb53380211..aba5c0034c 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -784,7 +784,7 @@ extern int chmod_index_entry(struct index_state *, struct cache_entry *ce, char\n extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);\n extern void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);\n extern int index_name_is_other(const struct index_state *, const char *, int);\n-extern void *read_blob_data_from_index(const struct index_state *, const char *, unsigned long *);\n+extern void *read_blob_data_from_index(const struct index_state *, const char *, size_t *);\n \n /* do stat comparison even if CE_VALID is true */\n #define CE_MATCH_IGNORE_VALID\t\t01\n@@ -1281,10 +1281,10 @@ extern char *xdg_cache_home(const char *filename);\n \n extern int git_open_cloexec(const char *name, int flags);\n #define git_open(name) git_open_cloexec(name, O_RDONLY)\n-extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);\n-extern int parse_sha1_header(const char *hdr, unsigned long *sizep);\n+extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, size_t mapsize, void *buffer, size_t bufsiz);\n+extern int parse_sha1_header(const char *hdr, size_t *sizep);\n \n-extern int check_object_signature(const struct object_id *oid, void *buf, unsigned long size, const char *type);\n+extern int check_object_signature(const struct object_id *oid, void *buf, size_t size, const char *type);\n \n extern int finalize_object_file(const char *tmpfile, const char *filename);\n \n@@ -1446,7 +1446,7 @@ extern int cache_name_stage_compare(const char *name1, int len1, int stage1, con\n \n extern void *read_object_with_reference(const struct object_id *oid,\n \t\t\t\t\tconst char *required_type,\n-\t\t\t\t\tunsigned long *size,\n+\t\t\t\t\tsize_t *size,\n \t\t\t\t\tstruct object_id *oid_ret);\n \n extern struct object *peel_to_type(const char *name, int namelen,\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 1f6cde4d43..64d5c3a22b 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -287,7 +287,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,\n \n static char *grab_blob(struct repository *r,\n \t\t       const struct object_id *oid, unsigned int mode,\n-\t\t       unsigned long *size, struct userdiff_driver *textconv,\n+\t\t       size_t *size, struct userdiff_driver *textconv,\n \t\t       const char *path)\n {\n \tchar *blob;\n@@ -379,7 +379,7 @@ static void consume_hunk(void *state_,\n \tstate->sline[state->nb-1].p_lno[state->n] = state->ob;\n }\n \n-static void consume_line(void *state_, char *line, unsigned long len)\n+static void consume_line(void *state_, char *line, size_t len)\n {\n \tstruct combine_diff_state *state = state_;\n \tif (!state->lost_bucket)\n@@ -409,7 +409,7 @@ static void combine_diff(struct repository *r,\n \txdemitconf_t xecfg;\n \tmmfile_t parent_file;\n \tstruct combine_diff_state state;\n-\tunsigned long sz;\n+\tsize_t sz;\n \n \tif (result_deleted)\n \t\treturn; /* result deleted */\n@@ -979,7 +979,8 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\t    struct rev_info *rev)\n {\n \tstruct diff_options *opt = &rev->diffopt;\n-\tunsigned long result_size, cnt, lno;\n+\tunsigned long cnt, lno;\n+\tsize_t result_size;\n \tint result_deleted = 0;\n \tchar *result, *cp;\n \tstruct sline *sline; /* survived lines */\n@@ -1097,7 +1098,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\tis_binary = buffer_is_binary(result, result_size);\n \t\tfor (i = 0; !is_binary && i < num_parent; i++) {\n \t\t\tchar *buf;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\tbuf = grab_blob(opt->repo,\n \t\t\t\t\t&elem->parent[i].oid,\n \t\t\t\t\telem->parent[i].mode,\ndiff --git a/commit.c b/commit.c\nindex c0c1d70b67..f1aed09134 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -260,7 +260,7 @@ int unregister_shallow(const struct object_id *oid)\n \n struct commit_buffer {\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n };\n define_commit_slab(buffer_slab, struct commit_buffer);\n \n@@ -277,7 +277,7 @@ void free_commit_buffer_slab(struct buffer_slab *bs)\n \tfree(bs);\n }\n \n-void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer, unsigned long size)\n+void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer, size_t size)\n {\n \tstruct commit_buffer *v = buffer_slab_at(\n \t\tr->parsed_objects->buffer_slab, commit);\n@@ -285,7 +285,7 @@ void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer\n \tv->size = size;\n }\n \n-const void *get_cached_commit_buffer(struct repository *r, const struct commit *commit, unsigned long *sizep)\n+const void *get_cached_commit_buffer(struct repository *r, const struct commit *commit, size_t *sizep)\n {\n \tstruct commit_buffer *v = buffer_slab_peek(\n \t\tr->parsed_objects->buffer_slab, commit);\n@@ -301,12 +301,12 @@ const void *get_cached_commit_buffer(struct repository *r, const struct commit *\n \n const void *repo_get_commit_buffer(struct repository *r,\n \t\t\t\t   const struct commit *commit,\n-\t\t\t\t   unsigned long *sizep)\n+\t\t\t\t   size_t *sizep)\n {\n \tconst void *ret = get_cached_commit_buffer(r, commit, sizep);\n \tif (!ret) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tret = repo_read_object_file(r, &commit->object.oid, &type, &size);\n \t\tif (!ret)\n \t\t\tdie(\"cannot read commit object %s\",\n@@ -366,7 +366,7 @@ void release_commit_memory(struct parsed_object_pool *pool, struct commit *c)\n \tc->object.parsed = 0;\n }\n \n-const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n+const void *detach_commit_buffer(struct commit *commit, size_t *sizep)\n {\n \tstruct commit_buffer *v = buffer_slab_peek(\n \t\tthe_repository->parsed_objects->buffer_slab, commit);\n@@ -386,7 +386,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n \treturn ret;\n }\n \n-int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph)\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, size_t size, int check_graph)\n {\n \tconst char *tail = buffer;\n \tconst char *bufptr = buffer;\n@@ -455,7 +455,7 @@ int repo_parse_commit_internal(struct repository *r,\n {\n \tenum object_type type;\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tif (!item)\n@@ -976,7 +976,7 @@ int parse_signed_commit(const struct commit *commit,\n \t\t\tstruct strbuf *payload, struct strbuf *signature)\n {\n \n-\tunsigned long size;\n+\tsize_t size;\n \tconst char *buffer = get_commit_buffer(commit, &size);\n \tint in_signature, saw_signature = -1;\n \tconst char *line, *tail;\n@@ -1051,7 +1051,7 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header\n \tstruct merge_remote_desc *desc;\n \tstruct commit_extra_header *mergetag;\n \tchar *buf;\n-\tunsigned long size, len;\n+\tsize_t size, len;\n \tenum object_type type;\n \n \tdesc = merge_remote_util(parent);\n@@ -1159,7 +1159,7 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,\n \t\t\t\t\t\t      const char **exclude)\n {\n \tstruct commit_extra_header *extra = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \tconst char *buffer = get_commit_buffer(commit, &size);\n \textra = read_commit_extra_header_lines(buffer, size, exclude);\n \trepo_unuse_commit_buffer(the_repository, commit, buffer);\ndiff --git a/commit.h b/commit.h\nindex 42728c2906..bcf3227b85 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -79,7 +79,7 @@ struct commit *lookup_commit_reference_by_name(const char *name);\n  */\n struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);\n \n-int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph);\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, size_t size, int check_graph);\n int repo_parse_commit_internal(struct repository *r, struct commit *item,\n \t\t\t       int quiet_on_missing, int use_commit_graph);\n int repo_parse_commit_gently(struct repository *r,\n@@ -105,13 +105,13 @@ void free_commit_buffer_slab(struct buffer_slab *bs);\n  * Associate an object buffer with the commit. The ownership of the\n  * memory is handed over to the commit, and must be free()-able.\n  */\n-void set_commit_buffer(struct repository *r, struct commit *, void *buffer, unsigned long size);\n+void set_commit_buffer(struct repository *r, struct commit *, void *buffer, size_t size);\n \n /*\n  * Get any cached object buffer associated with the commit. Returns NULL\n  * if none. The resulting memory should not be freed.\n  */\n-const void *get_cached_commit_buffer(struct repository *, const struct commit *, unsigned long *size);\n+const void *get_cached_commit_buffer(struct repository *, const struct commit *, size_t *size);\n \n /*\n  * Get the commit's object contents, either from cache or by reading the object\n@@ -120,7 +120,7 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,\n  */\n const void *repo_get_commit_buffer(struct repository *r,\n \t\t\t\t   const struct commit *,\n-\t\t\t\t   unsigned long *size);\n+\t\t\t\t   size_t *size);\n #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS\n #define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s)\n #endif\n@@ -156,7 +156,7 @@ void release_commit_memory(struct parsed_object_pool *pool, struct commit *c);\n  * Disassociate any cached object buffer from the commit, but do not free it.\n  * The buffer (or NULL, if none) is returned.\n  */\n-const void *detach_commit_buffer(struct commit *, unsigned long *sizep);\n+const void *detach_commit_buffer(struct commit *, size_t *sizep);\n \n /* Find beginning and length of commit subject. */\n int find_commit_subject(const char *commit_buffer, const char **subject);\ndiff --git a/config.c b/config.c\nindex 2032a051e8..1178293d30 100644\n--- a/config.c\n+++ b/config.c\n@@ -1594,7 +1594,7 @@ int git_config_from_blob_oid(config_fn_t fn,\n {\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tbuf = repo_read_object_file(the_repository, oid, &type, &size);\ndiff --git a/convert.c b/convert.c\nindex e0848226d2..f66b23c2bf 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -43,9 +43,9 @@ struct text_stat {\n \tunsigned printable, nonprintable;\n };\n \n-static void gather_stats(const char *buf, unsigned long size, struct text_stat *stats)\n+static void gather_stats(const char *buf, size_t size, struct text_stat *stats)\n {\n-\tunsigned long i;\n+\tsize_t i;\n \n \tmemset(stats, 0, sizeof(*stats));\n \n@@ -92,7 +92,7 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *\n  * The same heuristics as diff.c::mmfile_is_binary()\n  * We treat files with bare CR as binary\n  */\n-static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n+static int convert_is_binary(size_t size, const struct text_stat *stats)\n {\n \tif (stats->lonecr)\n \t\treturn 1;\n@@ -103,7 +103,7 @@ static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n \treturn 0;\n }\n \n-static unsigned int gather_convert_stats(const char *data, unsigned long size)\n+static unsigned int gather_convert_stats(const char *data, size_t size)\n {\n \tstruct text_stat stats;\n \tint ret = 0;\n@@ -120,7 +120,7 @@ static unsigned int gather_convert_stats(const char *data, unsigned long size)\n \treturn ret;\n }\n \n-static const char *gather_convert_stats_ascii(const char *data, unsigned long size)\n+static const char *gather_convert_stats_ascii(const char *data, size_t size)\n {\n \tunsigned int convert_stats = gather_convert_stats(data, size);\n \n@@ -142,7 +142,7 @@ const char *get_cached_convert_stats_ascii(const struct index_state *istate,\n \t\t\t\t\t   const char *path)\n {\n \tconst char *ret;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tvoid *data = read_blob_data_from_index(istate, path, &sz);\n \tret = gather_convert_stats_ascii(data, sz);\n \tfree(data);\n@@ -224,7 +224,7 @@ static void check_global_conv_flags_eol(const char *path, enum crlf_action crlf_\n \n static int has_crlf_in_index(const struct index_state *istate, const char *path)\n {\n-\tunsigned long sz;\n+\tsize_t sz;\n \tvoid *data;\n \tconst char *crp;\n \tint has_crlf = 0;\n@@ -630,7 +630,7 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \n struct filter_params {\n \tconst char *src;\n-\tunsigned long size;\n+\tsize_t size;\n \tint fd;\n \tconst char *cmd;\n \tconst char *path;\n@@ -1048,7 +1048,7 @@ static int read_convert_config(const char *var, const char *value, void *cb)\n \treturn 0;\n }\n \n-static int count_ident(const char *cp, unsigned long size)\n+static int count_ident(const char *cp, size_t size)\n {\n \t/*\n \t * \"$Id: 0000000000000000000000000000000000000000 $\" <=> \"$Id$\"\ndiff --git a/delta.h b/delta.h\nindex 9b67531dfa..541171230c 100644\n--- a/delta.h\n+++ b/delta.h\n@@ -42,8 +42,8 @@ extern unsigned long sizeof_delta_index(struct delta_index *index);\n  */\n extern void *\n create_delta(const struct delta_index *index,\n-\t     const void *buf, unsigned long bufsize,\n-\t     unsigned long *delta_size, unsigned long max_delta_size);\n+\t     const void *buf, size_t bufsize,\n+\t     size_t *delta_size, size_t max_delta_size);\n \n /*\n  * diff_delta: create a delta from source buffer to target buffer\n@@ -54,9 +54,9 @@ create_delta(const struct delta_index *index,\n  * updated with its size.  The returned buffer must be freed by the caller.\n  */\n static inline void *\n-diff_delta(const void *src_buf, unsigned long src_bufsize,\n-\t   const void *trg_buf, unsigned long trg_bufsize,\n-\t   unsigned long *delta_size, unsigned long max_delta_size)\n+diff_delta(const void *src_buf, size_t src_bufsize,\n+\t   const void *trg_buf, size_t trg_bufsize,\n+\t   size_t *delta_size, size_t max_delta_size)\n {\n \tstruct delta_index *index = create_delta_index(src_buf, src_bufsize);\n \tif (index) {\n@@ -75,9 +75,9 @@ diff_delta(const void *src_buf, unsigned long src_bufsize,\n  * *trg_bufsize is updated with its size.  On failure a NULL pointer is\n  * returned.  The returned buffer must be freed by the caller.\n  */\n-extern void *patch_delta(const void *src_buf, unsigned long src_size,\n-\t\t\t const void *delta_buf, unsigned long delta_size,\n-\t\t\t unsigned long *dst_size);\n+extern void *patch_delta(const void *src_buf, size_t src_size,\n+\t\t\t const void *delta_buf, size_t delta_size,\n+\t\t\t size_t *dst_size);\n \n /* the smallest possible delta size is 4 bytes */\n #define DELTA_SIZE_MIN\t4\n@@ -86,11 +86,11 @@ extern void *patch_delta(const void *src_buf, unsigned long src_size,\n  * This must be called twice on the delta data buffer, first to get the\n  * expected source buffer size, and again to get the target buffer size.\n  */\n-static inline unsigned long get_delta_hdr_size(const unsigned char **datap,\n+static inline size_t get_delta_hdr_size(const unsigned char **datap,\n \t\t\t\t\t       const unsigned char *top)\n {\n \tconst unsigned char *data = *datap;\n-\tunsigned long cmd, size = 0;\n+\tsize_t cmd, size = 0;\n \tint i = 0;\n \tdo {\n \t\tcmd = *data++;\ndiff --git a/diff-delta.c b/diff-delta.c\nindex e49643353b..072a5ca839 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -316,8 +316,8 @@ unsigned long sizeof_delta_index(struct delta_index *index)\n \n void *\n create_delta(const struct delta_index *index,\n-\t     const void *trg_buf, unsigned long trg_size,\n-\t     unsigned long *delta_size, unsigned long max_size)\n+\t     const void *trg_buf, size_t trg_size,\n+\t     size_t *delta_size, size_t max_size)\n {\n \tunsigned int i, val;\n \toff_t outpos, moff;\ndiff --git a/diff.c b/diff.c\nindex deb3697c16..12266586f3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2258,7 +2258,7 @@ static void find_lno(const char *line, struct emit_callback *ecbdata)\n \tecbdata->lno_in_postimage = strtol(p + 1, NULL, 10);\n }\n \n-static void fn_out_consume(void *priv, char *line, unsigned long len)\n+static void fn_out_consume(void *priv, char *line, size_t len)\n {\n \tstruct emit_callback *ecbdata = priv;\n \tconst char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);\n@@ -2461,7 +2461,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,\n \treturn x;\n }\n \n-static void diffstat_consume(void *priv, char *line, unsigned long len)\n+static void diffstat_consume(void *priv, char *line, size_t len)\n {\n \tstruct diffstat_t *diffstat = priv;\n \tstruct diffstat_file *x = diffstat->files[diffstat->nr - 1];\n@@ -3141,7 +3141,7 @@ static void checkdiff_consume_hunk(void *priv,\n \tdata->lineno = nb - 1;\n }\n \n-static void checkdiff_consume(void *priv, char *line, unsigned long len)\n+static void checkdiff_consume(void *priv, char *line, size_t len)\n {\n \tstruct checkdiff_t *data = priv;\n \tint marker_size = data->conflict_marker_size;\n@@ -3180,8 +3180,8 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)\n }\n \n static unsigned char *deflate_it(char *data,\n-\t\t\t\t unsigned long size,\n-\t\t\t\t unsigned long *result_size)\n+\t\t\t\t size_t size,\n+\t\t\t\t size_t *result_size)\n {\n \tint bound;\n \tunsigned char *deflated;\n@@ -3209,10 +3209,10 @@ static void emit_binary_diff_body(struct diff_options *o,\n \tvoid *delta;\n \tvoid *deflated;\n \tvoid *data;\n-\tunsigned long orig_size;\n-\tunsigned long delta_size;\n-\tunsigned long deflate_size;\n-\tunsigned long data_size;\n+\tsize_t orig_size;\n+\tsize_t delta_size;\n+\tsize_t deflate_size;\n+\tsize_t data_size;\n \n \t/* We could do deflated delta, or we could do just deflated two,\n \t * whichever is smaller.\n@@ -3998,7 +3998,7 @@ void diff_free_filespec_data(struct diff_filespec *s)\n static void prep_temp_blob(struct index_state *istate,\n \t\t\t   const char *path, struct diff_tempfile *temp,\n \t\t\t   void *blob,\n-\t\t\t   unsigned long size,\n+\t\t\t   size_t size,\n \t\t\t   const struct object_id *oid,\n \t\t\t   int mode)\n {\n@@ -5658,9 +5658,9 @@ struct patch_id_t {\n \tint patchlen;\n };\n \n-static int remove_space(char *line, int len)\n+static size_t remove_space(char *line, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tchar *dst = line;\n \tunsigned char c;\n \n@@ -5671,10 +5671,10 @@ static int remove_space(char *line, int len)\n \treturn dst - line;\n }\n \n-static void patch_id_consume(void *priv, char *line, unsigned long len)\n+static void patch_id_consume(void *priv, char *line, size_t len)\n {\n \tstruct patch_id_t *data = priv;\n-\tint new_len;\n+\tsize_t new_len;\n \n \tnew_len = remove_space(line, len);\n \n@@ -6435,7 +6435,7 @@ int textconv_object(struct repository *r,\n \t\t    const struct object_id *oid,\n \t\t    int oid_valid,\n \t\t    char **buf,\n-\t\t    unsigned long *buf_size)\n+\t\t    size_t *buf_size)\n {\n \tstruct diff_filespec *df;\n \tstruct userdiff_driver *textconv;\ndiff --git a/diff.h b/diff.h\nindex b512d0477a..9faeab924e 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -474,7 +474,7 @@ int textconv_object(struct repository *repo,\n \t\t    const char *path,\n \t\t    unsigned mode,\n \t\t    const struct object_id *oid, int oid_valid,\n-\t\t    char **buf, unsigned long *buf_size);\n+\t\t    char **buf, size_t *buf_size);\n \n int parse_rename_score(const char **cp_p);\n \ndiff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c\nindex ad939d2861..d78b510465 100644\n--- a/diffcore-pickaxe.c\n+++ b/diffcore-pickaxe.c\n@@ -19,7 +19,7 @@ struct diffgrep_cb {\n \tint hit;\n };\n \n-static void diffgrep_consume(void *priv, char *line, unsigned long len)\n+static void diffgrep_consume(void *priv, char *line, size_t len)\n {\n \tstruct diffgrep_cb *data = priv;\n \tregmatch_t regmatch;\n@@ -71,7 +71,7 @@ static int diff_grep(mmfile_t *one, mmfile_t *two,\n static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws)\n {\n \tunsigned int cnt;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tconst char *data;\n \n \tsz = mf->size;\ndiff --git a/diffcore.h b/diffcore.h\nindex b651061c0e..b47778dd36 100644\n--- a/diffcore.h\n+++ b/diffcore.h\n@@ -33,7 +33,7 @@ struct diff_filespec {\n \tchar *path;\n \tvoid *data;\n \tvoid *cnt_data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint count;               /* Reference count */\n \tint rename_used;         /* Count of rename users */\n \tunsigned short mode;\t /* file mode */\ndiff --git a/dir.c b/dir.c\nindex 34d0ecb469..893576f544 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -183,7 +183,7 @@ static size_t common_prefix_len(const struct pathspec *pathspec)\n  */\n char *common_prefix(const struct pathspec *pathspec)\n {\n-\tunsigned long len = common_prefix_len(pathspec);\n+\tsize_t len = common_prefix_len(pathspec);\n \n \treturn len ? xmemdupz(pathspec->items[0].match, len) : NULL;\n }\n@@ -239,7 +239,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,\n \t\t\tsize_t *size_out, char **data_out)\n {\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tchar *data;\n \n \t*size_out = 0;\n@@ -2826,7 +2826,7 @@ static void load_oid_stat(struct oid_stat *oid_stat, const unsigned char *data,\n \toid_stat->valid = 1;\n }\n \n-struct untracked_cache *read_untracked_extension(const void *data, unsigned long sz)\n+struct untracked_cache *read_untracked_extension(const void *data, size_t sz)\n {\n \tstruct untracked_cache *uc;\n \tstruct read_data rd;\ndiff --git a/dir.h b/dir.h\nindex e3ec26143d..7dc741cd41 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -360,7 +360,7 @@ void untracked_cache_remove_from_index(struct index_state *, const char *);\n void untracked_cache_add_to_index(struct index_state *, const char *);\n \n void free_untracked_cache(struct untracked_cache *);\n-struct untracked_cache *read_untracked_extension(const void *data, unsigned long sz);\n+struct untracked_cache *read_untracked_extension(const void *data, size_t sz);\n void write_untracked_extension(struct strbuf *out, struct untracked_cache *untracked);\n void add_untracked_cache(struct index_state *istate);\n void remove_untracked_cache(struct index_state *istate);\ndiff --git a/entry.c b/entry.c\nindex ee87c355b1..4f4ea27587 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -83,7 +83,7 @@ static int create_file(const char *path, unsigned int mode)\n \treturn open(path, O_WRONLY | O_CREAT | O_EXCL, mode);\n }\n \n-static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size)\n+static void *read_blob_entry(const struct cache_entry *ce, size_t *size)\n {\n \tenum object_type type;\n \tvoid *blob_data = repo_read_object_file(the_repository, &ce->oid,\n@@ -260,7 +260,7 @@ static int write_entry(struct cache_entry *ce,\n \tint fd, ret, fstat_done = 0;\n \tchar *new_blob;\n \tstruct strbuf buf = STRBUF_INIT;\n-\tunsigned long size;\n+\tsize_t size;\n \tssize_t wrote;\n \tsize_t newsize = 0;\n \tstruct stat st;\ndiff --git a/fast-import.c b/fast-import.c\nindex 5d4a6f1b19..c8f7f0cedd 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -895,7 +895,7 @@ static int store_object(\n \tstruct object_entry *e;\n \tunsigned char hdr[96];\n \tstruct object_id oid;\n-\tunsigned long hdrlen, deltalen;\n+\tsize_t hdrlen, deltalen;\n \tgit_hash_ctx c;\n \tgit_zstream s;\n \n@@ -1036,7 +1036,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)\n \tunsigned char *out_buf = xmalloc(out_sz);\n \tstruct object_entry *e;\n \tstruct object_id oid;\n-\tunsigned long hdrlen;\n+\tsize_t hdrlen;\n \toff_t offset;\n \tgit_hash_ctx c;\n \tgit_zstream s;\n@@ -1154,7 +1154,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)\n  */\n static void *gfi_unpack_entry(\n \tstruct object_entry *oe,\n-\tunsigned long *sizep)\n+\tsize_t *sizep)\n {\n \tenum object_type type;\n \tstruct packed_git *p = all_packs[oe->pack_id];\n@@ -1200,7 +1200,7 @@ static void load_tree(struct tree_entry *root)\n \tstruct object_id *oid = &root->versions[1].oid;\n \tstruct object_entry *myoe;\n \tstruct tree_content *t;\n-\tunsigned long size;\n+\tsize_t size;\n \tchar *buf;\n \tconst char *c;\n \n@@ -1873,7 +1873,7 @@ static int validate_raw_date(const char *src, struct strbuf *result)\n {\n \tconst char *orig_src = src;\n \tchar *endp;\n-\tunsigned long num;\n+\tsize_t num;\n \n \terrno = 0;\n \n@@ -2400,7 +2400,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", commit_mark);\n \t\toidcpy(&commit_oid, &commit_oe->idx.oid);\n \t} else if (!get_oid(p, &commit_oid)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf = read_object_with_reference(&commit_oid,\n \t\t\t\t\t\t       commit_type, &size,\n \t\t\t\t\t\t       &commit_oid);\n@@ -2453,7 +2453,7 @@ static void file_change_deleteall(struct branch *b)\n \tb->num_notes = 0;\n }\n \n-static void parse_from_commit(struct branch *b, char *buf, unsigned long size)\n+static void parse_from_commit(struct branch *b, char *buf, size_t size)\n {\n \tif (!buf || size < GIT_SHA1_HEXSZ + 6)\n \t\tdie(\"Not a valid commit: %s\", oid_to_hex(&b->oid));\n@@ -2470,7 +2470,7 @@ static void parse_from_existing(struct branch *b)\n \t\toidclr(&b->branch_tree.versions[0].oid);\n \t\toidclr(&b->branch_tree.versions[1].oid);\n \t} else {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf;\n \n \t\tbuf = read_object_with_reference(&b->oid, commit_type, &size,\n@@ -2507,7 +2507,7 @@ static int parse_from(struct branch *b)\n \t\tif (!oideq(&b->oid, &oe->idx.oid)) {\n \t\t\toidcpy(&b->oid, &oe->idx.oid);\n \t\t\tif (oe->pack_id != MAX_PACK_ID) {\n-\t\t\t\tunsigned long size;\n+\t\t\t\tsize_t size;\n \t\t\t\tchar *buf = gfi_unpack_entry(oe, &size);\n \t\t\t\tparse_from_commit(b, buf, size);\n \t\t\t\tfree(buf);\n@@ -2550,7 +2550,7 @@ static struct hash_list *parse_merge(unsigned int *count)\n \t\t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", idnum);\n \t\t\toidcpy(&n->oid, &oe->idx.oid);\n \t\t} else if (!get_oid(from, &n->oid)) {\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\tchar *buf = read_object_with_reference(&n->oid,\n \t\t\t\t\t\t\t       commit_type,\n \t\t\t\t\t\t\t       &size, &n->oid);\n@@ -2776,7 +2776,7 @@ static void parse_reset_branch(const char *arg)\n \t\tunread_command_buf = 1;\n }\n \n-static void cat_blob_write(const char *buf, unsigned long size)\n+static void cat_blob_write(const char *buf, size_t size)\n {\n \tif (write_in_full(cat_blob_fd, buf, size) < 0)\n \t\tdie_errno(\"Write to frontend failed\");\n@@ -2785,7 +2785,7 @@ static void cat_blob_write(const char *buf, unsigned long size)\n static void cat_blob(struct object_entry *oe, struct object_id *oid)\n {\n \tstruct strbuf line = STRBUF_INIT;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type = 0;\n \tchar *buf;\n \n@@ -2869,7 +2869,7 @@ static void parse_cat_blob(const char *p)\n static struct object_entry *dereference(struct object_entry *oe,\n \t\t\t\t\tstruct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tchar *buf = NULL;\n \tif (!oe) {\n \t\tenum object_type type = oid_object_info(the_repository, oid,\ndiff --git a/fsck.c b/fsck.c\nindex a0006dfe5c..b6d4291546 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -850,7 +850,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,\n }\n \n static int fsck_commit(struct commit *commit, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tconst char *buffer = data ?  data : get_commit_buffer(commit, &size);\n \tint ret = fsck_commit_buffer(commit, buffer, size, options);\n@@ -860,7 +860,7 @@ static int fsck_commit(struct commit *commit, const char *data,\n }\n \n static int fsck_tag_buffer(struct tag *tag, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tstruct object_id oid;\n \tint ret = 0;\n@@ -956,7 +956,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,\n }\n \n static int fsck_tag(struct tag *tag, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tstruct object *tagged = tag->tagged;\n \n@@ -1007,7 +1007,7 @@ static int fsck_gitmodules_fn(const char *var, const char *value, void *vdata)\n }\n \n static int fsck_blob(struct blob *blob, const char *buf,\n-\t\t     unsigned long size, struct fsck_options *options)\n+\t\t     size_t size, struct fsck_options *options)\n {\n \tstruct fsck_gitmodules_data data;\n \tstruct config_options config_opts = { 0 };\n@@ -1043,7 +1043,7 @@ static int fsck_blob(struct blob *blob, const char *buf,\n \treturn data.ret;\n }\n \n-int fsck_object(struct object *obj, void *data, unsigned long size,\n+int fsck_object(struct object *obj, void *data, size_t size,\n \tstruct fsck_options *options)\n {\n \tif (!obj)\n@@ -1085,7 +1085,7 @@ int fsck_finish(struct fsck_options *options)\n \twhile ((oid = oidset_iter_next(&iter))) {\n \t\tstruct blob *blob;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf;\n \n \t\tif (oidset_contains(&gitmodules_done, oid))\ndiff --git a/fsck.h b/fsck.h\nindex b95595ae5f..939ccf856b 100644\n--- a/fsck.h\n+++ b/fsck.h\n@@ -53,7 +53,7 @@ struct fsck_options {\n  */\n int fsck_walk(struct object *obj, void *data, struct fsck_options *options);\n /* If NULL is passed for data, we assume the object is local and read it. */\n-int fsck_object(struct object *obj, void *data, unsigned long size,\n+int fsck_object(struct object *obj, void *data, size_t size,\n \tstruct fsck_options *options);\n \n /*\ndiff --git a/fuzz-pack-headers.c b/fuzz-pack-headers.c\nindex 99da1d0fd3..d04e264e23 100644\n--- a/fuzz-pack-headers.c\n+++ b/fuzz-pack-headers.c\n@@ -5,10 +5,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);\n int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)\n {\n \tenum object_type type;\n-\tunsigned long len;\n+\tsize_t len;\n \n \tunpack_object_header_buffer((const unsigned char *)data,\n-\t\t\t\t    (unsigned long)size, &type, &len);\n+\t\t\t\t    size, &type, &len);\n \n \treturn 0;\n }\ndiff --git a/grep.h b/grep.h\nindex fb04893721..5765213f4b 100644\n--- a/grep.h\n+++ b/grep.h\n@@ -209,7 +209,7 @@ struct grep_source {\n \tvoid *identifier;\n \n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tchar *path; /* for attribute lookups */\n \tstruct userdiff_driver *driver;\ndiff --git a/http-push.c b/http-push.c\nindex 42815c42d1..88c49d3c27 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -359,7 +359,7 @@ static void start_put(struct transfer_request *request)\n \tenum object_type type;\n \tchar hdr[50];\n \tvoid *unpacked;\n-\tunsigned long len;\n+\tsize_t len;\n \tint hdrlen;\n \tssize_t size;\n \tgit_zstream stream;\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex a62624a1ce..ef31a7660e 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -154,7 +154,7 @@ static enum list_objects_filter_result filter_blobs_limit(\n \tvoid *filter_data_)\n {\n \tstruct filter_blobs_limit_data *filter_data = filter_data_;\n-\tunsigned long object_length;\n+\tsize_t object_length;\n \tenum object_type t;\n \n \tswitch (filter_situation) {\ndiff --git a/mailmap.c b/mailmap.c\nindex f3ffea0e17..088bea4325 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -217,7 +217,7 @@ static int read_mailmap_blob(struct string_list *map,\n {\n \tstruct object_id oid;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \n \tif (!name)\ndiff --git a/match-trees.c b/match-trees.c\nindex 8d9f43e9c9..62f53dae27 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -53,7 +53,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc,\n {\n \tvoid *buffer;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tbuffer = repo_read_object_file(the_repository, hash, &type, &size);\n \tif (!buffer)\n@@ -177,7 +177,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,\n \tchar *subpath;\n \tint toplen;\n \tchar *buf;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tstruct tree_desc desc;\n \tstruct object_id *rewrite_here;\n \tconst struct object_id *rewrite_with;\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex 757e338715..ba67132044 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -9,7 +9,7 @@\n static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n {\n \tvoid *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \n \tbuf = repo_read_object_file(the_repository, &obj->object.oid, &type,\n@@ -35,7 +35,7 @@ static void *three_way_filemerge(struct index_state *istate,\n \t\t\t\t mmfile_t *base,\n \t\t\t\t mmfile_t *our,\n \t\t\t\t mmfile_t *their,\n-\t\t\t\t unsigned long *size)\n+\t\t\t\t size_t *size)\n {\n \tint merge_status;\n \tmmbuffer_t res;\n@@ -58,7 +58,7 @@ static void *three_way_filemerge(struct index_state *istate,\n \n void *merge_blobs(struct index_state *istate, const char *path,\n \t\t  struct blob *base, struct blob *our,\n-\t\t  struct blob *their, unsigned long *size)\n+\t\t  struct blob *their, size_t *size)\n {\n \tvoid *res = NULL;\n \tmmfile_t f1, f2, common;\ndiff --git a/merge-blobs.h b/merge-blobs.h\nindex cc31038b80..7f37952b0e 100644\n--- a/merge-blobs.h\n+++ b/merge-blobs.h\n@@ -6,6 +6,6 @@ struct index_state;\n \n extern void *merge_blobs(struct index_state *, const char *,\n \t\t\t struct blob *, struct blob *,\n-\t\t\t struct blob *, unsigned long *);\n+\t\t\t struct blob *, size_t *);\n \n #endif /* MERGE_BLOBS_H */\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 4d8415ce52..e8484f5798 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -951,7 +951,7 @@ static int update_file_flags(struct merge_options *o,\n \tif (update_wd) {\n \t\tenum object_type type;\n \t\tvoid *buf;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \n \t\tif (S_ISGITLINK(mode)) {\n \t\t\t/*\n@@ -3005,7 +3005,7 @@ static int read_oid_strbuf(struct merge_options *o,\n {\n \tvoid *buf;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n \tif (!buf)\n \t\treturn err(o, _(\"cannot read object %s\"), oid_to_hex(oid));\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 59cdf0e1bb..2f1b08d135 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -77,7 +77,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \tconst struct object_id *value_oid;\n \tenum object_type type;\n \tchar *value;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tvalue_oid = get_note(&c->tree, key_oid);\n \tif (!value_oid)\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 659b4dcc69..e38b34aa1f 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -297,7 +297,7 @@ static void check_notes_merge_worktree(struct notes_merge_options *o)\n }\n \n static void write_buf_to_worktree(const struct object_id *obj,\n-\t\t\t\t  const char *buf, unsigned long size)\n+\t\t\t\t  const char *buf, size_t size)\n {\n \tint fd;\n \tchar *path = git_pathdup(NOTES_MERGE_WORKTREE \"/%s\", oid_to_hex(obj));\n@@ -326,7 +326,7 @@ static void write_note_to_worktree(const struct object_id *obj,\n \t\t\t\t   const struct object_id *note)\n {\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *buf = repo_read_object_file(the_repository, note, &type, &size);\n \n \tif (!buf)\ndiff --git a/notes.c b/notes.c\nindex 608e303438..9a03a72b56 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -791,7 +791,7 @@ int combine_notes_concatenate(struct object_id *cur_oid,\n \t\t\t      const struct object_id *new_oid)\n {\n \tchar *cur_msg = NULL, *new_msg = NULL, *buf;\n-\tunsigned long cur_len, new_len, buf_len;\n+\tsize_t cur_len, new_len, buf_len;\n \tenum object_type cur_type, new_type;\n \tint ret;\n \n@@ -854,7 +854,7 @@ static int string_list_add_note_lines(struct string_list *list,\n \t\t\t\t      const struct object_id *oid)\n {\n \tchar *data;\n-\tunsigned long len;\n+\tsize_t len;\n \tenum object_type t;\n \n \tif (is_null_oid(oid))\n@@ -1208,7 +1208,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n \tstatic const char utf8[] = \"utf-8\";\n \tconst struct object_id *oid;\n \tchar *msg, *msg_p;\n-\tunsigned long linelen, msglen;\n+\tsize_t linelen, msglen;\n \tenum object_type type;\n \n \tif (!t)\ndiff --git a/object-store.h b/object-store.h\nindex 8dceed0f31..886c81d9c8 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -155,16 +155,16 @@ void raw_object_store_clear(struct raw_object_store *o);\n  */\n const char *loose_object_path(struct repository *r, struct strbuf *buf, const unsigned char *sha1);\n \n-void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size);\n+void *map_sha1_file(struct repository *r, const unsigned char *sha1, size_t *size);\n \n extern void *read_object_file_extended(struct repository *r,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       enum object_type *type,\n-\t\t\t\t       unsigned long *size, int lookup_replace);\n+\t\t\t\t       size_t *size, int lookup_replace);\n static inline void *repo_read_object_file(struct repository *r,\n \t\t\t\t\t  const struct object_id *oid,\n \t\t\t\t\t  enum object_type *type,\n-\t\t\t\t\t  unsigned long *size)\n+\t\t\t\t\t  size_t *size)\n {\n \treturn read_object_file_extended(r, oid, type, size, 1);\n }\n@@ -173,19 +173,19 @@ static inline void *repo_read_object_file(struct repository *r,\n #endif\n \n /* Read and unpack an object file into memory, write memory to an object file */\n-int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);\n+int oid_object_info(struct repository *r, const struct object_id *, size_t *);\n \n-extern int hash_object_file(const void *buf, unsigned long len,\n+extern int hash_object_file(const void *buf, size_t len,\n \t\t\t    const char *type, struct object_id *oid);\n \n-extern int write_object_file(const void *buf, unsigned long len,\n+extern int write_object_file(const void *buf, size_t len,\n \t\t\t     const char *type, struct object_id *oid);\n \n-extern int hash_object_file_literally(const void *buf, unsigned long len,\n+extern int hash_object_file_literally(const void *buf, size_t len,\n \t\t\t\t      const char *type, struct object_id *oid,\n \t\t\t\t      unsigned flags);\n \n-extern int pretend_object_file(void *, unsigned long, enum object_type,\n+extern int pretend_object_file(void *, size_t, enum object_type,\n \t\t\t       struct object_id *oid);\n \n extern int force_object_loose(const struct object_id *oid, time_t mtime);\n@@ -200,7 +200,7 @@ extern int force_object_loose(const struct object_id *oid, time_t mtime);\n int read_loose_object(const char *path,\n \t\t      const struct object_id *expected_oid,\n \t\t      enum object_type *type,\n-\t\t      unsigned long *size,\n+\t\t      size_t *size,\n \t\t      void **contents);\n \n /*\n@@ -242,7 +242,7 @@ extern void assert_oid_type(const struct object_id *oid, enum object_type expect\n struct object_info {\n \t/* Request */\n \tenum object_type *typep;\n-\tunsigned long *sizep;\n+\tsize_t *sizep;\n \toff_t *disk_sizep;\n \tunsigned char *delta_base_sha1;\n \tstruct strbuf *type_name;\ndiff --git a/object.c b/object.c\nindex c29a97a7e9..ad8c09c041 100644\n--- a/object.c\n+++ b/object.c\n@@ -186,7 +186,7 @@ struct object *lookup_unknown_object(const unsigned char *sha1)\n \treturn obj;\n }\n \n-struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)\n+struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, size_t size, void *buffer, int *eaten_p)\n {\n \tstruct object *obj;\n \t*eaten_p = 0;\n@@ -248,7 +248,7 @@ struct object *parse_object_or_die(const struct object_id *oid,\n \n struct object *parse_object(struct repository *r, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tint eaten;\n \tconst struct object_id *repl = lookup_replace_object(r, oid);\ndiff --git a/object.h b/object.h\nindex 796792cb32..b97a625882 100644\n--- a/object.h\n+++ b/object.h\n@@ -140,7 +140,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name\n  * parsing it.  eaten_p indicates if the object has a borrowed copy\n  * of buffer and the caller should not free() it.\n  */\n-struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);\n+struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, size_t size, void *buffer, int *eaten_p);\n \n /** Returns the object, with potentially excess memory allocated. **/\n struct object *lookup_unknown_object(const unsigned  char *sha1);\ndiff --git a/pack-check.c b/pack-check.c\nindex 4ff725a89c..b86a5e17b5 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -108,7 +108,7 @@ static int verify_packfile(struct repository *r,\n \tfor (i = 0; i < nr_objects; i++) {\n \t\tvoid *data;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\toff_t curpos;\n \t\tint data_valid;\n \ndiff --git a/pack-objects.h b/pack-objects.h\nindex 3fda9da83a..24937553bb 100644\n--- a/pack-objects.h\n+++ b/pack-objects.h\n@@ -320,9 +320,9 @@ static inline void oe_set_delta_sibling(struct packing_data *pack,\n \t\te->delta_sibling_idx = 0;\n }\n \n-unsigned long oe_get_size_slow(struct packing_data *pack,\n+size_t oe_get_size_slow(struct packing_data *pack,\n \t\t\t       const struct object_entry *e);\n-static inline unsigned long oe_size(struct packing_data *pack,\n+static inline size_t oe_size(struct packing_data *pack,\n \t\t\t\t    const struct object_entry *e)\n {\n \tif (e->size_valid)\n@@ -333,7 +333,7 @@ static inline unsigned long oe_size(struct packing_data *pack,\n \n static inline int oe_size_less_than(struct packing_data *pack,\n \t\t\t\t    const struct object_entry *lhs,\n-\t\t\t\t    unsigned long rhs)\n+\t\t\t\t    size_t rhs)\n {\n \tif (lhs->size_valid)\n \t\treturn lhs->size_ < rhs;\n@@ -344,7 +344,7 @@ static inline int oe_size_less_than(struct packing_data *pack,\n \n static inline int oe_size_greater_than(struct packing_data *pack,\n \t\t\t\t       const struct object_entry *lhs,\n-\t\t\t\t       unsigned long rhs)\n+\t\t\t\t       size_t rhs)\n {\n \tif (lhs->size_valid)\n \t\treturn lhs->size_ > rhs;\n@@ -355,7 +355,7 @@ static inline int oe_size_greater_than(struct packing_data *pack,\n \n static inline void oe_set_size(struct packing_data *pack,\n \t\t\t       struct object_entry *e,\n-\t\t\t       unsigned long size)\n+\t\t\t       size_t size)\n {\n \tif (size < pack->oe_size_limit) {\n \t\te->size_ = size;\n@@ -367,7 +367,7 @@ static inline void oe_set_size(struct packing_data *pack,\n \t}\n }\n \n-static inline unsigned long oe_delta_size(struct packing_data *pack,\n+static inline size_t oe_delta_size(struct packing_data *pack,\n \t\t\t\t\t  const struct object_entry *e)\n {\n \tif (e->delta_size_valid)\n@@ -386,7 +386,7 @@ static inline unsigned long oe_delta_size(struct packing_data *pack,\n \n static inline void oe_set_delta_size(struct packing_data *pack,\n \t\t\t\t     struct object_entry *e,\n-\t\t\t\t     unsigned long size)\n+\t\t\t\t     size_t size)\n {\n \tif (size < pack->oe_delta_size_limit) {\n \t\te->delta_size_ = size;\ndiff --git a/pack.h b/pack.h\nindex da99fdd1d2..6f61f83485 100644\n--- a/pack.h\n+++ b/pack.h\n@@ -77,7 +77,7 @@ struct pack_idx_entry {\n \n struct progress;\n /* Note, the data argument could be NULL if object type is blob */\n-typedef int (*verify_fn)(const struct object_id *, enum object_type, unsigned long, void*, int*);\n+typedef int (*verify_fn)(const struct object_id *, enum object_type, size_t, void*, int*);\n \n extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, const struct pack_idx_option *, const unsigned char *sha1);\n extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off_t offset, off_t len, unsigned int nr);\ndiff --git a/packfile.c b/packfile.c\nindex 373adbc8a6..672b6aca4a 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -163,8 +163,8 @@ int load_idx(const char *path, const unsigned int hashsz, void *idx_map,\n \t\t * variable sized table containing 8-byte entries\n \t\t * for offsets larger than 2^31.\n \t\t */\n-\t\tunsigned long min_size = 8 + 4*256 + nr*(hashsz + 4 + 4) + hashsz + hashsz;\n-\t\tunsigned long max_size = min_size;\n+\t\tsize_t min_size = 8 + 4*256 + nr*(hashsz + 4 + 4) + hashsz + hashsz;\n+\t\tsize_t max_size = min_size;\n \t\tif (nr)\n \t\t\tmax_size += (nr - 1)*8;\n \t\tif (idx_size < min_size || idx_size > max_size)\n@@ -1047,12 +1047,12 @@ struct list_head *get_packed_git_mru(struct repository *r)\n \treturn &r->objects->packed_git_mru;\n }\n \n-unsigned long unpack_object_header_buffer(const unsigned char *buf,\n-\t\tunsigned long len, enum object_type *type, unsigned long *sizep)\n+size_t unpack_object_header_buffer(const unsigned char *buf,\n+\t\tsize_t len, enum object_type *type, size_t *sizep)\n {\n \tunsigned shift;\n-\tunsigned long size, c;\n-\tunsigned long used = 0;\n+\tsize_t size, c;\n+\tsize_t used = 0;\n \n \tc = buf[used++];\n \t*type = (c >> 4) & 7;\n@@ -1072,7 +1072,7 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,\n \treturn used;\n }\n \n-unsigned long get_size_from_delta(struct packed_git *p,\n+size_t get_size_from_delta(struct packed_git *p,\n \t\t\t\t  struct pack_window **w_curs,\n \t\t\t\t  off_t curpos)\n {\n@@ -1114,11 +1114,11 @@ unsigned long get_size_from_delta(struct packed_git *p,\n int unpack_object_header(struct packed_git *p,\n \t\t\t struct pack_window **w_curs,\n \t\t\t off_t *curpos,\n-\t\t\t unsigned long *sizep)\n+\t\t\t size_t *sizep)\n {\n \tunsigned char *base;\n \tsize_t left;\n-\tunsigned long used;\n+\tsize_t used;\n \tenum object_type type;\n \n \t/* use_pack() assures us we have [base, base + 20) available\n@@ -1269,7 +1269,7 @@ static enum object_type packed_to_object_type(struct repository *r,\n \n \twhile (type == OBJ_OFS_DELTA || type == OBJ_REF_DELTA) {\n \t\toff_t base_offset;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\t/* Push the object we're going to leave behind */\n \t\tif (poi_stack_nr >= poi_stack_alloc && poi_stack == small_poi_stack) {\n \t\t\tpoi_stack_alloc = alloc_nr(poi_stack_nr);\n@@ -1339,7 +1339,7 @@ struct delta_base_cache_entry {\n \tstruct delta_base_cache_key key;\n \tstruct list_head lru;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n };\n \n@@ -1404,7 +1404,7 @@ static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)\n }\n \n static void *cache_or_unpack_entry(struct repository *r, struct packed_git *p,\n-\t\t\t\t   off_t base_offset, unsigned long *base_size,\n+\t\t\t\t   off_t base_offset, size_t *base_size,\n \t\t\t\t   enum object_type *type)\n {\n \tstruct delta_base_cache_entry *ent;\n@@ -1437,7 +1437,7 @@ void clear_delta_base_cache(void)\n }\n \n static void add_delta_base_cache(struct packed_git *p, off_t base_offset,\n-\tvoid *base, unsigned long base_size, enum object_type type)\n+\tvoid *base, size_t base_size, enum object_type type)\n {\n \tstruct delta_base_cache_entry *ent = xmalloc(sizeof(*ent));\n \tstruct list_head *lru, *tmp;\n@@ -1469,7 +1469,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,\n \t\t       off_t obj_offset, struct object_info *oi)\n {\n \tstruct pack_window *w_curs = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t curpos = obj_offset;\n \tenum object_type type;\n \n@@ -1554,7 +1554,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,\n static void *unpack_compressed_entry(struct packed_git *p,\n \t\t\t\t    struct pack_window **w_curs,\n \t\t\t\t    off_t curpos,\n-\t\t\t\t    unsigned long size)\n+\t\t\t\t    size_t size)\n {\n \tint st;\n \tgit_zstream stream;\n@@ -1601,13 +1601,13 @@ int do_check_packed_object_crc;\n struct unpack_entry_stack_ent {\n \toff_t obj_offset;\n \toff_t curpos;\n-\tunsigned long size;\n+\tsize_t size;\n };\n \n static void *read_object(struct repository *r,\n \t\t\t const struct object_id *oid,\n \t\t\t enum object_type *type,\n-\t\t\t unsigned long *size)\n+\t\t\t size_t *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tvoid *content;\n@@ -1621,12 +1621,12 @@ static void *read_object(struct repository *r,\n }\n \n void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n-\t\t   enum object_type *final_type, unsigned long *final_size)\n+\t\t   enum object_type *final_type, size_t *final_size)\n {\n \tstruct pack_window *w_curs = NULL;\n \toff_t curpos = obj_offset;\n \tvoid *data = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tstruct unpack_entry_stack_ent small_delta_stack[UNPACK_ENTRY_STACK_PREALLOC];\n \tstruct unpack_entry_stack_ent *delta_stack = small_delta_stack;\n@@ -1726,7 +1726,7 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n \t\tvoid *delta_data;\n \t\tvoid *base = data;\n \t\tvoid *external_base = NULL;\n-\t\tunsigned long delta_size, base_size = size;\n+\t\tsize_t delta_size, base_size = size;\n \t\tint i;\n \n \t\tdata = NULL;\ndiff --git a/packfile.h b/packfile.h\nindex 7384b4a201..25459f7e96 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -131,10 +131,10 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);\n extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);\n \n extern int is_pack_valid(struct packed_git *);\n-extern void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object_type *, unsigned long *);\n-extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);\n-extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n-extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);\n+extern void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object_type *, size_t *);\n+extern size_t unpack_object_header_buffer(const unsigned char *buf, size_t len, enum object_type *type, size_t *sizep);\n+extern size_t get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n+extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, size_t *);\n \n extern void release_pack_memory(size_t);\n \ndiff --git a/patch-delta.c b/patch-delta.c\nindex b5c8594db6..42199fa956 100644\n--- a/patch-delta.c\n+++ b/patch-delta.c\n@@ -12,13 +12,13 @@\n #include \"git-compat-util.h\"\n #include \"delta.h\"\n \n-void *patch_delta(const void *src_buf, unsigned long src_size,\n-\t\t  const void *delta_buf, unsigned long delta_size,\n-\t\t  unsigned long *dst_size)\n+void *patch_delta(const void *src_buf, size_t src_size,\n+\t\t  const void *delta_buf, size_t delta_size,\n+\t\t  size_t *dst_size)\n {\n \tconst unsigned char *data, *top;\n \tunsigned char *dst_buf, *out, cmd;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tif (delta_size < DELTA_SIZE_MIN)\n \t\treturn NULL;\ndiff --git a/range-diff.c b/range-diff.c\nindex 767af8c5bb..dcb189f40d 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -192,7 +192,7 @@ static void find_exact_matches(struct string_list *a, struct string_list *b)\n \thashmap_free(&map, 0);\n }\n \n-static void diffsize_consume(void *data, char *line, unsigned long len)\n+static void diffsize_consume(void *data, char *line, size_t len)\n {\n \t(*(int *)data)++;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 78121bd63c..c37809292e 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -229,7 +229,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)\n {\n \tint match = -1;\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tstruct strbuf sb = STRBUF_INIT;\n \n@@ -1676,7 +1676,7 @@ int verify_index_checksum;\n /* Allow fsck to force verification of the cache entry order. */\n int verify_ce_order;\n \n-static int verify_hdr(const struct cache_header *hdr, unsigned long size)\n+static int verify_hdr(const struct cache_header *hdr, size_t size)\n {\n \tgit_hash_ctx c;\n \tunsigned char hash[GIT_MAX_RAWSZ];\n@@ -1700,7 +1700,7 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)\n }\n \n static int read_index_extension(struct index_state *istate,\n-\t\t\t\tconst char *ext, const char *data, unsigned long sz)\n+\t\t\t\tconst char *ext, const char *data, size_t sz)\n {\n \tswitch (CACHE_EXT(ext)) {\n \tcase CACHE_EXT_TREE:\n@@ -1746,7 +1746,7 @@ int read_index(struct index_state *istate)\n static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,\n \t\t\t\t\t    unsigned int version,\n \t\t\t\t\t    struct ondisk_cache_entry *ondisk,\n-\t\t\t\t\t    unsigned long *ent_size,\n+\t\t\t\t\t    size_t *ent_size,\n \t\t\t\t\t    const struct cache_entry *previous_ce)\n {\n \tstruct cache_entry *ce;\n@@ -1937,13 +1937,13 @@ struct load_index_extensions\n \tstruct index_state *istate;\n \tconst char *mmap;\n \tsize_t mmap_size;\n-\tunsigned long src_offset;\n+\tsize_t src_offset;\n };\n \n static void *load_index_extensions(void *_data)\n {\n \tstruct load_index_extensions *p = _data;\n-\tunsigned long src_offset = p->src_offset;\n+\tsize_t src_offset = p->src_offset;\n \n \twhile (src_offset <= p->mmap_size - the_hash_algo->rawsz - 8) {\n \t\t/* After an array of active_nr index entries,\n@@ -1971,17 +1971,17 @@ static void *load_index_extensions(void *_data)\n  * A helper function that will load the specified range of cache entries\n  * from the memory mapped file and add them to the given index.\n  */\n-static unsigned long load_cache_entry_block(struct index_state *istate,\n+static size_t load_cache_entry_block(struct index_state *istate,\n \t\t\tstruct mem_pool *ce_mem_pool, int offset, int nr, const char *mmap,\n-\t\t\tunsigned long start_offset, const struct cache_entry *previous_ce)\n+\t\t\tsize_t start_offset, const struct cache_entry *previous_ce)\n {\n \tint i;\n-\tunsigned long src_offset = start_offset;\n+\tsize_t src_offset = start_offset;\n \n \tfor (i = offset; i < offset + nr; i++) {\n \t\tstruct ondisk_cache_entry *disk_ce;\n \t\tstruct cache_entry *ce;\n-\t\tunsigned long consumed;\n+\t\tsize_t consumed;\n \n \t\tdisk_ce = (struct ondisk_cache_entry *)(mmap + src_offset);\n \t\tce = create_from_disk(ce_mem_pool, istate->version, disk_ce, &consumed, previous_ce);\n@@ -1993,10 +1993,10 @@ static unsigned long load_cache_entry_block(struct index_state *istate,\n \treturn src_offset - start_offset;\n }\n \n-static unsigned long load_all_cache_entries(struct index_state *istate,\n-\t\t\tconst char *mmap, size_t mmap_size, unsigned long src_offset)\n+static size_t load_all_cache_entries(struct index_state *istate,\n+\t\t\tconst char *mmap, size_t mmap_size, size_t src_offset)\n {\n-\tunsigned long consumed;\n+\tsize_t consumed;\n \n \tif (istate->version == 4) {\n \t\tmem_pool_init(&istate->ce_mem_pool,\n@@ -2030,7 +2030,7 @@ struct load_cache_entries_thread_data\n \tstruct index_entry_offset_table *ieot;\n \tint ieot_start;\t\t/* starting index into the ieot array */\n \tint ieot_blocks;\t/* count of ieot entries to process */\n-\tunsigned long consumed;\t/* return # of bytes in index file processed */\n+\tsize_t consumed;\t/* return # of bytes in index file processed */\n };\n \n /*\n@@ -2051,12 +2051,12 @@ static void *load_cache_entries_thread(void *_data)\n \treturn NULL;\n }\n \n-static unsigned long load_cache_entries_threaded(struct index_state *istate, const char *mmap, size_t mmap_size,\n-\t\t\tunsigned long src_offset, int nr_threads, struct index_entry_offset_table *ieot)\n+static size_t load_cache_entries_threaded(struct index_state *istate, const char *mmap, size_t mmap_size,\n+\t\t\tsize_t src_offset, int nr_threads, struct index_entry_offset_table *ieot)\n {\n \tint i, offset, ieot_blocks, ieot_start, err;\n \tstruct load_cache_entries_thread_data *data;\n-\tunsigned long consumed = 0;\n+\tsize_t consumed = 0;\n \n \t/* a little sanity checking */\n \tif (istate->name_hash_initialized)\n@@ -2127,7 +2127,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n {\n \tint fd;\n \tstruct stat st;\n-\tunsigned long src_offset;\n+\tsize_t src_offset;\n \tconst struct cache_header *hdr;\n \tconst char *mmap;\n \tsize_t mmap_size;\n@@ -2414,7 +2414,7 @@ int index_has_changes(struct index_state *istate,\n \n #define WRITE_BUFFER_SIZE 8192\n static unsigned char write_buffer[WRITE_BUFFER_SIZE];\n-static unsigned long write_buffer_len;\n+static size_t write_buffer_len;\n \n static int ce_write_flush(git_hash_ctx *context, int fd)\n {\n@@ -2999,9 +2999,9 @@ static int write_split_index(struct index_state *istate,\n \n static const char *shared_index_expire = \"2.weeks.ago\";\n \n-static unsigned long get_shared_index_expire_date(void)\n+static size_t get_shared_index_expire_date(void)\n {\n-\tstatic unsigned long shared_index_expire_date;\n+\tstatic size_t shared_index_expire_date;\n \tstatic int shared_index_expire_date_prepared;\n \n \tif (!shared_index_expire_date_prepared) {\n@@ -3017,7 +3017,7 @@ static unsigned long get_shared_index_expire_date(void)\n static int should_delete_shared_index(const char *shared_index_path)\n {\n \tstruct stat st;\n-\tunsigned long expiration;\n+\tsize_t expiration;\n \n \t/* Check timestamp */\n \texpiration = get_shared_index_expire_date();\n@@ -3250,10 +3250,10 @@ int index_name_is_other(const struct index_state *istate, const char *name,\n }\n \n void *read_blob_data_from_index(const struct index_state *istate,\n-\t\t\t\tconst char *path, unsigned long *size)\n+\t\t\t\tconst char *path, size_t *size)\n {\n \tint pos, len;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tenum object_type type;\n \tvoid *data;\n \ndiff --git a/ref-filter.c b/ref-filter.c\nindex 8f6e55a10e..26a55fee98 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -68,7 +68,7 @@ struct refname_atom {\n static struct expand_data {\n \tstruct object_id oid;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t disk_size;\n \tstruct object_id delta_base_oid;\n \tvoid *content;\n@@ -938,7 +938,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_\n }\n \n /* See grab_values */\n-static void grab_tag_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_tag_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tstruct tag *tag = (struct tag *) obj;\n@@ -960,7 +960,7 @@ static void grab_tag_values(struct atom_value *val, int deref, struct object *ob\n }\n \n /* See grab_values */\n-static void grab_commit_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_commit_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tstruct commit *commit = (struct commit *) obj;\n@@ -993,7 +993,7 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object\n \t}\n }\n \n-static const char *find_wholine(const char *who, int wholen, const char *buf, unsigned long sz)\n+static const char *find_wholine(const char *who, int wholen, const char *buf, size_t sz)\n {\n \tconst char *eol;\n \twhile (*buf) {\n@@ -1039,7 +1039,7 @@ static const char *copy_email(const char *buf)\n \treturn xmemdupz(email, eoemail + 1 - email);\n }\n \n-static char *copy_subject(const char *buf, unsigned long len)\n+static char *copy_subject(const char *buf, size_t len)\n {\n \tchar *r = xmemdupz(buf, len);\n \tint i;\n@@ -1089,7 +1089,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam\n }\n \n /* See grab_values */\n-static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tint wholen = strlen(who);\n@@ -1148,11 +1148,11 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru\n \t}\n }\n \n-static void find_subpos(const char *buf, unsigned long sz,\n-\t\t\tconst char **sub, unsigned long *sublen,\n-\t\t\tconst char **body, unsigned long *bodylen,\n-\t\t\tunsigned long *nonsiglen,\n-\t\t\tconst char **sig, unsigned long *siglen)\n+static void find_subpos(const char *buf, size_t sz,\n+\t\t\tconst char **sub, size_t *sublen,\n+\t\t\tconst char **body, size_t *bodylen,\n+\t\t\tsize_t *nonsiglen,\n+\t\t\tconst char **sig, size_t *siglen)\n {\n \tconst char *eol;\n \t/* skip past header until we hit empty line */\n@@ -1196,7 +1196,7 @@ static void find_subpos(const char *buf, unsigned long sz,\n  * If 'lines' is greater than 0, append that many lines from the given\n  * 'buf' of length 'size' to the given strbuf.\n  */\n-static void append_lines(struct strbuf *out, const char *buf, unsigned long size, int lines)\n+static void append_lines(struct strbuf *out, const char *buf, size_t size, int lines)\n {\n \tint i;\n \tconst char *sp, *eol;\n@@ -1217,11 +1217,11 @@ static void append_lines(struct strbuf *out, const char *buf, unsigned long size\n }\n \n /* See grab_values */\n-static void grab_sub_body_contents(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_sub_body_contents(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tconst char *subpos = NULL, *bodypos = NULL, *sigpos = NULL;\n-\tunsigned long sublen = 0, bodylen = 0, nonsiglen = 0, siglen = 0;\n+\tsize_t sublen = 0, bodylen = 0, nonsiglen = 0, siglen = 0;\n \n \tfor (i = 0; i < used_atom_cnt; i++) {\n \t\tstruct used_atom *atom = &used_atom[i];\n@@ -1290,7 +1290,7 @@ static void fill_missing_values(struct atom_value *val)\n  * pointed at by the ref itself; otherwise it is the object the\n  * ref (which is a tag) refers to.\n  */\n-static void grab_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tswitch (obj->type) {\n \tcase OBJ_TAG:\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex c846c9ee3b..df0f4c2445 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -56,7 +56,7 @@ static char *read_ref_note(const struct object_id *oid)\n {\n \tconst struct object_id *note_oid;\n \tchar *msg = NULL;\n-\tunsigned long msglen;\n+\tsize_t msglen;\n \tenum object_type type;\n \n \tinit_notes(NULL, notes_ref, NULL, 0);\n@@ -105,7 +105,7 @@ static int note2mark_cb(const struct object_id *object_oid,\n {\n \tFILE *file = (FILE *)cb_data;\n \tchar *msg;\n-\tunsigned long msglen;\n+\tsize_t msglen;\n \tenum object_type type;\n \tstruct rev_note note;\n \ndiff --git a/rerere.c b/rerere.c\nindex b2a8e02f17..d7ade78357 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -973,7 +973,7 @@ static int handle_cache(struct index_state *istate,\n \n \twhile (pos < istate->cache_nr) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \n \t\tce = istate->cache[pos++];\n \t\tif (ce_namelen(ce) != len || memcmp(ce->name, path, len))\ndiff --git a/sha1-file.c b/sha1-file.c\nindex 803c47e2fd..50d64c9d2b 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -200,7 +200,7 @@ static struct cached_object {\n \tstruct object_id oid;\n \tenum object_type type;\n \tvoid *buf;\n-\tunsigned long size;\n+\tsize_t size;\n } *cached_objects;\n static int cached_object_nr, cached_object_alloc;\n \n@@ -871,7 +871,7 @@ void *xmmap(void *start, size_t length,\n  * the streaming interface and rehash it to do the same.\n  */\n int check_object_signature(const struct object_id *oid, void *map,\n-\t\t\t   unsigned long size, const char *type)\n+\t\t\t   size_t size, const char *type)\n {\n \tstruct object_id real_oid;\n \tenum object_type obj_type;\n@@ -1012,7 +1012,7 @@ static int quick_has_loose(struct repository *r,\n  * searching for a loose object named \"sha1\".\n  */\n static void *map_sha1_file_1(struct repository *r, const char *path,\n-\t\t\t     const unsigned char *sha1, unsigned long *size)\n+\t\t\t     const unsigned char *sha1, size_t *size)\n {\n \tvoid *map;\n \tint fd;\n@@ -1040,14 +1040,14 @@ static void *map_sha1_file_1(struct repository *r, const char *path,\n }\n \n void *map_sha1_file(struct repository *r,\n-\t\t    const unsigned char *sha1, unsigned long *size)\n+\t\t    const unsigned char *sha1, size_t *size)\n {\n \treturn map_sha1_file_1(r, NULL, sha1, size);\n }\n \n static int unpack_sha1_short_header(git_zstream *stream,\n-\t\t\t\t    unsigned char *map, unsigned long mapsize,\n-\t\t\t\t    void *buffer, unsigned long bufsiz)\n+\t\t\t\t    unsigned char *map, size_t mapsize,\n+\t\t\t\t    void *buffer, size_t bufsiz)\n {\n \t/* Get the data stream */\n \tmemset(stream, 0, sizeof(*stream));\n@@ -1061,8 +1061,8 @@ static int unpack_sha1_short_header(git_zstream *stream,\n }\n \n int unpack_sha1_header(git_zstream *stream,\n-\t\t       unsigned char *map, unsigned long mapsize,\n-\t\t       void *buffer, unsigned long bufsiz)\n+\t\t       unsigned char *map, size_t mapsize,\n+\t\t       void *buffer, size_t bufsiz)\n {\n \tint status = unpack_sha1_short_header(stream, map, mapsize,\n \t\t\t\t\t      buffer, bufsiz);\n@@ -1077,8 +1077,8 @@ int unpack_sha1_header(git_zstream *stream,\n }\n \n static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,\n-\t\t\t\t\tunsigned long mapsize, void *buffer,\n-\t\t\t\t\tunsigned long bufsiz, struct strbuf *header)\n+\t\t\t\t\tsize_t mapsize, void *buffer,\n+\t\t\t\t\tsize_t bufsiz, struct strbuf *header)\n {\n \tint status;\n \n@@ -1112,11 +1112,11 @@ static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,\n \treturn -1;\n }\n \n-static void *unpack_sha1_rest(git_zstream *stream, void *buffer, unsigned long size, const unsigned char *sha1)\n+static void *unpack_sha1_rest(git_zstream *stream, void *buffer, size_t size, const unsigned char *sha1)\n {\n \tint bytes = strlen(buffer) + 1;\n \tunsigned char *buf = xmallocz(size);\n-\tunsigned long n;\n+\tsize_t n;\n \tint status = Z_OK;\n \n \tn = stream->total_out - bytes;\n@@ -1166,7 +1166,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,\n \t\t\t       unsigned int flags)\n {\n \tconst char *type_buf = hdr;\n-\tunsigned long size;\n+\tsize_t size;\n \tint type, type_len = 0;\n \n \t/*\n@@ -1206,7 +1206,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,\n \t\treturn -1;\n \tif (size) {\n \t\tfor (;;) {\n-\t\t\tunsigned long c = *hdr - '0';\n+\t\t\tsize_t c = *hdr - '0';\n \t\t\tif (c > 9)\n \t\t\t\tbreak;\n \t\t\thdr++;\n@@ -1223,7 +1223,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,\n \treturn *hdr ? -1 : type;\n }\n \n-int parse_sha1_header(const char *hdr, unsigned long *sizep)\n+int parse_sha1_header(const char *hdr, size_t *sizep)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \n@@ -1236,12 +1236,12 @@ static int sha1_loose_object_info(struct repository *r,\n \t\t\t\t  struct object_info *oi, int flags)\n {\n \tint status = 0;\n-\tunsigned long mapsize;\n+\tsize_t mapsize;\n \tvoid *map;\n \tgit_zstream stream;\n \tchar hdr[MAX_HEADER_LEN];\n \tstruct strbuf hdrbuf = STRBUF_INIT;\n-\tunsigned long size_scratch;\n+\tsize_t size_scratch;\n \n \tif (oi->delta_base_sha1)\n \t\thashclr(oi->delta_base_sha1);\n@@ -1409,7 +1409,7 @@ int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n /* returns enum object_type or negative */\n int oid_object_info(struct repository *r,\n \t\t    const struct object_id *oid,\n-\t\t    unsigned long *sizep)\n+\t\t    size_t *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n@@ -1425,7 +1425,7 @@ int oid_object_info(struct repository *r,\n static void *read_object(struct repository *r,\n \t\t\t const unsigned char *sha1,\n \t\t\t enum object_type *type,\n-\t\t\t unsigned long *size)\n+\t\t\t size_t *size)\n {\n \tstruct object_id oid;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n@@ -1441,7 +1441,7 @@ static void *read_object(struct repository *r,\n \treturn content;\n }\n \n-int pretend_object_file(void *buf, unsigned long len, enum object_type type,\n+int pretend_object_file(void *buf, size_t len, enum object_type type,\n \t\t\tstruct object_id *oid)\n {\n \tstruct cached_object *co;\n@@ -1467,7 +1467,7 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type,\n void *read_object_file_extended(struct repository *r,\n \t\t\t\tconst struct object_id *oid,\n \t\t\t\tenum object_type *type,\n-\t\t\t\tunsigned long *size,\n+\t\t\t\tsize_t *size,\n \t\t\t\tint lookup_replace)\n {\n \tvoid *data;\n@@ -1503,12 +1503,12 @@ void *read_object_file_extended(struct repository *r,\n \n void *read_object_with_reference(const struct object_id *oid,\n \t\t\t\t const char *required_type_name,\n-\t\t\t\t unsigned long *size,\n+\t\t\t\t size_t *size,\n \t\t\t\t struct object_id *actual_oid_return)\n {\n \tenum object_type type, required_type;\n \tvoid *buffer;\n-\tunsigned long isize;\n+\tsize_t isize;\n \tstruct object_id actual_oid;\n \n \trequired_type = type_from_string(required_type_name);\n@@ -1550,7 +1550,7 @@ void *read_object_with_reference(const struct object_id *oid,\n \t}\n }\n \n-static void write_object_file_prepare(const void *buf, unsigned long len,\n+static void write_object_file_prepare(const void *buf, size_t len,\n \t\t\t\t      const char *type, struct object_id *oid,\n \t\t\t\t      char *hdr, int *hdrlen)\n {\n@@ -1616,7 +1616,7 @@ static int write_buffer(int fd, const void *buf, size_t len)\n \treturn 0;\n }\n \n-int hash_object_file(const void *buf, unsigned long len, const char *type,\n+int hash_object_file(const void *buf, size_t len, const char *type,\n \t\t     struct object_id *oid)\n {\n \tchar hdr[MAX_HEADER_LEN];\n@@ -1680,7 +1680,7 @@ static int create_tmpfile(struct strbuf *tmp, const char *filename)\n }\n \n static int write_loose_object(const struct object_id *oid, char *hdr,\n-\t\t\t      int hdrlen, const void *buf, unsigned long len,\n+\t\t\t      int hdrlen, const void *buf, size_t len,\n \t\t\t      time_t mtime)\n {\n \tint fd, ret;\n@@ -1770,7 +1770,7 @@ static int freshen_packed_object(const struct object_id *oid)\n \treturn 1;\n }\n \n-int write_object_file(const void *buf, unsigned long len, const char *type,\n+int write_object_file(const void *buf, size_t len, const char *type,\n \t\t      struct object_id *oid)\n {\n \tchar hdr[MAX_HEADER_LEN];\n@@ -1785,7 +1785,7 @@ int write_object_file(const void *buf, unsigned long len, const char *type,\n \treturn write_loose_object(oid, hdr, hdrlen, buf, len, 0);\n }\n \n-int hash_object_file_literally(const void *buf, unsigned long len,\n+int hash_object_file_literally(const void *buf, size_t len,\n \t\t\t       const char *type, struct object_id *oid,\n \t\t\t       unsigned flags)\n {\n@@ -1811,7 +1811,7 @@ int hash_object_file_literally(const void *buf, unsigned long len,\n int force_object_loose(const struct object_id *oid, time_t mtime)\n {\n \tvoid *buf;\n-\tunsigned long len;\n+\tsize_t len;\n \tenum object_type type;\n \tchar hdr[MAX_HEADER_LEN];\n \tint hdrlen;\n@@ -2248,14 +2248,14 @@ void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)\n \n static int check_stream_sha1(git_zstream *stream,\n \t\t\t     const char *hdr,\n-\t\t\t     unsigned long size,\n+\t\t\t     size_t size,\n \t\t\t     const char *path,\n \t\t\t     const unsigned char *expected_sha1)\n {\n \tgit_hash_ctx c;\n \tunsigned char real_sha1[GIT_MAX_RAWSZ];\n \tunsigned char buf[4096];\n-\tunsigned long total_read;\n+\tsize_t total_read;\n \tint status = Z_OK;\n \n \tthe_hash_algo->init_fn(&c);\n@@ -2307,12 +2307,12 @@ static int check_stream_sha1(git_zstream *stream,\n int read_loose_object(const char *path,\n \t\t      const struct object_id *expected_oid,\n \t\t      enum object_type *type,\n-\t\t      unsigned long *size,\n+\t\t      size_t *size,\n \t\t      void **contents)\n {\n \tint ret = -1;\n \tvoid *map = NULL;\n-\tunsigned long mapsize;\n+\tsize_t mapsize;\n \tgit_zstream stream;\n \tchar hdr[MAX_HEADER_LEN];\n \ndiff --git a/sha1dc_git.c b/sha1dc_git.c\nindex e0cc9d988c..b24fc9af55 100644\n--- a/sha1dc_git.c\n+++ b/sha1dc_git.c\n@@ -25,7 +25,7 @@ void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)\n /*\n  * Same as SHA1DCUpdate, but adjust types to match git's usual interface.\n  */\n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, size_t len)\n {\n \tconst char *data = vdata;\n \t/* We expect an unsigned long, but sha1dc only takes an int */\ndiff --git a/sha1dc_git.h b/sha1dc_git.h\nindex 41e1c3fd3f..847b38fb4b 100644\n--- a/sha1dc_git.h\n+++ b/sha1dc_git.h\n@@ -15,7 +15,7 @@ void git_SHA1DCInit(SHA1_CTX *);\n #endif\n \n void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *);\n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, unsigned long len);\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, size_t len);\n \n #define platform_SHA_CTX SHA1_CTX\n #define platform_SHA1_Init git_SHA1DCInit\ndiff --git a/streaming.c b/streaming.c\nindex 891f82f51a..1e7a656738 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -69,19 +69,19 @@ struct filtered_istream {\n \n struct git_istream {\n \tconst struct stream_vtbl *vtbl;\n-\tunsigned long size; /* inflated size of full object */\n+\tsize_t size; /* inflated size of full object */\n \tgit_zstream z;\n \tenum { z_unused, z_used, z_done, z_error } z_state;\n \n \tunion {\n \t\tstruct {\n \t\t\tchar *buf; /* from read_object() */\n-\t\t\tunsigned long read_ptr;\n+\t\t\tsize_t read_ptr;\n \t\t} incore;\n \n \t\tstruct {\n \t\t\tvoid *mapped;\n-\t\t\tunsigned long mapsize;\n+\t\t\tsize_t mapsize;\n \t\t\tchar hdr[32];\n \t\t\tint hdr_avail;\n \t\t\tint hdr_used;\n@@ -112,7 +112,7 @@ static enum input_source istream_source(const struct object_id *oid,\n \t\t\t\t\tenum object_type *type,\n \t\t\t\t\tstruct object_info *oi)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tint status;\n \n \toi->typep = type;\n@@ -135,7 +135,7 @@ static enum input_source istream_source(const struct object_id *oid,\n \n struct git_istream *open_istream(const struct object_id *oid,\n \t\t\t\t enum object_type *type,\n-\t\t\t\t unsigned long *size,\n+\t\t\t\t size_t *size,\n \t\t\t\t struct stream_filter *filter)\n {\n \tstruct git_istream *st;\n@@ -516,7 +516,7 @@ int stream_blob_to_fd(int fd, const struct object_id *oid, struct stream_filter\n {\n \tstruct git_istream *st;\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tssize_t kept = 0;\n \tint result = -1;\n \ndiff --git a/streaming.h b/streaming.h\nindex 32f4626771..552eb1d7c5 100644\n--- a/streaming.h\n+++ b/streaming.h\n@@ -8,7 +8,7 @@\n /* opaque */\n struct git_istream;\n \n-extern struct git_istream *open_istream(const struct object_id *, enum object_type *, unsigned long *, struct stream_filter *);\n+extern struct git_istream *open_istream(const struct object_id *, enum object_type *, size_t *, struct stream_filter *);\n extern int close_istream(struct git_istream *);\n extern ssize_t read_istream(struct git_istream *, void *, size_t);\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex 86737087ba..46172820b1 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -527,7 +527,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,\n \t\tenum lookup_type lookup_type)\n {\n \tstruct strbuf rev = STRBUF_INIT;\n-\tunsigned long config_size;\n+\tsize_t config_size;\n \tchar *config = NULL;\n \tstruct object_id oid;\n \tenum object_type type;\ndiff --git a/t/helper/test-delta.c b/t/helper/test-delta.c\nindex e749a49c88..b613cd0216 100644\n--- a/t/helper/test-delta.c\n+++ b/t/helper/test-delta.c\n@@ -21,7 +21,7 @@ int cmd__delta(int argc, const char **argv)\n \tint fd;\n \tstruct stat st;\n \tvoid *from_buf, *data_buf, *out_buf;\n-\tunsigned long from_size, data_size, out_size;\n+\tsize_t from_size, data_size, out_size;\n \n \tif (argc != 5 || (strcmp(argv[1], \"-d\") && strcmp(argv[1], \"-p\"))) {\n \t\tfprintf(stderr, \"usage: %s\\n\", usage_str);\ndiff --git a/tag.c b/tag.c\nindex 1ed43ec925..90502454a0 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -41,7 +41,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n {\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \ttype = oid_object_info(the_repository, oid, NULL);\n@@ -132,7 +132,7 @@ void release_tag_memory(struct tag *t)\n \tt->date = 0;\n }\n \n-int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size)\n+int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, size_t size)\n {\n \tstruct object_id oid;\n \tchar type[20];\n@@ -195,7 +195,7 @@ int parse_tag(struct tag *item)\n {\n \tenum object_type type;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tif (item->object.parsed)\ndiff --git a/tag.h b/tag.h\nindex e669c3e497..b540b100ef 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -12,7 +12,7 @@ struct tag {\n \ttimestamp_t date;\n };\n extern struct tag *lookup_tag(struct repository *r, const struct object_id *oid);\n-extern int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size);\n+extern int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, size_t size);\n extern int parse_tag(struct tag *item);\n extern void release_tag_memory(struct tag *t);\n extern struct object *deref_tag(struct repository *r, struct object *, const char *, int);\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 5709e910e0..a0079aecee 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -82,7 +82,7 @@ int init_tree_desc_gently(struct tree_desc *desc, const void *buffer, unsigned l\n \n void *fill_tree_descriptor(struct tree_desc *desc, const struct object_id *oid)\n {\n-\tunsigned long size = 0;\n+\tsize_t size = 0;\n \tvoid *buf = NULL;\n \n \tif (oid) {\n@@ -108,8 +108,8 @@ static int update_tree_entry_internal(struct tree_desc *desc, struct strbuf *err\n {\n \tconst void *buf = desc->buffer;\n \tconst unsigned char *end = desc->entry.oid->hash + the_hash_algo->rawsz;\n-\tunsigned long size = desc->size;\n-\tunsigned long len = end - (const unsigned char *)buf;\n+\tsize_t size = desc->size;\n+\tsize_t len = end - (const unsigned char *)buf;\n \n \tif (size < len)\n \t\tdie(_(\"too-short tree file\"));\n@@ -493,7 +493,7 @@ int traverse_trees(struct index_state *istate,\n \n struct dir_state {\n \tvoid *tree;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_id oid;\n };\n \n@@ -536,7 +536,7 @@ int get_tree_entry(const struct object_id *tree_oid, const char *name, struct ob\n {\n \tint retval;\n \tvoid *tree;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_id root;\n \n \ttree = read_object_with_reference(tree_oid, tree_type, &size, &root);\n@@ -605,7 +605,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(struct object_id *tre\n \t\tif (!t.buffer) {\n \t\t\tvoid *tree;\n \t\t\tstruct object_id root;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\ttree = read_object_with_reference(&current_tree_oid,\n \t\t\t\t\t\t\t  tree_type, &size,\n \t\t\t\t\t\t\t  &root);\n@@ -701,7 +701,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(struct object_id *tre\n \t\t\tgoto done;\n \t\t} else if (S_ISLNK(*mode)) {\n \t\t\t/* Follow a symlink */\n-\t\t\tunsigned long link_len;\n+\t\t\tsize_t link_len;\n \t\t\tsize_t len;\n \t\t\tchar *contents, *contents_start;\n \t\t\tstruct dir_state *parent;\ndiff --git a/tree.c b/tree.c\nindex 3e82bd67d2..0b599169ea 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -220,7 +220,7 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)\n {\n \t enum object_type type;\n \t void *buffer;\n-\t unsigned long size;\n+\t size_t size;\n \n \tif (item->object.parsed)\n \t\treturn 0;\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex fdf377df71..44546d4a1a 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -169,7 +169,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename)\n \n void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \n \tif (oideq(oid, &null_oid)) {\n@@ -185,7 +185,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n }\n \n #define FIRST_FEW_BYTES 8000\n-int buffer_is_binary(const char *ptr, unsigned long size)\n+int buffer_is_binary(const char *ptr, size_t size)\n {\n \tif (FIRST_FEW_BYTES < size)\n \t\tsize = FIRST_FEW_BYTES;\ndiff --git a/xdiff-interface.h b/xdiff-interface.h\nindex 2d41fffd4c..6c99f8d047 100644\n--- a/xdiff-interface.h\n+++ b/xdiff-interface.h\n@@ -11,7 +11,7 @@\n  */\n #define MAX_XDIFF_SIZE (1024UL * 1024 * 1023)\n \n-typedef void (*xdiff_emit_line_fn)(void *, char *, unsigned long);\n+typedef void (*xdiff_emit_line_fn)(void *, char *, size_t);\n typedef void (*xdiff_emit_hunk_fn)(void *data,\n \t\t\t\t   long old_begin, long old_nr,\n \t\t\t\t   long new_begin, long new_nr,\n@@ -25,7 +25,7 @@ int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,\n \t\t  xpparam_t const *xpp, xdemitconf_t const *xecfg);\n int read_mmfile(mmfile_t *ptr, const char *filename);\n void read_mmblob(mmfile_t *ptr, const struct object_id *oid);\n-int buffer_is_binary(const char *ptr, unsigned long size);\n+int buffer_is_binary(const char *ptr, size_t size);\n \n extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags);\n extern void xdiff_clear_find_func(xdemitconf_t *xecfg);\n-- \n2.19.0.271.gfe8321ec05\n\n"},{"id":"363818","messageId":"17c472c4-34be-390d-947f-ff998398295c@gmail.com","threadId":"49844","inReplyTo":"20181120050456.16715-1-tboegi@web.de","subject":"Re: [PATCH v2 1/1] Use size_t instead of 'unsigned long' for data in memory","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-11-21T11:55:15Z","receivedAt":"2018-11-21T11:55:21Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 11/20/2018 12:04 AM, tboegi@web.de wrote:\n> From: Torsten Bögershausen <tboegi@web.de>\n>\n> Currently the length of data which is stored in memory is stored\n> in \"unsigned long\" at many places in the code base.\n> This is OK when both \"unsigned long\" and size_t are 32 bits,\n> (and is OK when both are 64 bits).\n> On a 64 bit Windows system am \"unsigned long\" is 32 bit, and\n> that may be too short to measure the size of objects in memory,\n> a size_t is the natural choice.\n\nIs this change enough to store 4GB files on Windows? Or is there more to \ndo?\n\n> Thanks for all the comments on V1.\n> Changes since V1:\n> - Make the motivation somewhat clearer in the commit message\n> - Rebase to the November 19 pu\n>\n> What we really need for this patch to fly are this branches:\n> mk/use-size-t-in-zlib\n> tb/print-size-t-with-uintmax-format\n\nI believe communicating these direct dependencies is the correct way to \ngo, and the rebase you mentioned is unnecessary (instead, test with a \nmerge).\n\nHopefully the patch applies on top of a merge of those branches.\n\n> @@ -529,7 +530,7 @@ static void *unpack_raw_entry(struct object_entry *obj,\n>   }\n>   \n>   static void *unpack_data(struct object_entry *obj,\n> -\t\t\t int (*consume)(const unsigned char *, unsigned long, void *),\n> +\t\t\t int (*consume)(const unsigned char *, size_t, void *),\n>   \t\t\t void *cb_data)\n\nThis is the only instance that is not paired directly with a variable \nname like \"size\", \"sz\", or \"len\". However, it appears to be correct from \ncontext.\n\nThanks for this!\n\nReviewed-by: Derrick Stolee <dstolee@microsoft.com>\n\n"},{"id":"366878","messageId":"5b9d020c-00cb-9340-b21f-f16f7fceb8cf@virtuell-zuhause.de","threadId":"49844","inReplyTo":"20181120050456.16715-1-tboegi@web.de","subject":"Re: [PATCH v2 1/1] Use size_t instead of 'unsigned long' for data in memory","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2019-01-16T21:46:13Z","receivedAt":"2019-01-16T21:46:22Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Am 20.11.2018 um 06:04 schrieb tboegi@web.de:\n\nI'm interested in helping getting this forward!\n\n> What we really need for this patch to fly are this branches:\n> mk/use-size-t-in-zlib\n\nIn pu.\n\n> tb/print-size-t-with-uintmax-format\n\nin master.\n\n> And then it is rebased on top of all cooking stuff, too many branches\n> to be mentioned here.\n> \n> It may be usefull to examine all \"unsigned long\" which are left after\n> this patch and turn them into (what ? unsigned int? size_t? uint32_t ?).\n> And once they are settled, re-do this patch with help of a coccinelle script.\n> I don't know.\n> I probably will rebase it until Junio says stop or someone else comes with\n> a better solution.\n\nI could not spot this series in the cooking list so what is good way\nforward?\n"},{"id":"367176","messageId":"b28d6db2-c2a7-67fe-ce56-12598efcca7c@web.de","threadId":"49844","inReplyTo":"5b9d020c-00cb-9340-b21f-f16f7fceb8cf@virtuell-zuhause.de","subject":"Re: [PATCH v2 1/1] Use size_t instead of 'unsigned long' for data in memory","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2019-01-19T17:06:05Z","receivedAt":"2019-01-19T17:06:04Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 16.01.19 22:46, Thomas Braun wrote:\n> Am 20.11.2018 um 06:04 schrieb tboegi@web.de:\n>\n> I'm interested in helping getting this forward!\n>\n>> What we really need for this patch to fly are this branches:\n>> mk/use-size-t-in-zlib\n>\n> In pu.\n\nJunio, is that branch ready for master ?\n\n>\n>> tb/print-size-t-with-uintmax-format\n>\n> in master.\n>\n>> And then it is rebased on top of all cooking stuff, too many branches\n>> to be mentioned here.\n>>\n>> It may be usefull to examine all \"unsigned long\" which are left after\n>> this patch and turn them into (what ? unsigned int? size_t? uint32_t ?).\n>> And once they are settled, re-do this patch with help of a coccinelle script.\n>> I don't know.\n>> I probably will rebase it until Junio says stop or someone else comes with\n>> a better solution.\n>\n> I could not spot this series in the cooking list so what is good way\n> forward?\n>\n\nThat patch never made it anywhere (yet)\nThe last update on master, which I did so far, is here:\n<https://github.com/tboegi/git/pull/new/tb.190104_0635_convert_size_t_only_git_master_181124_mk_size_t>\n\nDo you want to continue ?\n\n\n"},{"id":"367302","messageId":"df4deef6-20ad-707f-2ad9-3fbcb3a66973@virtuell-zuhause.de","threadId":"49844","inReplyTo":"b28d6db2-c2a7-67fe-ce56-12598efcca7c@web.de","subject":"Re: [PATCH v2 1/1] Use size_t instead of 'unsigned long' for data in memory","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2019-01-22T14:25:22Z","receivedAt":"2019-01-22T14:25:30Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Am 19.01.2019 um 18:06 schrieb Torsten Bögershausen:\n> On 16.01.19 22:46, Thomas Braun wrote:\n>> Am 20.11.2018 um 06:04 schrieb tboegi@web.de:\n>>\n>> I'm interested in helping getting this forward!\n>>\n>>> What we really need for this patch to fly are this branches:\n>>> mk/use-size-t-in-zlib\n>>\n>> In pu.\n> \n> Junio, is that branch ready for master ?\n> \n>>\n>>> tb/print-size-t-with-uintmax-format\n>>\n>> in master.\n>>\n>>> And then it is rebased on top of all cooking stuff, too many branches\n>>> to be mentioned here.\n>>>\n>>> It may be usefull to examine all \"unsigned long\" which are left after\n>>> this patch and turn them into (what ? unsigned int? size_t? uint32_t ?).\n>>> And once they are settled, re-do this patch with help of a coccinelle script.\n>>> I don't know.\n>>> I probably will rebase it until Junio says stop or someone else comes with\n>>> a better solution.\n>>\n>> I could not spot this series in the cooking list so what is good way\n>> forward?\n>>\n> \n> That patch never made it anywhere (yet)\n> The last update on master, which I did so far, is here:\n> <https://github.com/tboegi/git/pull/new/tb.190104_0635_convert_size_t_only_git_master_181124_mk_size_t>\n> \n> Do you want to continue ?\n> \n\nYeah I'll give it a shot in the near future.\n\n"},{"id":"373797","messageId":"20190413151850.29037-1-tboegi@web.de","threadId":"49844","inReplyTo":"20181117151139.22994-1-tboegi@web.de","subject":"[PATCH v3 1/1] Use size_t instead of 'unsigned long' for data in memory","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2019-04-13T15:18:50Z","receivedAt":"2019-04-13T15:19:29Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nCurrently the length of data which is stored in memory is stored\nin \"unsigned long\" at many places in the code base.\nThis is OK when both \"unsigned long\" and size_t are 32 bits,\n(and is OK when both are 64 bits).\nOn a 64 bit Windows system am \"unsigned long\" is 32 bit, and\nthat may be too short to measure the size of objects in memory,\na size_t is the natural choice.\n\nImprove the code base in \"small steps\", as small as possible.\nThe smallest step seems to be much bigger than expected.\nSee this code-snippet from convert.c:\n        const char *ret;\n        unsigned long sz;\n        void *data = read_blob_data_from_index(istate, path, &sz);\n        ret = gather_convert_stats_ascii(data, sz);\n\nThe corrected version looks like this:\n        const char *ret;\n        size_t sz;\n        void *data = read_blob_data_from_index(istate, path, &sz);\n        ret = gather_convert_stats_ascii(data, sz);\n\nHowever, when the Git code base is compiled with a compiler that\ncomplains that \"unsigned long\" is different from size_t, we end\nup in this huge patch, before the code base cleanly compiles.\n\nAnd: there is more to be done in the zlib interface.\n\nReviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n\nThis is the 3rd version of the patch.\n - Dscho contributed with a code-review (converted 2 more unsigned long)\n - Thomas Braun and Philip Oakley have done more work:\n   https://github.com/tboegi/git/pull/1\n   Those changes are not part of my patch series\n - Applying this patch on 'pu' gives 3 conflicts (blame.c, packfile.[ch])\n\n  apply.c                  | 78 ++++++++++++++++++++--------------------\n archive-tar.c            | 18 +++++-----\n archive-zip.c            |  2 +-\n archive.c                |  2 +-\n archive.h                |  2 +-\n bisect.c                 |  2 +-\n blame.c                  |  6 ++--\n blame.h                  |  2 +-\n builtin/cat-file.c       | 10 +++---\n builtin/difftool.c       |  2 +-\n builtin/fast-export.c    |  6 ++--\n builtin/fmt-merge-msg.c  |  4 +--\n builtin/fsck.c           |  6 ++--\n builtin/grep.c           |  8 ++---\n builtin/index-pack.c     | 26 +++++++-------\n builtin/log.c            |  4 +--\n builtin/ls-tree.c        |  2 +-\n builtin/merge-tree.c     |  6 ++--\n builtin/mktag.c          |  4 +--\n builtin/notes.c          |  6 ++--\n builtin/pack-objects.c   | 70 ++++++++++++++++++------------------\n builtin/reflog.c         |  2 +-\n builtin/replace.c        |  2 +-\n builtin/tag.c            |  4 +--\n builtin/unpack-file.c    |  2 +-\n builtin/unpack-objects.c | 34 +++++++++---------\n builtin/verify-commit.c  |  4 +--\n bundle.c                 |  2 +-\n cache.h                  | 11 +++---\n combine-diff.c           | 11 +++---\n commit.c                 | 22 ++++++------\n commit.h                 | 10 +++---\n config.c                 |  2 +-\n convert.c                | 16 ++++-----\n delta.h                  | 20 +++++------\n diff-delta.c             |  4 +--\n diff.c                   | 30 ++++++++--------\n diff.h                   |  2 +-\n diffcore-pickaxe.c       |  4 +--\n diffcore.h               |  2 +-\n dir.c                    |  6 ++--\n dir.h                    |  2 +-\n entry.c                  |  4 +--\n fast-import.c            | 26 +++++++-------\n fsck.c                   | 12 +++----\n fsck.h                   |  2 +-\n fuzz-pack-headers.c      |  4 +--\n grep.h                   |  2 +-\n http-push.c              |  2 +-\n list-objects-filter.c    |  2 +-\n mailmap.c                |  2 +-\n match-trees.c            |  4 +--\n merge-blobs.c            |  6 ++--\n merge-blobs.h            |  2 +-\n merge-recursive.c        |  4 +--\n notes-cache.c            |  2 +-\n notes-merge.c            |  4 +--\n notes.c                  |  6 ++--\n object-store.h           | 22 ++++++------\n object.c                 |  4 +--\n object.h                 |  2 +-\n pack-check.c             |  2 +-\n pack-objects.h           | 14 ++++----\n pack.h                   |  2 +-\n packfile.c               | 44 +++++++++++------------\n packfile.h               | 10 +++---\n patch-delta.c            |  8 ++---\n range-diff.c             |  2 +-\n read-cache.c             | 48 ++++++++++++-------------\n ref-filter.c             | 16 ++++-----\n remote-testsvn.c         |  4 +--\n rerere.c                 |  2 +-\n sha1-file.c              | 66 +++++++++++++++++-----------------\n sha1dc_git.c             |  2 +-\n sha1dc_git.h             |  2 +-\n streaming.c              | 12 +++----\n streaming.h              |  2 +-\n submodule-config.c       |  2 +-\n t/helper/test-delta.c    |  2 +-\n tag.c                    |  6 ++--\n tag.h                    |  2 +-\n tree-walk.c              | 14 ++++----\n tree.c                   |  2 +-\n xdiff-interface.c        |  4 +--\n xdiff-interface.h        |  4 +--\n 85 files changed, 422 insertions(+), 420 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex f15afa9f6a..7594859ce6 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -177,9 +177,9 @@ static void set_default_whitespace_mode(struct apply_state *state)\n  * of context lines.\n  */\n struct fragment {\n-\tunsigned long leading, trailing;\n-\tunsigned long oldpos, oldlines;\n-\tunsigned long newpos, newlines;\n+\tsize_t leading, trailing;\n+\tsize_t oldpos, oldlines;\n+\tsize_t newpos, newlines;\n \t/*\n \t * 'patch' is usually borrowed from buf in apply_patch(),\n \t * but some codepaths store an allocated buffer.\n@@ -423,9 +423,9 @@ static int read_patch_file(struct strbuf *sb, int fd)\n \treturn 0;\n }\n\n-static unsigned long linelen(const char *buffer, unsigned long size)\n+static size_t linelen(const char *buffer, size_t size)\n {\n-\tunsigned long len = 0;\n+\tsize_t len = 0;\n \twhile (size--) {\n \t\tlen++;\n \t\tif (*buffer++ == '\\n')\n@@ -1321,7 +1321,7 @@ static int parse_git_header(struct apply_state *state,\n \t\t\t    unsigned int size,\n \t\t\t    struct patch *patch)\n {\n-\tunsigned long offset;\n+\tsize_t offset;\n\n \t/* A git diff has explicit new/delete information, so we don't guess */\n \tpatch->is_new = 0;\n@@ -1391,7 +1391,7 @@ static int parse_git_header(struct apply_state *state,\n \treturn offset;\n }\n\n-static int parse_num(const char *line, unsigned long *p)\n+static int parse_num(const char *line, size_t *p)\n {\n \tchar *ptr;\n\n@@ -1402,7 +1402,7 @@ static int parse_num(const char *line, unsigned long *p)\n }\n\n static int parse_range(const char *line, int len, int offset, const char *expect,\n-\t\t       unsigned long *p1, unsigned long *p2)\n+\t\t       size_t *p1, size_t *p2)\n {\n \tint digits, ex;\n\n@@ -1517,11 +1517,11 @@ static int parse_fragment_header(const char *line, int len, struct fragment *fra\n  */\n static int find_header(struct apply_state *state,\n \t\t       const char *line,\n-\t\t       unsigned long size,\n+\t\t       size_t size,\n \t\t       int *hdrsize,\n \t\t       struct patch *patch)\n {\n-\tunsigned long offset, len;\n+\tsize_t offset, len;\n\n \tpatch->is_toplevel_relative = 0;\n \tpatch->is_rename = patch->is_copy = 0;\n@@ -1529,7 +1529,7 @@ static int find_header(struct apply_state *state,\n \tpatch->old_mode = patch->new_mode = 0;\n \tpatch->old_name = patch->new_name = NULL;\n \tfor (offset = 0; size > 0; offset += len, size -= len, line += len, state->linenr++) {\n-\t\tunsigned long nextlen;\n+\t\tsize_t nextlen;\n\n \t\tlen = linelen(line, size);\n \t\tif (!len)\n@@ -1667,14 +1667,14 @@ static void check_old_for_crlf(struct patch *patch, const char *line, int len)\n  */\n static int parse_fragment(struct apply_state *state,\n \t\t\t  const char *line,\n-\t\t\t  unsigned long size,\n+\t\t\t  size_t size,\n \t\t\t  struct patch *patch,\n \t\t\t  struct fragment *fragment)\n {\n \tint added, deleted;\n \tint len = linelen(line, size), offset;\n-\tunsigned long oldlines, newlines;\n-\tunsigned long leading, trailing;\n+\tsize_t oldlines, newlines;\n+\tsize_t leading, trailing;\n\n \toffset = parse_fragment_header(line, len, fragment);\n \tif (offset < 0)\n@@ -1789,11 +1789,11 @@ static int parse_fragment(struct apply_state *state,\n  */\n static int parse_single_patch(struct apply_state *state,\n \t\t\t      const char *line,\n-\t\t\t      unsigned long size,\n+\t\t\t      size_t size,\n \t\t\t      struct patch *patch)\n {\n-\tunsigned long offset = 0;\n-\tunsigned long oldlines = 0, newlines = 0, context = 0;\n+\tsize_t offset = 0;\n+\tsize_t oldlines = 0, newlines = 0, context = 0;\n \tstruct fragment **fragp = &patch->fragments;\n\n \twhile (size > 4 && !memcmp(line, \"@@ -\", 4)) {\n@@ -1864,8 +1864,8 @@ static inline int metadata_changes(struct patch *patch)\n \t\t patch->old_mode != patch->new_mode);\n }\n\n-static char *inflate_it(const void *data, unsigned long size,\n-\t\t\tunsigned long inflated_size)\n+static char *inflate_it(const void *data, size_t size,\n+\t\t\tsize_t inflated_size)\n {\n \tgit_zstream stream;\n \tvoid *out;\n@@ -1894,7 +1894,7 @@ static char *inflate_it(const void *data, unsigned long size,\n  */\n static struct fragment *parse_binary_hunk(struct apply_state *state,\n \t\t\t\t\t  char **buf_p,\n-\t\t\t\t\t  unsigned long *sz_p,\n+\t\t\t\t\t  size_t *sz_p,\n \t\t\t\t\t  int *status_p,\n \t\t\t\t\t  int *used_p)\n {\n@@ -1911,10 +1911,10 @@ static struct fragment *parse_binary_hunk(struct apply_state *state,\n \t * to 1-26 bytes, and 'a'-'z' corresponds to 27-52 bytes.\n \t */\n \tint llen, used;\n-\tunsigned long size = *sz_p;\n+\tsize_t size = *sz_p;\n \tchar *buffer = *buf_p;\n \tint patch_method;\n-\tunsigned long origlen;\n+\tsize_t origlen;\n \tchar *data = NULL;\n \tint hunk_size = 0;\n \tstruct fragment *frag;\n@@ -2006,7 +2006,7 @@ static struct fragment *parse_binary_hunk(struct apply_state *state,\n  */\n static int parse_binary(struct apply_state *state,\n \t\t\tchar *buffer,\n-\t\t\tunsigned long size,\n+\t\t\tsize_t size,\n \t\t\tstruct patch *patch)\n {\n \t/*\n@@ -2123,7 +2123,7 @@ static int use_patch(struct apply_state *state, struct patch *p)\n  *   the number of bytes consumed otherwise,\n  *     so that the caller can call us again for the next patch.\n  */\n-static int parse_chunk(struct apply_state *state, char *buffer, unsigned long size, struct patch *patch)\n+static int parse_chunk(struct apply_state *state, char *buffer, size_t size, struct patch *patch)\n {\n \tint hdrsize, patchsize;\n \tint offset = find_header(state, buffer, size, &hdrsize, patch);\n@@ -2153,7 +2153,7 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \tif (!patchsize) {\n \t\tstatic const char git_binary[] = \"GIT binary patch\\n\";\n \t\tint hd = hdrsize + offset;\n-\t\tunsigned long llen = linelen(buffer + hd, size - hd);\n+\t\tsize_t llen = linelen(buffer + hd, size - hd);\n\n \t\tif (llen == sizeof(git_binary) - 1 &&\n \t\t    !memcmp(git_binary, buffer + hd, llen)) {\n@@ -2397,7 +2397,7 @@ static void update_pre_post_images(struct image *preimage,\n static int line_by_line_fuzzy_match(struct image *img,\n \t\t\t\t    struct image *preimage,\n \t\t\t\t    struct image *postimage,\n-\t\t\t\t    unsigned long current,\n+\t\t\t\t    size_t current,\n \t\t\t\t    int current_lno,\n \t\t\t\t    int preimage_limit)\n {\n@@ -2466,7 +2466,7 @@ static int match_fragment(struct apply_state *state,\n \t\t\t  struct image *img,\n \t\t\t  struct image *preimage,\n \t\t\t  struct image *postimage,\n-\t\t\t  unsigned long current,\n+\t\t\t  size_t current,\n \t\t\t  int current_lno,\n \t\t\t  unsigned ws_rule,\n \t\t\t  int match_beginning, int match_end)\n@@ -2677,7 +2677,7 @@ static int find_pos(struct apply_state *state,\n \t\t    int match_beginning, int match_end)\n {\n \tint i;\n-\tunsigned long backwards, forwards, current;\n+\tsize_t backwards, forwards, current;\n \tint backwards_lno, forwards_lno, current_lno;\n\n \t/*\n@@ -2851,7 +2851,7 @@ static int apply_one_fragment(struct apply_state *state,\n \tint new_blank_lines_at_end = 0;\n \tint found_new_blank_lines_at_end = 0;\n \tint hunk_linenr = frag->linenr;\n-\tunsigned long leading, trailing;\n+\tsize_t leading, trailing;\n \tint pos, applied_pos;\n \tstruct image preimage;\n \tstruct image postimage;\n@@ -3075,9 +3075,9 @@ static int apply_one_fragment(struct apply_state *state,\n \t\t */\n \t\tif ((leading != frag->leading ||\n \t\t     trailing != frag->trailing) && state->apply_verbosity > verbosity_silent)\n-\t\t\tfprintf_ln(stderr, _(\"Context reduced to (%ld/%ld)\"\n+\t\t\tfprintf_ln(stderr, _(\"Context reduced to (%\"PRIuMAX\"/%\"PRIuMAX\")\"\n \t\t\t\t\t     \" to apply fragment at %d\"),\n-\t\t\t\t   leading, trailing, applied_pos+1);\n+\t\t\t\t   (uintmax_t)leading, (uintmax_t)trailing, applied_pos+1);\n \t\tupdate_image(state, img, applied_pos, &preimage, &postimage);\n \t} else {\n \t\tif (state->apply_verbosity > verbosity_normal)\n@@ -3099,7 +3099,7 @@ static int apply_binary_fragment(struct apply_state *state,\n \t\t\t\t struct patch *patch)\n {\n \tstruct fragment *fragment = patch->fragments;\n-\tunsigned long len;\n+\tsize_t len;\n \tvoid *dst;\n\n \tif (!fragment)\n@@ -3189,7 +3189,7 @@ static int apply_binary(struct apply_state *state,\n \tif (has_object_file(&oid)) {\n \t\t/* We already have the postimage */\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *result;\n\n \t\tresult = read_object_file(&oid, &type, &size);\n@@ -3234,7 +3234,7 @@ static int apply_fragments(struct apply_state *state, struct image *img, struct\n \twhile (frag) {\n \t\tnth++;\n \t\tif (apply_one_fragment(state, img, frag, inaccurate_eof, ws_rule, nth)) {\n-\t\t\terror(_(\"patch failed: %s:%ld\"), name, frag->oldpos);\n+\t\t\terror(_(\"patch failed: %s:%\"PRIuMAX), name, (uintmax_t)frag->oldpos);\n \t\t\tif (!state->apply_with_reject)\n \t\t\t\treturn -1;\n \t\t\tfrag->rejected = 1;\n@@ -3251,7 +3251,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns\n \t\tstrbuf_addf(buf, \"Subproject commit %s\\n\", oid_to_hex(oid));\n \t} else {\n \t\tenum object_type type;\n-\t\tunsigned long sz;\n+\t\tsize_t sz;\n \t\tchar *result;\n\n \t\tresult = read_object_file(oid, &type, &sz);\n@@ -4280,7 +4280,7 @@ static int add_index_file(struct apply_state *state,\n \t\t\t  const char *path,\n \t\t\t  unsigned mode,\n \t\t\t  void *buf,\n-\t\t\t  unsigned long size)\n+\t\t\t  size_t size)\n {\n \tstruct stat st;\n \tstruct cache_entry *ce;\n@@ -4334,7 +4334,7 @@ static int add_index_file(struct apply_state *state,\n  */\n static int try_create_file(struct apply_state *state, const char *path,\n \t\t\t   unsigned int mode, const char *buf,\n-\t\t\t   unsigned long size)\n+\t\t\t   size_t size)\n {\n \tint fd, res;\n \tstruct strbuf nbuf = STRBUF_INIT;\n@@ -4385,7 +4385,7 @@ static int create_one_file(struct apply_state *state,\n \t\t\t   char *path,\n \t\t\t   unsigned mode,\n \t\t\t   const char *buf,\n-\t\t\t   unsigned long size)\n+\t\t\t   size_t size)\n {\n \tint res;\n\n@@ -4477,7 +4477,7 @@ static int create_file(struct apply_state *state, struct patch *patch)\n {\n \tchar *path = patch->new_name;\n \tunsigned mode = patch->new_mode;\n-\tunsigned long size = patch->resultsize;\n+\tsize_t size = patch->resultsize;\n \tchar *buf = patch->result;\n\n \tif (!mode)\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 4aabd566fb..de051aa0e2 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -13,7 +13,7 @@\n #define BLOCKSIZE\t(RECORDSIZE * 20)\n\n static char block[BLOCKSIZE];\n-static unsigned long offset;\n+static size_t offset;\n\n static int tar_umask = 002;\n\n@@ -51,12 +51,12 @@ static void write_if_needed(void)\n  * queues up writes, so that all our write(2) calls write exactly one\n  * full block; pads writes to RECORDSIZE\n  */\n-static void do_write_blocked(const void *data, unsigned long size)\n+static void do_write_blocked(const void *data, size_t size)\n {\n \tconst char *buf = data;\n\n \tif (offset) {\n-\t\tunsigned long chunk = BLOCKSIZE - offset;\n+\t\tsize_t chunk = BLOCKSIZE - offset;\n \t\tif (size < chunk)\n \t\t\tchunk = size;\n \t\tmemcpy(block + offset, buf, chunk);\n@@ -78,7 +78,7 @@ static void do_write_blocked(const void *data, unsigned long size)\n\n static void finish_record(void)\n {\n-\tunsigned long tail;\n+\tsize_t tail;\n \ttail = offset % RECORDSIZE;\n \tif (tail)  {\n \t\tmemset(block + offset, 0, RECORDSIZE - tail);\n@@ -87,7 +87,7 @@ static void finish_record(void)\n \twrite_if_needed();\n }\n\n-static void write_blocked(const void *data, unsigned long size)\n+static void write_blocked(const void *data, size_t size)\n {\n \tdo_write_blocked(data, size);\n \tfinish_record();\n@@ -116,7 +116,7 @@ static int stream_blocked(const struct object_id *oid)\n {\n \tstruct git_istream *st;\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tchar buf[BLOCKSIZE];\n \tssize_t readlen;\n\n@@ -199,7 +199,7 @@ static size_t get_path_prefix(const char *path, size_t pathlen, size_t maxlen)\n\n static void prepare_header(struct archiver_args *args,\n \t\t\t   struct ustar_header *header,\n-\t\t\t   unsigned int mode, unsigned long size)\n+\t\t\t   unsigned int mode, size_t size)\n {\n \txsnprintf(header->mode, sizeof(header->mode), \"%07o\", mode & 07777);\n \txsnprintf(header->size, sizeof(header->size), \"%011\"PRIoMAX , S_ISREG(mode) ? (uintmax_t)size : (uintmax_t)0);\n@@ -220,7 +220,7 @@ static void prepare_header(struct archiver_args *args,\n\n static void write_extended_header(struct archiver_args *args,\n \t\t\t\t  const struct object_id *oid,\n-\t\t\t\t  const void *buffer, unsigned long size)\n+\t\t\t\t  const void *buffer, size_t size)\n {\n \tstruct ustar_header header;\n \tunsigned int mode;\n@@ -241,7 +241,7 @@ static int write_tar_entry(struct archiver_args *args,\n \tstruct ustar_header header;\n \tstruct strbuf ext_header = STRBUF_INIT;\n \tunsigned int old_mode = mode;\n-\tunsigned long size, size_in_header;\n+\tsize_t size, size_in_header;\n \tvoid *buffer;\n \tint err = 0;\n\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 155ee4a779..7bc9b8d425 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -297,7 +297,7 @@ static int write_zip_entry(struct archiver_args *args,\n \tvoid *buffer;\n \tstruct git_istream *stream = NULL;\n \tunsigned long flags = 0;\n-\tunsigned long size;\n+\tsize_t size;\n \tint is_binary = -1;\n \tconst char *path_without_prefix = path + args->baselen;\n \tunsigned int creator_version = 0;\ndiff --git a/archive.c b/archive.c\nindex 1f98324a93..4be6dc50bc 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -73,7 +73,7 @@ static void format_subst(const struct commit *commit,\n void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t     const char *path, const struct object_id *oid,\n \t\t\t     unsigned int mode, enum object_type *type,\n-\t\t\t     unsigned long *sizep)\n+\t\t\t     size_t *sizep)\n {\n \tvoid *buffer;\n \tconst struct commit *commit = args->convert ? args->commit : NULL;\ndiff --git a/archive.h b/archive.h\nindex 21ac010699..5b69ee1baf 100644\n--- a/archive.h\n+++ b/archive.h\n@@ -54,6 +54,6 @@ extern int write_archive_entries(struct archiver_args *args, write_archive_entry\n extern void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t\t    const char *path, const struct object_id *oid,\n \t\t\t\t    unsigned int mode, enum object_type *type,\n-\t\t\t\t    unsigned long *sizep);\n+\t\t\t\t    size_t *sizep);\n\n #endif\t/* ARCHIVE_H */\ndiff --git a/bisect.c b/bisect.c\nindex e87ac29a51..7ca069225d 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -137,7 +137,7 @@ static void show_list(const char *debug, int counted, int nr,\n \t\tstruct commit *commit = p->item;\n \t\tunsigned flags = commit->object.flags;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf = read_object_file(&commit->object.oid, &type,\n \t\t\t\t\t     &size);\n \t\tconst char *subject_start;\ndiff --git a/blame.c b/blame.c\nindex 5c07dec190..04d15a45a0 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -223,7 +223,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,\n \t\tstruct stat st;\n \t\tconst char *read_from;\n \t\tchar *buf_ptr;\n-\t\tunsigned long buf_len;\n+\t\tsize_t buf_len;\n\n \t\tif (contents_from) {\n \t\t\tif (stat(contents_from, &st) < 0)\n@@ -320,7 +320,7 @@ static void fill_origin_blob(struct diff_options *opt,\n {\n \tif (!o->file.ptr) {\n \t\tenum object_type type;\n-\t\tunsigned long file_size;\n+\t\tsize_t file_size;\n\n \t\t(*num_read_blob)++;\n \t\tif (opt->flags.allow_textconv &&\n@@ -1652,7 +1652,7 @@ static const char *get_next_line(const char *start, const char *end)\n static int prepare_lines(struct blame_scoreboard *sb)\n {\n \tconst char *buf = sb->final_buf;\n-\tunsigned long len = sb->final_buf_size;\n+\tsize_t len = sb->final_buf_size;\n \tconst char *end = buf + len;\n \tconst char *p;\n \tint *lineno;\ndiff --git a/blame.h b/blame.h\nindex be3a895043..0ef7ff1f3f 100644\n--- a/blame.h\n+++ b/blame.h\n@@ -112,7 +112,7 @@ struct blame_scoreboard {\n \t * indexed with scoreboard.lineno[blame_entry.lno].\n \t */\n \tconst char *final_buf;\n-\tunsigned long final_buf_size;\n+\tsize_t final_buf_size;\n\n \t/* linked list of blames */\n \tstruct blame_entry *ent;\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 0f092382e1..dc50207573 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -31,7 +31,7 @@ static const char *force_path;\n\n static int filter_object(const char *path, unsigned mode,\n \t\t\t const struct object_id *oid,\n-\t\t\t char **buf, unsigned long *size)\n+\t\t\t char **buf, size_t *size)\n {\n \tenum object_type type;\n\n@@ -64,7 +64,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tstruct object_id oid;\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_context obj_context;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tstruct strbuf sb = STRBUF_INIT;\n@@ -191,7 +191,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n struct expand_data {\n \tstruct object_id oid;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t disk_size;\n \tconst char *rest;\n \tstruct object_id delta_base_oid;\n@@ -303,7 +303,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\t\tfflush(stdout);\n \t\tif (opt->cmdmode) {\n \t\t\tchar *contents;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n\n \t\t\tif (!data->rest)\n \t\t\t\tdie(\"missing path for '%s'\", oid_to_hex(oid));\n@@ -334,7 +334,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t}\n \telse {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tvoid *contents;\n\n \t\tcontents = read_object_file(oid, &type, &size);\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex a3ea60ea71..224f36a0fd 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -307,7 +307,7 @@ static char *get_symlink(const struct object_id *oid, const char *path)\n \t\tdata = strbuf_detach(&link, NULL);\n \t} else {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tdata = read_object_file(oid, &type, &size);\n \t\tif (!data)\n \t\t\tdie(_(\"could not read object %s for symlink %s\"),\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 9e283482ef..09ce3b1996 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -226,7 +226,7 @@ static void show_progress(void)\n  * There's no need to cache this result with anonymize_mem, since\n  * we already handle blob content caching with marks.\n  */\n-static char *anonymize_blob(unsigned long *size)\n+static char *anonymize_blob(size_t *size)\n {\n \tstatic int counter;\n \tstruct strbuf out = STRBUF_INIT;\n@@ -237,7 +237,7 @@ static char *anonymize_blob(unsigned long *size)\n\n static void export_blob(const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf;\n \tstruct object *object;\n@@ -707,7 +707,7 @@ static void handle_tail(struct object_array *commits, struct rev_info *revs,\n\n static void handle_tag(const char *name, struct tag *tag)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf;\n \tconst char *tagger, *tagger_end, *message;\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex a4615587fd..0f049ba87e 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -471,7 +471,7 @@ static void fmt_merge_msg_title(struct strbuf *out,\n static void fmt_tag_signature(struct strbuf *tagbuf,\n \t\t\t      struct strbuf *sig,\n \t\t\t      const char *buf,\n-\t\t\t      unsigned long len)\n+\t\t\t      size_t len)\n {\n \tconst char *tag_body = strstr(buf, \"\\n\\n\");\n \tif (tag_body) {\n@@ -493,7 +493,7 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \tfor (i = 0; i < origins.nr; i++) {\n \t\tstruct object_id *oid = origins.items[i].util;\n \t\tenum object_type type;\n-\t\tunsigned long size, len;\n+\t\tsize_t size, len;\n \t\tchar *buf = read_object_file(oid, &type, &size);\n \t\tstruct strbuf sig = STRBUF_INIT;\n\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex d26fb0a044..96cfd64fb6 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -422,7 +422,7 @@ static void check_connectivity(void)\n \t}\n }\n\n-static int fsck_obj(struct object *obj, void *buffer, unsigned long size)\n+static int fsck_obj(struct object *obj, void *buffer, size_t size)\n {\n \tint err;\n\n@@ -470,7 +470,7 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)\n }\n\n static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,\n-\t\t\t   unsigned long size, void *buffer, int *eaten)\n+\t\t\t   size_t size, void *buffer, int *eaten)\n {\n \t/*\n \t * Note, buffer may be NULL if type is OBJ_BLOB. See\n@@ -625,7 +625,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)\n {\n \tstruct object *obj;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *contents;\n \tint eaten;\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 580fd38f41..97682a8643 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -295,7 +295,7 @@ static int grep_cmd_config(const char *var, const char *value, void *cb)\n \treturn st;\n }\n\n-static void *lock_and_read_oid_file(const struct object_id *oid, enum object_type *type, unsigned long *size)\n+static void *lock_and_read_oid_file(const struct object_id *oid, enum object_type *type, size_t *size)\n {\n \tvoid *data;\n\n@@ -452,7 +452,7 @@ static int grep_submodule(struct grep_opt *opt,\n \t\tstruct object *object;\n \t\tstruct tree_desc tree;\n \t\tvoid *data;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tstruct strbuf base = STRBUF_INIT;\n\n \t\tobject = parse_object_or_die(oid, oid_to_hex(oid));\n@@ -583,7 +583,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\t\tenum object_type type;\n \t\t\tstruct tree_desc sub;\n \t\t\tvoid *data;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n\n \t\t\tdata = lock_and_read_oid_file(&entry.oid, &type, &size);\n \t\t\tif (!data)\n@@ -618,7 +618,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,\n \tif (obj->type == OBJ_COMMIT || obj->type == OBJ_TREE) {\n \t\tstruct tree_desc tree;\n \t\tvoid *data;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tstruct strbuf base;\n \t\tint hit, len;\n\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 31046c7a0a..9e3f97f282 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -20,7 +20,7 @@ static const char index_pack_usage[] =\n\n struct object_entry {\n \tstruct pack_idx_entry idx;\n-\tunsigned long size;\n+\tsize_t size;\n \tunsigned char hdr_size;\n \tsigned char type;\n \tsigned char real_type;\n@@ -36,7 +36,7 @@ struct base_data {\n \tstruct base_data *child;\n \tstruct object_entry *obj;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ref_first, ref_last;\n \tint ofs_first, ofs_last;\n };\n@@ -198,7 +198,7 @@ static unsigned check_object(struct object *obj)\n \t\treturn 0;\n\n \tif (!(obj->flags & FLAG_CHECKED)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n@@ -412,7 +412,7 @@ static int is_delta_type(enum object_type type)\n \treturn (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA);\n }\n\n-static void *unpack_entry_data(off_t offset, unsigned long size,\n+static void *unpack_entry_data(off_t offset, size_t size,\n \t\t\t       enum object_type type, struct object_id *oid)\n {\n \tstatic char fixed_buf[8192];\n@@ -467,7 +467,7 @@ static void *unpack_raw_entry(struct object_entry *obj,\n \t\t\t      struct object_id *oid)\n {\n \tunsigned char *p;\n-\tunsigned long size, c;\n+\tsize_t size, c;\n \toff_t base_offset;\n \tunsigned shift;\n \tvoid *data;\n@@ -529,7 +529,7 @@ static void *unpack_raw_entry(struct object_entry *obj,\n }\n\n static void *unpack_data(struct object_entry *obj,\n-\t\t\t int (*consume)(const unsigned char *, unsigned long, void *),\n+\t\t\t int (*consume)(const unsigned char *, size_t, void *),\n \t\t\t void *cb_data)\n {\n \toff_t from = obj[0].idx.offset + obj[0].hdr_size;\n@@ -706,10 +706,10 @@ struct compare_data {\n \tstruct object_entry *entry;\n \tstruct git_istream *st;\n \tunsigned char *buf;\n-\tunsigned long buf_size;\n+\tsize_t buf_size;\n };\n\n-static int compare_objects(const unsigned char *buf, unsigned long size,\n+static int compare_objects(const unsigned char *buf, size_t size,\n \t\t\t   void *cb_data)\n {\n \tstruct compare_data *data = cb_data;\n@@ -741,7 +741,7 @@ static int check_collison(struct object_entry *entry)\n {\n \tstruct compare_data data;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n\n \tif (entry->size <= big_file_threshold || entry->type != OBJ_BLOB)\n \t\treturn -1;\n@@ -761,7 +761,7 @@ static int check_collison(struct object_entry *entry)\n }\n\n static void sha1_object(const void *data, struct object_entry *obj_entry,\n-\t\t\tunsigned long size, enum object_type type,\n+\t\t\tsize_t size, enum object_type type,\n \t\t\tconst struct object_id *oid)\n {\n \tvoid *new_data = NULL;\n@@ -785,7 +785,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \tif (collision_test_needed) {\n \t\tvoid *has_data;\n \t\tenum object_type has_type;\n-\t\tunsigned long has_size;\n+\t\tsize_t has_size;\n \t\tread_lock();\n \t\thas_type = oid_object_info(the_repository, oid, &has_size);\n \t\tif (has_type < 0)\n@@ -1288,11 +1288,11 @@ static int write_compressed(struct hashfile *f, void *in, unsigned int size)\n\n static struct object_entry *append_obj_to_pack(struct hashfile *f,\n \t\t\t       const unsigned char *sha1, void *buf,\n-\t\t\t       unsigned long size, enum object_type type)\n+\t\t\t       size_t size, enum object_type type)\n {\n \tstruct object_entry *obj = &objects[nr_objects++];\n \tunsigned char header[10];\n-\tunsigned long s = size;\n+\tsize_t s = size;\n \tint n = 0;\n \tunsigned char c = (type << 4) | (s & 15);\n \ts >>= 4;\ndiff --git a/builtin/log.c b/builtin/log.c\nindex ab859f5904..586e746183 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -507,7 +507,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \tstruct object_id oidc;\n \tstruct object_context obj_context;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n\n \tfflush(rev->diffopt.file);\n \tif (!rev->diffopt.flags.textconv_set_via_cmdline ||\n@@ -535,7 +535,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n\n static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = read_object_file(oid, &type, &size);\n \tint offset = 0;\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 7cad3f24eb..b4ceca9e25 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -94,7 +94,7 @@ static int show_tree(const struct object_id *oid, struct strbuf *base,\n \t\tif (ls_options & LS_SHOW_SIZE) {\n \t\t\tchar size_text[24];\n \t\t\tif (!strcmp(type, blob_type)) {\n-\t\t\t\tunsigned long size;\n+\t\t\t\tsize_t size;\n \t\t\t\tif (oid_object_info(the_repository, oid, &size) == OBJ_BAD)\n \t\t\t\t\txsnprintf(size_text, sizeof(size_text),\n \t\t\t\t\t\t  \"BAD\");\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 34ca0258b1..08f4ba3256 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -56,7 +56,7 @@ static const char *explanation(struct merge_list *entry)\n \treturn \"removed in remote\";\n }\n\n-static void *result(struct merge_list *entry, unsigned long *size)\n+static void *result(struct merge_list *entry, size_t *size)\n {\n \tenum object_type type;\n \tstruct blob *base, *our, *their;\n@@ -81,7 +81,7 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \t\t\t   base, our, their, size);\n }\n\n-static void *origin(struct merge_list *entry, unsigned long *size)\n+static void *origin(struct merge_list *entry, size_t *size)\n {\n \tenum object_type type;\n \twhile (entry) {\n@@ -103,7 +103,7 @@ static int show_outf(void *priv_, mmbuffer_t *mb, int nbuf)\n\n static void show_diff(struct merge_list *entry)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tmmfile_t src, dst;\n \txpparam_t xpp;\n \txdemitconf_t xecfg;\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 6fb7dc8578..955a353fde 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -24,7 +24,7 @@ static int verify_object(const struct object_id *oid, const char *expected_type)\n {\n \tint ret = -1;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *buffer = read_object_file(oid, &type, &size);\n \tconst struct object_id *repl = lookup_replace_object(the_repository, oid);\n\n@@ -36,7 +36,7 @@ static int verify_object(const struct object_id *oid, const char *expected_type)\n \treturn ret;\n }\n\n-static int verify_tag(char *buffer, unsigned long size)\n+static int verify_tag(char *buffer, size_t size)\n {\n \tint typelen;\n \tchar type[20];\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 02e97f55c5..5f232d5e66 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -122,7 +122,7 @@ static int list_each_note(const struct object_id *object_oid,\n\n static void copy_obj_to_fd(int fd, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = read_object_file(oid, &type, &size);\n \tif (buf) {\n@@ -252,7 +252,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n \tchar *buf;\n \tstruct object_id object;\n \tenum object_type type;\n-\tunsigned long len;\n+\tsize_t len;\n\n \tBUG_ON_OPT_NEG(unset);\n\n@@ -616,7 +616,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n\n \tif (note && !edit) {\n \t\t/* Append buf to previous note contents */\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tenum object_type type;\n \t\tchar *prev_buf = read_object_file(note, &type, &size);\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 4f953ece2f..0634f22ab6 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -81,7 +81,7 @@ static struct pack_idx_option pack_idx_opts;\n static const char *base_name;\n static int progress = 1;\n static int window = 10;\n-static unsigned long pack_size_limit;\n+static size_t pack_size_limit;\n static int depth = 50;\n static int delta_search_threads;\n static int pack_to_stdout;\n@@ -103,11 +103,11 @@ static int exclude_promisor_objects;\n\n static int use_delta_islands;\n\n-static unsigned long delta_cache_size = 0;\n-static unsigned long max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE;\n-static unsigned long cache_max_small_delta_size = 1000;\n+static size_t delta_cache_size = 0;\n+static size_t max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE;\n+static size_t cache_max_small_delta_size = 1000;\n\n-static unsigned long window_memory_limit = 0;\n+static size_t window_memory_limit = 0;\n\n static struct list_objects_filter_options filter_options;\n\n@@ -144,7 +144,7 @@ static void index_commit_for_bitmap(struct commit *commit)\n\n static void *get_delta(struct object_entry *entry)\n {\n-\tunsigned long size, base_size, delta_size;\n+\tsize_t size, base_size, delta_size;\n \tvoid *buf, *base_buf, *delta_buf;\n \tenum object_type type;\n\n@@ -170,11 +170,11 @@ static void *get_delta(struct object_entry *entry)\n \treturn delta_buf;\n }\n\n-static unsigned long do_compress(void **pptr, unsigned long size)\n+static size_t do_compress(void **pptr, size_t size)\n {\n \tgit_zstream stream;\n \tvoid *in, *out;\n-\tunsigned long maxsize;\n+\tsize_t maxsize;\n\n \tgit_deflate_init(&stream, pack_compression_level);\n \tmaxsize = git_deflate_bound(&stream, size);\n@@ -195,13 +195,13 @@ static unsigned long do_compress(void **pptr, unsigned long size)\n \treturn stream.total_out;\n }\n\n-static unsigned long write_large_blob_data(struct git_istream *st, struct hashfile *f,\n+static size_t write_large_blob_data(struct git_istream *st, struct hashfile *f,\n \t\t\t\t\t   const struct object_id *oid)\n {\n \tgit_zstream stream;\n \tunsigned char ibuf[1024 * 16];\n \tunsigned char obuf[1024 * 16];\n-\tunsigned long olen = 0;\n+\tsize_t olen = 0;\n\n \tgit_deflate_init(&stream, pack_compression_level);\n\n@@ -242,7 +242,7 @@ static int check_pack_inflate(struct packed_git *p,\n \t\tstruct pack_window **w_curs,\n \t\toff_t offset,\n \t\toff_t len,\n-\t\tunsigned long expect)\n+\t\tsize_t expect)\n {\n \tgit_zstream stream;\n \tunsigned char fakebuf[4096], *in;\n@@ -284,10 +284,10 @@ static void copy_pack_data(struct hashfile *f,\n }\n\n /* Return 0 if we will bust the pack-size limit */\n-static unsigned long write_no_reuse_object(struct hashfile *f, struct object_entry *entry,\n-\t\t\t\t\t   unsigned long limit, int usable_delta)\n+static size_t write_no_reuse_object(struct hashfile *f, struct object_entry *entry,\n+\t\t\t\t\t   size_t limit, int usable_delta)\n {\n-\tunsigned long size, datalen;\n+\tsize_t size, datalen;\n \tunsigned char header[MAX_PACK_OBJECT_HEADER],\n \t\t      dheader[MAX_PACK_OBJECT_HEADER];\n \tunsigned hdrlen;\n@@ -396,7 +396,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent\n\n /* Return 0 if we will bust the pack-size limit */\n static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,\n-\t\t\t\tunsigned long limit, int usable_delta)\n+\t\t\t\tsize_t limit, int usable_delta)\n {\n \tstruct packed_git *p = IN_PACK(entry);\n \tstruct pack_window *w_curs = NULL;\n@@ -408,7 +408,7 @@ static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,\n \t\t      dheader[MAX_PACK_OBJECT_HEADER];\n \tunsigned hdrlen;\n \tconst unsigned hashsz = the_hash_algo->rawsz;\n-\tunsigned long entry_size = SIZE(entry);\n+\tsize_t entry_size = SIZE(entry);\n\n \tif (DELTA(entry))\n \t\ttype = (allow_ofs_delta && DELTA(entry)->idx.offset) ?\n@@ -479,7 +479,7 @@ static off_t write_object(struct hashfile *f,\n \t\t\t  struct object_entry *entry,\n \t\t\t  off_t write_offset)\n {\n-\tunsigned long limit;\n+\tsize_t limit;\n \toff_t len;\n \tint usable_delta, to_reuse;\n\n@@ -1210,7 +1210,7 @@ struct pbase_tree_cache {\n \tint ref;\n \tint temporary;\n \tvoid *tree_data;\n-\tunsigned long tree_size;\n+\tsize_t tree_size;\n };\n\n static struct pbase_tree_cache *(pbase_tree_cache[256]);\n@@ -1237,7 +1237,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n {\n \tstruct pbase_tree_cache *ent, *nent;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tint neigh;\n \tint my_ix = pbase_tree_cache_ix(oid);\n@@ -1420,7 +1420,7 @@ static void add_preferred_base(struct object_id *oid)\n {\n \tstruct pbase_tree *it;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_id tree_oid;\n\n \tif (window <= num_preferred_base++)\n@@ -1524,7 +1524,7 @@ static int can_reuse_delta(const unsigned char *base_sha1,\n\n static void check_object(struct object_entry *entry)\n {\n-\tunsigned long canonical_size;\n+\tsize_t canonical_size;\n\n \tif (IN_PACK(entry)) {\n \t\tstruct packed_git *p = IN_PACK(entry);\n@@ -1536,7 +1536,7 @@ static void check_object(struct object_entry *entry)\n \t\toff_t ofs;\n \t\tunsigned char *buf, c;\n \t\tenum object_type type;\n-\t\tunsigned long in_pack_size;\n+\t\tsize_t in_pack_size;\n\n \t\tbuf = use_pack(p, &w_curs, entry->in_pack_offset, &avail);\n\n@@ -1702,7 +1702,7 @@ static void drop_reused_delta(struct object_entry *entry)\n \tunsigned *idx = &to_pack.objects[entry->delta_idx - 1].delta_child_idx;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n\n \twhile (*idx) {\n \t\tstruct object_entry *oe = &to_pack.objects[*idx - 1];\n@@ -1905,8 +1905,8 @@ static int type_size_sort(const void *_a, const void *_b)\n \tconst struct object_entry *b = *(struct object_entry **)_b;\n \tconst enum object_type a_type = oe_type(a);\n \tconst enum object_type b_type = oe_type(b);\n-\tconst unsigned long a_size = SIZE(a);\n-\tconst unsigned long b_size = SIZE(b);\n+\tconst size_t a_size = SIZE(a);\n+\tconst size_t b_size = SIZE(b);\n\n \tif (a_type > b_type)\n \t\treturn -1;\n@@ -1939,8 +1939,8 @@ struct unpacked {\n \tunsigned depth;\n };\n\n-static int delta_cacheable(unsigned long src_size, unsigned long trg_size,\n-\t\t\t   unsigned long delta_size)\n+static int delta_cacheable(size_t src_size, size_t trg_size,\n+\t\t\t   size_t delta_size)\n {\n \tif (max_delta_cache_size && delta_cache_size + delta_size > max_delta_cache_size)\n \t\treturn 0;\n@@ -1980,14 +1980,14 @@ static pthread_mutex_t progress_mutex;\n  * reconstruction (so non-deltas are true object sizes, but deltas\n  * return the size of the delta data).\n  */\n-unsigned long oe_get_size_slow(struct packing_data *pack,\n+size_t oe_get_size_slow(struct packing_data *pack,\n \t\t\t       const struct object_entry *e)\n {\n \tstruct packed_git *p;\n \tstruct pack_window *w_curs;\n \tunsigned char *buf;\n \tenum object_type type;\n-\tunsigned long used, size;\n+\tsize_t used, size;\n \tsize_t avail;\n\n \tif (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {\n@@ -2017,11 +2017,11 @@ unsigned long oe_get_size_slow(struct packing_data *pack,\n }\n\n static int try_delta(struct unpacked *trg, struct unpacked *src,\n-\t\t     unsigned max_depth, unsigned long *mem_usage)\n+\t\t     unsigned max_depth, size_t *mem_usage)\n {\n \tstruct object_entry *trg_entry = trg->entry;\n \tstruct object_entry *src_entry = src->entry;\n-\tunsigned long trg_size, src_size, delta_size, sizediff, max_size, sz;\n+\tsize_t trg_size, src_size, delta_size, sizediff, max_size, sz;\n \tunsigned ref_depth;\n \tenum object_type type;\n \tvoid *delta_buf;\n@@ -2177,9 +2177,9 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)\n \treturn m;\n }\n\n-static unsigned long free_unpacked(struct unpacked *n)\n+static size_t free_unpacked(struct unpacked *n)\n {\n-\tunsigned long freed_mem = sizeof_delta_index(n->index);\n+\tsize_t freed_mem = sizeof_delta_index(n->index);\n \tfree_delta_index(n->index);\n \tn->index = NULL;\n \tif (n->data) {\n@@ -2196,7 +2196,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,\n {\n \tuint32_t i, idx = 0, count = 0;\n \tstruct unpacked *array;\n-\tunsigned long mem_usage = 0;\n+\tsize_t mem_usage = 0;\n\n \tarray = xcalloc(window, sizeof(struct unpacked));\n\n@@ -2279,7 +2279,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,\n \t\t * between writes at that moment.\n \t\t */\n \t\tif (entry->delta_data && !pack_to_stdout) {\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n\n \t\t\tsize = do_compress(&entry->delta_data, DELTA_SIZE(entry));\n \t\t\tif (size < (1U << OE_Z_DELTA_BITS)) {\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 4d3430900d..610968c174 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -82,7 +82,7 @@ static int tree_is_complete(const struct object_id *oid)\n\n \tif (!tree->buffer) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tvoid *data = read_object_file(oid, &type, &size);\n \t\tif (!data) {\n \t\t\ttree->object.flags |= INCOMPLETE;\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex f5701629a8..915f324c5b 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -443,7 +443,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle)\n \tstruct commit *commit;\n \tstruct strbuf buf = STRBUF_INIT;\n \tconst char *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n\n \tif (get_oid(old_ref, &old_oid) < 0)\n \t\treturn error(_(\"not a valid object name: '%s'\"), old_ref);\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 02f6bd1279..3a76b590c1 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -165,7 +165,7 @@ static int git_tag_config(const char *var, const char *value, void *cb)\n\n static void write_tag_body(int fd, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf, *sp;\n\n@@ -286,7 +286,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \tenum object_type type;\n \tstruct commit *c;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint subject_len = 0;\n \tconst char *subject_start;\n\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex 58652229f2..61200ed57c 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -7,7 +7,7 @@ static char *create_temp_file(struct object_id *oid)\n \tstatic char path[50];\n \tvoid *buf;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tint fd;\n\n \tbuf = read_object_file(oid, &type, &size);\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 80478808b3..69bf9c8500 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -32,7 +32,7 @@ static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;\n  */\n struct obj_buffer {\n \tchar *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n };\n\n static struct decoration obj_decorate;\n@@ -42,7 +42,7 @@ static struct obj_buffer *lookup_object_buffer(struct object *base)\n \treturn lookup_decoration(&obj_decorate, base);\n }\n\n-static void add_object_buffer(struct object *object, char *buffer, unsigned long size)\n+static void add_object_buffer(struct object *object, char *buffer, size_t size)\n {\n \tstruct obj_buffer *obj;\n \tobj = xcalloc(1, sizeof(struct obj_buffer));\n@@ -94,7 +94,7 @@ static void use(int bytes)\n \t\tdie(_(\"pack exceeds maximum allowed size\"));\n }\n\n-static void *get_data(unsigned long size)\n+static void *get_data(size_t size)\n {\n \tgit_zstream stream;\n \tvoid *buf = xmallocz(size);\n@@ -131,7 +131,7 @@ struct delta_info {\n \tstruct object_id base_oid;\n \tunsigned nr;\n \toff_t base_offset;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *delta;\n \tstruct delta_info *next;\n };\n@@ -140,7 +140,7 @@ static struct delta_info *delta_list;\n\n static void add_delta_to_list(unsigned nr, const struct object_id *base_oid,\n \t\t\t      off_t base_offset,\n-\t\t\t      void *delta, unsigned long size)\n+\t\t\t      void *delta, size_t size)\n {\n \tstruct delta_info *info = xmalloc(sizeof(*info));\n\n@@ -199,7 +199,7 @@ static int check_object(struct object *obj, int type, void *data, struct fsck_op\n \t\tdie(\"object type mismatch\");\n\n \tif (!(obj->flags & FLAG_OPEN)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n@@ -229,7 +229,7 @@ static void write_rest(void)\n }\n\n static void added_object(unsigned nr, enum object_type type,\n-\t\t\t void *data, unsigned long size);\n+\t\t\t void *data, size_t size);\n\n /*\n  * Write out nr-th object from the list, now we know the contents\n@@ -237,7 +237,7 @@ static void added_object(unsigned nr, enum object_type type,\n  * to be checked at the end.\n  */\n static void write_object(unsigned nr, enum object_type type,\n-\t\t\t void *buf, unsigned long size)\n+\t\t\t void *buf, size_t size)\n {\n \tif (!strict) {\n \t\tif (write_object_file(buf, size, type_name(type),\n@@ -277,11 +277,11 @@ static void write_object(unsigned nr, enum object_type type,\n }\n\n static void resolve_delta(unsigned nr, enum object_type type,\n-\t\t\t  void *base, unsigned long base_size,\n-\t\t\t  void *delta, unsigned long delta_size)\n+\t\t\t  void *base, size_t base_size,\n+\t\t\t  void *delta, size_t delta_size)\n {\n \tvoid *result;\n-\tunsigned long result_size;\n+\tsize_t result_size;\n\n \tresult = patch_delta(base, base_size,\n \t\t\t     delta, delta_size,\n@@ -297,7 +297,7 @@ static void resolve_delta(unsigned nr, enum object_type type,\n  * resolve all the deltified objects that are based on it.\n  */\n static void added_object(unsigned nr, enum object_type type,\n-\t\t\t void *data, unsigned long size)\n+\t\t\t void *data, size_t size)\n {\n \tstruct delta_info **p = &delta_list;\n \tstruct delta_info *info;\n@@ -316,7 +316,7 @@ static void added_object(unsigned nr, enum object_type type,\n \t}\n }\n\n-static void unpack_non_delta_entry(enum object_type type, unsigned long size,\n+static void unpack_non_delta_entry(enum object_type type, size_t size,\n \t\t\t\t   unsigned nr)\n {\n \tvoid *buf = get_data(size);\n@@ -328,7 +328,7 @@ static void unpack_non_delta_entry(enum object_type type, unsigned long size,\n }\n\n static int resolve_against_held(unsigned nr, const struct object_id *base,\n-\t\t\t\tvoid *delta_data, unsigned long delta_size)\n+\t\t\t\tvoid *delta_data, size_t delta_size)\n {\n \tstruct object *obj;\n \tstruct obj_buffer *obj_buffer;\n@@ -343,11 +343,11 @@ static int resolve_against_held(unsigned nr, const struct object_id *base,\n \treturn 1;\n }\n\n-static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n+static void unpack_delta_entry(enum object_type type, size_t delta_size,\n \t\t\t       unsigned nr)\n {\n \tvoid *delta_data, *base;\n-\tunsigned long base_size;\n+\tsize_t base_size;\n \tstruct object_id base_oid;\n\n \tif (type == OBJ_REF_DELTA) {\n@@ -442,7 +442,7 @@ static void unpack_one(unsigned nr)\n {\n \tunsigned shift;\n \tunsigned char *pack;\n-\tunsigned long size, c;\n+\tsize_t size, c;\n \tenum object_type type;\n\n \tobj_list[nr].offset = consumed_bytes;\ndiff --git a/builtin/verify-commit.c b/builtin/verify-commit.c\nindex 7772c07ed7..0c25550ef1 100644\n--- a/builtin/verify-commit.c\n+++ b/builtin/verify-commit.c\n@@ -21,7 +21,7 @@ static const char * const verify_commit_usage[] = {\n \t\tNULL\n };\n\n-static int run_gpg_verify(const struct object_id *oid, const char *buf, unsigned long size, unsigned flags)\n+static int run_gpg_verify(const struct object_id *oid, const char *buf, size_t size, unsigned flags)\n {\n \tstruct signature_check signature_check;\n \tint ret;\n@@ -41,7 +41,7 @@ static int verify_commit(const char *name, unsigned flags)\n \tenum object_type type;\n \tstruct object_id oid;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n\n \tif (get_oid(name, &oid))\ndiff --git a/bundle.c b/bundle.c\nindex b45666c49b..518763818f 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -217,7 +217,7 @@ int list_bundle_refs(struct bundle_header *header, int argc, const char **argv)\n\n static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = NULL, *line, *lineend;\n \ttimestamp_t date;\ndiff --git a/cache.h b/cache.h\nindex 5c4aab2ff7..ed84392728 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -782,7 +782,7 @@ extern int chmod_index_entry(struct index_state *, struct cache_entry *ce, char\n extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);\n extern void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);\n extern int index_name_is_other(const struct index_state *, const char *, int);\n-extern void *read_blob_data_from_index(const struct index_state *, const char *, unsigned long *);\n+extern void *read_blob_data_from_index(const struct index_state *, const char *, size_t *);\n\n /* do stat comparison even if CE_VALID is true */\n #define CE_MATCH_IGNORE_VALID\t\t01\n@@ -1297,10 +1297,11 @@ extern char *xdg_cache_home(const char *filename);\n\n extern int git_open_cloexec(const char *name, int flags);\n #define git_open(name) git_open_cloexec(name, O_RDONLY)\n-extern int unpack_loose_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);\n-extern int parse_loose_header(const char *hdr, unsigned long *sizep);\n\n-extern int check_object_signature(const struct object_id *oid, void *buf, unsigned long size, const char *type);\n+extern int unpack_loose_header(git_zstream *stream, unsigned char *map, size_t mapsize, void *buffer, size_t bufsiz);\n+extern int parse_loose_header(const char *hdr, size_t *sizep);\n+\n+extern int check_object_signature(const struct object_id *oid, void *buf, size_t size, const char *type);\n\n extern int finalize_object_file(const char *tmpfile, const char *filename);\n\n@@ -1481,7 +1482,7 @@ extern int cache_name_stage_compare(const char *name1, int len1, int stage1, con\n\n extern void *read_object_with_reference(const struct object_id *oid,\n \t\t\t\t\tconst char *required_type,\n-\t\t\t\t\tunsigned long *size,\n+\t\t\t\t\tsize_t *size,\n \t\t\t\t\tstruct object_id *oid_ret);\n\n extern struct object *peel_to_type(const char *name, int namelen,\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 3e49f3bda8..5fe1e24faf 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -311,7 +311,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,\n\n static char *grab_blob(struct repository *r,\n \t\t       const struct object_id *oid, unsigned int mode,\n-\t\t       unsigned long *size, struct userdiff_driver *textconv,\n+\t\t       size_t *size, struct userdiff_driver *textconv,\n \t\t       const char *path)\n {\n \tchar *blob;\n@@ -403,7 +403,7 @@ static void consume_hunk(void *state_,\n \tstate->sline[state->nb-1].p_lno[state->n] = state->ob;\n }\n\n-static void consume_line(void *state_, char *line, unsigned long len)\n+static void consume_line(void *state_, char *line, size_t len)\n {\n \tstruct combine_diff_state *state = state_;\n \tif (!state->lost_bucket)\n@@ -433,7 +433,7 @@ static void combine_diff(struct repository *r,\n \txdemitconf_t xecfg;\n \tmmfile_t parent_file;\n \tstruct combine_diff_state state;\n-\tunsigned long sz;\n+\tsize_t sz;\n\n \tif (result_deleted)\n \t\treturn; /* result deleted */\n@@ -1016,7 +1016,8 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\t    struct rev_info *rev)\n {\n \tstruct diff_options *opt = &rev->diffopt;\n-\tunsigned long result_size, cnt, lno;\n+\tunsigned long cnt, lno;\n+\tsize_t result_size;\n \tint result_deleted = 0;\n \tchar *result, *cp;\n \tstruct sline *sline; /* survived lines */\n@@ -1134,7 +1135,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\tis_binary = buffer_is_binary(result, result_size);\n \t\tfor (i = 0; !is_binary && i < num_parent; i++) {\n \t\t\tchar *buf;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\tbuf = grab_blob(opt->repo,\n \t\t\t\t\t&elem->parent[i].oid,\n \t\t\t\t\telem->parent[i].mode,\ndiff --git a/commit.c b/commit.c\nindex a5333c7ac6..b9d8793910 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -260,7 +260,7 @@ int unregister_shallow(const struct object_id *oid)\n\n struct commit_buffer {\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n };\n define_commit_slab(buffer_slab, struct commit_buffer);\n\n@@ -277,7 +277,7 @@ void free_commit_buffer_slab(struct buffer_slab *bs)\n \tfree(bs);\n }\n\n-void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer, unsigned long size)\n+void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer, size_t size)\n {\n \tstruct commit_buffer *v = buffer_slab_at(\n \t\tr->parsed_objects->buffer_slab, commit);\n@@ -285,7 +285,7 @@ void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer\n \tv->size = size;\n }\n\n-const void *get_cached_commit_buffer(struct repository *r, const struct commit *commit, unsigned long *sizep)\n+const void *get_cached_commit_buffer(struct repository *r, const struct commit *commit, size_t *sizep)\n {\n \tstruct commit_buffer *v = buffer_slab_peek(\n \t\tr->parsed_objects->buffer_slab, commit);\n@@ -301,12 +301,12 @@ const void *get_cached_commit_buffer(struct repository *r, const struct commit *\n\n const void *repo_get_commit_buffer(struct repository *r,\n \t\t\t\t   const struct commit *commit,\n-\t\t\t\t   unsigned long *sizep)\n+\t\t\t\t   size_t *sizep)\n {\n \tconst void *ret = get_cached_commit_buffer(r, commit, sizep);\n \tif (!ret) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tret = repo_read_object_file(r, &commit->object.oid, &type, &size);\n \t\tif (!ret)\n \t\t\tdie(\"cannot read commit object %s\",\n@@ -366,7 +366,7 @@ void release_commit_memory(struct parsed_object_pool *pool, struct commit *c)\n \tc->object.parsed = 0;\n }\n\n-const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n+const void *detach_commit_buffer(struct commit *commit, size_t *sizep)\n {\n \tstruct commit_buffer *v = buffer_slab_peek(\n \t\tthe_repository->parsed_objects->buffer_slab, commit);\n@@ -386,7 +386,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n \treturn ret;\n }\n\n-int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph)\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, size_t size, int check_graph)\n {\n \tconst char *tail = buffer;\n \tconst char *bufptr = buffer;\n@@ -455,7 +455,7 @@ int repo_parse_commit_internal(struct repository *r,\n {\n \tenum object_type type;\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n\n \tif (!item)\n@@ -976,7 +976,7 @@ int parse_signed_commit(const struct commit *commit,\n \t\t\tstruct strbuf *payload, struct strbuf *signature)\n {\n\n-\tunsigned long size;\n+\tsize_t size;\n \tconst char *buffer = get_commit_buffer(commit, &size);\n \tint in_signature, saw_signature = -1;\n \tconst char *line, *tail;\n@@ -1051,7 +1051,7 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header\n \tstruct merge_remote_desc *desc;\n \tstruct commit_extra_header *mergetag;\n \tchar *buf;\n-\tunsigned long size, len;\n+\tsize_t size, len;\n \tenum object_type type;\n\n \tdesc = merge_remote_util(parent);\n@@ -1158,7 +1158,7 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,\n \t\t\t\t\t\t      const char **exclude)\n {\n \tstruct commit_extra_header *extra = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \tconst char *buffer = get_commit_buffer(commit, &size);\n \textra = read_commit_extra_header_lines(buffer, size, exclude);\n \tunuse_commit_buffer(commit, buffer);\ndiff --git a/commit.h b/commit.h\nindex 42728c2906..bcf3227b85 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -79,7 +79,7 @@ struct commit *lookup_commit_reference_by_name(const char *name);\n  */\n struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);\n\n-int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph);\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, size_t size, int check_graph);\n int repo_parse_commit_internal(struct repository *r, struct commit *item,\n \t\t\t       int quiet_on_missing, int use_commit_graph);\n int repo_parse_commit_gently(struct repository *r,\n@@ -105,13 +105,13 @@ void free_commit_buffer_slab(struct buffer_slab *bs);\n  * Associate an object buffer with the commit. The ownership of the\n  * memory is handed over to the commit, and must be free()-able.\n  */\n-void set_commit_buffer(struct repository *r, struct commit *, void *buffer, unsigned long size);\n+void set_commit_buffer(struct repository *r, struct commit *, void *buffer, size_t size);\n\n /*\n  * Get any cached object buffer associated with the commit. Returns NULL\n  * if none. The resulting memory should not be freed.\n  */\n-const void *get_cached_commit_buffer(struct repository *, const struct commit *, unsigned long *size);\n+const void *get_cached_commit_buffer(struct repository *, const struct commit *, size_t *size);\n\n /*\n  * Get the commit's object contents, either from cache or by reading the object\n@@ -120,7 +120,7 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,\n  */\n const void *repo_get_commit_buffer(struct repository *r,\n \t\t\t\t   const struct commit *,\n-\t\t\t\t   unsigned long *size);\n+\t\t\t\t   size_t *size);\n #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS\n #define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s)\n #endif\n@@ -156,7 +156,7 @@ void release_commit_memory(struct parsed_object_pool *pool, struct commit *c);\n  * Disassociate any cached object buffer from the commit, but do not free it.\n  * The buffer (or NULL, if none) is returned.\n  */\n-const void *detach_commit_buffer(struct commit *, unsigned long *sizep);\n+const void *detach_commit_buffer(struct commit *, size_t *sizep);\n\n /* Find beginning and length of commit subject. */\n int find_commit_subject(const char *commit_buffer, const char **subject);\ndiff --git a/config.c b/config.c\nindex 0f0cdd8c0f..d83e4eb4ae 100644\n--- a/config.c\n+++ b/config.c\n@@ -1596,7 +1596,7 @@ int git_config_from_blob_oid(config_fn_t fn,\n {\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n\n \tbuf = read_object_file(oid, &type, &size);\ndiff --git a/convert.c b/convert.c\nindex 94ff837649..a8f94eec73 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -42,9 +42,9 @@ struct text_stat {\n \tunsigned printable, nonprintable;\n };\n\n-static void gather_stats(const char *buf, unsigned long size, struct text_stat *stats)\n+static void gather_stats(const char *buf, size_t size, struct text_stat *stats)\n {\n-\tunsigned long i;\n+\tsize_t i;\n\n \tmemset(stats, 0, sizeof(*stats));\n\n@@ -102,7 +102,7 @@ static int convert_is_binary(const struct text_stat *stats)\n \treturn 0;\n }\n\n-static unsigned int gather_convert_stats(const char *data, unsigned long size)\n+static unsigned int gather_convert_stats(const char *data, size_t size)\n {\n \tstruct text_stat stats;\n \tint ret = 0;\n@@ -119,7 +119,7 @@ static unsigned int gather_convert_stats(const char *data, unsigned long size)\n \treturn ret;\n }\n\n-static const char *gather_convert_stats_ascii(const char *data, unsigned long size)\n+static const char *gather_convert_stats_ascii(const char *data, size_t size)\n {\n \tunsigned int convert_stats = gather_convert_stats(data, size);\n\n@@ -141,7 +141,7 @@ const char *get_cached_convert_stats_ascii(const struct index_state *istate,\n \t\t\t\t\t   const char *path)\n {\n \tconst char *ret;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tvoid *data = read_blob_data_from_index(istate, path, &sz);\n \tret = gather_convert_stats_ascii(data, sz);\n \tfree(data);\n@@ -223,7 +223,7 @@ static void check_global_conv_flags_eol(const char *path, enum crlf_action crlf_\n\n static int has_crlf_in_index(const struct index_state *istate, const char *path)\n {\n-\tunsigned long sz;\n+\tsize_t sz;\n \tvoid *data;\n \tconst char *crp;\n \tint has_crlf = 0;\n@@ -629,7 +629,7 @@ static int crlf_to_worktree(const char *src, size_t len,\n\n struct filter_params {\n \tconst char *src;\n-\tunsigned long size;\n+\tsize_t size;\n \tint fd;\n \tconst char *cmd;\n \tconst char *path;\n@@ -1048,7 +1048,7 @@ static int read_convert_config(const char *var, const char *value, void *cb)\n \treturn 0;\n }\n\n-static int count_ident(const char *cp, unsigned long size)\n+static int count_ident(const char *cp, size_t size)\n {\n \t/*\n \t * \"$Id: 0000000000000000000000000000000000000000 $\" <=> \"$Id$\"\ndiff --git a/delta.h b/delta.h\nindex 9b67531dfa..541171230c 100644\n--- a/delta.h\n+++ b/delta.h\n@@ -42,8 +42,8 @@ extern unsigned long sizeof_delta_index(struct delta_index *index);\n  */\n extern void *\n create_delta(const struct delta_index *index,\n-\t     const void *buf, unsigned long bufsize,\n-\t     unsigned long *delta_size, unsigned long max_delta_size);\n+\t     const void *buf, size_t bufsize,\n+\t     size_t *delta_size, size_t max_delta_size);\n\n /*\n  * diff_delta: create a delta from source buffer to target buffer\n@@ -54,9 +54,9 @@ create_delta(const struct delta_index *index,\n  * updated with its size.  The returned buffer must be freed by the caller.\n  */\n static inline void *\n-diff_delta(const void *src_buf, unsigned long src_bufsize,\n-\t   const void *trg_buf, unsigned long trg_bufsize,\n-\t   unsigned long *delta_size, unsigned long max_delta_size)\n+diff_delta(const void *src_buf, size_t src_bufsize,\n+\t   const void *trg_buf, size_t trg_bufsize,\n+\t   size_t *delta_size, size_t max_delta_size)\n {\n \tstruct delta_index *index = create_delta_index(src_buf, src_bufsize);\n \tif (index) {\n@@ -75,9 +75,9 @@ diff_delta(const void *src_buf, unsigned long src_bufsize,\n  * *trg_bufsize is updated with its size.  On failure a NULL pointer is\n  * returned.  The returned buffer must be freed by the caller.\n  */\n-extern void *patch_delta(const void *src_buf, unsigned long src_size,\n-\t\t\t const void *delta_buf, unsigned long delta_size,\n-\t\t\t unsigned long *dst_size);\n+extern void *patch_delta(const void *src_buf, size_t src_size,\n+\t\t\t const void *delta_buf, size_t delta_size,\n+\t\t\t size_t *dst_size);\n\n /* the smallest possible delta size is 4 bytes */\n #define DELTA_SIZE_MIN\t4\n@@ -86,11 +86,11 @@ extern void *patch_delta(const void *src_buf, unsigned long src_size,\n  * This must be called twice on the delta data buffer, first to get the\n  * expected source buffer size, and again to get the target buffer size.\n  */\n-static inline unsigned long get_delta_hdr_size(const unsigned char **datap,\n+static inline size_t get_delta_hdr_size(const unsigned char **datap,\n \t\t\t\t\t       const unsigned char *top)\n {\n \tconst unsigned char *data = *datap;\n-\tunsigned long cmd, size = 0;\n+\tsize_t cmd, size = 0;\n \tint i = 0;\n \tdo {\n \t\tcmd = *data++;\ndiff --git a/diff-delta.c b/diff-delta.c\nindex e49643353b..072a5ca839 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -316,8 +316,8 @@ unsigned long sizeof_delta_index(struct delta_index *index)\n\n void *\n create_delta(const struct delta_index *index,\n-\t     const void *trg_buf, unsigned long trg_size,\n-\t     unsigned long *delta_size, unsigned long max_size)\n+\t     const void *trg_buf, size_t trg_size,\n+\t     size_t *delta_size, size_t max_size)\n {\n \tunsigned int i, val;\n \toff_t outpos, moff;\ndiff --git a/diff.c b/diff.c\nindex ec5c095199..adaecfb2b9 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2322,7 +2322,7 @@ static void find_lno(const char *line, struct emit_callback *ecbdata)\n \tecbdata->lno_in_postimage = strtol(p + 1, NULL, 10);\n }\n\n-static void fn_out_consume(void *priv, char *line, unsigned long len)\n+static void fn_out_consume(void *priv, char *line, size_t len)\n {\n \tstruct emit_callback *ecbdata = priv;\n \tstruct diff_options *o = ecbdata->opt;\n@@ -2524,7 +2524,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,\n \treturn x;\n }\n\n-static void diffstat_consume(void *priv, char *line, unsigned long len)\n+static void diffstat_consume(void *priv, char *line, size_t len)\n {\n \tstruct diffstat_t *diffstat = priv;\n \tstruct diffstat_file *x = diffstat->files[diffstat->nr - 1];\n@@ -3204,7 +3204,7 @@ static void checkdiff_consume_hunk(void *priv,\n \tdata->lineno = nb - 1;\n }\n\n-static void checkdiff_consume(void *priv, char *line, unsigned long len)\n+static void checkdiff_consume(void *priv, char *line, size_t len)\n {\n \tstruct checkdiff_t *data = priv;\n \tint marker_size = data->conflict_marker_size;\n@@ -3243,8 +3243,8 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)\n }\n\n static unsigned char *deflate_it(char *data,\n-\t\t\t\t unsigned long size,\n-\t\t\t\t unsigned long *result_size)\n+\t\t\t\t size_t size,\n+\t\t\t\t size_t *result_size)\n {\n \tint bound;\n \tunsigned char *deflated;\n@@ -3272,10 +3272,10 @@ static void emit_binary_diff_body(struct diff_options *o,\n \tvoid *delta;\n \tvoid *deflated;\n \tvoid *data;\n-\tunsigned long orig_size;\n-\tunsigned long delta_size;\n-\tunsigned long deflate_size;\n-\tunsigned long data_size;\n+\tsize_t orig_size;\n+\tsize_t delta_size;\n+\tsize_t deflate_size;\n+\tsize_t data_size;\n\n \t/* We could do deflated delta, or we could do just deflated two,\n \t * whichever is smaller.\n@@ -4063,7 +4063,7 @@ void diff_free_filespec_data(struct diff_filespec *s)\n static void prep_temp_blob(struct index_state *istate,\n \t\t\t   const char *path, struct diff_tempfile *temp,\n \t\t\t   void *blob,\n-\t\t\t   unsigned long size,\n+\t\t\t   size_t size,\n \t\t\t   const struct object_id *oid,\n \t\t\t   int mode)\n {\n@@ -5863,9 +5863,9 @@ struct patch_id_t {\n \tint patchlen;\n };\n\n-static int remove_space(char *line, int len)\n+static size_t remove_space(char *line, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tchar *dst = line;\n \tunsigned char c;\n\n@@ -5876,10 +5876,10 @@ static int remove_space(char *line, int len)\n \treturn dst - line;\n }\n\n-static void patch_id_consume(void *priv, char *line, unsigned long len)\n+static void patch_id_consume(void *priv, char *line, size_t len)\n {\n \tstruct patch_id_t *data = priv;\n-\tint new_len;\n+\tsize_t new_len;\n\n \tnew_len = remove_space(line, len);\n\n@@ -6642,7 +6642,7 @@ int textconv_object(struct repository *r,\n \t\t    const struct object_id *oid,\n \t\t    int oid_valid,\n \t\t    char **buf,\n-\t\t    unsigned long *buf_size)\n+\t\t    size_t *buf_size)\n {\n \tstruct diff_filespec *df;\n \tstruct userdiff_driver *textconv;\ndiff --git a/diff.h b/diff.h\nindex c9db9825bb..9aba0ade75 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -477,7 +477,7 @@ int textconv_object(struct repository *repo,\n \t\t    const char *path,\n \t\t    unsigned mode,\n \t\t    const struct object_id *oid, int oid_valid,\n-\t\t    char **buf, unsigned long *buf_size);\n+\t\t    char **buf, size_t *buf_size);\n\n int parse_rename_score(const char **cp_p);\n\ndiff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c\nindex a9c6d60df2..7d15d4ecb9 100644\n--- a/diffcore-pickaxe.c\n+++ b/diffcore-pickaxe.c\n@@ -19,7 +19,7 @@ struct diffgrep_cb {\n \tint hit;\n };\n\n-static void diffgrep_consume(void *priv, char *line, unsigned long len)\n+static void diffgrep_consume(void *priv, char *line, size_t len)\n {\n \tstruct diffgrep_cb *data = priv;\n \tregmatch_t regmatch;\n@@ -71,7 +71,7 @@ static int diff_grep(mmfile_t *one, mmfile_t *two,\n static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws)\n {\n \tunsigned int cnt;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tconst char *data;\n\n \tsz = mf->size;\ndiff --git a/diffcore.h b/diffcore.h\nindex b651061c0e..b47778dd36 100644\n--- a/diffcore.h\n+++ b/diffcore.h\n@@ -33,7 +33,7 @@ struct diff_filespec {\n \tchar *path;\n \tvoid *data;\n \tvoid *cnt_data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint count;               /* Reference count */\n \tint rename_used;         /* Count of rename users */\n \tunsigned short mode;\t /* file mode */\ndiff --git a/dir.c b/dir.c\nindex b2cabadf25..a59b99d516 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -182,7 +182,7 @@ static size_t common_prefix_len(const struct pathspec *pathspec)\n  */\n char *common_prefix(const struct pathspec *pathspec)\n {\n-\tunsigned long len = common_prefix_len(pathspec);\n+\tsize_t len = common_prefix_len(pathspec);\n\n \treturn len ? xmemdupz(pathspec->items[0].match, len) : NULL;\n }\n@@ -238,7 +238,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,\n \t\t\tsize_t *size_out, char **data_out)\n {\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tchar *data;\n\n \t*size_out = 0;\n@@ -2825,7 +2825,7 @@ static void load_oid_stat(struct oid_stat *oid_stat, const unsigned char *data,\n \toid_stat->valid = 1;\n }\n\n-struct untracked_cache *read_untracked_extension(const void *data, unsigned long sz)\n+struct untracked_cache *read_untracked_extension(const void *data, size_t sz)\n {\n \tstruct untracked_cache *uc;\n \tstruct read_data rd;\ndiff --git a/dir.h b/dir.h\nindex e3ec26143d..7dc741cd41 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -360,7 +360,7 @@ void untracked_cache_remove_from_index(struct index_state *, const char *);\n void untracked_cache_add_to_index(struct index_state *, const char *);\n\n void free_untracked_cache(struct untracked_cache *);\n-struct untracked_cache *read_untracked_extension(const void *data, unsigned long sz);\n+struct untracked_cache *read_untracked_extension(const void *data, size_t sz);\n void write_untracked_extension(struct strbuf *out, struct untracked_cache *untracked);\n void add_untracked_cache(struct index_state *istate);\n void remove_untracked_cache(struct index_state *istate);\ndiff --git a/entry.c b/entry.c\nindex 0e4f2f2910..fa9802e73a 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -83,7 +83,7 @@ static int create_file(const char *path, unsigned int mode)\n \treturn open(path, O_WRONLY | O_CREAT | O_EXCL, mode);\n }\n\n-static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size)\n+static void *read_blob_entry(const struct cache_entry *ce, size_t *size)\n {\n \tenum object_type type;\n \tvoid *blob_data = read_object_file(&ce->oid, &type, size);\n@@ -259,7 +259,7 @@ static int write_entry(struct cache_entry *ce,\n \tint fd, ret, fstat_done = 0;\n \tchar *new_blob;\n \tstruct strbuf buf = STRBUF_INIT;\n-\tunsigned long size;\n+\tsize_t size;\n \tssize_t wrote;\n \tsize_t newsize = 0;\n \tstruct stat st;\ndiff --git a/fast-import.c b/fast-import.c\nindex b7ba755c2b..adb09ef10e 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -895,7 +895,7 @@ static int store_object(\n \tstruct object_entry *e;\n \tunsigned char hdr[96];\n \tstruct object_id oid;\n-\tunsigned long hdrlen, deltalen;\n+\tsize_t hdrlen, deltalen;\n \tgit_hash_ctx c;\n \tgit_zstream s;\n\n@@ -1036,7 +1036,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)\n \tunsigned char *out_buf = xmalloc(out_sz);\n \tstruct object_entry *e;\n \tstruct object_id oid;\n-\tunsigned long hdrlen;\n+\tsize_t hdrlen;\n \toff_t offset;\n \tgit_hash_ctx c;\n \tgit_zstream s;\n@@ -1154,7 +1154,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)\n  */\n static void *gfi_unpack_entry(\n \tstruct object_entry *oe,\n-\tunsigned long *sizep)\n+\tsize_t *sizep)\n {\n \tenum object_type type;\n \tstruct packed_git *p = all_packs[oe->pack_id];\n@@ -1200,7 +1200,7 @@ static void load_tree(struct tree_entry *root)\n \tstruct object_id *oid = &root->versions[1].oid;\n \tstruct object_entry *myoe;\n \tstruct tree_content *t;\n-\tunsigned long size;\n+\tsize_t size;\n \tchar *buf;\n \tconst char *c;\n\n@@ -1873,7 +1873,7 @@ static int validate_raw_date(const char *src, struct strbuf *result)\n {\n \tconst char *orig_src = src;\n \tchar *endp;\n-\tunsigned long num;\n+\tsize_t num;\n\n \terrno = 0;\n\n@@ -2400,7 +2400,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", commit_mark);\n \t\toidcpy(&commit_oid, &commit_oe->idx.oid);\n \t} else if (!get_oid(p, &commit_oid)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf = read_object_with_reference(&commit_oid,\n \t\t\t\t\t\t       commit_type, &size,\n \t\t\t\t\t\t       &commit_oid);\n@@ -2453,7 +2453,7 @@ static void file_change_deleteall(struct branch *b)\n \tb->num_notes = 0;\n }\n\n-static void parse_from_commit(struct branch *b, char *buf, unsigned long size)\n+static void parse_from_commit(struct branch *b, char *buf, size_t size)\n {\n \tif (!buf || size < GIT_SHA1_HEXSZ + 6)\n \t\tdie(\"Not a valid commit: %s\", oid_to_hex(&b->oid));\n@@ -2470,7 +2470,7 @@ static void parse_from_existing(struct branch *b)\n \t\toidclr(&b->branch_tree.versions[0].oid);\n \t\toidclr(&b->branch_tree.versions[1].oid);\n \t} else {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf;\n\n \t\tbuf = read_object_with_reference(&b->oid, commit_type, &size,\n@@ -2507,7 +2507,7 @@ static int parse_from(struct branch *b)\n \t\tif (!oideq(&b->oid, &oe->idx.oid)) {\n \t\t\toidcpy(&b->oid, &oe->idx.oid);\n \t\t\tif (oe->pack_id != MAX_PACK_ID) {\n-\t\t\t\tunsigned long size;\n+\t\t\t\tsize_t size;\n \t\t\t\tchar *buf = gfi_unpack_entry(oe, &size);\n \t\t\t\tparse_from_commit(b, buf, size);\n \t\t\t\tfree(buf);\n@@ -2550,7 +2550,7 @@ static struct hash_list *parse_merge(unsigned int *count)\n \t\t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", idnum);\n \t\t\toidcpy(&n->oid, &oe->idx.oid);\n \t\t} else if (!get_oid(from, &n->oid)) {\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\tchar *buf = read_object_with_reference(&n->oid,\n \t\t\t\t\t\t\t       commit_type,\n \t\t\t\t\t\t\t       &size, &n->oid);\n@@ -2776,7 +2776,7 @@ static void parse_reset_branch(const char *arg)\n \t\tunread_command_buf = 1;\n }\n\n-static void cat_blob_write(const char *buf, unsigned long size)\n+static void cat_blob_write(const char *buf, size_t size)\n {\n \tif (write_in_full(cat_blob_fd, buf, size) < 0)\n \t\tdie_errno(\"Write to frontend failed\");\n@@ -2785,7 +2785,7 @@ static void cat_blob_write(const char *buf, unsigned long size)\n static void cat_blob(struct object_entry *oe, struct object_id *oid)\n {\n \tstruct strbuf line = STRBUF_INIT;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type = 0;\n \tchar *buf;\n\n@@ -2869,7 +2869,7 @@ static void parse_cat_blob(const char *p)\n static struct object_entry *dereference(struct object_entry *oe,\n \t\t\t\t\tstruct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tchar *buf = NULL;\n \tif (!oe) {\n \t\tenum object_type type = oid_object_info(the_repository, oid,\ndiff --git a/fsck.c b/fsck.c\nindex 2260adb71e..542b6d0a11 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -850,7 +850,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,\n }\n\n static int fsck_commit(struct commit *commit, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tconst char *buffer = data ?  data : get_commit_buffer(commit, &size);\n \tint ret = fsck_commit_buffer(commit, buffer, size, options);\n@@ -860,7 +860,7 @@ static int fsck_commit(struct commit *commit, const char *data,\n }\n\n static int fsck_tag_buffer(struct tag *tag, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tstruct object_id oid;\n \tint ret = 0;\n@@ -955,7 +955,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,\n }\n\n static int fsck_tag(struct tag *tag, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tstruct object *tagged = tag->tagged;\n\n@@ -1006,7 +1006,7 @@ static int fsck_gitmodules_fn(const char *var, const char *value, void *vdata)\n }\n\n static int fsck_blob(struct blob *blob, const char *buf,\n-\t\t     unsigned long size, struct fsck_options *options)\n+\t\t     size_t size, struct fsck_options *options)\n {\n \tstruct fsck_gitmodules_data data;\n \tstruct config_options config_opts = { 0 };\n@@ -1042,7 +1042,7 @@ static int fsck_blob(struct blob *blob, const char *buf,\n \treturn data.ret;\n }\n\n-int fsck_object(struct object *obj, void *data, unsigned long size,\n+int fsck_object(struct object *obj, void *data, size_t size,\n \tstruct fsck_options *options)\n {\n \tif (!obj)\n@@ -1084,7 +1084,7 @@ int fsck_finish(struct fsck_options *options)\n \twhile ((oid = oidset_iter_next(&iter))) {\n \t\tstruct blob *blob;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf;\n\n \t\tif (oidset_contains(&gitmodules_done, oid))\ndiff --git a/fsck.h b/fsck.h\nindex b95595ae5f..939ccf856b 100644\n--- a/fsck.h\n+++ b/fsck.h\n@@ -53,7 +53,7 @@ struct fsck_options {\n  */\n int fsck_walk(struct object *obj, void *data, struct fsck_options *options);\n /* If NULL is passed for data, we assume the object is local and read it. */\n-int fsck_object(struct object *obj, void *data, unsigned long size,\n+int fsck_object(struct object *obj, void *data, size_t size,\n \tstruct fsck_options *options);\n\n /*\ndiff --git a/fuzz-pack-headers.c b/fuzz-pack-headers.c\nindex 99da1d0fd3..d04e264e23 100644\n--- a/fuzz-pack-headers.c\n+++ b/fuzz-pack-headers.c\n@@ -5,10 +5,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);\n int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)\n {\n \tenum object_type type;\n-\tunsigned long len;\n+\tsize_t len;\n\n \tunpack_object_header_buffer((const unsigned char *)data,\n-\t\t\t\t    (unsigned long)size, &type, &len);\n+\t\t\t\t    size, &type, &len);\n\n \treturn 0;\n }\ndiff --git a/grep.h b/grep.h\nindex fb04893721..5765213f4b 100644\n--- a/grep.h\n+++ b/grep.h\n@@ -209,7 +209,7 @@ struct grep_source {\n \tvoid *identifier;\n\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n\n \tchar *path; /* for attribute lookups */\n \tstruct userdiff_driver *driver;\ndiff --git a/http-push.c b/http-push.c\nindex b22c7caea0..1de36435e5 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -359,7 +359,7 @@ static void start_put(struct transfer_request *request)\n \tenum object_type type;\n \tchar hdr[50];\n \tvoid *unpacked;\n-\tunsigned long len;\n+\tsize_t len;\n \tint hdrlen;\n \tssize_t size;\n \tgit_zstream stream;\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex ee449de3f7..f12bfd0a30 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -236,7 +236,7 @@ static enum list_objects_filter_result filter_blobs_limit(\n \tvoid *filter_data_)\n {\n \tstruct filter_blobs_limit_data *filter_data = filter_data_;\n-\tunsigned long object_length;\n+\tsize_t object_length;\n \tenum object_type t;\n\n \tswitch (filter_situation) {\ndiff --git a/mailmap.c b/mailmap.c\nindex 962fd86d6d..ec7ba47eef 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -217,7 +217,7 @@ static int read_mailmap_blob(struct string_list *map,\n {\n \tstruct object_id oid;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n\n \tif (!name)\ndiff --git a/match-trees.c b/match-trees.c\nindex ddc4d39845..4cfb556589 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -53,7 +53,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc,\n {\n \tvoid *buffer;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n\n \tbuffer = read_object_file(hash, &type, &size);\n \tif (!buffer)\n@@ -175,7 +175,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,\n \tchar *subpath;\n \tint toplen;\n \tchar *buf;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tstruct tree_desc desc;\n \tunsigned char *rewrite_here;\n \tconst struct object_id *rewrite_with;\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex ee0a0e90c9..f19ee015cc 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -9,7 +9,7 @@\n static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n {\n \tvoid *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n\n \tbuf = read_object_file(&obj->object.oid, &type, &size);\n@@ -34,7 +34,7 @@ static void *three_way_filemerge(struct index_state *istate,\n \t\t\t\t mmfile_t *base,\n \t\t\t\t mmfile_t *our,\n \t\t\t\t mmfile_t *their,\n-\t\t\t\t unsigned long *size)\n+\t\t\t\t size_t *size)\n {\n \tint merge_status;\n \tmmbuffer_t res;\n@@ -57,7 +57,7 @@ static void *three_way_filemerge(struct index_state *istate,\n\n void *merge_blobs(struct index_state *istate, const char *path,\n \t\t  struct blob *base, struct blob *our,\n-\t\t  struct blob *their, unsigned long *size)\n+\t\t  struct blob *their, size_t *size)\n {\n \tvoid *res = NULL;\n \tmmfile_t f1, f2, common;\ndiff --git a/merge-blobs.h b/merge-blobs.h\nindex cc31038b80..7f37952b0e 100644\n--- a/merge-blobs.h\n+++ b/merge-blobs.h\n@@ -6,6 +6,6 @@ struct index_state;\n\n extern void *merge_blobs(struct index_state *, const char *,\n \t\t\t struct blob *, struct blob *,\n-\t\t\t struct blob *, unsigned long *);\n+\t\t\t struct blob *, size_t *);\n\n #endif /* MERGE_BLOBS_H */\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 6c40c61c47..d2e2f6642c 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -961,7 +961,7 @@ static int update_file_flags(struct merge_options *o,\n \tif (update_wd) {\n \t\tenum object_type type;\n \t\tvoid *buf;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n\n \t\tif (S_ISGITLINK(mode)) {\n \t\t\t/*\n@@ -3012,7 +3012,7 @@ static int read_oid_strbuf(struct merge_options *o,\n {\n \tvoid *buf;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tbuf = read_object_file(oid, &type, &size);\n \tif (!buf)\n \t\treturn err(o, _(\"cannot read object %s\"), oid_to_hex(oid));\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 2473314d68..7914f1073f 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -76,7 +76,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \tconst struct object_id *value_oid;\n \tenum object_type type;\n \tchar *value;\n-\tunsigned long size;\n+\tsize_t size;\n\n \tvalue_oid = get_note(&c->tree, key_oid);\n \tif (!value_oid)\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 280aa8e6c1..c2be818112 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -297,7 +297,7 @@ static void check_notes_merge_worktree(struct notes_merge_options *o)\n }\n\n static void write_buf_to_worktree(const struct object_id *obj,\n-\t\t\t\t  const char *buf, unsigned long size)\n+\t\t\t\t  const char *buf, size_t size)\n {\n \tint fd;\n \tchar *path = git_pathdup(NOTES_MERGE_WORKTREE \"/%s\", oid_to_hex(obj));\n@@ -326,7 +326,7 @@ static void write_note_to_worktree(const struct object_id *obj,\n \t\t\t\t   const struct object_id *note)\n {\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *buf = read_object_file(note, &type, &size);\n\n \tif (!buf)\ndiff --git a/notes.c b/notes.c\nindex 7f7cc4d511..e13f986e48 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -791,7 +791,7 @@ int combine_notes_concatenate(struct object_id *cur_oid,\n \t\t\t      const struct object_id *new_oid)\n {\n \tchar *cur_msg = NULL, *new_msg = NULL, *buf;\n-\tunsigned long cur_len, new_len, buf_len;\n+\tsize_t cur_len, new_len, buf_len;\n \tenum object_type cur_type, new_type;\n \tint ret;\n\n@@ -852,7 +852,7 @@ static int string_list_add_note_lines(struct string_list *list,\n \t\t\t\t      const struct object_id *oid)\n {\n \tchar *data;\n-\tunsigned long len;\n+\tsize_t len;\n \tenum object_type t;\n\n \tif (is_null_oid(oid))\n@@ -1206,7 +1206,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n \tstatic const char utf8[] = \"utf-8\";\n \tconst struct object_id *oid;\n \tchar *msg, *msg_p;\n-\tunsigned long linelen, msglen;\n+\tsize_t linelen, msglen;\n \tenum object_type type;\n\n \tif (!t)\ndiff --git a/object-store.h b/object-store.h\nindex 14fc935bd1..21708e1aa3 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -139,7 +139,7 @@ struct raw_object_store {\n \t * These two fields are not meant for direct access. Use\n \t * approximate_object_count() instead.\n \t */\n-\tunsigned long approximate_object_count;\n+\tsize_t approximate_object_count;\n \tunsigned approximate_object_count_valid : 1;\n\n \t/*\n@@ -160,16 +160,16 @@ const char *loose_object_path(struct repository *r, struct strbuf *buf,\n \t\t\t      const struct object_id *oid);\n\n void *map_loose_object(struct repository *r, const struct object_id *oid,\n-\t\t       unsigned long *size);\n+\t\t       size_t *size);\n\n extern void *read_object_file_extended(struct repository *r,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       enum object_type *type,\n-\t\t\t\t       unsigned long *size, int lookup_replace);\n+\t\t\t\t       size_t *size, int lookup_replace);\n static inline void *repo_read_object_file(struct repository *r,\n \t\t\t\t\t  const struct object_id *oid,\n \t\t\t\t\t  enum object_type *type,\n-\t\t\t\t\t  unsigned long *size)\n+\t\t\t\t\t  size_t *size)\n {\n \treturn read_object_file_extended(r, oid, type, size, 1);\n }\n@@ -178,19 +178,19 @@ static inline void *repo_read_object_file(struct repository *r,\n #endif\n\n /* Read and unpack an object file into memory, write memory to an object file */\n-int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);\n+int oid_object_info(struct repository *r, const struct object_id *, size_t *);\n\n-extern int hash_object_file(const void *buf, unsigned long len,\n+extern int hash_object_file(const void *buf, size_t len,\n \t\t\t    const char *type, struct object_id *oid);\n\n-extern int write_object_file(const void *buf, unsigned long len,\n+extern int write_object_file(const void *buf, size_t len,\n \t\t\t     const char *type, struct object_id *oid);\n\n-extern int hash_object_file_literally(const void *buf, unsigned long len,\n+extern int hash_object_file_literally(const void *buf, size_t len,\n \t\t\t\t      const char *type, struct object_id *oid,\n \t\t\t\t      unsigned flags);\n\n-extern int pretend_object_file(void *, unsigned long, enum object_type,\n+extern int pretend_object_file(void *, size_t, enum object_type,\n \t\t\t       struct object_id *oid);\n\n extern int force_object_loose(const struct object_id *oid, time_t mtime);\n@@ -205,7 +205,7 @@ extern int force_object_loose(const struct object_id *oid, time_t mtime);\n int read_loose_object(const char *path,\n \t\t      const struct object_id *expected_oid,\n \t\t      enum object_type *type,\n-\t\t      unsigned long *size,\n+\t\t      size_t *size,\n \t\t      void **contents);\n\n #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS\n@@ -234,7 +234,7 @@ extern void assert_oid_type(const struct object_id *oid, enum object_type expect\n struct object_info {\n \t/* Request */\n \tenum object_type *typep;\n-\tunsigned long *sizep;\n+\tsize_t *sizep;\n \toff_t *disk_sizep;\n \tunsigned char *delta_base_sha1;\n \tstruct strbuf *type_name;\ndiff --git a/object.c b/object.c\nindex e81d47a79c..e0d6575609 100644\n--- a/object.c\n+++ b/object.c\n@@ -187,7 +187,7 @@ struct object *lookup_unknown_object(const unsigned char *sha1)\n \treturn obj;\n }\n\n-struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)\n+struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, size_t size, void *buffer, int *eaten_p)\n {\n \tstruct object *obj;\n \t*eaten_p = 0;\n@@ -249,7 +249,7 @@ struct object *parse_object_or_die(const struct object_id *oid,\n\n struct object *parse_object(struct repository *r, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tint eaten;\n \tconst struct object_id *repl = lookup_replace_object(r, oid);\ndiff --git a/object.h b/object.h\nindex 796792cb32..b97a625882 100644\n--- a/object.h\n+++ b/object.h\n@@ -140,7 +140,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name\n  * parsing it.  eaten_p indicates if the object has a borrowed copy\n  * of buffer and the caller should not free() it.\n  */\n-struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);\n+struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, size_t size, void *buffer, int *eaten_p);\n\n /** Returns the object, with potentially excess memory allocated. **/\n struct object *lookup_unknown_object(const unsigned  char *sha1);\ndiff --git a/pack-check.c b/pack-check.c\nindex 4ff725a89c..b86a5e17b5 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -108,7 +108,7 @@ static int verify_packfile(struct repository *r,\n \tfor (i = 0; i < nr_objects; i++) {\n \t\tvoid *data;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\toff_t curpos;\n \t\tint data_valid;\n\ndiff --git a/pack-objects.h b/pack-objects.h\nindex 6fde7ce27c..e4843efa35 100644\n--- a/pack-objects.h\n+++ b/pack-objects.h\n@@ -325,9 +325,9 @@ static inline void oe_set_delta_sibling(struct packing_data *pack,\n \t\te->delta_sibling_idx = 0;\n }\n\n-unsigned long oe_get_size_slow(struct packing_data *pack,\n+size_t oe_get_size_slow(struct packing_data *pack,\n \t\t\t       const struct object_entry *e);\n-static inline unsigned long oe_size(struct packing_data *pack,\n+static inline size_t oe_size(struct packing_data *pack,\n \t\t\t\t    const struct object_entry *e)\n {\n \tif (e->size_valid)\n@@ -338,7 +338,7 @@ static inline unsigned long oe_size(struct packing_data *pack,\n\n static inline int oe_size_less_than(struct packing_data *pack,\n \t\t\t\t    const struct object_entry *lhs,\n-\t\t\t\t    unsigned long rhs)\n+\t\t\t\t    size_t rhs)\n {\n \tif (lhs->size_valid)\n \t\treturn lhs->size_ < rhs;\n@@ -349,7 +349,7 @@ static inline int oe_size_less_than(struct packing_data *pack,\n\n static inline int oe_size_greater_than(struct packing_data *pack,\n \t\t\t\t       const struct object_entry *lhs,\n-\t\t\t\t       unsigned long rhs)\n+\t\t\t\t       size_t rhs)\n {\n \tif (lhs->size_valid)\n \t\treturn lhs->size_ > rhs;\n@@ -360,7 +360,7 @@ static inline int oe_size_greater_than(struct packing_data *pack,\n\n static inline void oe_set_size(struct packing_data *pack,\n \t\t\t       struct object_entry *e,\n-\t\t\t       unsigned long size)\n+\t\t\t       size_t size)\n {\n \tif (size < pack->oe_size_limit) {\n \t\te->size_ = size;\n@@ -372,7 +372,7 @@ static inline void oe_set_size(struct packing_data *pack,\n \t}\n }\n\n-static inline unsigned long oe_delta_size(struct packing_data *pack,\n+static inline size_t oe_delta_size(struct packing_data *pack,\n \t\t\t\t\t  const struct object_entry *e)\n {\n \tif (e->delta_size_valid)\n@@ -391,7 +391,7 @@ static inline unsigned long oe_delta_size(struct packing_data *pack,\n\n static inline void oe_set_delta_size(struct packing_data *pack,\n \t\t\t\t     struct object_entry *e,\n-\t\t\t\t     unsigned long size)\n+\t\t\t\t     size_t size)\n {\n \tif (size < pack->oe_delta_size_limit) {\n \t\te->delta_size_ = size;\ndiff --git a/pack.h b/pack.h\nindex da99fdd1d2..6f61f83485 100644\n--- a/pack.h\n+++ b/pack.h\n@@ -77,7 +77,7 @@ struct pack_idx_entry {\n\n struct progress;\n /* Note, the data argument could be NULL if object type is blob */\n-typedef int (*verify_fn)(const struct object_id *, enum object_type, unsigned long, void*, int*);\n+typedef int (*verify_fn)(const struct object_id *, enum object_type, size_t, void*, int*);\n\n extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, const struct pack_idx_option *, const unsigned char *sha1);\n extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off_t offset, off_t len, unsigned int nr);\ndiff --git a/packfile.c b/packfile.c\nindex 6afd7e30d0..e84bea8d90 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -163,8 +163,8 @@ int load_idx(const char *path, const unsigned int hashsz, void *idx_map,\n \t\t * variable sized table containing 8-byte entries\n \t\t * for offsets larger than 2^31.\n \t\t */\n-\t\tunsigned long min_size = 8 + 4*256 + nr*(hashsz + 4 + 4) + hashsz + hashsz;\n-\t\tunsigned long max_size = min_size;\n+\t\tsize_t min_size = 8 + 4*256 + nr*(hashsz + 4 + 4) + hashsz + hashsz;\n+\t\tsize_t max_size = min_size;\n \t\tif (nr)\n \t\t\tmax_size += (nr - 1)*8;\n \t\tif (idx_size < min_size || idx_size > max_size)\n@@ -893,10 +893,10 @@ static void prepare_packed_git(struct repository *r);\n  * all unreachable objects about to be pruned, in which case they're not really\n  * interesting as a measure of repo size in the first place.\n  */\n-unsigned long approximate_object_count(void)\n+size_t approximate_object_count(void)\n {\n \tif (!the_repository->objects->approximate_object_count_valid) {\n-\t\tunsigned long count;\n+\t\tsize_t count;\n \t\tstruct multi_pack_index *m;\n \t\tstruct packed_git *p;\n\n@@ -1044,12 +1044,12 @@ struct list_head *get_packed_git_mru(struct repository *r)\n \treturn &r->objects->packed_git_mru;\n }\n\n-unsigned long unpack_object_header_buffer(const unsigned char *buf,\n-\t\tunsigned long len, enum object_type *type, unsigned long *sizep)\n+size_t unpack_object_header_buffer(const unsigned char *buf,\n+\t\tsize_t len, enum object_type *type, size_t *sizep)\n {\n \tunsigned shift;\n-\tunsigned long size, c;\n-\tunsigned long used = 0;\n+\tsize_t size, c;\n+\tsize_t used = 0;\n\n \tc = buf[used++];\n \t*type = (c >> 4) & 7;\n@@ -1069,7 +1069,7 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,\n \treturn used;\n }\n\n-unsigned long get_size_from_delta(struct packed_git *p,\n+size_t get_size_from_delta(struct packed_git *p,\n \t\t\t\t  struct pack_window **w_curs,\n \t\t\t\t  off_t curpos)\n {\n@@ -1111,11 +1111,11 @@ unsigned long get_size_from_delta(struct packed_git *p,\n int unpack_object_header(struct packed_git *p,\n \t\t\t struct pack_window **w_curs,\n \t\t\t off_t *curpos,\n-\t\t\t unsigned long *sizep)\n+\t\t\t size_t *sizep)\n {\n \tunsigned char *base;\n \tsize_t left;\n-\tunsigned long used;\n+\tsize_t used;\n \tenum object_type type;\n\n \t/* use_pack() assures us we have [base, base + 20) available\n@@ -1266,7 +1266,7 @@ static enum object_type packed_to_object_type(struct repository *r,\n\n \twhile (type == OBJ_OFS_DELTA || type == OBJ_REF_DELTA) {\n \t\toff_t base_offset;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\t/* Push the object we're going to leave behind */\n \t\tif (poi_stack_nr >= poi_stack_alloc && poi_stack == small_poi_stack) {\n \t\t\tpoi_stack_alloc = alloc_nr(poi_stack_nr);\n@@ -1336,7 +1336,7 @@ struct delta_base_cache_entry {\n \tstruct delta_base_cache_key key;\n \tstruct list_head lru;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n };\n\n@@ -1401,7 +1401,7 @@ static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)\n }\n\n static void *cache_or_unpack_entry(struct repository *r, struct packed_git *p,\n-\t\t\t\t   off_t base_offset, unsigned long *base_size,\n+\t\t\t\t   off_t base_offset, size_t *base_size,\n \t\t\t\t   enum object_type *type)\n {\n \tstruct delta_base_cache_entry *ent;\n@@ -1434,7 +1434,7 @@ void clear_delta_base_cache(void)\n }\n\n static void add_delta_base_cache(struct packed_git *p, off_t base_offset,\n-\tvoid *base, unsigned long base_size, enum object_type type)\n+\tvoid *base, size_t base_size, enum object_type type)\n {\n \tstruct delta_base_cache_entry *ent = xmalloc(sizeof(*ent));\n \tstruct list_head *lru, *tmp;\n@@ -1466,7 +1466,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,\n \t\t       off_t obj_offset, struct object_info *oi)\n {\n \tstruct pack_window *w_curs = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t curpos = obj_offset;\n \tenum object_type type;\n\n@@ -1551,7 +1551,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,\n static void *unpack_compressed_entry(struct packed_git *p,\n \t\t\t\t    struct pack_window **w_curs,\n \t\t\t\t    off_t curpos,\n-\t\t\t\t    unsigned long size)\n+\t\t\t\t    size_t size)\n {\n \tint st;\n \tgit_zstream stream;\n@@ -1598,13 +1598,13 @@ int do_check_packed_object_crc;\n struct unpack_entry_stack_ent {\n \toff_t obj_offset;\n \toff_t curpos;\n-\tunsigned long size;\n+\tsize_t size;\n };\n\n static void *read_object(struct repository *r,\n \t\t\t const struct object_id *oid,\n \t\t\t enum object_type *type,\n-\t\t\t unsigned long *size)\n+\t\t\t size_t *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tvoid *content;\n@@ -1618,12 +1618,12 @@ static void *read_object(struct repository *r,\n }\n\n void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n-\t\t   enum object_type *final_type, unsigned long *final_size)\n+\t\t   enum object_type *final_type, size_t *final_size)\n {\n \tstruct pack_window *w_curs = NULL;\n \toff_t curpos = obj_offset;\n \tvoid *data = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tstruct unpack_entry_stack_ent small_delta_stack[UNPACK_ENTRY_STACK_PREALLOC];\n \tstruct unpack_entry_stack_ent *delta_stack = small_delta_stack;\n@@ -1723,7 +1723,7 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n \t\tvoid *delta_data;\n \t\tvoid *base = data;\n \t\tvoid *external_base = NULL;\n-\t\tunsigned long delta_size, base_size = size;\n+\t\tsize_t delta_size, base_size = size;\n \t\tint i;\n\n \t\tdata = NULL;\ndiff --git a/packfile.h b/packfile.h\nindex 7384b4a201..b3082a9079 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -57,7 +57,7 @@ struct packed_git *get_all_packs(struct repository *r);\n  * Give a rough count of objects in the repository. This sacrifices accuracy\n  * for speed.\n  */\n-unsigned long approximate_object_count(void);\n+size_t approximate_object_count(void);\n\n extern struct packed_git *find_sha1_pack(const unsigned char *sha1,\n \t\t\t\t\t struct packed_git *packs);\n@@ -131,10 +131,10 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);\n extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);\n\n extern int is_pack_valid(struct packed_git *);\n-extern void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object_type *, unsigned long *);\n-extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);\n-extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n-extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);\n+extern void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object_type *, size_t *);\n+extern size_t unpack_object_header_buffer(const unsigned char *buf, size_t len, enum object_type *type, size_t *sizep);\n+extern size_t get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n+extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, size_t *);\n\n extern void release_pack_memory(size_t);\n\ndiff --git a/patch-delta.c b/patch-delta.c\nindex b5c8594db6..42199fa956 100644\n--- a/patch-delta.c\n+++ b/patch-delta.c\n@@ -12,13 +12,13 @@\n #include \"git-compat-util.h\"\n #include \"delta.h\"\n\n-void *patch_delta(const void *src_buf, unsigned long src_size,\n-\t\t  const void *delta_buf, unsigned long delta_size,\n-\t\t  unsigned long *dst_size)\n+void *patch_delta(const void *src_buf, size_t src_size,\n+\t\t  const void *delta_buf, size_t delta_size,\n+\t\t  size_t *dst_size)\n {\n \tconst unsigned char *data, *top;\n \tunsigned char *dst_buf, *out, cmd;\n-\tunsigned long size;\n+\tsize_t size;\n\n \tif (delta_size < DELTA_SIZE_MIN)\n \t\treturn NULL;\ndiff --git a/range-diff.c b/range-diff.c\nindex 48b0e1b4ce..a70499089e 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -192,7 +192,7 @@ static void find_exact_matches(struct string_list *a, struct string_list *b)\n \thashmap_free(&map, 0);\n }\n\n-static void diffsize_consume(void *data, char *line, unsigned long len)\n+static void diffsize_consume(void *data, char *line, size_t len)\n {\n \t(*(int *)data)++;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 4dc6de1b55..7c6c7505c5 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -227,7 +227,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)\n {\n \tint match = -1;\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tstruct strbuf sb = STRBUF_INIT;\n\n@@ -1680,7 +1680,7 @@ int verify_index_checksum;\n /* Allow fsck to force verification of the cache entry order. */\n int verify_ce_order;\n\n-static int verify_hdr(const struct cache_header *hdr, unsigned long size)\n+static int verify_hdr(const struct cache_header *hdr, size_t size)\n {\n \tgit_hash_ctx c;\n \tunsigned char hash[GIT_MAX_RAWSZ];\n@@ -1704,7 +1704,7 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)\n }\n\n static int read_index_extension(struct index_state *istate,\n-\t\t\t\tconst char *ext, const char *data, unsigned long sz)\n+\t\t\t\tconst char *ext, const char *data, size_t sz)\n {\n \tswitch (CACHE_EXT(ext)) {\n \tcase CACHE_EXT_TREE:\n@@ -1740,7 +1740,7 @@ static int read_index_extension(struct index_state *istate,\n static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,\n \t\t\t\t\t    unsigned int version,\n \t\t\t\t\t    struct ondisk_cache_entry *ondisk,\n-\t\t\t\t\t    unsigned long *ent_size,\n+\t\t\t\t\t    size_t *ent_size,\n \t\t\t\t\t    const struct cache_entry *previous_ce)\n {\n \tstruct cache_entry *ce;\n@@ -1931,13 +1931,13 @@ struct load_index_extensions\n \tstruct index_state *istate;\n \tconst char *mmap;\n \tsize_t mmap_size;\n-\tunsigned long src_offset;\n+\tsize_t src_offset;\n };\n\n static void *load_index_extensions(void *_data)\n {\n \tstruct load_index_extensions *p = _data;\n-\tunsigned long src_offset = p->src_offset;\n+\tsize_t src_offset = p->src_offset;\n\n \twhile (src_offset <= p->mmap_size - the_hash_algo->rawsz - 8) {\n \t\t/* After an array of active_nr index entries,\n@@ -1965,17 +1965,17 @@ static void *load_index_extensions(void *_data)\n  * A helper function that will load the specified range of cache entries\n  * from the memory mapped file and add them to the given index.\n  */\n-static unsigned long load_cache_entry_block(struct index_state *istate,\n+static size_t load_cache_entry_block(struct index_state *istate,\n \t\t\tstruct mem_pool *ce_mem_pool, int offset, int nr, const char *mmap,\n-\t\t\tunsigned long start_offset, const struct cache_entry *previous_ce)\n+\t\t\tsize_t start_offset, const struct cache_entry *previous_ce)\n {\n \tint i;\n-\tunsigned long src_offset = start_offset;\n+\tsize_t src_offset = start_offset;\n\n \tfor (i = offset; i < offset + nr; i++) {\n \t\tstruct ondisk_cache_entry *disk_ce;\n \t\tstruct cache_entry *ce;\n-\t\tunsigned long consumed;\n+\t\tsize_t consumed;\n\n \t\tdisk_ce = (struct ondisk_cache_entry *)(mmap + src_offset);\n \t\tce = create_from_disk(ce_mem_pool, istate->version, disk_ce, &consumed, previous_ce);\n@@ -1987,10 +1987,10 @@ static unsigned long load_cache_entry_block(struct index_state *istate,\n \treturn src_offset - start_offset;\n }\n\n-static unsigned long load_all_cache_entries(struct index_state *istate,\n-\t\t\tconst char *mmap, size_t mmap_size, unsigned long src_offset)\n+static size_t load_all_cache_entries(struct index_state *istate,\n+\t\t\tconst char *mmap, size_t mmap_size, size_t src_offset)\n {\n-\tunsigned long consumed;\n+\tsize_t consumed;\n\n \tif (istate->version == 4) {\n \t\tmem_pool_init(&istate->ce_mem_pool,\n@@ -2024,7 +2024,7 @@ struct load_cache_entries_thread_data\n \tstruct index_entry_offset_table *ieot;\n \tint ieot_start;\t\t/* starting index into the ieot array */\n \tint ieot_blocks;\t/* count of ieot entries to process */\n-\tunsigned long consumed;\t/* return # of bytes in index file processed */\n+\tsize_t consumed;\t/* return # of bytes in index file processed */\n };\n\n /*\n@@ -2045,12 +2045,12 @@ static void *load_cache_entries_thread(void *_data)\n \treturn NULL;\n }\n\n-static unsigned long load_cache_entries_threaded(struct index_state *istate, const char *mmap, size_t mmap_size,\n-\t\t\tunsigned long src_offset, int nr_threads, struct index_entry_offset_table *ieot)\n+static size_t load_cache_entries_threaded(struct index_state *istate, const char *mmap, size_t mmap_size,\n+\t\t\tsize_t src_offset, int nr_threads, struct index_entry_offset_table *ieot)\n {\n \tint i, offset, ieot_blocks, ieot_start, err;\n \tstruct load_cache_entries_thread_data *data;\n-\tunsigned long consumed = 0;\n+\tsize_t consumed = 0;\n\n \t/* a little sanity checking */\n \tif (istate->name_hash_initialized)\n@@ -2121,7 +2121,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n {\n \tint fd;\n \tstruct stat st;\n-\tunsigned long src_offset;\n+\tsize_t src_offset;\n \tconst struct cache_header *hdr;\n \tconst char *mmap;\n \tsize_t mmap_size;\n@@ -2429,7 +2429,7 @@ int repo_index_has_changes(struct repository *repo,\n\n #define WRITE_BUFFER_SIZE 8192\n static unsigned char write_buffer[WRITE_BUFFER_SIZE];\n-static unsigned long write_buffer_len;\n+static size_t write_buffer_len;\n\n static int ce_write_flush(git_hash_ctx *context, int fd)\n {\n@@ -3066,9 +3066,9 @@ static int write_split_index(struct index_state *istate,\n\n static const char *shared_index_expire = \"2.weeks.ago\";\n\n-static unsigned long get_shared_index_expire_date(void)\n+static size_t get_shared_index_expire_date(void)\n {\n-\tstatic unsigned long shared_index_expire_date;\n+\tstatic size_t shared_index_expire_date;\n \tstatic int shared_index_expire_date_prepared;\n\n \tif (!shared_index_expire_date_prepared) {\n@@ -3084,7 +3084,7 @@ static unsigned long get_shared_index_expire_date(void)\n static int should_delete_shared_index(const char *shared_index_path)\n {\n \tstruct stat st;\n-\tunsigned long expiration;\n+\tsize_t expiration;\n\n \t/* Check timestamp */\n \texpiration = get_shared_index_expire_date();\n@@ -3325,10 +3325,10 @@ int index_name_is_other(const struct index_state *istate, const char *name,\n }\n\n void *read_blob_data_from_index(const struct index_state *istate,\n-\t\t\t\tconst char *path, unsigned long *size)\n+\t\t\t\tconst char *path, size_t *size)\n {\n \tint pos, len;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tenum object_type type;\n \tvoid *data;\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 3aca105307..e18e445acf 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -67,7 +67,7 @@ struct refname_atom {\n static struct expand_data {\n \tstruct object_id oid;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t disk_size;\n \tstruct object_id delta_base_oid;\n \tvoid *content;\n@@ -1018,7 +1018,7 @@ static const char *copy_email(const char *buf)\n \treturn xmemdupz(email, eoemail + 1 - email);\n }\n\n-static char *copy_subject(const char *buf, unsigned long len)\n+static char *copy_subject(const char *buf, size_t len)\n {\n \tchar *r = xmemdupz(buf, len);\n \tint i;\n@@ -1128,10 +1128,10 @@ static void grab_person(const char *who, struct atom_value *val, int deref, void\n }\n\n static void find_subpos(const char *buf,\n-\t\t\tconst char **sub, unsigned long *sublen,\n-\t\t\tconst char **body, unsigned long *bodylen,\n-\t\t\tunsigned long *nonsiglen,\n-\t\t\tconst char **sig, unsigned long *siglen)\n+\t\t\tconst char **sub, size_t *sublen,\n+\t\t\tconst char **body, size_t *bodylen,\n+\t\t\tsize_t *nonsiglen,\n+\t\t\tconst char **sig, size_t *siglen)\n {\n \tconst char *eol;\n \t/* skip past header until we hit empty line */\n@@ -1175,7 +1175,7 @@ static void find_subpos(const char *buf,\n  * If 'lines' is greater than 0, append that many lines from the given\n  * 'buf' of length 'size' to the given strbuf.\n  */\n-static void append_lines(struct strbuf *out, const char *buf, unsigned long size, int lines)\n+static void append_lines(struct strbuf *out, const char *buf, size_t size, int lines)\n {\n \tint i;\n \tconst char *sp, *eol;\n@@ -1200,7 +1200,7 @@ static void grab_sub_body_contents(struct atom_value *val, int deref, void *buf)\n {\n \tint i;\n \tconst char *subpos = NULL, *bodypos = NULL, *sigpos = NULL;\n-\tunsigned long sublen = 0, bodylen = 0, nonsiglen = 0, siglen = 0;\n+\tsize_t sublen = 0, bodylen = 0, nonsiglen = 0, siglen = 0;\n\n \tfor (i = 0; i < used_atom_cnt; i++) {\n \t\tstruct used_atom *atom = &used_atom[i];\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex 3af708c5b6..38f79aaf8a 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -56,7 +56,7 @@ static char *read_ref_note(const struct object_id *oid)\n {\n \tconst struct object_id *note_oid;\n \tchar *msg = NULL;\n-\tunsigned long msglen;\n+\tsize_t msglen;\n \tenum object_type type;\n\n \tinit_notes(NULL, notes_ref, NULL, 0);\n@@ -105,7 +105,7 @@ static int note2mark_cb(const struct object_id *object_oid,\n {\n \tFILE *file = (FILE *)cb_data;\n \tchar *msg;\n-\tunsigned long msglen;\n+\tsize_t msglen;\n \tenum object_type type;\n \tstruct rev_note note;\n\ndiff --git a/rerere.c b/rerere.c\nindex 17abb47321..4e1d525817 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -973,7 +973,7 @@ static int handle_cache(struct index_state *istate,\n\n \twhile (pos < istate->cache_nr) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n\n \t\tce = istate->cache[pos++];\n \t\tif (ce_namelen(ce) != len || memcmp(ce->name, path, len))\ndiff --git a/sha1-file.c b/sha1-file.c\nindex 494606f771..caef36f9b4 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -200,7 +200,7 @@ static struct cached_object {\n \tstruct object_id oid;\n \tenum object_type type;\n \tvoid *buf;\n-\tunsigned long size;\n+\tsize_t size;\n } *cached_objects;\n static int cached_object_nr, cached_object_alloc;\n\n@@ -871,7 +871,7 @@ void *xmmap(void *start, size_t length,\n  * the streaming interface and rehash it to do the same.\n  */\n int check_object_signature(const struct object_id *oid, void *map,\n-\t\t\t   unsigned long size, const char *type)\n+\t\t\t   size_t size, const char *type)\n {\n \tstruct object_id real_oid;\n \tenum object_type obj_type;\n@@ -1007,7 +1007,7 @@ static int quick_has_loose(struct repository *r,\n  * searching for a loose object named \"oid\".\n  */\n static void *map_loose_object_1(struct repository *r, const char *path,\n-\t\t\t     const struct object_id *oid, unsigned long *size)\n+\t\t\t     const struct object_id *oid, size_t *size)\n {\n \tvoid *map;\n \tint fd;\n@@ -1037,14 +1037,14 @@ static void *map_loose_object_1(struct repository *r, const char *path,\n\n void *map_loose_object(struct repository *r,\n \t\t       const struct object_id *oid,\n-\t\t       unsigned long *size)\n+\t\t       size_t *size)\n {\n \treturn map_loose_object_1(r, NULL, oid, size);\n }\n\n static int unpack_loose_short_header(git_zstream *stream,\n-\t\t\t\t     unsigned char *map, unsigned long mapsize,\n-\t\t\t\t     void *buffer, unsigned long bufsiz)\n+\t\t\t\t     unsigned char *map, size_t mapsize,\n+\t\t\t\t     void *buffer, size_t bufsiz)\n {\n \t/* Get the data stream */\n \tmemset(stream, 0, sizeof(*stream));\n@@ -1058,8 +1058,8 @@ static int unpack_loose_short_header(git_zstream *stream,\n }\n\n int unpack_loose_header(git_zstream *stream,\n-\t\t\tunsigned char *map, unsigned long mapsize,\n-\t\t\tvoid *buffer, unsigned long bufsiz)\n+\t\t\tunsigned char *map, size_t mapsize,\n+\t\t\tvoid *buffer, size_t bufsiz)\n {\n \tint status = unpack_loose_short_header(stream, map, mapsize,\n \t\t\t\t\t       buffer, bufsiz);\n@@ -1074,8 +1074,8 @@ int unpack_loose_header(git_zstream *stream,\n }\n\n static int unpack_loose_header_to_strbuf(git_zstream *stream, unsigned char *map,\n-\t\t\t\t\t unsigned long mapsize, void *buffer,\n-\t\t\t\t\t unsigned long bufsiz, struct strbuf *header)\n+\t\t\t\t\t size_t mapsize, void *buffer,\n+\t\t\t\t\t size_t bufsiz, struct strbuf *header)\n {\n \tint status;\n\n@@ -1110,12 +1110,12 @@ static int unpack_loose_header_to_strbuf(git_zstream *stream, unsigned char *map\n }\n\n static void *unpack_loose_rest(git_zstream *stream,\n-\t\t\t       void *buffer, unsigned long size,\n+\t\t\t       void *buffer, size_t size,\n \t\t\t       const struct object_id *oid)\n {\n \tint bytes = strlen(buffer) + 1;\n \tunsigned char *buf = xmallocz(size);\n-\tunsigned long n;\n+\tsize_t n;\n \tint status = Z_OK;\n\n \tn = stream->total_out - bytes;\n@@ -1165,7 +1165,7 @@ static int parse_loose_header_extended(const char *hdr, struct object_info *oi,\n \t\t\t\t       unsigned int flags)\n {\n \tconst char *type_buf = hdr;\n-\tunsigned long size;\n+\tsize_t size;\n \tint type, type_len = 0;\n\n \t/*\n@@ -1205,7 +1205,7 @@ static int parse_loose_header_extended(const char *hdr, struct object_info *oi,\n \t\treturn -1;\n \tif (size) {\n \t\tfor (;;) {\n-\t\t\tunsigned long c = *hdr - '0';\n+\t\t\tsize_t c = *hdr - '0';\n \t\t\tif (c > 9)\n \t\t\t\tbreak;\n \t\t\thdr++;\n@@ -1222,7 +1222,7 @@ static int parse_loose_header_extended(const char *hdr, struct object_info *oi,\n \treturn *hdr ? -1 : type;\n }\n\n-int parse_loose_header(const char *hdr, unsigned long *sizep)\n+int parse_loose_header(const char *hdr, size_t *sizep)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n\n@@ -1235,12 +1235,12 @@ static int loose_object_info(struct repository *r,\n \t\t\t     struct object_info *oi, int flags)\n {\n \tint status = 0;\n-\tunsigned long mapsize;\n+\tsize_t mapsize;\n \tvoid *map;\n \tgit_zstream stream;\n \tchar hdr[MAX_HEADER_LEN];\n \tstruct strbuf hdrbuf = STRBUF_INIT;\n-\tunsigned long size_scratch;\n+\tsize_t size_scratch;\n\n \tif (oi->delta_base_sha1)\n \t\thashclr(oi->delta_base_sha1);\n@@ -1408,7 +1408,7 @@ int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n /* returns enum object_type or negative */\n int oid_object_info(struct repository *r,\n \t\t    const struct object_id *oid,\n-\t\t    unsigned long *sizep)\n+\t\t    size_t *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n@@ -1423,7 +1423,7 @@ int oid_object_info(struct repository *r,\n\n static void *read_object(struct repository *r,\n \t\t\t const struct object_id *oid, enum object_type *type,\n-\t\t\t unsigned long *size)\n+\t\t\t size_t *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tvoid *content;\n@@ -1436,7 +1436,7 @@ static void *read_object(struct repository *r,\n \treturn content;\n }\n\n-int pretend_object_file(void *buf, unsigned long len, enum object_type type,\n+int pretend_object_file(void *buf, size_t len, enum object_type type,\n \t\t\tstruct object_id *oid)\n {\n \tstruct cached_object *co;\n@@ -1462,7 +1462,7 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type,\n void *read_object_file_extended(struct repository *r,\n \t\t\t\tconst struct object_id *oid,\n \t\t\t\tenum object_type *type,\n-\t\t\t\tunsigned long *size,\n+\t\t\t\tsize_t *size,\n \t\t\t\tint lookup_replace)\n {\n \tvoid *data;\n@@ -1498,12 +1498,12 @@ void *read_object_file_extended(struct repository *r,\n\n void *read_object_with_reference(const struct object_id *oid,\n \t\t\t\t const char *required_type_name,\n-\t\t\t\t unsigned long *size,\n+\t\t\t\t size_t *size,\n \t\t\t\t struct object_id *actual_oid_return)\n {\n \tenum object_type type, required_type;\n \tvoid *buffer;\n-\tunsigned long isize;\n+\tsize_t isize;\n \tstruct object_id actual_oid;\n\n \trequired_type = type_from_string(required_type_name);\n@@ -1544,7 +1544,7 @@ void *read_object_with_reference(const struct object_id *oid,\n \t}\n }\n\n-static void write_object_file_prepare(const void *buf, unsigned long len,\n+static void write_object_file_prepare(const void *buf, size_t len,\n \t\t\t\t      const char *type, struct object_id *oid,\n \t\t\t\t      char *hdr, int *hdrlen)\n {\n@@ -1610,7 +1610,7 @@ static int write_buffer(int fd, const void *buf, size_t len)\n \treturn 0;\n }\n\n-int hash_object_file(const void *buf, unsigned long len, const char *type,\n+int hash_object_file(const void *buf, size_t len, const char *type,\n \t\t     struct object_id *oid)\n {\n \tchar hdr[MAX_HEADER_LEN];\n@@ -1674,7 +1674,7 @@ static int create_tmpfile(struct strbuf *tmp, const char *filename)\n }\n\n static int write_loose_object(const struct object_id *oid, char *hdr,\n-\t\t\t      int hdrlen, const void *buf, unsigned long len,\n+\t\t\t      int hdrlen, const void *buf, size_t len,\n \t\t\t      time_t mtime)\n {\n \tint fd, ret;\n@@ -1764,7 +1764,7 @@ static int freshen_packed_object(const struct object_id *oid)\n \treturn 1;\n }\n\n-int write_object_file(const void *buf, unsigned long len, const char *type,\n+int write_object_file(const void *buf, size_t len, const char *type,\n \t\t      struct object_id *oid)\n {\n \tchar hdr[MAX_HEADER_LEN];\n@@ -1779,7 +1779,7 @@ int write_object_file(const void *buf, unsigned long len, const char *type,\n \treturn write_loose_object(oid, hdr, hdrlen, buf, len, 0);\n }\n\n-int hash_object_file_literally(const void *buf, unsigned long len,\n+int hash_object_file_literally(const void *buf, size_t len,\n \t\t\t       const char *type, struct object_id *oid,\n \t\t\t       unsigned flags)\n {\n@@ -1805,7 +1805,7 @@ int hash_object_file_literally(const void *buf, unsigned long len,\n int force_object_loose(const struct object_id *oid, time_t mtime)\n {\n \tvoid *buf;\n-\tunsigned long len;\n+\tsize_t len;\n \tenum object_type type;\n \tchar hdr[MAX_HEADER_LEN];\n \tint hdrlen;\n@@ -2248,14 +2248,14 @@ void odb_clear_loose_cache(struct object_directory *odb)\n\n static int check_stream_oid(git_zstream *stream,\n \t\t\t    const char *hdr,\n-\t\t\t    unsigned long size,\n+\t\t\t    size_t size,\n \t\t\t    const char *path,\n \t\t\t    const struct object_id *expected_oid)\n {\n \tgit_hash_ctx c;\n \tstruct object_id real_oid;\n \tunsigned char buf[4096];\n-\tunsigned long total_read;\n+\tsize_t total_read;\n \tint status = Z_OK;\n\n \tthe_hash_algo->init_fn(&c);\n@@ -2307,12 +2307,12 @@ static int check_stream_oid(git_zstream *stream,\n int read_loose_object(const char *path,\n \t\t      const struct object_id *expected_oid,\n \t\t      enum object_type *type,\n-\t\t      unsigned long *size,\n+\t\t      size_t *size,\n \t\t      void **contents)\n {\n \tint ret = -1;\n \tvoid *map = NULL;\n-\tunsigned long mapsize;\n+\tsize_t mapsize;\n \tgit_zstream stream;\n \tchar hdr[MAX_HEADER_LEN];\n\ndiff --git a/sha1dc_git.c b/sha1dc_git.c\nindex e0cc9d988c..b24fc9af55 100644\n--- a/sha1dc_git.c\n+++ b/sha1dc_git.c\n@@ -25,7 +25,7 @@ void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)\n /*\n  * Same as SHA1DCUpdate, but adjust types to match git's usual interface.\n  */\n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, size_t len)\n {\n \tconst char *data = vdata;\n \t/* We expect an unsigned long, but sha1dc only takes an int */\ndiff --git a/sha1dc_git.h b/sha1dc_git.h\nindex 41e1c3fd3f..847b38fb4b 100644\n--- a/sha1dc_git.h\n+++ b/sha1dc_git.h\n@@ -15,7 +15,7 @@ void git_SHA1DCInit(SHA1_CTX *);\n #endif\n\n void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *);\n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, unsigned long len);\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, size_t len);\n\n #define platform_SHA_CTX SHA1_CTX\n #define platform_SHA1_Init git_SHA1DCInit\ndiff --git a/streaming.c b/streaming.c\nindex fcd6303219..00771e8de7 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -69,19 +69,19 @@ struct filtered_istream {\n\n struct git_istream {\n \tconst struct stream_vtbl *vtbl;\n-\tunsigned long size; /* inflated size of full object */\n+\tsize_t size; /* inflated size of full object */\n \tgit_zstream z;\n \tenum { z_unused, z_used, z_done, z_error } z_state;\n\n \tunion {\n \t\tstruct {\n \t\t\tchar *buf; /* from read_object() */\n-\t\t\tunsigned long read_ptr;\n+\t\t\tsize_t read_ptr;\n \t\t} incore;\n\n \t\tstruct {\n \t\t\tvoid *mapped;\n-\t\t\tunsigned long mapsize;\n+\t\t\tsize_t mapsize;\n \t\t\tchar hdr[32];\n \t\t\tint hdr_avail;\n \t\t\tint hdr_used;\n@@ -112,7 +112,7 @@ static enum input_source istream_source(const struct object_id *oid,\n \t\t\t\t\tenum object_type *type,\n \t\t\t\t\tstruct object_info *oi)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tint status;\n\n \toi->typep = type;\n@@ -135,7 +135,7 @@ static enum input_source istream_source(const struct object_id *oid,\n\n struct git_istream *open_istream(const struct object_id *oid,\n \t\t\t\t enum object_type *type,\n-\t\t\t\t unsigned long *size,\n+\t\t\t\t size_t *size,\n \t\t\t\t struct stream_filter *filter)\n {\n \tstruct git_istream *st;\n@@ -516,7 +516,7 @@ int stream_blob_to_fd(int fd, const struct object_id *oid, struct stream_filter\n {\n \tstruct git_istream *st;\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tssize_t kept = 0;\n \tint result = -1;\n\ndiff --git a/streaming.h b/streaming.h\nindex 32f4626771..552eb1d7c5 100644\n--- a/streaming.h\n+++ b/streaming.h\n@@ -8,7 +8,7 @@\n /* opaque */\n struct git_istream;\n\n-extern struct git_istream *open_istream(const struct object_id *, enum object_type *, unsigned long *, struct stream_filter *);\n+extern struct git_istream *open_istream(const struct object_id *, enum object_type *, size_t *, struct stream_filter *);\n extern int close_istream(struct git_istream *);\n extern ssize_t read_istream(struct git_istream *, void *, size_t);\n\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 66653e86b9..e9f5f32305 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -534,7 +534,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,\n \t\tenum lookup_type lookup_type)\n {\n \tstruct strbuf rev = STRBUF_INIT;\n-\tunsigned long config_size;\n+\tsize_t config_size;\n \tchar *config = NULL;\n \tstruct object_id oid;\n \tenum object_type type;\ndiff --git a/t/helper/test-delta.c b/t/helper/test-delta.c\nindex e749a49c88..b613cd0216 100644\n--- a/t/helper/test-delta.c\n+++ b/t/helper/test-delta.c\n@@ -21,7 +21,7 @@ int cmd__delta(int argc, const char **argv)\n \tint fd;\n \tstruct stat st;\n \tvoid *from_buf, *data_buf, *out_buf;\n-\tunsigned long from_size, data_size, out_size;\n+\tsize_t from_size, data_size, out_size;\n\n \tif (argc != 5 || (strcmp(argv[1], \"-d\") && strcmp(argv[1], \"-p\"))) {\n \t\tfprintf(stderr, \"usage: %s\\n\", usage_str);\ndiff --git a/tag.c b/tag.c\nindex 7445b8f6ea..a6c07419dc 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -41,7 +41,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n {\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n\n \ttype = oid_object_info(the_repository, oid, NULL);\n@@ -132,7 +132,7 @@ void release_tag_memory(struct tag *t)\n \tt->date = 0;\n }\n\n-int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size)\n+int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, size_t size)\n {\n \tstruct object_id oid;\n \tchar type[20];\n@@ -195,7 +195,7 @@ int parse_tag(struct tag *item)\n {\n \tenum object_type type;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n\n \tif (item->object.parsed)\ndiff --git a/tag.h b/tag.h\nindex e669c3e497..b540b100ef 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -12,7 +12,7 @@ struct tag {\n \ttimestamp_t date;\n };\n extern struct tag *lookup_tag(struct repository *r, const struct object_id *oid);\n-extern int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size);\n+extern int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, size_t size);\n extern int parse_tag(struct tag *item);\n extern void release_tag_memory(struct tag *t);\n extern struct object *deref_tag(struct repository *r, struct object *, const char *, int);\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 1e4bbc8a0e..d6a3f8233a 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -83,7 +83,7 @@ int init_tree_desc_gently(struct tree_desc *desc, const void *buffer, unsigned l\n\n void *fill_tree_descriptor(struct tree_desc *desc, const struct object_id *oid)\n {\n-\tunsigned long size = 0;\n+\tsize_t size = 0;\n \tvoid *buf = NULL;\n\n \tif (oid) {\n@@ -109,8 +109,8 @@ static int update_tree_entry_internal(struct tree_desc *desc, struct strbuf *err\n {\n \tconst void *buf = desc->buffer;\n \tconst unsigned char *end = (const unsigned char *)desc->entry.path + desc->entry.pathlen + 1 + the_hash_algo->rawsz;\n-\tunsigned long size = desc->size;\n-\tunsigned long len = end - (const unsigned char *)buf;\n+\tsize_t size = desc->size;\n+\tsize_t len = end - (const unsigned char *)buf;\n\n \tif (size < len)\n \t\tdie(_(\"too-short tree file\"));\n@@ -496,7 +496,7 @@ int traverse_trees(struct index_state *istate,\n\n struct dir_state {\n \tvoid *tree;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_id oid;\n };\n\n@@ -539,7 +539,7 @@ int get_tree_entry(const struct object_id *tree_oid, const char *name, struct ob\n {\n \tint retval;\n \tvoid *tree;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_id root;\n\n \ttree = read_object_with_reference(tree_oid, tree_type, &size, &root);\n@@ -608,7 +608,7 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct object_id *tree_oid, c\n \t\tif (!t.buffer) {\n \t\t\tvoid *tree;\n \t\t\tstruct object_id root;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\ttree = read_object_with_reference(&current_tree_oid,\n \t\t\t\t\t\t\t  tree_type, &size,\n \t\t\t\t\t\t\t  &root);\n@@ -704,7 +704,7 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct object_id *tree_oid, c\n \t\t\tgoto done;\n \t\t} else if (S_ISLNK(*mode)) {\n \t\t\t/* Follow a symlink */\n-\t\t\tunsigned long link_len;\n+\t\t\tsize_t link_len;\n \t\t\tsize_t len;\n \t\t\tchar *contents, *contents_start;\n \t\t\tstruct dir_state *parent;\ndiff --git a/tree.c b/tree.c\nindex f416afc57d..e3bfb75c45 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -219,7 +219,7 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)\n {\n \t enum object_type type;\n \t void *buffer;\n-\t unsigned long size;\n+\t size_t size;\n\n \tif (item->object.parsed)\n \t\treturn 0;\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 8509f9ea22..63039f6a37 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -169,7 +169,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename)\n\n void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n\n \tif (oideq(oid, &null_oid)) {\n@@ -185,7 +185,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n }\n\n #define FIRST_FEW_BYTES 8000\n-int buffer_is_binary(const char *ptr, unsigned long size)\n+int buffer_is_binary(const char *ptr, size_t size)\n {\n \tif (FIRST_FEW_BYTES < size)\n \t\tsize = FIRST_FEW_BYTES;\ndiff --git a/xdiff-interface.h b/xdiff-interface.h\nindex 2d41fffd4c..6c99f8d047 100644\n--- a/xdiff-interface.h\n+++ b/xdiff-interface.h\n@@ -11,7 +11,7 @@\n  */\n #define MAX_XDIFF_SIZE (1024UL * 1024 * 1023)\n\n-typedef void (*xdiff_emit_line_fn)(void *, char *, unsigned long);\n+typedef void (*xdiff_emit_line_fn)(void *, char *, size_t);\n typedef void (*xdiff_emit_hunk_fn)(void *data,\n \t\t\t\t   long old_begin, long old_nr,\n \t\t\t\t   long new_begin, long new_nr,\n@@ -25,7 +25,7 @@ int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,\n \t\t  xpparam_t const *xpp, xdemitconf_t const *xecfg);\n int read_mmfile(mmfile_t *ptr, const char *filename);\n void read_mmblob(mmfile_t *ptr, const struct object_id *oid);\n-int buffer_is_binary(const char *ptr, unsigned long size);\n+int buffer_is_binary(const char *ptr, size_t size);\n\n extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags);\n extern void xdiff_clear_find_func(xdemitconf_t *xecfg);\n--\n2.20.1\n\n"}]}