{"thread":{"id":"46542","subject":"[PATCH] Convert size datatype to size_t","startedAt":"2017-08-08T20:01:13Z","lastAt":"2017-08-09T22:16:51Z","messageCount":9,"participants":["Martin Koegler","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"325849","messageId":"1502222450-20815-1-git-send-email-martin@mail.zuhause","threadId":"46542","inReplyTo":null,"subject":"[PATCH] Convert size datatype to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-08T20:00:50Z","receivedAt":"2017-08-08T20:01:13Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nIt changes the signature of the core object access function\nincluding any other functions to assure a clean compile if\nsizeof(size_t) != sizeof(unsigned long).\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n\nThere is much more to change in the codebase. It JUST fixes the signature\nof some functions.\n\n apply.c                  |  6 +++---\n archive-tar.c            |  4 ++--\n archive-zip.c            |  2 +-\n archive.c                |  2 +-\n archive.h                |  2 +-\n blame.c                  |  4 ++--\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  |  2 +-\n builtin/fsck.c           |  2 +-\n builtin/grep.c           |  6 +++---\n builtin/index-pack.c     | 12 ++++++------\n builtin/log.c            |  4 ++--\n builtin/ls-tree.c        |  2 +-\n builtin/merge-tree.c     |  6 +++---\n builtin/mktag.c          |  2 +-\n builtin/notes.c          |  6 +++---\n builtin/pack-objects.c   | 10 +++++-----\n builtin/reflog.c         |  2 +-\n builtin/tag.c            |  4 ++--\n builtin/unpack-file.c    |  2 +-\n builtin/unpack-objects.c | 14 +++++++-------\n builtin/verify-commit.c  |  2 +-\n bundle.c                 |  2 +-\n cache.h                  | 22 +++++++++++-----------\n combine-diff.c           |  9 +++++----\n commit.c                 |  6 +++---\n config.c                 |  2 +-\n delta.h                  | 26 +++++++++++++-------------\n diff-delta.c             | 16 ++++++++--------\n diff.c                   | 14 +++++++-------\n diff.h                   |  2 +-\n diffcore.h               |  2 +-\n dir.c                    |  2 +-\n entry.c                  |  4 ++--\n fast-import.c            | 18 +++++++++---------\n fsck.c                   |  2 +-\n grep.h                   |  2 +-\n http-push.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            |  2 +-\n notes.c                  |  6 +++---\n object.c                 |  2 +-\n pack-check.c             |  2 +-\n pack-objects.h           |  6 +++---\n patch-delta.c            | 11 ++++++-----\n read-cache.c             |  4 ++--\n ref-filter.c             |  4 ++--\n remote-testsvn.c         |  4 ++--\n rerere.c                 |  2 +-\n sha1_file.c              | 44 ++++++++++++++++++++++----------------------\n streaming.c              |  8 ++++----\n streaming.h              |  2 +-\n submodule-config.c       |  2 +-\n t/helper/test-delta.c    |  2 +-\n tag.c                    |  4 ++--\n tree-walk.c              |  8 ++++----\n tree.c                   |  2 +-\n xdiff-interface.c        |  2 +-\n 66 files changed, 193 insertions(+), 191 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex f2d5991..ea97fd2 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3085,7 +3085,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@@ -3174,7 +3174,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_sha1_file(oid.hash, &type, &size);\n@@ -3236,7 +3236,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_sha1_file(oid->hash, &type, &sz);\ndiff --git a/archive-tar.c b/archive-tar.c\nindex c6ed96e..719673d 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -115,7 +115,7 @@ static int stream_blocked(const unsigned char *sha1)\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@@ -240,7 +240,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 e8913e5..4492d64 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -295,7 +295,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 60b3035..5d1b6b7 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -66,7 +66,7 @@ static void format_subst(const struct commit *commit,\n void *sha1_file_to_archive(const struct archiver_args *args,\n \t\t\t   const char *path, const unsigned char *sha1,\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 62d1d82..dd831a3 100644\n--- a/archive.h\n+++ b/archive.h\n@@ -42,6 +42,6 @@ const char *archive_format_from_filename(const char *filename);\n extern void *sha1_file_to_archive(const struct archiver_args *args,\n \t\t\t\t  const char *path, const unsigned char *sha1,\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/blame.c b/blame.c\nindex f575e9c..739a280 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -193,7 +193,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\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@@ -290,7 +290,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 (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&\ndiff --git a/blame.h b/blame.h\nindex a6c915c..9a0ed1c 100644\n--- a/blame.h\n+++ b/blame.h\n@@ -111,7 +111,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 96b786e..8c658a7 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -27,7 +27,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@@ -53,7 +53,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@@ -176,7 +176,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@@ -288,7 +288,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@@ -316,7 +316,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_sha1_file(oid->hash, &type, &size);\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex a1a26ba..54ceecb 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -295,7 +295,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_sha1_file(oid->hash, &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 d412c0a..d3d72cf 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -205,7 +205,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@@ -216,7 +216,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@@ -644,7 +644,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 10cbb43..8d6663f 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -485,7 +485,7 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \tfor (i = 0; i < origins.nr; i++) {\n \t\tunsigned char *sha1 = 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_sha1_file(sha1, &type, &size);\n \t\tstruct strbuf sig = STRBUF_INIT;\n \ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 99dea7a..ea35912 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -497,7 +497,7 @@ static struct object *parse_loose_object(const struct object_id *oid,\n \tstruct object *obj;\n \tvoid *contents;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tint eaten;\n \n \tif (read_loose_object(path, oid->hash, &type, &size, &contents) < 0)\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 7e79eb1..6305972 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -311,7 +311,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@@ -781,7 +781,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@@ -816,7 +816,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 26828c1..6f1365c 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -18,8 +18,8 @@ static const char index_pack_usage[] =\n \n struct object_entry {\n \tstruct pack_idx_entry idx;\n-\tunsigned long size;\n-\tunsigned char hdr_size;\n+\tsize_t size;\n+\tsize_t hdr_size;\n \tsigned char type;\n \tsigned char real_type;\n };\n@@ -34,7 +34,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@@ -219,7 +219,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 = sha1_object_info(obj->oid.hash, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n@@ -763,7 +763,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@@ -807,7 +807,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 = sha1_object_info(oid->hash, &has_size);\n \t\tif (has_type < 0)\ndiff --git a/builtin/log.c b/builtin/log.c\nindex c6362cf..c6a3517 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -477,7 +477,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 (!DIFF_OPT_TOUCHED(&rev->diffopt, ALLOW_TEXTCONV) ||\n@@ -503,7 +503,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_sha1_file(oid->hash, &type, &size);\n \tint offset = 0;\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex ef96540..3ab99c4 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -93,7 +93,7 @@ static int show_tree(const unsigned char *sha1, 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 (sha1_object_info(sha1, &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 bad6735..b691d68 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -53,7 +53,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@@ -77,7 +77,7 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \treturn merge_blobs(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@@ -98,7 +98,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 031b750..0663106 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -22,7 +22,7 @@ static int verify_object(const unsigned char *sha1, 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_sha1_file(sha1, &type, &size);\n \tconst unsigned char *repl = lookup_replace_object(sha1);\n \ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 77573cf..75c8f6f 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -120,7 +120,7 @@ static int list_each_note(const struct object_id *object_oid,\n \n static void copy_obj_to_fd(int fd, const unsigned char *sha1)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = read_sha1_file(sha1, &type, &size);\n \tif (buf) {\n@@ -246,7 +246,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 \tif (d->buf.len)\n \t\tstrbuf_addch(&d->buf, '\\n');\n@@ -605,7 +605,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_sha1_file(note->hash, &type, &size);\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex f4a8441..78beec8 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -103,7 +103,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@@ -241,7 +241,7 @@ static void copy_pack_data(struct sha1file *f,\n static unsigned long write_no_reuse_object(struct sha1file *f, struct object_entry *entry,\n \t\t\t\t\t   unsigned long 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@@ -1147,7 +1147,7 @@ static struct pbase_tree_cache *pbase_tree_get(const unsigned char *sha1)\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(sha1);\n@@ -1331,7 +1331,7 @@ static void add_preferred_base(unsigned char *sha1)\n {\n \tstruct pbase_tree *it;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tunsigned char tree_sha1[20];\n \n \tif (window <= num_preferred_base++)\n@@ -1806,7 +1806,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\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;\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex e237d92..7f0382d 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -73,7 +73,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_sha1_file(oid->hash, &type, &size);\n \t\tif (!data) {\n \t\t\ttree->object.flags |= INCOMPLETE;\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 01154ea..87c2d38 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -185,7 +185,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@@ -302,7 +302,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 73f1334..3ba3a5e 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -6,7 +6,7 @@ static char *create_temp_file(unsigned char *sha1)\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_sha1_file(sha1, &type, &size);\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 689a29f..001dd4b 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -196,7 +196,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 = sha1_object_info(obj->oid.hash, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n@@ -271,11 +271,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@@ -322,7 +322,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@@ -337,11 +337,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) {\ndiff --git a/builtin/verify-commit.c b/builtin/verify-commit.c\nindex ba38ac9..ea0857a 100644\n--- a/builtin/verify-commit.c\n+++ b/builtin/verify-commit.c\n@@ -38,7 +38,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 d15db03..c49cb13 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -209,7 +209,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 71fe092..387324e 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1162,8 +1162,8 @@ extern char *xdg_cache_home(const char *filename);\n \n extern void *read_sha1_file_extended(const unsigned char *sha1,\n \t\t\t\t     enum object_type *type,\n-\t\t\t\t     unsigned long *size, int lookup_replace);\n-static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *type, unsigned long *size)\n+\t\t\t\t     size_t *size, int lookup_replace);\n+static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *type, size_t *size)\n {\n \treturn read_sha1_file_extended(sha1, type, size, 1);\n }\n@@ -1188,7 +1188,7 @@ static inline const unsigned char *lookup_replace_object(const unsigned char *sh\n }\n \n /* Read and unpack a sha1 file into memory, write memory to a sha1 file */\n-extern int sha1_object_info(const unsigned char *, unsigned long *);\n+extern int sha1_object_info(const unsigned char *, size_t *);\n extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);\n extern int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *return_sha1);\n extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, unsigned char *sha1, unsigned flags);\n@@ -1198,12 +1198,12 @@ extern int git_open_cloexec(const char *name, int flags);\n #define git_open(name) git_open_cloexec(name, O_RDONLY)\n extern void *map_sha1_file(const unsigned char *sha1, unsigned long *size);\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 parse_sha1_header(const char *hdr, size_t *sizep);\n \n /* global flag to enable extra checks when accessing packed objects */\n extern int do_check_packed_object_crc;\n \n-extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);\n+extern int check_sha1_signature(const unsigned char *sha1, void *buf, size_t size, const char *type);\n \n extern int finalize_object_file(const char *tmpfile, const char *filename);\n \n@@ -1219,7 +1219,7 @@ extern int has_sha1_pack(const unsigned char *sha1);\n int read_loose_object(const char *path,\n \t\t      const unsigned char *expected_sha1,\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@@ -1398,7 +1398,7 @@ extern int cache_name_stage_compare(const char *name1, int len1, int stage1, con\n \n extern void *read_object_with_reference(const unsigned char *sha1,\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\tunsigned char *sha1_ret);\n \n extern struct object *peel_to_type(const char *name, int namelen,\n@@ -1720,10 +1720,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 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 void *unpack_entry(struct packed_git *, off_t, enum object_type *, size_t *);\n+extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, size_t *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 int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, size_t *);\n \n /*\n  * Iterate over the files in the loose-object parts of the object\n@@ -1789,7 +1789,7 @@ extern int for_each_packed_object(each_packed_object_fn, void *, unsigned flags)\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 *typename;\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 9e163d5..acf39ec 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -285,7 +285,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,\n }\n \n static char *grab_blob(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@@ -401,7 +401,7 @@ static void combine_diff(const struct object_id *parent, unsigned int mode,\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@@ -971,7 +971,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+\tsize_t result_size;\n+\tunsigned long cnt, lno;\n \tint result_deleted = 0;\n \tchar *result, *cp;\n \tstruct sline *sline; /* survived lines */\n@@ -1087,7 +1088,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(&elem->parent[i].oid,\n \t\t\t\t\telem->parent[i].mode,\n \t\t\t\t\t&size, NULL, NULL);\ndiff --git a/commit.c b/commit.c\nindex cbfd689..02849bc 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -262,7 +262,7 @@ const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)\n \tconst void *ret = get_cached_commit_buffer(commit, sizep);\n \tif (!ret) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tret = read_sha1_file(commit->object.oid.hash, &type, &size);\n \t\tif (!ret)\n \t\t\tdie(\"cannot read commit object %s\",\n@@ -373,7 +373,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)\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@@ -1204,7 +1204,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);\ndiff --git a/config.c b/config.c\nindex 231f9a7..9c3fa2d 100644\n--- a/config.c\n+++ b/config.c\n@@ -1467,7 +1467,7 @@ int git_config_from_blob_sha1(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_sha1_file(sha1, &type, &size);\ndiff --git a/delta.h b/delta.h\nindex 9b67531..2df0f55 100644\n--- a/delta.h\n+++ b/delta.h\n@@ -14,7 +14,7 @@ struct delta_index;\n  * using free_delta_index().\n  */\n extern struct delta_index *\n-create_delta_index(const void *buf, unsigned long bufsize);\n+create_delta_index(const void *buf, size_t bufsize);\n \n /*\n  * free_delta_index: free the index created by create_delta_index()\n@@ -28,7 +28,7 @@ extern void free_delta_index(struct delta_index *index);\n  *\n  * Given pointer must be what create_delta_index() returned, or NULL.\n  */\n-extern unsigned long sizeof_delta_index(struct delta_index *index);\n+extern size_t sizeof_delta_index(struct delta_index *index);\n \n /*\n  * create_delta: create a delta from given index for the given buffer\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-\t\t\t\t\t       const unsigned char *top)\n+static inline size_t get_delta_hdr_size(const unsigned char **datap,\n+\t\t\t\t\tconst 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 cd238c8..3d5e1ef 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -123,14 +123,14 @@ struct unpacked_index_entry {\n };\n \n struct delta_index {\n-\tunsigned long memsize;\n+\tsize_t memsize;\n \tconst void *src_buf;\n-\tunsigned long src_size;\n+\tsize_t src_size;\n \tunsigned int hash_mask;\n \tstruct index_entry *hash[FLEX_ARRAY];\n };\n \n-struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)\n+struct delta_index * create_delta_index(const void *buf, size_t bufsize)\n {\n \tunsigned int i, hsize, hmask, entries, prev_val, *hash_count;\n \tconst unsigned char *data, *buffer = buf;\n@@ -138,7 +138,7 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)\n \tstruct unpacked_index_entry *entry, **hash;\n \tstruct index_entry *packed_entry, **packed_hash;\n \tvoid *mem;\n-\tunsigned long memsize;\n+\tsize_t memsize;\n \n \tif (!buf || !bufsize)\n \t\treturn NULL;\n@@ -300,7 +300,7 @@ void free_delta_index(struct delta_index *index)\n \tfree(index);\n }\n \n-unsigned long sizeof_delta_index(struct delta_index *index)\n+size_t sizeof_delta_index(struct delta_index *index)\n {\n \tif (index)\n \t\treturn index->memsize;\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;\n@@ -407,7 +407,7 @@ create_delta(const struct delta_index *index,\n \t\t\t}\n \t\t\tmsize = 0;\n \t\t} else {\n-\t\t\tunsigned int left;\n+\t\t\tsize_t left;\n \t\t\tunsigned char *op;\n \n \t\t\tif (inscnt) {\ndiff --git a/diff.c b/diff.c\nindex 85e714f..882c091 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2203,8 +2203,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@@ -2232,10 +2232,10 @@ static void emit_binary_diff_body(FILE *file, mmfile_t *one, mmfile_t *two,\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@@ -5270,7 +5270,7 @@ int textconv_object(const char *path,\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 2d442e2..0901822 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -390,7 +390,7 @@ extern struct userdiff_driver *get_textconv(struct diff_filespec *one);\n  * if the textconv driver exists.\n  * Return 1 if the conversion succeeds, 0 otherwise.\n  */\n-extern int textconv_object(const char *path, unsigned mode, const struct object_id *oid, int oid_valid, char **buf, unsigned long *buf_size);\n+extern int textconv_object(const char *path, unsigned mode, const struct object_id *oid, int oid_valid, char **buf, size_t *buf_size);\n \n extern int parse_rename_score(const char **cp_p);\n \ndiff --git a/diffcore.h b/diffcore.h\nindex a30da16..8ad1823 100644\n--- a/diffcore.h\n+++ b/diffcore.h\n@@ -29,7 +29,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 ae6f5c9..ed4e362 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -605,7 +605,7 @@ static void *read_skip_worktree_file_from_index(const struct index_state *istate\n \t\t\t\t\t\tstruct sha1_stat *sha1_stat)\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/entry.c b/entry.c\nindex d6b263f..ea048de 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -80,7 +80,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 *new = read_sha1_file(ce->oid.hash, &type, size);\n@@ -144,7 +144,7 @@ static int write_entry(struct cache_entry *ce,\n \tint fd, ret, fstat_done = 0;\n \tchar *new;\n \tstruct strbuf buf = STRBUF_INIT;\n-\tunsigned long size;\n+\tsize_t size;\n \tsize_t wrote, newsize = 0;\n \tstruct stat st;\n \tconst struct submodule *sub;\ndiff --git a/fast-import.c b/fast-import.c\nindex a959161..011da20 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1090,7 +1090,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_SHA_CTX c;\n \tgit_zstream s;\n \n@@ -1345,7 +1345,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@@ -1391,7 +1391,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@@ -2579,7 +2579,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.hash,\n \t\t\tcommit_type, &size, commit_oid.hash);\n \t\tif (!buf || size < 46)\n@@ -2647,7 +2647,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.hash,\n@@ -2685,7 +2685,7 @@ static int parse_from(struct branch *b)\n \t\tif (oidcmp(&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@@ -2728,7 +2728,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.hash,\n \t\t\t\tcommit_type, &size, n->oid.hash);\n \t\t\tif (!buf || size < 46)\n@@ -2958,7 +2958,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@@ -3042,7 +3042,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 = sha1_object_info(oid->hash, NULL);\ndiff --git a/fsck.c b/fsck.c\nindex b4204d7..10909ef 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -796,7 +796,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 \tunsigned char sha1[20];\n \tint ret = 0;\ndiff --git a/grep.h b/grep.h\nindex 0c091e5..7b3409e 100644\n--- a/grep.h\n+++ b/grep.h\n@@ -198,7 +198,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 c91f40a..a097d01 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -355,7 +355,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/mailmap.c b/mailmap.c\nindex c1a79c1..cb292b8 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -216,7 +216,7 @@ static int read_mailmap_blob(struct string_list *map,\n {\n \tunsigned char sha1[20];\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 396b733..d4b7c1e 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -52,7 +52,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_sha1_file(hash->hash, &type, &size);\n \tif (!buffer)\n@@ -169,7 +169,7 @@ static int splice_tree(const unsigned char *hash1,\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 unsigned char *rewrite_with;\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex 9b6eac2..f7e55c4 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -8,7 +8,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_sha1_file(obj->object.oid.hash, &type, &size);\n@@ -28,7 +28,7 @@ static void free_mmfile(mmfile_t *f)\n \tfree(f->ptr);\n }\n \n-static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our, mmfile_t *their, unsigned long *size)\n+static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our, mmfile_t *their, size_t *size)\n {\n \tint merge_status;\n \tmmbuffer_t res;\n@@ -48,7 +48,7 @@ static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our\n \treturn res.ptr;\n }\n \n-void *merge_blobs(const char *path, struct blob *base, struct blob *our, struct blob *their, unsigned long *size)\n+void *merge_blobs(const char *path, struct blob *base, struct blob *our, 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 62b569e..e66eee7 100644\n--- a/merge-blobs.h\n+++ b/merge-blobs.h\n@@ -3,6 +3,6 @@\n \n #include \"blob.h\"\n \n-extern void *merge_blobs(const char *, struct blob *, struct blob *, struct blob *, unsigned long *);\n+extern void *merge_blobs(const char *, struct blob *, struct blob *, struct blob *, size_t *);\n \n #endif /* MERGE_BLOBS_H */\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 1494ffd..e6b547c 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -787,7 +787,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@@ -1602,7 +1602,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_sha1_file(oid->hash, &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 29b4ced..df86765 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -72,7 +72,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 70e3fbe..9c07d76 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -324,7 +324,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_sha1_file(note->hash, &type, &size);\n \n \tif (!buf)\ndiff --git a/notes.c b/notes.c\nindex 8f47c20..be29bd3 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -808,7 +808,7 @@ int combine_notes_concatenate(unsigned char *cur_sha1,\n \t\tconst unsigned char *new_sha1)\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@@ -869,7 +869,7 @@ static int string_list_add_note_lines(struct string_list *list,\n \t\t\t\t      const unsigned char *sha1)\n {\n \tchar *data;\n-\tunsigned long len;\n+\tsize_t len;\n \tenum object_type t;\n \n \tif (is_null_sha1(sha1))\n@@ -1222,7 +1222,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.c b/object.c\nindex f818777..1b945c7 100644\n--- a/object.c\n+++ b/object.c\n@@ -242,7 +242,7 @@ struct object *parse_object_or_die(const struct object_id *oid,\n \n struct object *parse_object(const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tint eaten;\n \tconst unsigned char *repl = lookup_replace_object(oid->hash);\ndiff --git a/pack-check.c b/pack-check.c\nindex e1fcb22..6f7714f 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -104,7 +104,7 @@ static int verify_packfile(struct packed_git *p,\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 03f1191..3a2cf4e 100644\n--- a/pack-objects.h\n+++ b/pack-objects.h\n@@ -3,7 +3,7 @@\n \n struct object_entry {\n \tstruct pack_idx_entry idx;\n-\tunsigned long size;\t/* uncompressed size */\n+\tsize_t size;\t/* uncompressed size */\n \tstruct packed_git *in_pack;\t/* already in pack */\n \toff_t in_pack_offset;\n \tstruct object_entry *delta;\t/* delta base object */\n@@ -12,8 +12,8 @@ struct object_entry {\n \t\t\t\t\t     * uses the same base as me\n \t\t\t\t\t     */\n \tvoid *delta_data;\t/* cached delta (uncompressed) */\n-\tunsigned long delta_size;\t/* delta data size (uncompressed) */\n-\tunsigned long z_delta_size;\t/* delta data size (compressed) */\n+\tsize_t delta_size;\t/* delta data size (uncompressed) */\n+\tsize_t z_delta_size;\t/* delta data size (compressed) */\n \tenum object_type type;\n \tenum object_type in_pack_type;\t/* could be delta */\n \tuint32_t hash;\t\t\t/* name hint hash */\ndiff --git a/patch-delta.c b/patch-delta.c\nindex 56e0a5e..8b2fa20 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;\n@@ -39,7 +39,8 @@ void *patch_delta(const void *src_buf, unsigned long src_size,\n \twhile (data < top) {\n \t\tcmd = *data++;\n \t\tif (cmd & 0x80) {\n-\t\t\tunsigned long cp_off = 0, cp_size = 0;\n+\t\t\toff_t cp_off = 0;\n+\t\t\tsize_t cp_size = 0;\n \t\t\tif (cmd & 0x01) cp_off = *data++;\n \t\t\tif (cmd & 0x02) cp_off |= (*data++ << 8);\n \t\t\tif (cmd & 0x04) cp_off |= (*data++ << 16);\ndiff --git a/read-cache.c b/read-cache.c\nindex 2121b6e..c966e86 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -172,7 +172,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@@ -2584,7 +2584,7 @@ void *read_blob_data_from_index(const struct index_state *istate,\n \t\t\t\tconst char *path, unsigned long *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 ae6ecbd..4e19527 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -684,7 +684,7 @@ int verify_ref_format(const char *format)\n  * by the \"struct object\" representation, set *eaten as well---it is a\n  * signal from parse_object_buffer to us not to free the buffer.\n  */\n-static void *get_obj(const struct object_id *oid, struct object **obj, unsigned long *sz, int *eaten)\n+static void *get_obj(const struct object_id *oid, struct object **obj, size_t *sz, int *eaten)\n {\n \tenum object_type type;\n \tvoid *buf = read_sha1_file(oid->hash, &type, sz);\n@@ -1303,7 +1303,7 @@ static void populate_value(struct ref_array_item *ref)\n \tvoid *buf;\n \tstruct object *obj;\n \tint eaten, i;\n-\tunsigned long size;\n+\tsize_t size;\n \tconst struct object_id *tagged;\n \n \tref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex 0ff4a31..08748ca 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -55,7 +55,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@@ -104,7 +104,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 70634d4..41852f0 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -974,7 +974,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu\n \n \twhile (pos < active_nr) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \n \t\tce = active_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 b60ae15..6fe09c0 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1631,7 +1631,7 @@ static const struct packed_git *has_packed_and_bad(const unsigned char *sha1)\n  * the streaming interface and rehash it to do the same.\n  */\n int check_sha1_signature(const unsigned char *sha1, void *map,\n-\t\t\t unsigned long size, const char *type)\n+\t\t\t size_t size, const char *type)\n {\n \tunsigned char real_sha1[20];\n \tenum object_type obj_type;\n@@ -1795,11 +1795,11 @@ void *map_sha1_file(const unsigned char *sha1, unsigned long *size)\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+\t\tunsigned long 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@@ -1997,7 +1997,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@@ -2118,7 +2118,7 @@ static const unsigned char *get_delta_base_sha1(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 \tunsigned long left;\n@@ -2171,7 +2171,7 @@ static enum object_type packed_to_object_type(struct packed_git *p,\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@@ -2306,7 +2306,7 @@ static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)\n }\n \n static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,\n-\tunsigned long *base_size, enum object_type *type)\n+\tsize_t *base_size, enum object_type *type)\n {\n \tstruct delta_base_cache_entry *ent;\n \n@@ -2370,7 +2370,7 @@ int packed_object_info(struct packed_git *p, off_t obj_offset,\n \t\t       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@@ -2484,7 +2484,7 @@ static void *unpack_compressed_entry(struct packed_git *p,\n }\n \n static void *read_object(const unsigned char *sha1, enum object_type *type,\n-\t\t\t unsigned long *size);\n+\t\t\t size_t *size);\n \n static void write_pack_access_log(struct packed_git *p, off_t obj_offset)\n {\n@@ -2503,12 +2503,12 @@ struct unpack_entry_stack_ent {\n };\n \n void *unpack_entry(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@@ -2608,7 +2608,7 @@ void *unpack_entry(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;\n@@ -2913,7 +2913,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,\n \tgit_zstream stream;\n \tchar hdr[32];\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@@ -3050,7 +3050,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,\n }\n \n /* returns enum object_type or negative */\n-int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)\n+int sha1_object_info(const unsigned char *sha1, size_t *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n@@ -3064,7 +3064,7 @@ int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)\n }\n \n static void *read_packed_sha1(const unsigned char *sha1,\n-\t\t\t      enum object_type *type, unsigned long *size)\n+\t\t\t      enum object_type *type, size_t *size)\n {\n \tstruct pack_entry e;\n \tvoid *data;\n@@ -3106,7 +3106,7 @@ int pretend_sha1_file(void *buf, unsigned long len, enum object_type type,\n }\n \n static void *read_object(const unsigned char *sha1, 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@@ -3126,7 +3126,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,\n  */\n void *read_sha1_file_extended(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 \t\t\t      int lookup_replace)\n {\n \tvoid *data;\n@@ -3162,12 +3162,12 @@ void *read_sha1_file_extended(const unsigned char *sha1,\n \n void *read_object_with_reference(const unsigned char *sha1,\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 unsigned char *actual_sha1_return)\n {\n \tenum object_type type, required_type;\n \tvoid *buffer;\n-\tunsigned long isize;\n+\tsize_t isize;\n \tunsigned char actual_sha1[20];\n \n \trequired_type = type_from_string(required_type_name);\n@@ -3461,7 +3461,7 @@ int hash_sha1_file_literally(const void *buf, unsigned long len, const char *typ\n int force_object_loose(const unsigned char *sha1, time_t mtime)\n {\n \tvoid *buf;\n-\tunsigned long len;\n+\tsize_t len;\n \tenum object_type type;\n \tchar hdr[32];\n \tint hdrlen;\n@@ -3985,7 +3985,7 @@ static int check_stream_sha1(git_zstream *stream,\n int read_loose_object(const char *path,\n \t\t      const unsigned char *expected_sha1,\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;\ndiff --git a/streaming.c b/streaming.c\nindex 9afa66b..04a8b99 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -65,7 +65,7 @@ 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@@ -108,7 +108,7 @@ static enum input_source istream_source(const unsigned char *sha1,\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@@ -131,7 +131,7 @@ static enum input_source istream_source(const unsigned char *sha1,\n \n struct git_istream *open_istream(const unsigned char *sha1,\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@@ -502,7 +502,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 73c1d15..49f42c3 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 unsigned char *, enum object_type *, unsigned long *, struct stream_filter *);\n+extern struct git_istream *open_istream(const unsigned char *, 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 5fe2d07..675d426 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -468,7 +468,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 \tunsigned char sha1[20];\n \tenum object_type type;\ndiff --git a/t/helper/test-delta.c b/t/helper/test-delta.c\nindex 59937dc..6524fbd 100644\n--- a/t/helper/test-delta.c\n+++ b/t/helper/test-delta.c\n@@ -20,7 +20,7 @@ int cmd_main(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 47f60ae..02676a9 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -38,7 +38,7 @@ int gpg_verify_tag(const unsigned char *sha1, 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 = sha1_object_info(sha1, NULL);\n@@ -177,7 +177,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/tree-walk.c b/tree-walk.c\nindex 6a42e40..7c9f9e3 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -80,7 +80,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 unsigned char *sha1)\n {\n-\tunsigned long size = 0;\n+\tsize_t size = 0;\n \tvoid *buf = NULL;\n \n \tif (sha1) {\n@@ -530,7 +530,7 @@ int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned ch\n {\n \tint retval;\n \tvoid *tree;\n-\tunsigned long size;\n+\tsize_t size;\n \tunsigned char root[20];\n \n \ttree = read_object_with_reference(tree_sha1, tree_type, &size, root);\n@@ -600,7 +600,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s\n \t\tif (!t.buffer) {\n \t\t\tvoid *tree;\n \t\t\tunsigned char root[20];\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\ttree = read_object_with_reference(current_tree_sha1,\n \t\t\t\t\t\t\t  tree_type, &size,\n \t\t\t\t\t\t\t  root);\n@@ -696,7 +696,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s\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 b224115..5e42f83 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -215,7 +215,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 018e033..d82cd4a 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -181,7 +181,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 (!oidcmp(oid, &null_oid)) {\n-- \n2.1.4\n\n"},{"id":"325861","messageId":"xmqqr2wlah7f.fsf@gitster.mtv.corp.google.com","threadId":"46542","inReplyTo":"1502222450-20815-1-git-send-email-martin@mail.zuhause","subject":"Re: [PATCH] Convert size datatype to size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-08T21:21:40Z","receivedAt":"2017-08-08T21:21:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Koegler <martin.koegler@chello.at> writes:\n\n> From: Martin Koegler <martin.koegler@chello.at>\n>\n> It changes the signature of the core object access function\n> including any other functions to assure a clean compile if\n> sizeof(size_t) != sizeof(unsigned long).\n>\n> Signed-off-by: Martin Koegler <martin.koegler@chello.at>\n> ---\n> ...\n>  66 files changed, 193 insertions(+), 191 deletions(-)\n\nWow, that's a lot of changes.  What version did you worked this\npatch on?  The reason I ask is because...\n\n> diff --git a/diff-delta.c b/diff-delta.c\n> index cd238c8..3d5e1ef 100644\n\n... I do not see any version of Git that had blob cd238c8 at that\npath, so \"git am -3\" is having hard time applying this pach to allow\nme reviewing it.\n"},{"id":"325864","messageId":"xmqqmv79ag1r.fsf@gitster.mtv.corp.google.com","threadId":"46542","inReplyTo":"1502222450-20815-1-git-send-email-martin@mail.zuhause","subject":"Re: [PATCH] Convert size datatype to size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-08T21:46:40Z","receivedAt":"2017-08-08T21:46:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Koegler <martin.koegler@chello.at> writes:\n\n> diff --git a/apply.c b/apply.c\n> index f2d5991..ea97fd2 100644\n> --- a/apply.c\n> +++ b/apply.c\n> @@ -3085,7 +3085,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\nThis variable is made size_t because it receives the result size of\npatch_delta().  And it later is assigned to img->len field, which\nalready is size_t before this patch.\n\nCuriously, the patch_delta() invocation with this patch reads like\nthis:\n\n\t\tdst = patch_delta(img->buf, img->len, fragment->patch,\n\t\t\t\t  fragment->size, &len);\n\nwhere patch_delta() is updated (correctly) to:\n\n    void *patch_delta(const void *src_buf, size_t src_size,\n                      const void *delta_buf, size_t delta_size,\n                      size_t *dst_size)\n\nwith this patch.  But \"size\" field in \"struct fragment\" is still\n\"int\".  So we'd need to update it as well, not necessarily in this\npatch (which is already too big) but as part of a larger whole.\n\n> @@ -3174,7 +3174,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_sha1_file(oid.hash, &type, &size);\n\nThis is to receive the resulting size from read_sha1_file().  It is\nassigned to img->len, which is already size_t, so all is good here.\n\n> @@ -3236,7 +3236,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_sha1_file(oid->hash, &type, &sz);\n\nBy reading the remainder of this function, this conversion also is\ngood.  sz that is now size_t is used as the size attached to an\nexisting strbuf like so:\n\n\t\tresult = read_sha1_file(oid->hash, &type, &sz);\n\t\tif (!result)\n\t\t\treturn -1;\n\t\t/* XXX read_sha1_file NUL-terminates */\n\t\tstrbuf_attach(buf, result, sz, sz + 1);\n\nin the part beyond the post context of this hunk.  In the longer\nterm, sz+1 we see here may want to become the overflow-safe variant\nst_add().\n\nAs you said in the comment after three-dashes in the patch, a lot\nmore work is needed and your patch is a good starting point.\n\nI am not sure if we can split the patch somehow to make it easier to\nreview.  The deceptively small part of your patch, i.e.\n\n apply.c                  |  6 +++---\n\nneeds the above analysis to see if they are correct and what more\nwork is necessary, and there are 65 more files with ~190 lines\nchanged.\n\n"},{"id":"325920","messageId":"xmqq8tit8efv.fsf@gitster.mtv.corp.google.com","threadId":"46542","inReplyTo":"1502222450-20815-1-git-send-email-martin@mail.zuhause","subject":"Re: [PATCH] Convert size datatype to size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-09T06:04:20Z","receivedAt":"2017-08-09T06:04:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Koegler <martin.koegler@chello.at> writes:\n\n> From: Martin Koegler <martin.koegler@chello.at>\n>\n> It changes the signature of the core object access function\n> including any other functions to assure a clean compile if\n> sizeof(size_t) != sizeof(unsigned long).\n\nAs https://travis-ci.org/git/git/jobs/262463159 shows, unfortunately\nit turns out that things are not so simple X-<.  On Linux32, size_t\nis uint, which is the same size as ulong, but \"%lu\" is not appropriate\nfor showing a size_t value.\n\nSo you are correct to say in the comment under three-dashes that\nthere is much more to change in the codebase.\n\n\n"},{"id":"325924","messageId":"20170809071906.GA19310@mail.zuhause","threadId":"46542","inReplyTo":"xmqq8tit8efv.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] Convert size datatype to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-09T07:19:06Z","receivedAt":"2017-08-09T07:19:16Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"On Tue, Aug 08, 2017 at 11:04:20PM -0700, Junio C Hamano wrote:\n> Martin Koegler <martin.koegler@chello.at> writes:\n> \n> > From: Martin Koegler <martin.koegler@chello.at>\n> >\n> > It changes the signature of the core object access function\n> > including any other functions to assure a clean compile if\n> > sizeof(size_t) != sizeof(unsigned long).\n> \n> As https://travis-ci.org/git/git/jobs/262463159 shows, unfortunately\n> it turns out that things are not so simple X-<.  On Linux32, size_t\n> is uint, which is the same size as ulong, but \"%lu\" is not appropriate\n> for showing a size_t value.\n> \n> So you are correct to say in the comment under three-dashes that\n> there is much more to change in the codebase.\n\nMy patch is based on V2 of my \"Fix delta integer overflows\" patch [also changing the variable types].\n\nI'll post a new version fixing the *printf issues.\n\nThe patch can't be splitted without causing compile errors, if sizeof(size_t) != sizeof(ulong).\nMany variables are not changed to keep the patch small.\n\nRegards,\nMartin\n"},{"id":"325925","messageId":"20170809072613.GA20347@mail.zuhause","threadId":"46542","inReplyTo":"20170809071906.GA19310@mail.zuhause","subject":"Re: [PATCH] Convert size datatype to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-09T07:26:13Z","receivedAt":"2017-08-09T07:26:29Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"On Wed, Aug 09, 2017 at 09:19:06AM +0200, Martin Koegler wrote:\n> On Tue, Aug 08, 2017 at 11:04:20PM -0700, Junio C Hamano wrote:\n> > As https://travis-ci.org/git/git/jobs/262463159 shows, unfortunately\n> > it turns out that things are not so simple X-<.  On Linux32, size_t\n> > is uint, which is the same size as ulong, but \"%lu\" is not appropriate\n> > for showing a size_t value.\n> > \n> > So you are correct to say in the comment under three-dashes that\n> > there is much more to change in the codebase.\n> \n> I'll post a new version fixing the *printf issues.\n\nWhat is the correct format specifier for size_t?\nLinux has %zu (C99). Is that OK for the GIT codebase?\n\nRegards,\nMartin\n"},{"id":"325964","messageId":"xmqqa8387khm.fsf@gitster.mtv.corp.google.com","threadId":"46542","inReplyTo":"20170809072613.GA20347@mail.zuhause","subject":"Re: [PATCH] Convert size datatype to size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-09T16:51:17Z","receivedAt":"2017-08-09T16:51:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Koegler <martin.koegler@chello.at> writes:\n\n> On Wed, Aug 09, 2017 at 09:19:06AM +0200, Martin Koegler wrote:\n>> On Tue, Aug 08, 2017 at 11:04:20PM -0700, Junio C Hamano wrote:\n>> > As https://travis-ci.org/git/git/jobs/262463159 shows, unfortunately\n>> > it turns out that things are not so simple X-<.  On Linux32, size_t\n>> > is uint, which is the same size as ulong, but \"%lu\" is not appropriate\n>> > for showing a size_t value.\n>> > \n>> > So you are correct to say in the comment under three-dashes that\n>> > there is much more to change in the codebase.\n>> \n>> I'll post a new version fixing the *printf issues.\n>\n> What is the correct format specifier for size_t?\n> Linux has %zu (C99). Is that OK for the GIT codebase?\n\nI haven't double checked, but IIRC we cast to uintmax_t and use\nPRIuMAX.\n"},{"id":"325997","messageId":"alpine.DEB.2.21.1.1708100011391.11175@virtualbox","threadId":"46542","inReplyTo":"xmqqa8387khm.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] Convert size datatype to size_t","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-08-09T22:12:48Z","receivedAt":"2017-08-09T22:13:06Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 9 Aug 2017, Junio C Hamano wrote:\n\n> Martin Koegler <martin.koegler@chello.at> writes:\n> \n> > On Wed, Aug 09, 2017 at 09:19:06AM +0200, Martin Koegler wrote:\n> >> On Tue, Aug 08, 2017 at 11:04:20PM -0700, Junio C Hamano wrote:\n> >> > As https://travis-ci.org/git/git/jobs/262463159 shows, unfortunately\n> >> > it turns out that things are not so simple X-<.  On Linux32, size_t\n> >> > is uint, which is the same size as ulong, but \"%lu\" is not appropriate\n> >> > for showing a size_t value.\n> >> > \n> >> > So you are correct to say in the comment under three-dashes that\n> >> > there is much more to change in the codebase.\n> >> \n> >> I'll post a new version fixing the *printf issues.\n> >\n> > What is the correct format specifier for size_t?\n> > Linux has %zu (C99). Is that OK for the GIT codebase?\n> \n> I haven't double checked, but IIRC we cast to uintmax_t and use\n> PRIuMAX.\n\nThat would be my preference, too. This is the patch that I need to make\n`pu` compile for me again (note: there is one `unsigned long` -> `size_t`\nchange hiding between all the `%lu` -> `%PRIuMAX` changes):\n\n-- snipsnap --\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex bc19e08a62d..10428cbeb0b 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -232,7 +232,7 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len,\n \t\tif (data->mark_query)\n \t\t\tdata->info.sizep = &data->size;\n \t\telse\n-\t\t\tstrbuf_addf(sb, \"%lu\", data->size);\n+\t\t\tstrbuf_addf(sb, \"%\" PRIuMAX, (uintmax_t)data->size);\n \t} else if (is_atom(\"objectsize:disk\", atom, len)) {\n \t\tif (data->mark_query)\n \t\t\tdata->info.disk_sizep = &data->disk_size;\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 9be8f817f2f..e3e33f3baab 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -437,7 +437,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));\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 3ab99c47a0c..b09d9cba7e4 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -99,7 +99,7 @@ static int show_tree(const unsigned char *sha1, struct strbuf *base,\n \t\t\t\t\t\t  \"BAD\");\n \t\t\t\telse\n \t\t\t\t\txsnprintf(size_text, sizeof(size_text),\n-\t\t\t\t\t\t  \"%lu\", size);\n+\t\t\t\t\t\t  \"%\" PRIuMAX, (uintmax_t)size);\n \t\t\t} else\n \t\t\t\txsnprintf(size_text, sizeof(size_text), \"-\");\n \t\t\tprintf(\"%06o %s %s %7s\\t\", mode, type,\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 126e7097bf6..d94fd170243 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1863,9 +1863,10 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t\t\tdie(\"object %s cannot be read\",\n \t\t\t    oid_to_hex(&trg_entry->idx.oid));\n \t\tif (sz != trg_size)\n-\t\t\tdie(\"object %s inconsistent object length (%lu vs %lu)\",\n-\t\t\t    oid_to_hex(&trg_entry->idx.oid), sz,\n-\t\t\t    trg_size);\n+\t\t\tdie(\"object %s inconsistent object length (%\" PRIuMAX\n+\t\t\t    \" vs %\" PRIuMAX \")\",\n+\t\t\t    oid_to_hex(&trg_entry->idx.oid), (uintmax_t)sz,\n+\t\t\t    (uintmax_t)trg_size);\n \t\t*mem_usage += sz;\n \t}\n \tif (!src->data) {\n@@ -1891,9 +1892,10 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t\t\t    oid_to_hex(&src_entry->idx.oid));\n \t\t}\n \t\tif (sz != src_size)\n-\t\t\tdie(\"object %s inconsistent object length (%lu vs %lu)\",\n-\t\t\t    oid_to_hex(&src_entry->idx.oid), sz,\n-\t\t\t    src_size);\n+\t\t\tdie(\"object %s inconsistent object length (%\" PRIuMAX\n+\t\t\t    \" vs %\" PRIuMAX \")\",\n+\t\t\t    oid_to_hex(&src_entry->idx.oid), (uintmax_t)sz,\n+\t\t\t    (uintmax_t)src_size);\n \t\t*mem_usage += sz;\n \t}\n \tif (!src->index) {\ndiff --git a/diff.c b/diff.c\nindex 6084487a2fc..1e815e87acb 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2971,7 +2971,7 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t}\n \n \tif (delta && delta_size < deflate_size) {\n-\t\tchar *s = xstrfmt(\"%lu\", orig_size);\n+\t\tchar *s = xstrfmt(\"%\" PRIuMAX, (uintmax_t)orig_size);\n \t\temit_diff_symbol(o, DIFF_SYMBOL_BINARY_DIFF_HEADER_DELTA,\n \t\t\t\t s, strlen(s), 0);\n \t\tfree(s);\ndiff --git a/fast-import.c b/fast-import.c\nindex 011da200cb6..bfde330f215 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -2986,8 +2986,8 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)\n \t\tdie(\"Object %s is a %s but a blob was expected.\",\n \t\t    oid_to_hex(oid), typename(type));\n \tstrbuf_reset(&line);\n-\tstrbuf_addf(&line, \"%s %s %lu\\n\", oid_to_hex(oid),\n-\t\t\t\t\t\ttypename(type), size);\n+\tstrbuf_addf(&line, \"%s %s %\" PRIuMAX \"\\n\", oid_to_hex(oid),\n+\t\t    typename(type), (uintmax_t)size);\n \tcat_blob_write(line.buf, line.len);\n \tstrbuf_release(&line);\n \tcat_blob_write(buf, size);\ndiff --git a/http-push.c b/http-push.c\nindex 676149ceac3..af229428c1c 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -356,7 +356,8 @@ static void start_put(struct transfer_request *request)\n \tgit_zstream stream;\n \n \tunpacked = read_sha1_file(request->obj->oid.hash, &type, &len);\n-\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %lu\", typename(type), len) + 1;\n+\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %\" PRIuMAX,\n+\t\t\t   typename(type), (uintmax_t)len) + 1;\n \n \t/* Set it up */\n \tgit_deflate_init(&stream, zlib_compression_level);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex c63f478a311..84b9c6b6ec8 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -983,7 +983,8 @@ int check_sha1_signature(const unsigned char *sha1, void *map,\n \t\treturn -1;\n \n \t/* Generate the header */\n-\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %lu\", typename(obj_type), size) + 1;\n+\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %\" PRIuMAX,\n+\t\t\t   typename(obj_type), (uintmax_t)size) + 1;\n \n \t/* Sha1.. */\n \tgit_SHA1_Init(&c);\n@@ -2794,7 +2795,8 @@ int force_object_loose(const unsigned char *sha1, time_t mtime)\n \tbuf = read_packed_sha1(sha1, &type, &len);\n \tif (!buf)\n \t\treturn error(\"cannot read sha1_file for %s\", sha1_to_hex(sha1));\n-\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %lu\", typename(type), len) + 1;\n+\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %\" PRIuMAX,\n+\t\t\t   typename(type), (uintmax_t)len) + 1;\n \tret = write_loose_object(sha1, hdr, hdrlen, buf, len, mtime);\n \tfree(buf);\n \n"},{"id":"325998","messageId":"alpine.DEB.2.21.1.1708100015460.11175@virtualbox","threadId":"46542","inReplyTo":"1502222450-20815-1-git-send-email-martin@mail.zuhause","subject":"Re: [PATCH] Convert size datatype to size_t","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-08-09T22:16:10Z","receivedAt":"2017-08-09T22:16:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Martin,\n\nOn Tue, 8 Aug 2017, Martin Koegler wrote:\n\n> From: Martin Koegler <martin.koegler@chello.at>\n> \n> It changes the signature of the core object access function\n> including any other functions to assure a clean compile if\n> sizeof(size_t) != sizeof(unsigned long).\n> \n> Signed-off-by: Martin Koegler <martin.koegler@chello.at>\n> ---\n\nThank you for working on this!\n\nMuch appreciated,\nDscho\n"}]}