{"thread":{"id":"47878","subject":"[PATCH 00/36] object_id part 12","startedAt":"2018-02-19T22:59:40Z","lastAt":"2018-02-22T00:24:22Z","messageCount":39,"participants":["brian m. carlson","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":36},"messages":[{"id":"339649","messageId":"20180219225927.386065-1-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":null,"subject":"[PATCH 00/36] object_id part 12","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:58:51Z","receivedAt":"2018-02-19T22:59:40Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is the twelfth in a series of patches to convert from unsigned char\n[20] to struct object_id.  This series is based on next.\n\nIncluded in this series are conversions for find_unique_abbrev and\nlookup_replace_object, as well as parts of the sha1_file code.\n\nConflicts with pu are average in number but minor, mostly because of the\ntype_name conversion.  None of them are tricky, except that the\nintroduction of get_tree_entry_if_blob requires a conversion of that\nfunction.\n\nbrian m. carlson (36):\n  bulk-checkin: convert index_bulk_checkin to struct object_id\n  builtin/write-tree: convert to struct object_id\n  cache-tree: convert write_*_as_tree to object_id\n  cache-tree: convert remnants to struct object_id\n  resolve-undo: convert struct resolve_undo_info to object_id\n  tree: convert read_tree_recursive to struct object_id\n  ref-filter: convert grab_objectname to struct object_id\n  strbuf: convert strbuf_add_unique_abbrev to use struct object_id\n  wt-status: convert struct wt_status_state to object_id\n  Convert find_unique_abbrev* to struct object_id\n  http-walker: convert struct object_request to use struct object_id\n  send-pack: convert remaining functions to struct object_id\n  replace_object: convert struct replace_object to object_id\n  builtin/mktag: convert to struct object_id\n  archive: convert write_archive_entry_fn_t to object_id\n  archive: convert sha1_file_to_archive to struct object_id\n  builtin/index-pack: convert struct ref_delta_entry to object_id\n  sha1_file: convert read_loose_object to use struct object_id\n  sha1_file: convert check_sha1_signature to struct object_id\n  streaming: convert open_istream to use struct object_id\n  builtin/mktree: convert to struct object_id\n  sha1_file: convert assert_sha1_type to object_id\n  sha1_file: convert retry_bad_packed_offset to struct object_id\n  packfile: convert unpack_entry to struct object_id\n  Convert remaining callers of sha1_object_info_extended to object_id\n  sha1_file: convert sha1_object_info* to object_id\n  builtin/fmt-merge-msg: convert remaining code to object_id\n  builtin/notes: convert static functions to object_id\n  tree-walk: convert get_tree_entry_follow_symlinks internals to\n    object_id\n  streaming: convert istream internals to struct object_id\n  tree-walk: convert tree entry functions to object_id\n  sha1_file: convert read_object_with_reference to object_id\n  sha1_file: convert read_sha1_file to struct object_id\n  Convert lookup_replace_object to struct object_id\n  sha1_file: introduce a constant for max header length\n  convert: convert to struct object_id\n\n apply.c                  |   4 +-\n archive-tar.c            |  28 ++++----\n archive-zip.c            |  18 ++---\n archive.c                |  32 ++++-----\n archive.h                |  10 +--\n bisect.c                 |   3 +-\n blame.c                  |  18 +++--\n builtin/am.c             |   8 +--\n builtin/blame.c          |   4 +-\n builtin/branch.c         |   2 +-\n builtin/cat-file.c       |  30 +++++----\n builtin/checkout.c       |  12 ++--\n builtin/commit-tree.c    |   2 +-\n builtin/describe.c       |   6 +-\n builtin/difftool.c       |   2 +-\n builtin/fast-export.c    |   8 +--\n builtin/fetch.c          |  10 +--\n builtin/fmt-merge-msg.c  |   4 +-\n builtin/fsck.c           |   4 +-\n builtin/grep.c           |   6 +-\n builtin/index-pack.c     |  43 ++++++------\n builtin/log.c            |   8 +--\n builtin/ls-files.c       |   4 +-\n builtin/ls-tree.c        |   8 +--\n builtin/merge-tree.c     |   5 +-\n builtin/merge.c          |   8 +--\n builtin/mktag.c          |  20 +++---\n builtin/mktree.c         |  24 +++----\n builtin/name-rev.c       |   2 +-\n builtin/notes.c          |  14 ++--\n builtin/pack-objects.c   |  27 ++++----\n builtin/prune.c          |   2 +-\n builtin/receive-pack.c   |   8 +--\n builtin/reflog.c         |   2 +-\n builtin/replace.c        |  10 +--\n builtin/reset.c          |   2 +-\n builtin/rev-list.c       |   2 +-\n builtin/rev-parse.c      |   2 +-\n builtin/rm.c             |   2 +-\n builtin/show-branch.c    |   2 +-\n builtin/show-ref.c       |   4 +-\n builtin/tag.c            |  16 +++--\n builtin/unpack-file.c    |   2 +-\n builtin/unpack-objects.c |   4 +-\n builtin/update-index.c   |   2 +-\n builtin/verify-commit.c  |   2 +-\n builtin/worktree.c       |   4 +-\n builtin/write-tree.c     |   6 +-\n bulk-checkin.c           |  18 ++---\n bulk-checkin.h           |   2 +-\n bundle.c                 |   2 +-\n cache-tree.c             |  36 +++++-----\n cache-tree.h             |   4 +-\n cache.h                  |  42 ++++++------\n combine-diff.c           |   6 +-\n commit.c                 |   8 +--\n config.c                 |   2 +-\n convert.c                |  12 ++--\n convert.h                |   2 +-\n diff.c                   |   6 +-\n dir.c                    |   2 +-\n entry.c                  |   4 +-\n fast-import.c            |  31 ++++-----\n fsck.c                   |   2 +-\n grep.c                   |   2 +-\n http-push.c              |   2 +-\n http-walker.c            |  16 ++---\n line-log.c               |   3 +-\n list-objects-filter.c    |   2 +-\n log-tree.c               |  12 ++--\n mailmap.c                |   2 +-\n match-trees.c            |  10 +--\n merge-blobs.c            |   4 +-\n merge-recursive.c        |  20 +++---\n notes-cache.c            |   2 +-\n notes-merge.c            |   2 +-\n notes.c                  |  10 +--\n object.c                 |  12 ++--\n pack-bitmap-write.c      |   3 +-\n pack-check.c             |   4 +-\n packfile.c               |  30 ++++-----\n pretty.c                 |   8 +--\n reachable.c              |   2 +-\n read-cache.c             |   4 +-\n ref-filter.c             |  14 ++--\n refs.c                   |   2 +-\n remote-testsvn.c         |   4 +-\n remote.c                 |   2 +-\n replace_object.c         |  26 ++++----\n rerere.c                 |   4 +-\n resolve-undo.c           |   8 +--\n resolve-undo.h           |   2 +-\n send-pack.c              |  12 ++--\n sequencer.c              |   9 +--\n sha1_file.c              | 137 ++++++++++++++++++++-------------------\n sha1_name.c              |  31 +++++----\n strbuf.c                 |   4 +-\n strbuf.h                 |   8 ++-\n streaming.c              |  18 ++---\n streaming.h              |   2 +-\n submodule-config.c       |   2 +-\n submodule.c              |   6 +-\n tag.c                    |  10 +--\n transport.c              |   6 +-\n tree-walk.c              |  45 +++++++------\n tree-walk.h              |   2 +-\n tree.c                   |  16 ++---\n tree.h                   |   2 +-\n wt-status.c              |  20 +++---\n wt-status.h              |   6 +-\n xdiff-interface.c        |   2 +-\n 111 files changed, 593 insertions(+), 582 deletions(-)\n\n"},{"id":"339650","messageId":"20180219225927.386065-2-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 01/36] bulk-checkin: convert index_bulk_checkin to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:58:52Z","receivedAt":"2018-02-19T22:59:42Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the index_bulk_checkin function, and the static functions it\ncalls, to use pointers to struct object_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n bulk-checkin.c | 18 +++++++++---------\n bulk-checkin.h |  2 +-\n sha1_file.c    |  2 +-\n 3 files changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 8bcd1c8665..6f5ee25bff 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -60,17 +60,17 @@ static void finish_bulk_checkin(struct bulk_checkin_state *state)\n \treprepare_packed_git();\n }\n \n-static int already_written(struct bulk_checkin_state *state, unsigned char sha1[])\n+static int already_written(struct bulk_checkin_state *state, struct object_id *oid)\n {\n \tint i;\n \n \t/* The object may already exist in the repository */\n-\tif (has_sha1_file(sha1))\n+\tif (has_sha1_file(oid->hash))\n \t\treturn 1;\n \n \t/* Might want to keep the list sorted */\n \tfor (i = 0; i < state->nr_written; i++)\n-\t\tif (!hashcmp(state->written[i]->oid.hash, sha1))\n+\t\tif (!oidcmp(&state->written[i]->oid, oid))\n \t\t\treturn 1;\n \n \t/* This is a new object we need to keep */\n@@ -186,7 +186,7 @@ static void prepare_to_stream(struct bulk_checkin_state *state,\n }\n \n static int deflate_to_pack(struct bulk_checkin_state *state,\n-\t\t\t   unsigned char result_sha1[],\n+\t\t\t   struct object_id *result_oid,\n \t\t\t   int fd, size_t size,\n \t\t\t   enum object_type type, const char *path,\n \t\t\t   unsigned flags)\n@@ -236,17 +236,17 @@ static int deflate_to_pack(struct bulk_checkin_state *state,\n \t\tif (lseek(fd, seekback, SEEK_SET) == (off_t) -1)\n \t\t\treturn error(\"cannot seek back\");\n \t}\n-\tthe_hash_algo->final_fn(result_sha1, &ctx);\n+\tthe_hash_algo->final_fn(result_oid->hash, &ctx);\n \tif (!idx)\n \t\treturn 0;\n \n \tidx->crc32 = crc32_end(state->f);\n-\tif (already_written(state, result_sha1)) {\n+\tif (already_written(state, result_oid)) {\n \t\thashfile_truncate(state->f, &checkpoint);\n \t\tstate->offset = checkpoint.offset;\n \t\tfree(idx);\n \t} else {\n-\t\thashcpy(idx->oid.hash, result_sha1);\n+\t\toidcpy(&idx->oid, result_oid);\n \t\tALLOC_GROW(state->written,\n \t\t\t   state->nr_written + 1,\n \t\t\t   state->alloc_written);\n@@ -255,11 +255,11 @@ static int deflate_to_pack(struct bulk_checkin_state *state,\n \treturn 0;\n }\n \n-int index_bulk_checkin(unsigned char *sha1,\n+int index_bulk_checkin(struct object_id *oid,\n \t\t       int fd, size_t size, enum object_type type,\n \t\t       const char *path, unsigned flags)\n {\n-\tint status = deflate_to_pack(&state, sha1, fd, size, type,\n+\tint status = deflate_to_pack(&state, oid, fd, size, type,\n \t\t\t\t     path, flags);\n \tif (!state.plugged)\n \t\tfinish_bulk_checkin(&state);\ndiff --git a/bulk-checkin.h b/bulk-checkin.h\nindex fbd40fc98c..a85527318b 100644\n--- a/bulk-checkin.h\n+++ b/bulk-checkin.h\n@@ -4,7 +4,7 @@\n #ifndef BULK_CHECKIN_H\n #define BULK_CHECKIN_H\n \n-extern int index_bulk_checkin(unsigned char sha1[],\n+extern int index_bulk_checkin(struct object_id *oid,\n \t\t\t      int fd, size_t size, enum object_type type,\n \t\t\t      const char *path, unsigned flags);\n \ndiff --git a/sha1_file.c b/sha1_file.c\nindex 826d7a0ae3..c1d06c6109 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1892,7 +1892,7 @@ static int index_stream(struct object_id *oid, int fd, size_t size,\n \t\t\tenum object_type type, const char *path,\n \t\t\tunsigned flags)\n {\n-\treturn index_bulk_checkin(oid->hash, fd, size, type, path, flags);\n+\treturn index_bulk_checkin(oid, fd, size, type, path, flags);\n }\n \n int index_fd(struct object_id *oid, int fd, struct stat *st,\n"},{"id":"339651","messageId":"20180219225927.386065-3-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 02/36] builtin/write-tree: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:58:53Z","receivedAt":"2018-02-19T22:59:45Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is needed to convert parts of the cache-tree code.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/write-tree.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/write-tree.c b/builtin/write-tree.c\nindex bd0a78aa3c..299a121531 100644\n--- a/builtin/write-tree.c\n+++ b/builtin/write-tree.c\n@@ -19,7 +19,7 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)\n {\n \tint flags = 0, ret;\n \tconst char *prefix = NULL;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tconst char *me = \"git-write-tree\";\n \tstruct option write_tree_options[] = {\n \t\tOPT_BIT(0, \"missing-ok\", &flags, N_(\"allow missing objects\"),\n@@ -38,10 +38,10 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)\n \targc = parse_options(argc, argv, unused_prefix, write_tree_options,\n \t\t\t     write_tree_usage, 0);\n \n-\tret = write_cache_as_tree(sha1, flags, prefix);\n+\tret = write_cache_as_tree(oid.hash, flags, prefix);\n \tswitch (ret) {\n \tcase 0:\n-\t\tprintf(\"%s\\n\", sha1_to_hex(sha1));\n+\t\tprintf(\"%s\\n\", oid_to_hex(&oid));\n \t\tbreak;\n \tcase WRITE_TREE_UNREADABLE_INDEX:\n \t\tdie(\"%s: error reading the index\", me);\n"},{"id":"339652","messageId":"20180219225927.386065-4-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 03/36] cache-tree: convert write_*_as_tree to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:58:54Z","receivedAt":"2018-02-19T22:59:46Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert write_index_as_tree and write_cache_as_tree to use struct\nobject_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/am.c         |  8 ++++----\n builtin/merge.c      |  2 +-\n builtin/write-tree.c |  2 +-\n cache-tree.c         | 10 +++++-----\n cache-tree.h         |  4 ++--\n sequencer.c          |  4 ++--\n 6 files changed, 15 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 6661edc162..220c5deed8 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1546,7 +1546,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa\n \tdiscard_cache();\n \tread_cache_from(index_path);\n \n-\tif (write_index_as_tree(orig_tree.hash, &the_index, index_path, 0, NULL))\n+\tif (write_index_as_tree(&orig_tree, &the_index, index_path, 0, NULL))\n \t\treturn error(_(\"Repository lacks necessary blobs to fall back on 3-way merge.\"));\n \n \tsay(state, stdout, _(\"Using index info to reconstruct a base tree...\"));\n@@ -1571,7 +1571,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa\n \t\treturn error(_(\"Did you hand edit your patch?\\n\"\n \t\t\t\t\"It does not apply to blobs recorded in its index.\"));\n \n-\tif (write_index_as_tree(their_tree.hash, &the_index, index_path, 0, NULL))\n+\tif (write_index_as_tree(&their_tree, &the_index, index_path, 0, NULL))\n \t\treturn error(\"could not write tree\");\n \n \tsay(state, stdout, _(\"Falling back to patching base and 3-way merge...\"));\n@@ -1622,7 +1622,7 @@ static void do_commit(const struct am_state *state)\n \tif (run_hook_le(NULL, \"pre-applypatch\", NULL))\n \t\texit(1);\n \n-\tif (write_cache_as_tree(tree.hash, 0, NULL))\n+\tif (write_cache_as_tree(&tree, 0, NULL))\n \t\tdie(_(\"git write-tree failed to write a tree\"));\n \n \tif (!get_oid_commit(\"HEAD\", &parent)) {\n@@ -2001,7 +2001,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem\n \tif (fast_forward_to(head_tree, head_tree, 1))\n \t\treturn -1;\n \n-\tif (write_cache_as_tree(index.hash, 0, NULL))\n+\tif (write_cache_as_tree(&index, 0, NULL))\n \t\treturn -1;\n \n \tindex_tree = parse_tree_indirect(&index);\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 92ba99a1a5..861b170468 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -638,7 +638,7 @@ static int read_tree_trivial(struct object_id *common, struct object_id *head,\n \n static void write_tree_trivial(struct object_id *oid)\n {\n-\tif (write_cache_as_tree(oid->hash, 0, NULL))\n+\tif (write_cache_as_tree(oid, 0, NULL))\n \t\tdie(_(\"git write-tree failed to write a tree\"));\n }\n \ndiff --git a/builtin/write-tree.c b/builtin/write-tree.c\nindex 299a121531..c9d3c544e7 100644\n--- a/builtin/write-tree.c\n+++ b/builtin/write-tree.c\n@@ -38,7 +38,7 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)\n \targc = parse_options(argc, argv, unused_prefix, write_tree_options,\n \t\t\t     write_tree_usage, 0);\n \n-\tret = write_cache_as_tree(oid.hash, flags, prefix);\n+\tret = write_cache_as_tree(&oid, flags, prefix);\n \tswitch (ret) {\n \tcase 0:\n \t\tprintf(\"%s\\n\", oid_to_hex(&oid));\ndiff --git a/cache-tree.c b/cache-tree.c\nindex c52e4303df..ba07a8067e 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -599,7 +599,7 @@ static struct cache_tree *cache_tree_find(struct cache_tree *it, const char *pat\n \treturn it;\n }\n \n-int write_index_as_tree(unsigned char *sha1, struct index_state *index_state, const char *index_path, int flags, const char *prefix)\n+int write_index_as_tree(struct object_id *oid, struct index_state *index_state, const char *index_path, int flags, const char *prefix)\n {\n \tint entries, was_valid;\n \tstruct lock_file lock_file = LOCK_INIT;\n@@ -640,19 +640,19 @@ int write_index_as_tree(unsigned char *sha1, struct index_state *index_state, co\n \t\t\tret = WRITE_TREE_PREFIX_ERROR;\n \t\t\tgoto out;\n \t\t}\n-\t\thashcpy(sha1, subtree->oid.hash);\n+\t\toidcpy(oid, &subtree->oid);\n \t}\n \telse\n-\t\thashcpy(sha1, index_state->cache_tree->oid.hash);\n+\t\toidcpy(oid, &index_state->cache_tree->oid);\n \n out:\n \trollback_lock_file(&lock_file);\n \treturn ret;\n }\n \n-int write_cache_as_tree(unsigned char *sha1, int flags, const char *prefix)\n+int write_cache_as_tree(struct object_id *oid, int flags, const char *prefix)\n {\n-\treturn write_index_as_tree(sha1, &the_index, get_index_file(), flags, prefix);\n+\treturn write_index_as_tree(oid, &the_index, get_index_file(), flags, prefix);\n }\n \n static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)\ndiff --git a/cache-tree.h b/cache-tree.h\nindex f7b9cab7ee..cfd5328cc9 100644\n--- a/cache-tree.h\n+++ b/cache-tree.h\n@@ -47,8 +47,8 @@ int update_main_cache_tree(int);\n #define WRITE_TREE_UNMERGED_INDEX (-2)\n #define WRITE_TREE_PREFIX_ERROR (-3)\n \n-int write_index_as_tree(unsigned char *sha1, struct index_state *index_state, const char *index_path, int flags, const char *prefix);\n-int write_cache_as_tree(unsigned char *sha1, int flags, const char *prefix);\n+int write_index_as_tree(struct object_id *oid, struct index_state *index_state, const char *index_path, int flags, const char *prefix);\n+int write_cache_as_tree(struct object_id *oid, int flags, const char *prefix);\n void prime_cache_tree(struct index_state *, struct tree *);\n \n extern int cache_tree_matches_traversal(struct cache_tree *, struct name_entry *ent, struct traverse_info *info);\ndiff --git a/sequencer.c b/sequencer.c\nindex e9baaf59bd..d2fc1871ed 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1113,7 +1113,7 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \t\tcommit_list_insert(current_head, &parents);\n \t}\n \n-\tif (write_cache_as_tree(tree.hash, 0, NULL)) {\n+\tif (write_cache_as_tree(&tree, 0, NULL)) {\n \t\tres = error(_(\"git write-tree failed to write a tree\"));\n \t\tgoto out;\n \t}\n@@ -1475,7 +1475,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\t * that represents the \"current\" state for merge-recursive\n \t\t * to work on.\n \t\t */\n-\t\tif (write_cache_as_tree(head.hash, 0, NULL))\n+\t\tif (write_cache_as_tree(&head, 0, NULL))\n \t\t\treturn error(_(\"your index file is unmerged.\"));\n \t} else {\n \t\tunborn = get_oid(\"HEAD\", &head);\n"},{"id":"339653","messageId":"20180219225927.386065-8-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 07/36] ref-filter: convert grab_objectname to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:58:58Z","receivedAt":"2018-02-19T22:59:51Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is necessary in order to convert find_unique_abbrev.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n ref-filter.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex f9e25aea7a..9cbd92611c 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -737,18 +737,18 @@ static void *get_obj(const struct object_id *oid, struct object **obj, unsigned\n \treturn buf;\n }\n \n-static int grab_objectname(const char *name, const unsigned char *sha1,\n+static int grab_objectname(const char *name, const struct object_id *oid,\n \t\t\t   struct atom_value *v, struct used_atom *atom)\n {\n \tif (starts_with(name, \"objectname\")) {\n \t\tif (atom->u.objectname.option == O_SHORT) {\n-\t\t\tv->s = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV));\n+\t\t\tv->s = xstrdup(find_unique_abbrev(oid->hash, DEFAULT_ABBREV));\n \t\t\treturn 1;\n \t\t} else if (atom->u.objectname.option == O_FULL) {\n-\t\t\tv->s = xstrdup(sha1_to_hex(sha1));\n+\t\t\tv->s = xstrdup(oid_to_hex(oid));\n \t\t\treturn 1;\n \t\t} else if (atom->u.objectname.option == O_LENGTH) {\n-\t\t\tv->s = xstrdup(find_unique_abbrev(sha1, atom->u.objectname.length));\n+\t\t\tv->s = xstrdup(find_unique_abbrev(oid->hash, atom->u.objectname.length));\n \t\t\treturn 1;\n \t\t} else\n \t\t\tdie(\"BUG: unknown %%(objectname) option\");\n@@ -775,7 +775,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct object\n \t\t\tv->s = xstrfmt(\"%lu\", sz);\n \t\t}\n \t\telse if (deref)\n-\t\t\tgrab_objectname(name, obj->oid.hash, v, &used_atom[i]);\n+\t\t\tgrab_objectname(name, &obj->oid, v, &used_atom[i]);\n \t}\n }\n \n@@ -1439,7 +1439,7 @@ static void populate_value(struct ref_array_item *ref)\n \t\t\t\tv->s = xstrdup(buf + 1);\n \t\t\t}\n \t\t\tcontinue;\n-\t\t} else if (!deref && grab_objectname(name, ref->objectname.hash, v, atom)) {\n+\t\t} else if (!deref && grab_objectname(name, &ref->objectname, v, atom)) {\n \t\t\tcontinue;\n \t\t} else if (!strcmp(name, \"HEAD\")) {\n \t\t\tif (atom->u.head && !strcmp(ref->refname, atom->u.head))\n"},{"id":"339654","messageId":"20180219225927.386065-14-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 13/36] replace_object: convert struct replace_object to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:04Z","receivedAt":"2018-02-19T22:59:53Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the two members of this struct to be instances of struct\nobject_id.  Adjust the various functions in this file accordingly.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n replace_object.c | 14 +++++++-------\n 1 file changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/replace_object.c b/replace_object.c\nindex 3e49965d05..232e8b8550 100644\n--- a/replace_object.c\n+++ b/replace_object.c\n@@ -8,8 +8,8 @@\n  * sha1.\n  */\n static struct replace_object {\n-\tunsigned char original[20];\n-\tunsigned char replacement[20];\n+\tstruct object_id original;\n+\tstruct object_id replacement;\n } **replace_object;\n \n static int replace_object_alloc, replace_object_nr;\n@@ -17,7 +17,7 @@ static int replace_object_alloc, replace_object_nr;\n static const unsigned char *replace_sha1_access(size_t index, void *table)\n {\n \tstruct replace_object **replace = table;\n-\treturn replace[index]->original;\n+\treturn replace[index]->original.hash;\n }\n \n static int replace_object_pos(const unsigned char *sha1)\n@@ -29,7 +29,7 @@ static int replace_object_pos(const unsigned char *sha1)\n static int register_replace_object(struct replace_object *replace,\n \t\t\t\t   int ignore_dups)\n {\n-\tint pos = replace_object_pos(replace->original);\n+\tint pos = replace_object_pos(replace->original.hash);\n \n \tif (0 <= pos) {\n \t\tif (ignore_dups)\n@@ -59,14 +59,14 @@ static int register_replace_ref(const char *refname,\n \tconst char *hash = slash ? slash + 1 : refname;\n \tstruct replace_object *repl_obj = xmalloc(sizeof(*repl_obj));\n \n-\tif (strlen(hash) != 40 || get_sha1_hex(hash, repl_obj->original)) {\n+\tif (get_oid_hex(hash, &repl_obj->original)) {\n \t\tfree(repl_obj);\n \t\twarning(\"bad replace ref name: %s\", refname);\n \t\treturn 0;\n \t}\n \n \t/* Copy sha1 from the read ref */\n-\thashcpy(repl_obj->replacement, oid->hash);\n+\toidcpy(&repl_obj->replacement, oid);\n \n \t/* Register new object */\n \tif (register_replace_object(repl_obj, 1))\n@@ -113,7 +113,7 @@ const unsigned char *do_lookup_replace_object(const unsigned char *sha1)\n \n \t\tpos = replace_object_pos(cur);\n \t\tif (0 <= pos)\n-\t\t\tcur = replace_object[pos]->replacement;\n+\t\t\tcur = replace_object[pos]->replacement.hash;\n \t} while (0 <= pos);\n \n \treturn cur;\n"},{"id":"339655","messageId":"20180219225927.386065-15-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 14/36] builtin/mktag: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:05Z","receivedAt":"2018-02-19T22:59:56Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/mktag.c | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex beb552847b..65bb41e3cd 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -18,13 +18,13 @@\n /*\n  * We refuse to tag something we can't verify. Just because.\n  */\n-static int verify_object(const unsigned char *sha1, const char *expected_type)\n+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-\tvoid *buffer = read_sha1_file(sha1, &type, &size);\n-\tconst unsigned char *repl = lookup_replace_object(sha1);\n+\tvoid *buffer = read_sha1_file(oid->hash, &type, &size);\n+\tconst unsigned char *repl = lookup_replace_object(oid->hash);\n \n \tif (buffer) {\n \t\tif (type == type_from_string(expected_type))\n@@ -38,8 +38,8 @@ static int verify_tag(char *buffer, unsigned long size)\n {\n \tint typelen;\n \tchar type[20];\n-\tunsigned char sha1[20];\n-\tconst char *object, *type_line, *tag_line, *tagger_line, *lb, *rb;\n+\tstruct object_id oid;\n+\tconst char *object, *type_line, *tag_line, *tagger_line, *lb, *rb, *p;\n \tsize_t len;\n \n \tif (size < 84)\n@@ -52,11 +52,11 @@ static int verify_tag(char *buffer, unsigned long size)\n \tif (memcmp(object, \"object \", 7))\n \t\treturn error(\"char%d: does not start with \\\"object \\\"\", 0);\n \n-\tif (get_sha1_hex(object + 7, sha1))\n+\tif (parse_oid_hex(object + 7, &oid, &p))\n \t\treturn error(\"char%d: could not get SHA1 hash\", 7);\n \n \t/* Verify type line */\n-\ttype_line = object + 48;\n+\ttype_line = p + 1;\n \tif (memcmp(type_line - 1, \"\\ntype \", 6))\n \t\treturn error(\"char%d: could not find \\\"\\\\ntype \\\"\", 47);\n \n@@ -80,8 +80,8 @@ static int verify_tag(char *buffer, unsigned long size)\n \ttype[typelen] = 0;\n \n \t/* Verify that the object matches */\n-\tif (verify_object(sha1, type))\n-\t\treturn error(\"char%d: could not verify object %s\", 7, sha1_to_hex(sha1));\n+\tif (verify_object(&oid, type))\n+\t\treturn error(\"char%d: could not verify object %s\", 7, oid_to_hex(&oid));\n \n \t/* Verify the tag-name: we don't allow control characters or spaces in it */\n \ttag_line += 4;\n"},{"id":"339656","messageId":"20180219225927.386065-19-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 18/36] sha1_file: convert read_loose_object to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:09Z","receivedAt":"2018-02-19T22:59:59Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/fsck.c |  2 +-\n cache.h        |  4 ++--\n sha1_file.c    | 10 +++++-----\n 3 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 9981db2263..57509a4eac 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -513,7 +513,7 @@ static struct object *parse_loose_object(const struct object_id *oid,\n \tunsigned long size;\n \tint eaten;\n \n-\tif (read_loose_object(path, oid->hash, &type, &size, &contents) < 0)\n+\tif (read_loose_object(path, oid, &type, &size, &contents) < 0)\n \t\treturn NULL;\n \n \tif (!contents && type != OBJ_BLOB)\ndiff --git a/cache.h b/cache.h\nindex 09cd994bcc..8a9055f4e7 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1241,14 +1241,14 @@ extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned l\n extern int finalize_object_file(const char *tmpfile, const char *filename);\n \n /*\n- * Open the loose object at path, check its sha1, and return the contents,\n+ * Open the loose object at path, check its hash, and return the contents,\n  * type, and size. If the object is a blob, then \"contents\" may return NULL,\n  * to allow streaming of large blobs.\n  *\n  * Returns 0 on success, negative on error (details may be written to stderr).\n  */\n int read_loose_object(const char *path,\n-\t\t      const unsigned char *expected_sha1,\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      void **contents);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex c1d06c6109..69e8d27773 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -2176,7 +2176,7 @@ static int check_stream_sha1(git_zstream *stream,\n }\n \n int read_loose_object(const char *path,\n-\t\t      const unsigned char *expected_sha1,\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      void **contents)\n@@ -2208,19 +2208,19 @@ int read_loose_object(const char *path,\n \t}\n \n \tif (*type == OBJ_BLOB) {\n-\t\tif (check_stream_sha1(&stream, hdr, *size, path, expected_sha1) < 0)\n+\t\tif (check_stream_sha1(&stream, hdr, *size, path, expected_oid->hash) < 0)\n \t\t\tgoto out;\n \t} else {\n-\t\t*contents = unpack_sha1_rest(&stream, hdr, *size, expected_sha1);\n+\t\t*contents = unpack_sha1_rest(&stream, hdr, *size, expected_oid->hash);\n \t\tif (!*contents) {\n \t\t\terror(\"unable to unpack contents of %s\", path);\n \t\t\tgit_inflate_end(&stream);\n \t\t\tgoto out;\n \t\t}\n-\t\tif (check_sha1_signature(expected_sha1, *contents,\n+\t\tif (check_sha1_signature(expected_oid->hash, *contents,\n \t\t\t\t\t *size, typename(*type))) {\n \t\t\terror(\"sha1 mismatch for %s (expected %s)\", path,\n-\t\t\t      sha1_to_hex(expected_sha1));\n+\t\t\t      oid_to_hex(expected_oid));\n \t\t\tfree(*contents);\n \t\t\tgoto out;\n \t\t}\n"},{"id":"339657","messageId":"20180219225927.386065-21-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 20/36] streaming: convert open_istream to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:11Z","receivedAt":"2018-02-19T23:00:01Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n archive-tar.c          | 2 +-\n archive-zip.c          | 2 +-\n builtin/index-pack.c   | 2 +-\n builtin/pack-objects.c | 2 +-\n sha1_file.c            | 2 +-\n streaming.c            | 6 +++---\n streaming.h            | 2 +-\n 7 files changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex fd622eacc0..7a0d31d847 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -119,7 +119,7 @@ static int stream_blocked(const struct object_id *oid)\n \tchar buf[BLOCKSIZE];\n \tssize_t readlen;\n \n-\tst = open_istream(oid->hash, &type, &sz, NULL);\n+\tst = open_istream(oid, &type, &sz, NULL);\n \tif (!st)\n \t\treturn error(\"cannot stream blob %s\", oid_to_hex(oid));\n \tfor (;;) {\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 5841a6ceb6..18b951b732 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -337,7 +337,7 @@ static int write_zip_entry(struct archiver_args *args,\n \n \t\tif (S_ISREG(mode) && type == OBJ_BLOB && !args->convert &&\n \t\t    size > big_file_threshold) {\n-\t\t\tstream = open_istream(oid->hash, &type, &size, NULL);\n+\t\t\tstream = open_istream(oid, &type, &size, NULL);\n \t\t\tif (!stream)\n \t\t\t\treturn error(\"cannot stream blob %s\",\n \t\t\t\t\t     oid_to_hex(oid));\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex e0a776f1ac..a0ca525e99 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -771,7 +771,7 @@ static int check_collison(struct object_entry *entry)\n \n \tmemset(&data, 0, sizeof(data));\n \tdata.entry = entry;\n-\tdata.st = open_istream(entry->idx.oid.hash, &type, &size, NULL);\n+\tdata.st = open_istream(&entry->idx.oid, &type, &size, NULL);\n \tif (!data.st)\n \t\treturn -1;\n \tif (size != entry->size || type != entry->type)\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 5c674b2843..ef63aa5878 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -267,7 +267,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent\n \tif (!usable_delta) {\n \t\tif (entry->type == OBJ_BLOB &&\n \t\t    entry->size > big_file_threshold &&\n-\t\t    (st = open_istream(entry->idx.oid.hash, &type, &size, NULL)) != NULL)\n+\t\t    (st = open_istream(&entry->idx.oid, &type, &size, NULL)) != NULL)\n \t\t\tbuf = NULL;\n \t\telse {\n \t\t\tbuf = read_sha1_file(entry->idx.oid.hash, &type,\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 64f0905799..5dc85122c3 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -799,7 +799,7 @@ int check_object_signature(const struct object_id *oid, void *map,\n \t\treturn oidcmp(oid, &real_oid) ? -1 : 0;\n \t}\n \n-\tst = open_istream(oid->hash, &obj_type, &size, NULL);\n+\tst = open_istream(oid, &obj_type, &size, NULL);\n \tif (!st)\n \t\treturn -1;\n \ndiff --git a/streaming.c b/streaming.c\nindex 5892b50bd8..be85507922 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -130,14 +130,14 @@ static enum input_source istream_source(const unsigned char *sha1,\n \t}\n }\n \n-struct git_istream *open_istream(const unsigned char *sha1,\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 struct stream_filter *filter)\n {\n \tstruct git_istream *st;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n-\tconst unsigned char *real = lookup_replace_object(sha1);\n+\tconst unsigned char *real = lookup_replace_object(oid->hash);\n \tenum input_source src = istream_source(real, type, &oi);\n \n \tif (src < 0)\n@@ -507,7 +507,7 @@ int stream_blob_to_fd(int fd, const struct object_id *oid, struct stream_filter\n \tssize_t kept = 0;\n \tint result = -1;\n \n-\tst = open_istream(oid->hash, &type, &sz, filter);\n+\tst = open_istream(oid, &type, &sz, filter);\n \tif (!st) {\n \t\tif (filter)\n \t\t\tfree_stream_filter(filter);\ndiff --git a/streaming.h b/streaming.h\nindex 73c1d156b3..32f4626771 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 struct object_id *, enum object_type *, unsigned long *, struct stream_filter *);\n extern int close_istream(struct git_istream *);\n extern ssize_t read_istream(struct git_istream *, void *, size_t);\n \n"},{"id":"339658","messageId":"20180219225927.386065-22-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 21/36] builtin/mktree: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:12Z","receivedAt":"2018-02-19T23:00:04Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert this file to use struct object_id.  Modify one use of\nget_sha1_hex into parse_oid_hex; this is safe since we get the data from\na strbuf.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/mktree.c | 24 ++++++++++++------------\n 1 file changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 8dd9f52f77..d6ca19d835 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -10,13 +10,13 @@\n \n static struct treeent {\n \tunsigned mode;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tint len;\n \tchar name[FLEX_ARRAY];\n } **entries;\n static int alloc, used;\n \n-static void append_to_tree(unsigned mode, unsigned char *sha1, char *path)\n+static void append_to_tree(unsigned mode, struct object_id *oid, char *path)\n {\n \tstruct treeent *ent;\n \tsize_t len = strlen(path);\n@@ -26,7 +26,7 @@ static void append_to_tree(unsigned mode, unsigned char *sha1, char *path)\n \tFLEX_ALLOC_MEM(ent, name, path, len);\n \tent->mode = mode;\n \tent->len = len;\n-\thashcpy(ent->sha1, sha1);\n+\toidcpy(&ent->oid, oid);\n \n \tALLOC_GROW(entries, used + 1, alloc);\n \tentries[used++] = ent;\n@@ -54,7 +54,7 @@ static void write_tree(struct object_id *oid)\n \tfor (i = 0; i < used; i++) {\n \t\tstruct treeent *ent = entries[i];\n \t\tstrbuf_addf(&buf, \"%o %s%c\", ent->mode, ent->name, '\\0');\n-\t\tstrbuf_add(&buf, ent->sha1, 20);\n+\t\tstrbuf_add(&buf, ent->oid.hash, the_hash_algo->rawsz);\n \t}\n \n \twrite_object_file(buf.buf, buf.len, tree_type, oid);\n@@ -69,11 +69,12 @@ static const char *mktree_usage[] = {\n static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_missing)\n {\n \tchar *ptr, *ntr;\n+\tconst char *p;\n \tunsigned mode;\n \tenum object_type mode_type; /* object type derived from mode */\n \tenum object_type obj_type; /* object type derived from sha */\n \tchar *path, *to_free = NULL;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \n \tptr = buf;\n \t/*\n@@ -85,9 +86,8 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss\n \t\tdie(\"input format error: %s\", buf);\n \tptr = ntr + 1; /* type */\n \tntr = strchr(ptr, ' ');\n-\tif (!ntr || buf + len <= ntr + 40 ||\n-\t    ntr[41] != '\\t' ||\n-\t    get_sha1_hex(ntr + 1, sha1))\n+\tif (!ntr || parse_oid_hex(ntr + 1, &oid, &p) ||\n+\t    *p != '\\t')\n \t\tdie(\"input format error: %s\", buf);\n \n \t/* It is perfectly normal if we do not have a commit from a submodule */\n@@ -116,12 +116,12 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss\n \t}\n \n \t/* Check the type of object identified by sha1 */\n-\tobj_type = sha1_object_info(sha1, NULL);\n+\tobj_type = sha1_object_info(oid.hash, NULL);\n \tif (obj_type < 0) {\n \t\tif (allow_missing) {\n \t\t\t; /* no problem - missing objects are presumed to be of the right type */\n \t\t} else {\n-\t\t\tdie(\"entry '%s' object %s is unavailable\", path, sha1_to_hex(sha1));\n+\t\t\tdie(\"entry '%s' object %s is unavailable\", path, oid_to_hex(&oid));\n \t\t}\n \t} else {\n \t\tif (obj_type != mode_type) {\n@@ -131,11 +131,11 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss\n \t\t\t * because the new tree entry will never be correct.\n \t\t\t */\n \t\t\tdie(\"entry '%s' object %s is a %s but specified type was (%s)\",\n-\t\t\t\tpath, sha1_to_hex(sha1), typename(obj_type), typename(mode_type));\n+\t\t\t\tpath, oid_to_hex(&oid), typename(obj_type), typename(mode_type));\n \t\t}\n \t}\n \n-\tappend_to_tree(mode, sha1, path);\n+\tappend_to_tree(mode, &oid, path);\n \tfree(to_free);\n }\n \n"},{"id":"339659","messageId":"20180219225927.386065-25-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 24/36] packfile: convert unpack_entry to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:15Z","receivedAt":"2018-02-19T23:00:07Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert unpack_entry and read_object to use struct object_id.\n---\n packfile.c | 22 +++++++++++-----------\n 1 file changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/packfile.c b/packfile.c\nindex bfa6438b4e..ed7b342ebf 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1452,7 +1452,7 @@ struct unpack_entry_stack_ent {\n \tunsigned long size;\n };\n \n-static void *read_object(const unsigned char *sha1, enum object_type *type,\n+static void *read_object(const struct object_id *oid, enum object_type *type,\n \t\t\t unsigned long *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n@@ -1461,7 +1461,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,\n \toi.sizep = size;\n \toi.contentp = &content;\n \n-\tif (sha1_object_info_extended(sha1, &oi, 0) < 0)\n+\tif (sha1_object_info_extended(oid->hash, &oi, 0) < 0)\n \t\treturn NULL;\n \treturn content;\n }\n@@ -1501,11 +1501,11 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,\n \t\t\tstruct revindex_entry *revidx = find_pack_revindex(p, obj_offset);\n \t\t\toff_t len = revidx[1].offset - obj_offset;\n \t\t\tif (check_pack_crc(p, &w_curs, obj_offset, len, revidx->nr)) {\n-\t\t\t\tconst unsigned char *sha1 =\n-\t\t\t\t\tnth_packed_object_sha1(p, revidx->nr);\n+\t\t\t\tstruct object_id oid;\n+\t\t\t\tnth_packed_object_oid(&oid, p, revidx->nr);\n \t\t\t\terror(\"bad packed object CRC for %s\",\n-\t\t\t\t      sha1_to_hex(sha1));\n-\t\t\t\tmark_bad_packed_object(p, sha1);\n+\t\t\t\t      oid_to_hex(&oid));\n+\t\t\t\tmark_bad_packed_object(p, oid.hash);\n \t\t\t\tdata = NULL;\n \t\t\t\tgoto out;\n \t\t\t}\n@@ -1588,16 +1588,16 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,\n \t\t\t * of a corrupted pack, and is better than failing outright.\n \t\t\t */\n \t\t\tstruct revindex_entry *revidx;\n-\t\t\tconst unsigned char *base_sha1;\n+\t\t\tstruct object_id base_oid;\n \t\t\trevidx = find_pack_revindex(p, obj_offset);\n \t\t\tif (revidx) {\n-\t\t\t\tbase_sha1 = nth_packed_object_sha1(p, revidx->nr);\n+\t\t\t\tnth_packed_object_oid(&base_oid, p, revidx->nr);\n \t\t\t\terror(\"failed to read delta base object %s\"\n \t\t\t\t      \" at offset %\"PRIuMAX\" from %s\",\n-\t\t\t\t      sha1_to_hex(base_sha1), (uintmax_t)obj_offset,\n+\t\t\t\t      oid_to_hex(&base_oid), (uintmax_t)obj_offset,\n \t\t\t\t      p->pack_name);\n-\t\t\t\tmark_bad_packed_object(p, base_sha1);\n-\t\t\t\tbase = read_object(base_sha1, &type, &base_size);\n+\t\t\t\tmark_bad_packed_object(p, base_oid.hash);\n+\t\t\t\tbase = read_object(&base_oid, &type, &base_size);\n \t\t\t\texternal_base = base;\n \t\t\t}\n \t\t}\n"},{"id":"339660","messageId":"20180219225927.386065-23-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 22/36] sha1_file: convert assert_sha1_type to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:13Z","receivedAt":"2018-02-19T23:00:08Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert this function to take a pointer to struct object_id and rename\nit to assert_oid_type.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/commit-tree.c | 2 +-\n cache.h               | 2 +-\n commit.c              | 2 +-\n sha1_file.c           | 8 ++++----\n 4 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex e5bdf57b1e..ecf42191da 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -58,7 +58,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)\n \t\t\t\tusage(commit_tree_usage);\n \t\t\tif (get_oid_commit(argv[i], &oid))\n \t\t\t\tdie(\"Not a valid object name %s\", argv[i]);\n-\t\t\tassert_sha1_type(oid.hash, OBJ_COMMIT);\n+\t\t\tassert_oid_type(&oid, OBJ_COMMIT);\n \t\t\tnew_parent(lookup_commit(&oid), &parents);\n \t\t\tcontinue;\n \t\t}\ndiff --git a/cache.h b/cache.h\nindex f29ff43bbd..b1a117e404 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1275,7 +1275,7 @@ extern int has_object_file_with_flags(const struct object_id *oid, int flags);\n  */\n extern int has_loose_object_nonlocal(const unsigned char *sha1);\n \n-extern void assert_sha1_type(const unsigned char *sha1, enum object_type expect);\n+extern void assert_oid_type(const struct object_id *oid, enum object_type expect);\n \n /* Helper to check and \"touch\" a file */\n extern int check_and_freshen_file(const char *fn, int freshen);\ndiff --git a/commit.c b/commit.c\nindex e8a49b9c84..b9f028976f 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1517,7 +1517,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,\n \tint encoding_is_utf8;\n \tstruct strbuf buffer;\n \n-\tassert_sha1_type(tree->hash, OBJ_TREE);\n+\tassert_oid_type(tree, OBJ_TREE);\n \n \tif (memchr(msg, '\\0', msg_len))\n \t\treturn error(\"a NUL byte in commit log message not allowed.\");\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 5dc85122c3..fa69d86309 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1966,13 +1966,13 @@ int read_pack_header(int fd, struct pack_header *header)\n \treturn 0;\n }\n \n-void assert_sha1_type(const unsigned char *sha1, enum object_type expect)\n+void assert_oid_type(const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = sha1_object_info(sha1, NULL);\n+\tenum object_type type = sha1_object_info(oid->hash, NULL);\n \tif (type < 0)\n-\t\tdie(\"%s is not a valid object\", sha1_to_hex(sha1));\n+\t\tdie(\"%s is not a valid object\", oid_to_hex(oid));\n \tif (type != expect)\n-\t\tdie(\"%s is not a valid '%s' object\", sha1_to_hex(sha1),\n+\t\tdie(\"%s is not a valid '%s' object\", oid_to_hex(oid),\n \t\t    typename(expect));\n }\n \n"},{"id":"339661","messageId":"20180219225927.386065-30-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 29/36] tree-walk: convert get_tree_entry_follow_symlinks internals to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:20Z","receivedAt":"2018-02-19T23:00:12Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the internals of this function to use struct object_id.  This is\none of the last remaining callers of read_sha1_file_extended that has\nnot been converted yet.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n tree-walk.c | 22 +++++++++++-----------\n 1 file changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 63a87ed666..521defdaa2 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -583,14 +583,14 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s\n \tstruct dir_state *parents = NULL;\n \tsize_t parents_alloc = 0;\n \tsize_t i, parents_nr = 0;\n-\tunsigned char current_tree_sha1[20];\n+\tstruct object_id current_tree_oid;\n \tstruct strbuf namebuf = STRBUF_INIT;\n \tstruct tree_desc t;\n \tint follows_remaining = GET_TREE_ENTRY_FOLLOW_SYMLINKS_MAX_LINKS;\n \n \tinit_tree_desc(&t, NULL, 0UL);\n \tstrbuf_addstr(&namebuf, name);\n-\thashcpy(current_tree_sha1, tree_sha1);\n+\thashcpy(current_tree_oid.hash, tree_sha1);\n \n \twhile (1) {\n \t\tint find_result;\n@@ -599,22 +599,22 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s\n \n \t\tif (!t.buffer) {\n \t\t\tvoid *tree;\n-\t\t\tunsigned char root[20];\n+\t\t\tstruct object_id root;\n \t\t\tunsigned long size;\n-\t\t\ttree = read_object_with_reference(current_tree_sha1,\n+\t\t\ttree = read_object_with_reference(current_tree_oid.hash,\n \t\t\t\t\t\t\t  tree_type, &size,\n-\t\t\t\t\t\t\t  root);\n+\t\t\t\t\t\t\t  root.hash);\n \t\t\tif (!tree)\n \t\t\t\tgoto done;\n \n \t\t\tALLOC_GROW(parents, parents_nr + 1, parents_alloc);\n \t\t\tparents[parents_nr].tree = tree;\n \t\t\tparents[parents_nr].size = size;\n-\t\t\thashcpy(parents[parents_nr].sha1, root);\n+\t\t\thashcpy(parents[parents_nr].sha1, root.hash);\n \t\t\tparents_nr++;\n \n \t\t\tif (namebuf.buf[0] == '\\0') {\n-\t\t\t\thashcpy(result, root);\n+\t\t\t\thashcpy(result, root.hash);\n \t\t\t\tretval = FOUND;\n \t\t\t\tgoto done;\n \t\t\t}\n@@ -671,14 +671,14 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s\n \n \t\t/* Look up the first (or only) path component in the tree. */\n \t\tfind_result = find_tree_entry(&t, namebuf.buf,\n-\t\t\t\t\t      current_tree_sha1, mode);\n+\t\t\t\t\t      current_tree_oid.hash, mode);\n \t\tif (find_result) {\n \t\t\tgoto done;\n \t\t}\n \n \t\tif (S_ISDIR(*mode)) {\n \t\t\tif (!remainder) {\n-\t\t\t\thashcpy(result, current_tree_sha1);\n+\t\t\t\thashcpy(result, current_tree_oid.hash);\n \t\t\t\tretval = FOUND;\n \t\t\t\tgoto done;\n \t\t\t}\n@@ -688,7 +688,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s\n \t\t\t\t      1 + first_slash - namebuf.buf);\n \t\t} else if (S_ISREG(*mode)) {\n \t\t\tif (!remainder) {\n-\t\t\t\thashcpy(result, current_tree_sha1);\n+\t\t\t\thashcpy(result, current_tree_oid.hash);\n \t\t\t\tretval = FOUND;\n \t\t\t} else {\n \t\t\t\tretval = NOT_DIR;\n@@ -714,7 +714,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s\n \t\t\t */\n \t\t\tretval = DANGLING_SYMLINK;\n \n-\t\t\tcontents = read_sha1_file(current_tree_sha1, &type,\n+\t\t\tcontents = read_sha1_file(current_tree_oid.hash, &type,\n \t\t\t\t\t\t  &link_len);\n \n \t\t\tif (!contents)\n"},{"id":"339662","messageId":"20180219225927.386065-32-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 31/36] tree-walk: convert tree entry functions to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:22Z","receivedAt":"2018-02-19T23:00:14Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert get_tree_entry and find_tree_entry to take pointers to struct\nobject_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n archive.c              |  4 ++--\n blame.c                |  6 ++----\n builtin/rm.c           |  2 +-\n builtin/update-index.c |  2 +-\n line-log.c             |  3 +--\n match-trees.c          |  6 +++---\n merge-recursive.c      | 12 ++++++------\n notes.c                |  2 +-\n sha1_name.c            |  7 +++----\n tree-walk.c            | 20 ++++++++++----------\n tree-walk.h            |  2 +-\n 11 files changed, 31 insertions(+), 35 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex da62b2f541..1ab62d426e 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -397,8 +397,8 @@ static void parse_treeish_arg(const char **argv,\n \t\tunsigned int mode;\n \t\tint err;\n \n-\t\terr = get_tree_entry(tree->object.oid.hash, prefix,\n-\t\t\t\t     tree_oid.hash, &mode);\n+\t\terr = get_tree_entry(&tree->object.oid, prefix, &tree_oid,\n+\t\t\t\t     &mode);\n \t\tif (err || !S_ISDIR(mode))\n \t\t\tdie(\"current working directory is untracked\");\n \ndiff --git a/blame.c b/blame.c\nindex c1df10cdd2..3f9bd29615 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -80,7 +80,7 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)\n \t\tstruct object_id blob_oid;\n \t\tunsigned mode;\n \n-\t\tif (!get_tree_entry(commit_oid->hash, path, blob_oid.hash, &mode) &&\n+\t\tif (!get_tree_entry(commit_oid, path, &blob_oid, &mode) &&\n \t\t    oid_object_info(&blob_oid, NULL) == OBJ_BLOB)\n \t\t\treturn;\n \t}\n@@ -502,9 +502,7 @@ static int fill_blob_sha1_and_mode(struct blame_origin *origin)\n {\n \tif (!is_null_oid(&origin->blob_oid))\n \t\treturn 0;\n-\tif (get_tree_entry(origin->commit->object.oid.hash,\n-\t\t\t   origin->path,\n-\t\t\t   origin->blob_oid.hash, &origin->mode))\n+\tif (get_tree_entry(&origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))\n \t\tgoto error_out;\n \tif (oid_object_info(&origin->blob_oid, NULL) != OBJ_BLOB)\n \t\tgoto error_out;\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 4a2fcca27b..974a7ef5bf 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -178,7 +178,7 @@ static int check_local_mod(struct object_id *head, int index_only)\n \t\t * way as changed from the HEAD.\n \t\t */\n \t\tif (no_head\n-\t\t     || get_tree_entry(head->hash, name, oid.hash, &mode)\n+\t\t     || get_tree_entry(head, name, &oid, &mode)\n \t\t     || ce->ce_mode != create_ce_mode(mode)\n \t\t     || oidcmp(&ce->oid, &oid))\n \t\t\tstaged_changes = 1;\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 58d1c2d282..9625d1e10a 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -592,7 +592,7 @@ static struct cache_entry *read_one_ent(const char *which,\n \tint size;\n \tstruct cache_entry *ce;\n \n-\tif (get_tree_entry(ent->hash, path, oid.hash, &mode)) {\n+\tif (get_tree_entry(ent, path, &oid, &mode)) {\n \t\tif (which)\n \t\t\terror(\"%s: not in %s branch.\", path, which);\n \t\treturn NULL;\ndiff --git a/line-log.c b/line-log.c\nindex 545ad0f28b..700121eb92 100644\n--- a/line-log.c\n+++ b/line-log.c\n@@ -501,8 +501,7 @@ static void fill_blob_sha1(struct commit *commit, struct diff_filespec *spec)\n \tunsigned mode;\n \tstruct object_id oid;\n \n-\tif (get_tree_entry(commit->object.oid.hash, spec->path,\n-\t\t\t   oid.hash, &mode))\n+\tif (get_tree_entry(&commit->object.oid, spec->path, &oid, &mode))\n \t\tdie(\"There is no path %s in the commit\", spec->path);\n \tfill_filespec(spec, &oid, 1, mode);\n \ndiff --git a/match-trees.c b/match-trees.c\nindex 0ca99d5162..10d6c39d47 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -269,7 +269,7 @@ void shift_tree(const struct object_id *hash1,\n \t\tif (!*del_prefix)\n \t\t\treturn;\n \n-\t\tif (get_tree_entry(hash2->hash, del_prefix, shifted->hash, &mode))\n+\t\tif (get_tree_entry(hash2, del_prefix, shifted, &mode))\n \t\t\tdie(\"cannot find path %s in tree %s\",\n \t\t\t    del_prefix, oid_to_hex(hash2));\n \t\treturn;\n@@ -296,12 +296,12 @@ void shift_tree_by(const struct object_id *hash1,\n \tunsigned candidate = 0;\n \n \t/* Can hash2 be a tree at shift_prefix in tree hash1? */\n-\tif (!get_tree_entry(hash1->hash, shift_prefix, sub1.hash, &mode1) &&\n+\tif (!get_tree_entry(hash1, shift_prefix, &sub1, &mode1) &&\n \t    S_ISDIR(mode1))\n \t\tcandidate |= 1;\n \n \t/* Can hash1 be a tree at shift_prefix in tree hash2? */\n-\tif (!get_tree_entry(hash2->hash, shift_prefix, sub2.hash, &mode2) &&\n+\tif (!get_tree_entry(hash2, shift_prefix, &sub2, &mode2) &&\n \t    S_ISDIR(mode2))\n \t\tcandidate |= 2;\n \ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex f58f13957e..85f8cbee99 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -370,12 +370,12 @@ static struct stage_data *insert_stage_data(const char *path,\n {\n \tstruct string_list_item *item;\n \tstruct stage_data *e = xcalloc(1, sizeof(struct stage_data));\n-\tget_tree_entry(o->object.oid.hash, path,\n-\t\t\te->stages[1].oid.hash, &e->stages[1].mode);\n-\tget_tree_entry(a->object.oid.hash, path,\n-\t\t\te->stages[2].oid.hash, &e->stages[2].mode);\n-\tget_tree_entry(b->object.oid.hash, path,\n-\t\t\te->stages[3].oid.hash, &e->stages[3].mode);\n+\tget_tree_entry(&o->object.oid, path,\n+\t\t\t&e->stages[1].oid, &e->stages[1].mode);\n+\tget_tree_entry(&a->object.oid, path,\n+\t\t\t&e->stages[2].oid, &e->stages[2].mode);\n+\tget_tree_entry(&b->object.oid, path,\n+\t\t\t&e->stages[3].oid, &e->stages[3].mode);\n \titem = string_list_insert(entries, path);\n \titem->util = e;\n \treturn e;\ndiff --git a/notes.c b/notes.c\nindex ce9a8f53f8..d25121a65d 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -1012,7 +1012,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,\n \t\treturn;\n \tif (flags & NOTES_INIT_WRITABLE && read_ref(notes_ref, &object_oid))\n \t\tdie(\"Cannot use notes ref %s\", notes_ref);\n-\tif (get_tree_entry(object_oid.hash, \"\", oid.hash, &mode))\n+\tif (get_tree_entry(&object_oid, \"\", &oid, &mode))\n \t\tdie(\"Failed to read notes tree referenced by %s (%s)\",\n \t\t    notes_ref, oid_to_hex(&object_oid));\n \ndiff --git a/sha1_name.c b/sha1_name.c\nindex 6d4c6033c8..8b0012c253 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -1529,8 +1529,7 @@ static void diagnose_invalid_oid_path(const char *prefix,\n \tif (is_missing_file_error(errno)) {\n \t\tchar *fullname = xstrfmt(\"%s%s\", prefix, filename);\n \n-\t\tif (!get_tree_entry(tree_oid->hash, fullname,\n-\t\t\t\t    oid.hash, &mode)) {\n+\t\tif (!get_tree_entry(tree_oid, fullname, &oid, &mode)) {\n \t\t\tdie(\"Path '%s' exists, but not '%s'.\\n\"\n \t\t\t    \"Did you mean '%.*s:%s' aka '%.*s:./%s'?\",\n \t\t\t    fullname,\n@@ -1722,8 +1721,8 @@ static int get_oid_with_context_1(const char *name,\n \t\t\t\t\tfilename, oid->hash, &oc->symlink_path,\n \t\t\t\t\t&oc->mode);\n \t\t\t} else {\n-\t\t\t\tret = get_tree_entry(tree_oid.hash, filename,\n-\t\t\t\t\t\t     oid->hash, &oc->mode);\n+\t\t\t\tret = get_tree_entry(&tree_oid, filename, oid,\n+\t\t\t\t\t\t     &oc->mode);\n \t\t\t\tif (ret && only_to_die) {\n \t\t\t\t\tdiagnose_invalid_oid_path(prefix,\n \t\t\t\t\t\t\t\t   filename,\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 521defdaa2..a60837c491 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -492,7 +492,7 @@ struct dir_state {\n \tunsigned char sha1[20];\n };\n \n-static int find_tree_entry(struct tree_desc *t, const char *name, unsigned char *result, unsigned *mode)\n+static int find_tree_entry(struct tree_desc *t, const char *name, struct object_id *result, unsigned *mode)\n {\n \tint namelen = strlen(name);\n \twhile (t->size) {\n@@ -511,7 +511,7 @@ static int find_tree_entry(struct tree_desc *t, const char *name, unsigned char\n \t\tif (cmp < 0)\n \t\t\tbreak;\n \t\tif (entrylen == namelen) {\n-\t\t\thashcpy(result, oid->hash);\n+\t\t\toidcpy(result, oid);\n \t\t\treturn 0;\n \t\t}\n \t\tif (name[entrylen] != '/')\n@@ -519,27 +519,27 @@ static int find_tree_entry(struct tree_desc *t, const char *name, unsigned char\n \t\tif (!S_ISDIR(*mode))\n \t\t\tbreak;\n \t\tif (++entrylen == namelen) {\n-\t\t\thashcpy(result, oid->hash);\n+\t\t\toidcpy(result, oid);\n \t\t\treturn 0;\n \t\t}\n-\t\treturn get_tree_entry(oid->hash, name + entrylen, result, mode);\n+\t\treturn get_tree_entry(oid, name + entrylen, result, mode);\n \t}\n \treturn -1;\n }\n \n-int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned char *sha1, unsigned *mode)\n+int get_tree_entry(const struct object_id *tree_oid, const char *name, struct object_id *oid, unsigned *mode)\n {\n \tint retval;\n \tvoid *tree;\n \tunsigned long size;\n-\tunsigned char root[20];\n+\tstruct object_id root;\n \n-\ttree = read_object_with_reference(tree_sha1, tree_type, &size, root);\n+\ttree = read_object_with_reference(tree_oid->hash, tree_type, &size, root.hash);\n \tif (!tree)\n \t\treturn -1;\n \n \tif (name[0] == '\\0') {\n-\t\thashcpy(sha1, root);\n+\t\toidcpy(oid, &root);\n \t\tfree(tree);\n \t\treturn 0;\n \t}\n@@ -549,7 +549,7 @@ int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned ch\n \t} else {\n \t\tstruct tree_desc t;\n \t\tinit_tree_desc(&t, tree, size);\n-\t\tretval = find_tree_entry(&t, name, sha1, mode);\n+\t\tretval = find_tree_entry(&t, name, oid, mode);\n \t}\n \tfree(tree);\n \treturn retval;\n@@ -671,7 +671,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s\n \n \t\t/* Look up the first (or only) path component in the tree. */\n \t\tfind_result = find_tree_entry(&t, namebuf.buf,\n-\t\t\t\t\t      current_tree_oid.hash, mode);\n+\t\t\t\t\t      &current_tree_oid, mode);\n \t\tif (find_result) {\n \t\t\tgoto done;\n \t\t}\ndiff --git a/tree-walk.h b/tree-walk.h\nindex b6bd1b4ccf..4617deeb0e 100644\n--- a/tree-walk.h\n+++ b/tree-walk.h\n@@ -79,7 +79,7 @@ struct traverse_info {\n \tint show_all_errors;\n };\n \n-int get_tree_entry(const unsigned char *, const char *, unsigned char *, unsigned *);\n+int get_tree_entry(const struct object_id *, const char *, struct object_id *, unsigned *);\n extern char *make_traverse_path(char *path, const struct traverse_info *info, const struct name_entry *n);\n extern void setup_traverse_info(struct traverse_info *info, const char *base);\n \n"},{"id":"339663","messageId":"20180219225927.386065-33-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 32/36] sha1_file: convert read_object_with_reference to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:23Z","receivedAt":"2018-02-19T23:00:20Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert read_object_with_reference to take pointers to struct object_id.\nUpdate the internals of the function accordingly.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/cat-file.c     |  2 +-\n builtin/grep.c         |  4 ++--\n builtin/pack-objects.c |  2 +-\n cache.h                |  4 ++--\n fast-import.c          | 15 ++++++++-------\n sha1_file.c            | 20 ++++++++++----------\n tree-walk.c            |  9 ++++-----\n 7 files changed, 28 insertions(+), 28 deletions(-)\n\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 3264bada39..17382f2fa4 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -159,7 +159,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\t * fall-back to the usual case.\n \t\t\t */\n \t\t}\n-\t\tbuf = read_object_with_reference(oid.hash, exp_type, &size, NULL);\n+\t\tbuf = read_object_with_reference(&oid, exp_type, &size, NULL);\n \t\tbreak;\n \n \tdefault:\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3ca4ac80d8..7c2843a492 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -445,7 +445,7 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,\n \t\tobject = parse_object_or_die(oid, oid_to_hex(oid));\n \n \t\tgrep_read_lock();\n-\t\tdata = read_object_with_reference(object->oid.hash, tree_type,\n+\t\tdata = read_object_with_reference(&object->oid, tree_type,\n \t\t\t\t\t\t  &size, NULL);\n \t\tgrep_read_unlock();\n \n@@ -607,7 +607,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\tint hit, len;\n \n \t\tgrep_read_lock();\n-\t\tdata = read_object_with_reference(obj->oid.hash, tree_type,\n+\t\tdata = read_object_with_reference(&obj->oid, tree_type,\n \t\t\t\t\t\t  &size, NULL);\n \t\tgrep_read_unlock();\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex f8148eb9d5..16d6069e16 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1351,7 +1351,7 @@ static void add_preferred_base(struct object_id *oid)\n \tif (window <= num_preferred_base++)\n \t\treturn;\n \n-\tdata = read_object_with_reference(oid->hash, tree_type, &size, tree_oid.hash);\n+\tdata = read_object_with_reference(oid, tree_type, &size, &tree_oid);\n \tif (!data)\n \t\treturn;\n \ndiff --git a/cache.h b/cache.h\nindex b965a073f2..c482fb92fe 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1431,10 +1431,10 @@ extern int df_name_compare(const char *name1, int len1, int mode1, const char *n\n extern int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n extern int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n \n-extern void *read_object_with_reference(const unsigned char *sha1,\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\tunsigned char *sha1_ret);\n+\t\t\t\t\tstruct object_id *oid_ret);\n \n extern struct object *peel_to_type(const char *name, int namelen,\n \t\t\t\t   struct object *o, enum object_type);\ndiff --git a/fast-import.c b/fast-import.c\nindex 71b60f9068..004a9c9f99 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -2583,8 +2583,9 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\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\tchar *buf = read_object_with_reference(commit_oid.hash,\n-\t\t\tcommit_type, &size, commit_oid.hash);\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 \t\tif (!buf || size < 46)\n \t\t\tdie(\"Not a valid commit: %s\", p);\n \t\tfree(buf);\n@@ -2653,9 +2654,8 @@ static void parse_from_existing(struct branch *b)\n \t\tunsigned long size;\n \t\tchar *buf;\n \n-\t\tbuf = read_object_with_reference(b->oid.hash,\n-\t\t\t\t\t\t commit_type, &size,\n-\t\t\t\t\t\t b->oid.hash);\n+\t\tbuf = read_object_with_reference(&b->oid, commit_type, &size,\n+\t\t\t\t\t\t &b->oid);\n \t\tparse_from_commit(b, buf, size);\n \t\tfree(buf);\n \t}\n@@ -2732,8 +2732,9 @@ static struct hash_list *parse_merge(unsigned int *count)\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\tchar *buf = read_object_with_reference(n->oid.hash,\n-\t\t\t\tcommit_type, &size, n->oid.hash);\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 \t\t\tif (!buf || size < 46)\n \t\t\t\tdie(\"Not a valid commit: %s\", from);\n \t\t\tfree(buf);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 1719c218e2..bf8a713185 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1399,29 +1399,29 @@ void *read_sha1_file_extended(const unsigned char *sha1,\n \treturn NULL;\n }\n \n-void *read_object_with_reference(const unsigned char *sha1,\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 unsigned char *actual_sha1_return)\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-\tunsigned char actual_sha1[20];\n+\tstruct object_id actual_oid;\n \n \trequired_type = type_from_string(required_type_name);\n-\thashcpy(actual_sha1, sha1);\n+\toidcpy(&actual_oid, oid);\n \twhile (1) {\n \t\tint ref_length = -1;\n \t\tconst char *ref_type = NULL;\n \n-\t\tbuffer = read_sha1_file(actual_sha1, &type, &isize);\n+\t\tbuffer = read_sha1_file(actual_oid.hash, &type, &isize);\n \t\tif (!buffer)\n \t\t\treturn NULL;\n \t\tif (type == required_type) {\n \t\t\t*size = isize;\n-\t\t\tif (actual_sha1_return)\n-\t\t\t\thashcpy(actual_sha1_return, actual_sha1);\n+\t\t\tif (actual_oid_return)\n+\t\t\t\toidcpy(actual_oid_return, &actual_oid);\n \t\t\treturn buffer;\n \t\t}\n \t\t/* Handle references */\n@@ -1435,15 +1435,15 @@ void *read_object_with_reference(const unsigned char *sha1,\n \t\t}\n \t\tref_length = strlen(ref_type);\n \n-\t\tif (ref_length + 40 > isize ||\n+\t\tif (ref_length + GIT_SHA1_HEXSZ > isize ||\n \t\t    memcmp(buffer, ref_type, ref_length) ||\n-\t\t    get_sha1_hex((char *) buffer + ref_length, actual_sha1)) {\n+\t\t    get_oid_hex((char *) buffer + ref_length, &actual_oid)) {\n \t\t\tfree(buffer);\n \t\t\treturn NULL;\n \t\t}\n \t\tfree(buffer);\n \t\t/* Now we have the ID of the referred-to object in\n-\t\t * actual_sha1.  Check again. */\n+\t\t * actual_oid.  Check again. */\n \t}\n }\n \ndiff --git a/tree-walk.c b/tree-walk.c\nindex a60837c491..b7e504070c 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -84,8 +84,7 @@ void *fill_tree_descriptor(struct tree_desc *desc, const struct object_id *oid)\n \tvoid *buf = NULL;\n \n \tif (oid) {\n-\t\tbuf = read_object_with_reference(oid->hash, tree_type, &size,\n-\t\t\t\t\t\t NULL);\n+\t\tbuf = read_object_with_reference(oid, tree_type, &size, NULL);\n \t\tif (!buf)\n \t\t\tdie(\"unable to read tree %s\", oid_to_hex(oid));\n \t}\n@@ -534,7 +533,7 @@ int get_tree_entry(const struct object_id *tree_oid, const char *name, struct ob\n \tunsigned long size;\n \tstruct object_id root;\n \n-\ttree = read_object_with_reference(tree_oid->hash, tree_type, &size, root.hash);\n+\ttree = read_object_with_reference(tree_oid, tree_type, &size, &root);\n \tif (!tree)\n \t\treturn -1;\n \n@@ -601,9 +600,9 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s\n \t\t\tvoid *tree;\n \t\t\tstruct object_id root;\n \t\t\tunsigned long size;\n-\t\t\ttree = read_object_with_reference(current_tree_oid.hash,\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.hash);\n+\t\t\t\t\t\t\t  &root);\n \t\t\tif (!tree)\n \t\t\t\tgoto done;\n \n"},{"id":"339664","messageId":"20180219225927.386065-36-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 35/36] sha1_file: introduce a constant for max header length","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:26Z","receivedAt":"2018-02-19T23:00:23Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"There were several instances of 32 sprinkled throughout this file, all\nof which were used for allocating a buffer to store the header of an\nobject.  Introduce a constant, MAX_HEADER_LEN, for this purpose.\n\nNote that this constant is slightly larger than required; the longest\npossible header is 28 (7 for \"commit\", 1 for a space, 20 for a 63-bit\nlength in decimal, and 1 for the NUL).  However, the overallocation\nshould not cause any problems, so leave it as it is.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n sha1_file.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex c41fbe2f01..4d4f9248c7 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -30,6 +30,9 @@\n #include \"packfile.h\"\n #include \"fetch-object.h\"\n \n+/* The maximum size for an object header. */\n+#define MAX_HEADER_LEN 32\n+\n const unsigned char null_sha1[GIT_MAX_RAWSZ];\n const struct object_id null_oid;\n const struct object_id empty_tree_oid = {\n@@ -791,7 +794,7 @@ int check_object_signature(const struct object_id *oid, void *map,\n \tenum object_type obj_type;\n \tstruct git_istream *st;\n \tgit_hash_ctx c;\n-\tchar hdr[32];\n+\tchar hdr[MAX_HEADER_LEN];\n \tint hdrlen;\n \n \tif (map) {\n@@ -1150,7 +1153,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,\n \tunsigned long mapsize;\n \tvoid *map;\n \tgit_zstream stream;\n-\tchar hdr[32];\n+\tchar hdr[MAX_HEADER_LEN];\n \tstruct strbuf hdrbuf = STRBUF_INIT;\n \tunsigned long size_scratch;\n \n@@ -1512,7 +1515,7 @@ static int write_buffer(int fd, const void *buf, size_t len)\n int hash_object_file(const void *buf, unsigned long len, const char *type,\n \t\t     struct object_id *oid)\n {\n-\tchar hdr[32];\n+\tchar hdr[MAX_HEADER_LEN];\n \tint hdrlen = sizeof(hdr);\n \twrite_object_file_prepare(buf, len, type, oid, hdr, &hdrlen);\n \treturn 0;\n@@ -1667,7 +1670,7 @@ static int freshen_packed_object(const unsigned char *sha1)\n int write_object_file(const void *buf, unsigned long len, const char *type,\n \t\t      struct object_id *oid)\n {\n-\tchar hdr[32];\n+\tchar hdr[MAX_HEADER_LEN];\n \tint hdrlen = sizeof(hdr);\n \n \t/* Normally if we have it in the pack then we do not bother writing\n@@ -1687,7 +1690,7 @@ int hash_object_file_literally(const void *buf, unsigned long len,\n \tint hdrlen, status = 0;\n \n \t/* type string, SP, %lu of the length plus NUL must fit this */\n-\thdrlen = strlen(type) + 32;\n+\thdrlen = strlen(type) + MAX_HEADER_LEN;\n \theader = xmalloc(hdrlen);\n \twrite_object_file_prepare(buf, len, type, oid, header, &hdrlen);\n \n@@ -1707,7 +1710,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)\n \tvoid *buf;\n \tunsigned long len;\n \tenum object_type type;\n-\tchar hdr[32];\n+\tchar hdr[MAX_HEADER_LEN];\n \tint hdrlen;\n \tint ret;\n \n@@ -2189,7 +2192,7 @@ int read_loose_object(const char *path,\n \tvoid *map = NULL;\n \tunsigned long mapsize;\n \tgit_zstream stream;\n-\tchar hdr[32];\n+\tchar hdr[MAX_HEADER_LEN];\n \n \t*contents = NULL;\n \n"},{"id":"339665","messageId":"20180219225927.386065-34-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 33/36] sha1_file: convert read_sha1_file to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:24Z","receivedAt":"2018-02-19T23:00:28Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert read_sha1_file to take a pointer to struct object_id and rename\nit read_object_file.  Do the same for read_sha1_file_extended.\n\nConvert one use in grep.c to use the new function without any other code\nchange, since the pointer being passed is a void pointer that is already\ninitialized with a pointer to struct object_id.  Update the declaration\nand definitions of the modified functions, and apply the following\nsemantic patch to convert the remaining callers:\n\n@@\nexpression E1, E2, E3;\n@@\n- read_sha1_file(E1.hash, E2, E3)\n+ read_object_file(&E1, E2, E3)\n\n@@\nexpression E1, E2, E3;\n@@\n- read_sha1_file(E1->hash, E2, E3)\n+ read_object_file(E1, E2, E3)\n\n@@\nexpression E1, E2, E3, E4;\n@@\n- read_sha1_file_extended(E1.hash, E2, E3, E4)\n+ read_object_file_extended(&E1, E2, E3, E4)\n\n@@\nexpression E1, E2, E3, E4;\n@@\n- read_sha1_file_extended(E1->hash, E2, E3, E4)\n+ read_object_file_extended(E1, E2, E3, E4)\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n apply.c                  |  4 ++--\n archive.c                |  2 +-\n bisect.c                 |  3 ++-\n blame.c                  |  8 ++++----\n builtin/cat-file.c       | 14 ++++++++------\n builtin/difftool.c       |  2 +-\n builtin/fast-export.c    |  4 ++--\n builtin/fmt-merge-msg.c  |  2 +-\n builtin/grep.c           |  2 +-\n builtin/index-pack.c     |  5 +++--\n builtin/log.c            |  2 +-\n builtin/merge-tree.c     |  5 +++--\n builtin/mktag.c          |  2 +-\n builtin/notes.c          |  6 +++---\n builtin/pack-objects.c   | 16 ++++++----------\n builtin/reflog.c         |  2 +-\n builtin/tag.c            |  4 ++--\n builtin/unpack-file.c    |  2 +-\n builtin/unpack-objects.c |  2 +-\n builtin/verify-commit.c  |  2 +-\n bundle.c                 |  2 +-\n cache.h                  | 10 +++++-----\n combine-diff.c           |  2 +-\n commit.c                 |  6 +++---\n config.c                 |  2 +-\n diff.c                   |  2 +-\n dir.c                    |  2 +-\n entry.c                  |  2 +-\n fast-import.c            |  6 +++---\n fsck.c                   |  2 +-\n grep.c                   |  2 +-\n http-push.c              |  2 +-\n mailmap.c                |  2 +-\n match-trees.c            |  4 ++--\n merge-blobs.c            |  4 ++--\n merge-recursive.c        |  4 ++--\n notes-cache.c            |  2 +-\n notes-merge.c            |  2 +-\n notes.c                  |  8 ++++----\n object.c                 |  2 +-\n read-cache.c             |  4 ++--\n ref-filter.c             |  2 +-\n remote-testsvn.c         |  4 ++--\n rerere.c                 |  4 ++--\n sha1_file.c              | 20 ++++++++++----------\n streaming.c              |  2 +-\n submodule-config.c       |  2 +-\n tag.c                    |  4 ++--\n tree-walk.c              |  4 ++--\n tree.c                   |  2 +-\n xdiff-interface.c        |  2 +-\n 51 files changed, 104 insertions(+), 103 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 40a368b315..dd3cf99b7c 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3180,7 +3180,7 @@ static int apply_binary(struct apply_state *state,\n \t\tunsigned long size;\n \t\tchar *result;\n \n-\t\tresult = read_sha1_file(oid.hash, &type, &size);\n+\t\tresult = read_object_file(&oid, &type, &size);\n \t\tif (!result)\n \t\t\treturn error(_(\"the necessary postimage %s for \"\n \t\t\t\t       \"'%s' cannot be read\"),\n@@ -3242,7 +3242,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns\n \t\tunsigned long sz;\n \t\tchar *result;\n \n-\t\tresult = read_sha1_file(oid->hash, &type, &sz);\n+\t\tresult = read_object_file(oid, &type, &sz);\n \t\tif (!result)\n \t\t\treturn -1;\n \t\t/* XXX read_sha1_file NUL-terminates */\ndiff --git a/archive.c b/archive.c\nindex 1ab62d426e..93ab175b0b 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -72,7 +72,7 @@ void *object_file_to_archive(const struct archiver_args *args,\n \tconst struct commit *commit = args->convert ? args->commit : NULL;\n \n \tpath += args->baselen;\n-\tbuffer = read_sha1_file(oid->hash, type, sizep);\n+\tbuffer = read_object_file(oid, type, sizep);\n \tif (buffer && S_ISREG(mode)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tsize_t size = 0;\ndiff --git a/bisect.c b/bisect.c\nindex f6d05bd66f..ad395bb2b8 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -132,7 +132,8 @@ static void show_list(const char *debug, int counted, int nr,\n \t\tunsigned flags = commit->object.flags;\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tchar *buf = read_sha1_file(commit->object.oid.hash, &type, &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;\n \t\tint subject_len;\n \ndiff --git a/blame.c b/blame.c\nindex 3f9bd29615..e5ed80083e 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -297,8 +297,8 @@ static void fill_origin_blob(struct diff_options *opt,\n \t\t    textconv_object(o->path, o->mode, &o->blob_oid, 1, &file->ptr, &file_size))\n \t\t\t;\n \t\telse\n-\t\t\tfile->ptr = read_sha1_file(o->blob_oid.hash, &type,\n-\t\t\t\t\t\t   &file_size);\n+\t\t\tfile->ptr = read_object_file(&o->blob_oid, &type,\n+\t\t\t\t\t\t     &file_size);\n \t\tfile->size = file_size;\n \n \t\tif (!file->ptr)\n@@ -1828,8 +1828,8 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam\n \t\t\t\t    &sb->final_buf_size))\n \t\t\t;\n \t\telse\n-\t\t\tsb->final_buf = read_sha1_file(o->blob_oid.hash, &type,\n-\t\t\t\t\t\t       &sb->final_buf_size);\n+\t\t\tsb->final_buf = read_object_file(&o->blob_oid, &type,\n+\t\t\t\t\t\t\t &sb->final_buf_size);\n \n \t\tif (!sb->final_buf)\n \t\t\tdie(_(\"cannot read blob %s for path %s\"),\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 17382f2fa4..044b82bcee 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -32,7 +32,7 @@ static int filter_object(const char *path, unsigned mode,\n {\n \tenum object_type type;\n \n-\t*buf = read_sha1_file(oid->hash, &type, size);\n+\t*buf = read_object_file(oid, &type, size);\n \tif (!*buf)\n \t\treturn error(_(\"cannot read object %s '%s'\"),\n \t\t\t     oid_to_hex(oid), path);\n@@ -130,7 +130,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \n \t\tif (type == OBJ_BLOB)\n \t\t\treturn stream_blob_to_fd(1, &oid, NULL, 0);\n-\t\tbuf = read_sha1_file(oid.hash, &type, &size);\n+\t\tbuf = read_object_file(&oid, &type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"Cannot read object %s\", obj_name);\n \n@@ -141,7 +141,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\tif (type_from_string(exp_type) == OBJ_BLOB) {\n \t\t\tstruct object_id blob_oid;\n \t\t\tif (oid_object_info(&oid, NULL) == OBJ_TAG) {\n-\t\t\t\tchar *buffer = read_sha1_file(oid.hash, &type, &size);\n+\t\t\t\tchar *buffer = read_object_file(&oid, &type,\n+\t\t\t\t\t\t\t\t&size);\n \t\t\t\tconst char *target;\n \t\t\t\tif (!skip_prefix(buffer, \"object \", &target) ||\n \t\t\t\t    get_oid_hex(target, &blob_oid))\n@@ -304,8 +305,9 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\t\t\tenum object_type type;\n \t\t\t\tif (!textconv_object(data->rest, 0100644, oid,\n \t\t\t\t\t\t     1, &contents, &size))\n-\t\t\t\t\tcontents = read_sha1_file(oid->hash, &type,\n-\t\t\t\t\t\t\t\t  &size);\n+\t\t\t\t\tcontents = read_object_file(oid,\n+\t\t\t\t\t\t\t\t    &type,\n+\t\t\t\t\t\t\t\t    &size);\n \t\t\t\tif (!contents)\n \t\t\t\t\tdie(\"could not convert '%s' %s\",\n \t\t\t\t\t    oid_to_hex(oid), data->rest);\n@@ -321,7 +323,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\tunsigned long size;\n \t\tvoid *contents;\n \n-\t\tcontents = read_sha1_file(oid->hash, &type, &size);\n+\t\tcontents = read_object_file(oid, &type, &size);\n \t\tif (!contents)\n \t\t\tdie(\"object %s disappeared\", oid_to_hex(oid));\n \t\tif (type != data->type)\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex bcc79d1888..ee8dce019e 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} else {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tdata = read_sha1_file(oid->hash, &type, &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\"),\n \t\t\t\toid_to_hex(oid), path);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 02ec19060d..aedae7a14d 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -237,7 +237,7 @@ static void export_blob(const struct object_id *oid)\n \t\tobject = (struct object *)lookup_blob(oid);\n \t\teaten = 0;\n \t} else {\n-\t\tbuf = read_sha1_file(oid->hash, &type, &size);\n+\t\tbuf = read_object_file(oid, &type, &size);\n \t\tif (!buf)\n \t\t\tdie (\"Could not read blob %s\", oid_to_hex(oid));\n \t\tif (check_object_signature(oid, buf, size, typename(type)) < 0)\n@@ -682,7 +682,7 @@ static void handle_tag(const char *name, struct tag *tag)\n \t\treturn;\n \t}\n \n-\tbuf = read_sha1_file(tag->object.oid.hash, &type, &size);\n+\tbuf = read_object_file(&tag->object.oid, &type, &size);\n \tif (!buf)\n \t\tdie (\"Could not read tag %s\", oid_to_hex(&tag->object.oid));\n \tmessage = memmem(buf, size, \"\\n\\n\", 2);\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 0bc0dda99c..bd680be687 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -488,7 +488,7 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \t\tstruct object_id *oid = origins.items[i].util;\n \t\tenum object_type type;\n \t\tunsigned long size, len;\n-\t\tchar *buf = read_sha1_file(oid->hash, &type, &size);\n+\t\tchar *buf = read_object_file(oid, &type, &size);\n \t\tstruct strbuf sig = STRBUF_INIT;\n \n \t\tif (!buf || type != OBJ_TAG)\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 7c2843a492..a0592ed065 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -307,7 +307,7 @@ static void *lock_and_read_oid_file(const struct object_id *oid, enum object_typ\n \tvoid *data;\n \n \tgrep_read_lock();\n-\tdata = read_sha1_file(oid->hash, type, size);\n+\tdata = read_object_file(oid, type, size);\n \tgrep_read_unlock();\n \treturn data;\n }\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 27aa50396b..5b6ef98f48 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -815,7 +815,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\n \t\t\tdie(_(\"SHA1 COLLISION FOUND WITH %s !\"), oid_to_hex(oid));\n-\t\thas_data = read_sha1_file(oid->hash, &has_type, &has_size);\n+\t\thas_data = read_object_file(oid, &has_type, &has_size);\n \t\tread_unlock();\n \t\tif (!data)\n \t\t\tdata = new_data = get_data_from_pack(obj_entry);\n@@ -1373,7 +1373,8 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \n \t\tif (objects[d->obj_no].real_type != OBJ_REF_DELTA)\n \t\t\tcontinue;\n-\t\tbase_obj->data = read_sha1_file(d->oid.hash, &type, &base_obj->size);\n+\t\tbase_obj->data = read_object_file(&d->oid, &type,\n+\t\t\t\t\t\t  &base_obj->size);\n \t\tif (!base_obj->data)\n \t\t\tcontinue;\n \ndiff --git a/builtin/log.c b/builtin/log.c\nindex 411339c1ed..71f68a3e4f 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -518,7 +518,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = read_sha1_file(oid->hash, &type, &size);\n+\tchar *buf = read_object_file(oid, &type, &size);\n \tint offset = 0;\n \n \tif (!buf)\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex d01ddecf66..32736e0b10 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -60,7 +60,7 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \tconst char *path = entry->path;\n \n \tif (!entry->stage)\n-\t\treturn read_sha1_file(entry->blob->object.oid.hash, &type, size);\n+\t\treturn read_object_file(&entry->blob->object.oid, &type, size);\n \tbase = NULL;\n \tif (entry->stage == 1) {\n \t\tbase = entry->blob;\n@@ -82,7 +82,8 @@ static void *origin(struct merge_list *entry, unsigned long *size)\n \tenum object_type type;\n \twhile (entry) {\n \t\tif (entry->stage == 2)\n-\t\t\treturn read_sha1_file(entry->blob->object.oid.hash, &type, size);\n+\t\t\treturn read_object_file(&entry->blob->object.oid,\n+\t\t\t\t\t\t&type, size);\n \t\tentry = entry->link;\n \t}\n \treturn NULL;\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 810b24bef3..cfb777b3c8 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -23,7 +23,7 @@ static int verify_object(const struct object_id *oid, const char *expected_type)\n \tint ret = -1;\n \tenum object_type type;\n \tunsigned long size;\n-\tvoid *buffer = read_sha1_file(oid->hash, &type, &size);\n+\tvoid *buffer = read_object_file(oid, &type, &size);\n \tconst unsigned char *repl = lookup_replace_object(oid->hash);\n \n \tif (buffer) {\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 08ab9d7130..5ddfa44cde 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -122,7 +122,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = read_sha1_file(oid->hash, &type, &size);\n+\tchar *buf = read_object_file(oid, &type, &size);\n \tif (buf) {\n \t\tif (size)\n \t\t\twrite_or_die(fd, buf, size);\n@@ -253,7 +253,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n \n \tif (get_oid(arg, &object))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), arg);\n-\tif (!(buf = read_sha1_file(object.hash, &type, &len))) {\n+\tif (!(buf = read_object_file(&object, &type, &len))) {\n \t\tfree(buf);\n \t\tdie(_(\"failed to read object '%s'.\"), arg);\n \t}\n@@ -608,7 +608,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \t\t/* Append buf to previous note contents */\n \t\tunsigned long size;\n \t\tenum object_type type;\n-\t\tchar *prev_buf = read_sha1_file(note->hash, &type, &size);\n+\t\tchar *prev_buf = read_object_file(note, &type, &size);\n \n \t\tstrbuf_grow(&d.buf, size + 1);\n \t\tif (d.buf.len && prev_buf && size)\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 16d6069e16..91c7b62ec3 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -122,11 +122,10 @@ static void *get_delta(struct object_entry *entry)\n \tvoid *buf, *base_buf, *delta_buf;\n \tenum object_type type;\n \n-\tbuf = read_sha1_file(entry->idx.oid.hash, &type, &size);\n+\tbuf = read_object_file(&entry->idx.oid, &type, &size);\n \tif (!buf)\n \t\tdie(\"unable to read %s\", oid_to_hex(&entry->idx.oid));\n-\tbase_buf = read_sha1_file(entry->delta->idx.oid.hash, &type,\n-\t\t\t\t  &base_size);\n+\tbase_buf = read_object_file(&entry->delta->idx.oid, &type, &base_size);\n \tif (!base_buf)\n \t\tdie(\"unable to read %s\",\n \t\t    oid_to_hex(&entry->delta->idx.oid));\n@@ -270,8 +269,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent\n \t\t    (st = open_istream(&entry->idx.oid, &type, &size, NULL)) != NULL)\n \t\t\tbuf = NULL;\n \t\telse {\n-\t\t\tbuf = read_sha1_file(entry->idx.oid.hash, &type,\n-\t\t\t\t\t     &size);\n+\t\t\tbuf = read_object_file(&entry->idx.oid, &type, &size);\n \t\t\tif (!buf)\n \t\t\t\tdie(_(\"unable to read %s\"),\n \t\t\t\t    oid_to_hex(&entry->idx.oid));\n@@ -1190,7 +1188,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n \t/* Did not find one.  Either we got a bogus request or\n \t * we need to read and perhaps cache.\n \t */\n-\tdata = read_sha1_file(oid->hash, &type, &size);\n+\tdata = read_object_file(oid, &type, &size);\n \tif (!data)\n \t\treturn NULL;\n \tif (type != OBJ_TREE) {\n@@ -1870,8 +1868,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t/* Load data if not already done */\n \tif (!trg->data) {\n \t\tread_lock();\n-\t\ttrg->data = read_sha1_file(trg_entry->idx.oid.hash, &type,\n-\t\t\t\t\t   &sz);\n+\t\ttrg->data = read_object_file(&trg_entry->idx.oid, &type, &sz);\n \t\tread_unlock();\n \t\tif (!trg->data)\n \t\t\tdie(\"object %s cannot be read\",\n@@ -1884,8 +1881,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t}\n \tif (!src->data) {\n \t\tread_lock();\n-\t\tsrc->data = read_sha1_file(src_entry->idx.oid.hash, &type,\n-\t\t\t\t\t   &sz);\n+\t\tsrc->data = read_object_file(&src_entry->idx.oid, &type, &sz);\n \t\tread_unlock();\n \t\tif (!src->data) {\n \t\t\tif (src_entry->preferred_base) {\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 2233725315..e8e32db92e 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -74,7 +74,7 @@ static int tree_is_complete(const struct object_id *oid)\n \tif (!tree->buffer) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tvoid *data = read_sha1_file(oid->hash, &type, &size);\n+\t\tvoid *data = read_object_file(oid, &type, &size);\n \t\tif (!data) {\n \t\t\ttree->object.flags |= INCOMPLETE;\n \t\t\treturn 0;\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 3340cbedd4..85d326fbe0 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -168,7 +168,7 @@ static void write_tag_body(int fd, const struct object_id *oid)\n \tenum object_type type;\n \tchar *buf, *sp;\n \n-\tbuf = read_sha1_file(oid->hash, &type, &size);\n+\tbuf = read_object_file(oid, &type, &size);\n \tif (!buf)\n \t\treturn;\n \t/* skip header */\n@@ -300,7 +300,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\n \t\tbreak;\n \tcase OBJ_COMMIT:\n-\t\tif ((buf = read_sha1_file(oid->hash, &type, &size)) != NULL) {\n+\t\tif ((buf = read_object_file(oid, &type, &size)) != NULL) {\n \t\t\tsubject_len = find_commit_subject(buf, &subject_start);\n \t\t\tstrbuf_insert(sb, sb->len, subject_start, subject_len);\n \t\t} else {\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex 32e0155577..300eb59657 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -9,7 +9,7 @@ static char *create_temp_file(struct object_id *oid)\n \tunsigned long size;\n \tint fd;\n \n-\tbuf = read_sha1_file(oid->hash, &type, &size);\n+\tbuf = read_object_file(oid, &type, &size);\n \tif (!buf || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 6e712081e0..299608cc32 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -422,7 +422,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \tif (resolve_against_held(nr, &base_oid, delta_data, delta_size))\n \t\treturn;\n \n-\tbase = read_sha1_file(base_oid.hash, &type, &base_size);\n+\tbase = read_object_file(&base_oid, &type, &base_size);\n \tif (!base) {\n \t\terror(\"failed to read delta-pack base object %s\",\n \t\t      oid_to_hex(&base_oid));\ndiff --git a/builtin/verify-commit.c b/builtin/verify-commit.c\nindex ba38ac9b15..3c37ba911e 100644\n--- a/builtin/verify-commit.c\n+++ b/builtin/verify-commit.c\n@@ -44,7 +44,7 @@ static int verify_commit(const char *name, unsigned flags)\n \tif (get_oid(name, &oid))\n \t\treturn error(\"commit '%s' not found.\", name);\n \n-\tbuf = read_sha1_file(oid.hash, &type, &size);\n+\tbuf = read_object_file(&oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"%s: unable to read file.\", name);\n \tif (type != OBJ_COMMIT)\ndiff --git a/bundle.c b/bundle.c\nindex efe547e25f..902c9b5448 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -222,7 +222,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n \tif (revs->max_age == -1 && revs->min_age == -1)\n \t\tgoto out;\n \n-\tbuf = read_sha1_file(tag->oid.hash, &type, &size);\n+\tbuf = read_object_file(&tag->oid, &type, &size);\n \tif (!buf)\n \t\tgoto out;\n \tline = memmem(buf, size, \"\\ntagger \", 8);\ndiff --git a/cache.h b/cache.h\nindex c482fb92fe..970d6edd04 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1185,12 +1185,12 @@ extern char *xdg_config_home(const char *filename);\n  */\n 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+extern void *read_object_file_extended(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+static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size)\n {\n-\treturn read_sha1_file_extended(sha1, type, size, 1);\n+\treturn read_object_file_extended(oid, type, size, 1);\n }\n \n /*\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 3d86304c5a..e5290ac05c 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -306,7 +306,7 @@ static char *grab_blob(const struct object_id *oid, unsigned int mode,\n \t\t*size = fill_textconv(textconv, df, &blob);\n \t\tfree_filespec(df);\n \t} else {\n-\t\tblob = read_sha1_file(oid->hash, &type, size);\n+\t\tblob = read_object_file(oid, &type, size);\n \t\tif (type != OBJ_BLOB)\n \t\t\tdie(\"object '%s' is not a blob!\", oid_to_hex(oid));\n \t}\ndiff --git a/commit.c b/commit.c\nindex b9f028976f..5e401340c4 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -266,7 +266,7 @@ const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)\n \tif (!ret) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tret = read_sha1_file(commit->object.oid.hash, &type, &size);\n+\t\tret = read_object_file(&commit->object.oid, &type, &size);\n \t\tif (!ret)\n \t\t\tdie(\"cannot read commit object %s\",\n \t\t\t    oid_to_hex(&commit->object.oid));\n@@ -383,7 +383,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)\n \t\treturn -1;\n \tif (item->object.parsed)\n \t\treturn 0;\n-\tbuffer = read_sha1_file(item->object.oid.hash, &type, &size);\n+\tbuffer = read_object_file(&item->object.oid, &type, &size);\n \tif (!buffer)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\n@@ -1206,7 +1206,7 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header\n \tdesc = merge_remote_util(parent);\n \tif (!desc || !desc->obj)\n \t\treturn;\n-\tbuf = read_sha1_file(desc->obj->oid.hash, &type, &size);\n+\tbuf = read_object_file(&desc->obj->oid, &type, &size);\n \tif (!buf || type != OBJ_TAG)\n \t\tgoto free_return;\n \tlen = parse_signature(buf, size);\ndiff --git a/config.c b/config.c\nindex b0c20e6cb8..c698988f5e 100644\n--- a/config.c\n+++ b/config.c\n@@ -1488,7 +1488,7 @@ int git_config_from_blob_oid(config_fn_t fn,\n \tunsigned long size;\n \tint ret;\n \n-\tbuf = read_sha1_file(oid->hash, &type, &size);\n+\tbuf = read_object_file(oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"unable to load config blob object '%s'\", name);\n \tif (type != OBJ_BLOB) {\ndiff --git a/diff.c b/diff.c\nindex d838ee2e9a..b117bf5105 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3626,7 +3626,7 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)\n \t\t\t\treturn 0;\n \t\t\t}\n \t\t}\n-\t\ts->data = read_sha1_file(s->oid.hash, &type, &s->size);\n+\t\ts->data = read_object_file(&s->oid, &type, &s->size);\n \t\tif (!s->data)\n \t\t\tdie(\"unable to read %s\", oid_to_hex(&s->oid));\n \t\ts->should_free = 1;\ndiff --git a/dir.c b/dir.c\nindex 6dd91be818..b342ab344b 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -243,7 +243,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,\n \t*size_out = 0;\n \t*data_out = NULL;\n \n-\tdata = read_sha1_file(oid->hash, &type, &sz);\n+\tdata = read_object_file(oid, &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn -1;\ndiff --git a/entry.c b/entry.c\nindex 30211447ac..3f21d2c913 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -85,7 +85,7 @@ static int create_file(const char *path, unsigned int mode)\n static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size)\n {\n \tenum object_type type;\n-\tvoid *new = read_sha1_file(ce->oid.hash, &type, size);\n+\tvoid *new = read_object_file(&ce->oid, &type, size);\n \n \tif (new) {\n \t\tif (type == OBJ_BLOB)\ndiff --git a/fast-import.c b/fast-import.c\nindex 004a9c9f99..f1fdbac81a 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1412,7 +1412,7 @@ static void load_tree(struct tree_entry *root)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t} else {\n \t\tenum object_type type;\n-\t\tbuf = read_sha1_file(oid->hash, &type, &size);\n+\t\tbuf = read_object_file(oid, &type, &size);\n \t\tif (!buf || type != OBJ_TREE)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t}\n@@ -2967,7 +2967,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)\n \tchar *buf;\n \n \tif (!oe || oe->pack_id == MAX_PACK_ID) {\n-\t\tbuf = read_sha1_file(oid->hash, &type, &size);\n+\t\tbuf = read_object_file(oid, &type, &size);\n \t} else {\n \t\ttype = oe->type;\n \t\tbuf = gfi_unpack_entry(oe, &size);\n@@ -3072,7 +3072,7 @@ static struct object_entry *dereference(struct object_entry *oe,\n \t\tbuf = gfi_unpack_entry(oe, &size);\n \t} else {\n \t\tenum object_type unused;\n-\t\tbuf = read_sha1_file(oid->hash, &unused, &size);\n+\t\tbuf = read_object_file(oid, &unused, &size);\n \t}\n \tif (!buf)\n \t\tdie(\"Can't load object %s\", oid_to_hex(oid));\ndiff --git a/fsck.c b/fsck.c\nindex 032699e9ac..1e3724b0eb 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -811,7 +811,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,\n \t\tenum object_type type;\n \n \t\tbuffer = to_free =\n-\t\t\tread_sha1_file(tag->object.oid.hash, &type, &size);\n+\t\t\tread_object_file(&tag->object.oid, &type, &size);\n \t\tif (!buffer)\n \t\t\treturn report(options, &tag->object,\n \t\t\t\tFSCK_MSG_MISSING_TAG_OBJECT,\ndiff --git a/grep.c b/grep.c\nindex 3d7cd0e96f..b92a336591 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -2010,7 +2010,7 @@ static int grep_source_load_oid(struct grep_source *gs)\n \tenum object_type type;\n \n \tgrep_read_lock();\n-\tgs->buf = read_sha1_file(gs->identifier, &type, &gs->size);\n+\tgs->buf = read_object_file(gs->identifier, &type, &gs->size);\n \tgrep_read_unlock();\n \n \tif (!gs->buf)\ndiff --git a/http-push.c b/http-push.c\nindex 0913f8ab86..58dd57ffd3 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -361,7 +361,7 @@ static void start_put(struct transfer_request *request)\n \tssize_t size;\n \tgit_zstream stream;\n \n-\tunpacked = read_sha1_file(request->obj->oid.hash, &type, &len);\n+\tunpacked = read_object_file(&request->obj->oid, &type, &len);\n \thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %lu\", typename(type), len) + 1;\n \n \t/* Set it up */\ndiff --git a/mailmap.c b/mailmap.c\nindex cb921b4db6..13f0d2884e 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -224,7 +224,7 @@ static int read_mailmap_blob(struct string_list *map,\n \tif (get_oid(name, &oid) < 0)\n \t\treturn 0;\n \n-\tbuf = read_sha1_file(oid.hash, &type, &size);\n+\tbuf = read_object_file(&oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"unable to read mailmap object at %s\", name);\n \tif (type != OBJ_BLOB)\ndiff --git a/match-trees.c b/match-trees.c\nindex 10d6c39d47..72cc2baa3f 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -54,7 +54,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc,\n \tenum object_type type;\n \tunsigned long size;\n \n-\tbuffer = read_sha1_file(hash->hash, &type, &size);\n+\tbuffer = read_object_file(hash, &type, &size);\n \tif (!buffer)\n \t\tdie(\"unable to read tree (%s)\", oid_to_hex(hash));\n \tif (type != OBJ_TREE)\n@@ -180,7 +180,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,\n \tif (*subpath)\n \t\tsubpath++;\n \n-\tbuf = read_sha1_file(oid1->hash, &type, &sz);\n+\tbuf = read_object_file(oid1, &type, &sz);\n \tif (!buf)\n \t\tdie(\"cannot read tree %s\", oid_to_hex(oid1));\n \tinit_tree_desc(&desc, buf, sz);\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex 9b6eac22e4..fa49c17287 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -11,7 +11,7 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n \tunsigned long size;\n \tenum object_type type;\n \n-\tbuf = read_sha1_file(obj->object.oid.hash, &type, &size);\n+\tbuf = read_object_file(&obj->object.oid, &type, &size);\n \tif (!buf)\n \t\treturn -1;\n \tif (type != OBJ_BLOB) {\n@@ -66,7 +66,7 @@ void *merge_blobs(const char *path, struct blob *base, struct blob *our, struct\n \t\t\treturn NULL;\n \t\tif (!our)\n \t\t\tour = their;\n-\t\treturn read_sha1_file(our->object.oid.hash, &type, size);\n+\t\treturn read_object_file(&our->object.oid, &type, size);\n \t}\n \n \tif (fill_mmfile_blob(&f1, our) < 0)\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 85f8cbee99..c55401698d 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -842,7 +842,7 @@ static int update_file_flags(struct merge_options *o,\n \t\t\tgoto update_index;\n \t\t}\n \n-\t\tbuf = read_sha1_file(oid->hash, &type, &size);\n+\t\tbuf = read_object_file(oid, &type, &size);\n \t\tif (!buf)\n \t\t\treturn err(o, _(\"cannot read object %s '%s'\"), oid_to_hex(oid), path);\n \t\tif (type != OBJ_BLOB) {\n@@ -1656,7 +1656,7 @@ static int read_oid_strbuf(struct merge_options *o,\n \tvoid *buf;\n \tenum object_type type;\n \tunsigned long size;\n-\tbuf = read_sha1_file(oid->hash, &type, &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));\n \tif (type != OBJ_BLOB) {\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 398e61d5e9..e61988e503 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 \tvalue_oid = get_note(&c->tree, key_oid);\n \tif (!value_oid)\n \t\treturn NULL;\n-\tvalue = read_sha1_file(value_oid->hash, &type, &size);\n+\tvalue = read_object_file(value_oid, &type, &size);\n \n \t*outsize = size;\n \treturn value;\ndiff --git a/notes-merge.c b/notes-merge.c\nindex c09c5e0e47..8e0726a941 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -322,7 +322,7 @@ static void write_note_to_worktree(const struct object_id *obj,\n {\n \tenum object_type type;\n \tunsigned long size;\n-\tvoid *buf = read_sha1_file(note->hash, &type, &size);\n+\tvoid *buf = read_object_file(note, &type, &size);\n \n \tif (!buf)\n \t\tdie(\"cannot read note %s for object %s\",\ndiff --git a/notes.c b/notes.c\nindex d25121a65d..a386d450c4 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -796,13 +796,13 @@ int combine_notes_concatenate(struct object_id *cur_oid,\n \n \t/* read in both note blob objects */\n \tif (!is_null_oid(new_oid))\n-\t\tnew_msg = read_sha1_file(new_oid->hash, &new_type, &new_len);\n+\t\tnew_msg = read_object_file(new_oid, &new_type, &new_len);\n \tif (!new_msg || !new_len || new_type != OBJ_BLOB) {\n \t\tfree(new_msg);\n \t\treturn 0;\n \t}\n \tif (!is_null_oid(cur_oid))\n-\t\tcur_msg = read_sha1_file(cur_oid->hash, &cur_type, &cur_len);\n+\t\tcur_msg = read_object_file(cur_oid, &cur_type, &cur_len);\n \tif (!cur_msg || !cur_len || cur_type != OBJ_BLOB) {\n \t\tfree(cur_msg);\n \t\tfree(new_msg);\n@@ -858,7 +858,7 @@ static int string_list_add_note_lines(struct string_list *list,\n \t\treturn 0;\n \n \t/* read_sha1_file NUL-terminates */\n-\tdata = read_sha1_file(oid->hash, &t, &len);\n+\tdata = read_object_file(oid, &t, &len);\n \tif (t != OBJ_BLOB || !data || !len) {\n \t\tfree(data);\n \t\treturn t != OBJ_BLOB || !data;\n@@ -1217,7 +1217,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n \tif (!oid)\n \t\treturn;\n \n-\tif (!(msg = read_sha1_file(oid->hash, &type, &msglen)) || type != OBJ_BLOB) {\n+\tif (!(msg = read_object_file(oid, &type, &msglen)) || type != OBJ_BLOB) {\n \t\tfree(msg);\n \t\treturn;\n \t}\ndiff --git a/object.c b/object.c\nindex be8f23271b..ea1a6f18e8 100644\n--- a/object.c\n+++ b/object.c\n@@ -266,7 +266,7 @@ struct object *parse_object(const struct object_id *oid)\n \t\treturn lookup_object(oid->hash);\n \t}\n \n-\tbuffer = read_sha1_file(oid->hash, &type, &size);\n+\tbuffer = read_object_file(oid, &type, &size);\n \tif (buffer) {\n \t\tstruct object_id reploid;\n \t\thashcpy(reploid.hash, repl);\ndiff --git a/read-cache.c b/read-cache.c\nindex 28bf0db9d9..64d00e7fd0 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -184,7 +184,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)\n \tif (strbuf_readlink(&sb, ce->name, expected_size))\n \t\treturn -1;\n \n-\tbuffer = read_sha1_file(ce->oid.hash, &type, &size);\n+\tbuffer = read_object_file(&ce->oid, &type, &size);\n \tif (buffer) {\n \t\tif (size == sb.len)\n \t\t\tmatch = memcmp(buffer, sb.buf, size);\n@@ -2683,7 +2683,7 @@ void *read_blob_data_from_index(const struct index_state *istate,\n \t}\n \tif (pos < 0)\n \t\treturn NULL;\n-\tdata = read_sha1_file(istate->cache[pos]->oid.hash, &type, &sz);\n+\tdata = read_object_file(&istate->cache[pos]->oid, &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn NULL;\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 62834f7153..07cc454d0f 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -728,7 +728,7 @@ int verify_ref_format(struct ref_format *format)\n static void *get_obj(const struct object_id *oid, struct object **obj, unsigned long *sz, int *eaten)\n {\n \tenum object_type type;\n-\tvoid *buf = read_sha1_file(oid->hash, &type, sz);\n+\tvoid *buf = read_object_file(oid, &type, sz);\n \n \tif (buf)\n \t\t*obj = parse_object_buffer(oid, type, *sz, buf, eaten);\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex bcebb4c789..c4bb9a8ba9 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -61,7 +61,7 @@ static char *read_ref_note(const struct object_id *oid)\n \tinit_notes(NULL, notes_ref, NULL, 0);\n \tif (!(note_oid = get_note(NULL, oid)))\n \t\treturn NULL;\t/* note tree not found */\n-\tif (!(msg = read_sha1_file(note_oid->hash, &type, &msglen)))\n+\tif (!(msg = read_object_file(note_oid, &type, &msglen)))\n \t\terror(\"Empty notes tree. %s\", notes_ref);\n \telse if (!msglen || type != OBJ_BLOB) {\n \t\terror(\"Note contains unusable content. \"\n@@ -108,7 +108,7 @@ static int note2mark_cb(const struct object_id *object_oid,\n \tenum object_type type;\n \tstruct rev_note note;\n \n-\tif (!(msg = read_sha1_file(note_oid->hash, &type, &msglen)) ||\n+\tif (!(msg = read_object_file(note_oid, &type, &msglen)) ||\n \t\t\t!msglen || type != OBJ_BLOB) {\n \t\tfree(msg);\n \t\treturn 1;\ndiff --git a/rerere.c b/rerere.c\nindex 79203c6c1e..8af6b660e0 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -981,8 +981,8 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu\n \t\t\tbreak;\n \t\ti = ce_stage(ce) - 1;\n \t\tif (!mmfile[i].ptr) {\n-\t\t\tmmfile[i].ptr = read_sha1_file(ce->oid.hash, &type,\n-\t\t\t\t\t\t       &size);\n+\t\t\tmmfile[i].ptr = read_object_file(&ce->oid, &type,\n+\t\t\t\t\t\t\t &size);\n \t\t\tmmfile[i].size = size;\n \t\t}\n \t}\ndiff --git a/sha1_file.c b/sha1_file.c\nindex bf8a713185..7493bc7f11 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1363,17 +1363,17 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type,\n  * deal with them should arrange to call read_object() and give error\n  * messages themselves.\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      int lookup_replace)\n+void *read_object_file_extended(const struct object_id *oid,\n+\t\t\t\tenum object_type *type,\n+\t\t\t\tunsigned long *size,\n+\t\t\t\tint lookup_replace)\n {\n \tvoid *data;\n \tconst struct packed_git *p;\n \tconst char *path;\n \tstruct stat st;\n-\tconst unsigned char *repl = lookup_replace ? lookup_replace_object(sha1)\n-\t\t\t\t\t\t   : sha1;\n+\tconst unsigned char *repl = lookup_replace ? lookup_replace_object(oid->hash)\n+\t\t\t\t\t\t   : oid->hash;\n \n \terrno = 0;\n \tdata = read_object(repl, type, size);\n@@ -1381,12 +1381,12 @@ void *read_sha1_file_extended(const unsigned char *sha1,\n \t\treturn data;\n \n \tif (errno && errno != ENOENT)\n-\t\tdie_errno(\"failed to read object %s\", sha1_to_hex(sha1));\n+\t\tdie_errno(\"failed to read object %s\", oid_to_hex(oid));\n \n \t/* die if we replaced an object with one that does not exist */\n-\tif (repl != sha1)\n+\tif (repl != oid->hash)\n \t\tdie(\"replacement %s not found for %s\",\n-\t\t    sha1_to_hex(repl), sha1_to_hex(sha1));\n+\t\t    sha1_to_hex(repl), oid_to_hex(oid));\n \n \tif (!stat_sha1_file(repl, &st, &path))\n \t\tdie(\"loose object %s (stored in %s) is corrupt\",\n@@ -1415,7 +1415,7 @@ void *read_object_with_reference(const struct object_id *oid,\n \t\tint ref_length = -1;\n \t\tconst char *ref_type = NULL;\n \n-\t\tbuffer = read_sha1_file(actual_oid.hash, &type, &isize);\n+\t\tbuffer = read_object_file(&actual_oid, &type, &isize);\n \t\tif (!buffer)\n \t\t\treturn NULL;\n \t\tif (type == required_type) {\ndiff --git a/streaming.c b/streaming.c\nindex 3f4be1ea2c..72a3ca8d08 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -492,7 +492,7 @@ static struct stream_vtbl incore_vtbl = {\n \n static open_method_decl(incore)\n {\n-\tst->u.incore.buf = read_sha1_file_extended(oid->hash, type, &st->size, 0);\n+\tst->u.incore.buf = read_object_file_extended(oid, type, &st->size, 0);\n \tst->u.incore.read_ptr = 0;\n \tst->vtbl = &incore_vtbl;\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex 602ba8ca8b..3f2075764f 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -520,7 +520,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,\n \tif (submodule)\n \t\tgoto out;\n \n-\tconfig = read_sha1_file(oid.hash, &type, &config_size);\n+\tconfig = read_object_file(&oid, &type, &config_size);\n \tif (!config || type != OBJ_BLOB)\n \t\tgoto out;\n \ndiff --git a/tag.c b/tag.c\nindex ea963e406a..0354a0cc7e 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -49,7 +49,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \t\t\t\tfind_unique_abbrev(oid, DEFAULT_ABBREV),\n \t\t\t\ttypename(type));\n \n-\tbuf = read_sha1_file(oid->hash, &type, &size);\n+\tbuf = read_object_file(oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"%s: unable to read file.\",\n \t\t\t\tname_to_report ?\n@@ -182,7 +182,7 @@ int parse_tag(struct tag *item)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tdata = read_sha1_file(item->object.oid.hash, &type, &size);\n+\tdata = read_object_file(&item->object.oid, &type, &size);\n \tif (!data)\n \t\treturn error(\"Could not read %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\ndiff --git a/tree-walk.c b/tree-walk.c\nindex b7e504070c..e11b3063af 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -713,8 +713,8 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s\n \t\t\t */\n \t\t\tretval = DANGLING_SYMLINK;\n \n-\t\t\tcontents = read_sha1_file(current_tree_oid.hash, &type,\n-\t\t\t\t\t\t  &link_len);\n+\t\t\tcontents = read_object_file(&current_tree_oid, &type,\n+\t\t\t\t\t\t    &link_len);\n \n \t\t\tif (!contents)\n \t\t\t\tgoto done;\ndiff --git a/tree.c b/tree.c\nindex 1a0f03f520..1c68ea586b 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 \tif (item->object.parsed)\n \t\treturn 0;\n-\tbuffer = read_sha1_file(item->object.oid.hash, &type, &size);\n+\tbuffer = read_object_file(&item->object.oid, &type, &size);\n \tif (!buffer)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 770e1f7f81..9315bc0ede 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -191,7 +191,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n \t\treturn;\n \t}\n \n-\tptr->ptr = read_sha1_file(oid->hash, &type, &size);\n+\tptr->ptr = read_object_file(oid, &type, &size);\n \tif (!ptr->ptr || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \tptr->size = size;\n"},{"id":"339666","messageId":"20180219225927.386065-35-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 34/36] Convert lookup_replace_object to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:25Z","receivedAt":"2018-02-19T23:00:42Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert both the argument and the return value to be pointers to struct\nobject_id.  Update the callers and their internals to deal with the new\ntype.  Remove several temporaries which are no longer needed.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/mktag.c  |  7 ++-----\n cache.h          |  8 ++++----\n object.c         | 14 ++++----------\n replace_object.c | 14 +++++++-------\n sha1_file.c      | 44 ++++++++++++++++++++------------------------\n streaming.c      | 16 +++++-----------\n 6 files changed, 42 insertions(+), 61 deletions(-)\n\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex cfb777b3c8..9f5a50a8fd 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -24,14 +24,11 @@ static int verify_object(const struct object_id *oid, const char *expected_type)\n \tenum object_type type;\n \tunsigned long size;\n \tvoid *buffer = read_object_file(oid, &type, &size);\n-\tconst unsigned char *repl = lookup_replace_object(oid->hash);\n+\tconst struct object_id *repl = lookup_replace_object(oid);\n \n \tif (buffer) {\n-\t\tstruct object_id reploid;\n-\t\thashcpy(reploid.hash, repl);\n-\n \t\tif (type == type_from_string(expected_type))\n-\t\t\tret = check_object_signature(&reploid, buffer, size, expected_type);\n+\t\t\tret = check_object_signature(repl, buffer, size, expected_type);\n \t\tfree(buffer);\n \t}\n \treturn ret;\ndiff --git a/cache.h b/cache.h\nindex 970d6edd04..a70c52b22f 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1197,7 +1197,7 @@ static inline void *read_object_file(const struct object_id *oid, enum object_ty\n  * This internal function is only declared here for the benefit of\n  * lookup_replace_object().  Please do not call it directly.\n  */\n-extern const unsigned char *do_lookup_replace_object(const unsigned char *sha1);\n+extern const struct object_id *do_lookup_replace_object(const struct object_id *oid);\n \n /*\n  * If object sha1 should be replaced, return the replacement object's\n@@ -1205,11 +1205,11 @@ extern const unsigned char *do_lookup_replace_object(const unsigned char *sha1);\n  * either sha1 or a pointer to a permanently-allocated value.  When\n  * object replacement is suppressed, always return sha1.\n  */\n-static inline const unsigned char *lookup_replace_object(const unsigned char *sha1)\n+static inline const struct object_id *lookup_replace_object(const struct object_id *oid)\n {\n \tif (!check_replace_refs)\n-\t\treturn sha1;\n-\treturn do_lookup_replace_object(sha1);\n+\t\treturn oid;\n+\treturn do_lookup_replace_object(oid);\n }\n \n /* Read and unpack an object file into memory, write memory to an object file */\ndiff --git a/object.c b/object.c\nindex ea1a6f18e8..4e1c065d55 100644\n--- a/object.c\n+++ b/object.c\n@@ -244,7 +244,7 @@ struct object *parse_object(const struct object_id *oid)\n \tunsigned long size;\n \tenum object_type type;\n \tint eaten;\n-\tconst unsigned char *repl = lookup_replace_object(oid->hash);\n+\tconst struct object_id *repl = lookup_replace_object(oid);\n \tvoid *buffer;\n \tstruct object *obj;\n \n@@ -255,10 +255,7 @@ struct object *parse_object(const struct object_id *oid)\n \tif ((obj && obj->type == OBJ_BLOB && has_object_file(oid)) ||\n \t    (!obj && has_object_file(oid) &&\n \t     oid_object_info(oid, NULL) == OBJ_BLOB)) {\n-\t\tstruct object_id reploid;\n-\t\thashcpy(reploid.hash, repl);\n-\n-\t\tif (check_object_signature(&reploid, NULL, 0, NULL) < 0) {\n+\t\tif (check_object_signature(repl, NULL, 0, NULL) < 0) {\n \t\t\terror(\"sha1 mismatch %s\", oid_to_hex(oid));\n \t\t\treturn NULL;\n \t\t}\n@@ -268,12 +265,9 @@ struct object *parse_object(const struct object_id *oid)\n \n \tbuffer = read_object_file(oid, &type, &size);\n \tif (buffer) {\n-\t\tstruct object_id reploid;\n-\t\thashcpy(reploid.hash, repl);\n-\n-\t\tif (check_object_signature(&reploid, buffer, size, typename(type)) < 0) {\n+\t\tif (check_object_signature(repl, buffer, size, typename(type)) < 0) {\n \t\t\tfree(buffer);\n-\t\t\terror(\"sha1 mismatch %s\", sha1_to_hex(repl));\n+\t\t\terror(\"sha1 mismatch %s\", oid_to_hex(repl));\n \t\t\treturn NULL;\n \t\t}\n \ndiff --git a/replace_object.c b/replace_object.c\nindex 232e8b8550..336357394d 100644\n--- a/replace_object.c\n+++ b/replace_object.c\n@@ -92,16 +92,16 @@ static void prepare_replace_object(void)\n #define MAXREPLACEDEPTH 5\n \n /*\n- * If a replacement for object sha1 has been set up, return the\n+ * If a replacement for object oid has been set up, return the\n  * replacement object's name (replaced recursively, if necessary).\n- * The return value is either sha1 or a pointer to a\n+ * The return value is either oid or a pointer to a\n  * permanently-allocated value.  This function always respects replace\n  * references, regardless of the value of check_replace_refs.\n  */\n-const unsigned char *do_lookup_replace_object(const unsigned char *sha1)\n+const struct object_id *do_lookup_replace_object(const struct object_id *oid)\n {\n \tint pos, depth = MAXREPLACEDEPTH;\n-\tconst unsigned char *cur = sha1;\n+\tconst struct object_id *cur = oid;\n \n \tprepare_replace_object();\n \n@@ -109,11 +109,11 @@ const unsigned char *do_lookup_replace_object(const unsigned char *sha1)\n \tdo {\n \t\tif (--depth < 0)\n \t\t\tdie(\"replace depth too high for object %s\",\n-\t\t\t    sha1_to_hex(sha1));\n+\t\t\t    oid_to_hex(oid));\n \n-\t\tpos = replace_object_pos(cur);\n+\t\tpos = replace_object_pos(cur->hash);\n \t\tif (0 <= pos)\n-\t\t\tcur = replace_object[pos]->replacement.hash;\n+\t\t\tcur = &replace_object[pos]->replacement;\n \t} while (0 <= pos);\n \n \treturn cur;\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 7493bc7f11..c41fbe2f01 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1227,22 +1227,18 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi\n \tstatic struct object_info blank_oi = OBJECT_INFO_INIT;\n \tstruct pack_entry e;\n \tint rtype;\n-\tconst unsigned char *real = (flags & OBJECT_INFO_LOOKUP_REPLACE) ?\n-\t\t\t\t    lookup_replace_object(oid->hash) :\n-\t\t\t\t    oid->hash;\n+\tconst struct object_id *real = (flags & OBJECT_INFO_LOOKUP_REPLACE) ?\n+\t\t\t\t       lookup_replace_object(oid) :\n+\t\t\t\t       oid;\n \tint already_retried = 0;\n-\tstruct object_id realoid;\n-\n-\thashcpy(realoid.hash, real);\n-\n-\tif (is_null_sha1(real))\n+\tif (is_null_oid(real))\n \t\treturn -1;\n \n \tif (!oi)\n \t\toi = &blank_oi;\n \n \tif (!(flags & OBJECT_INFO_SKIP_CACHED)) {\n-\t\tstruct cached_object *co = find_cached_object(real);\n+\t\tstruct cached_object *co = find_cached_object(real->hash);\n \t\tif (co) {\n \t\t\tif (oi->typep)\n \t\t\t\t*(oi->typep) = co->type;\n@@ -1262,16 +1258,16 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi\n \t}\n \n \twhile (1) {\n-\t\tif (find_pack_entry(real, &e))\n+\t\tif (find_pack_entry(real->hash, &e))\n \t\t\tbreak;\n \n \t\t/* Most likely it's a loose object. */\n-\t\tif (!sha1_loose_object_info(real, oi, flags))\n+\t\tif (!sha1_loose_object_info(real->hash, oi, flags))\n \t\t\treturn 0;\n \n \t\t/* Not a loose object; someone else may have just packed it. */\n \t\treprepare_packed_git();\n-\t\tif (find_pack_entry(real, &e))\n+\t\tif (find_pack_entry(real->hash, &e))\n \t\t\tbreak;\n \n \t\t/* Check if it is a missing object */\n@@ -1281,7 +1277,7 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi\n \t\t\t * TODO Investigate haveing fetch_object() return\n \t\t\t * TODO error/success and stopping the music here.\n \t\t\t */\n-\t\t\tfetch_object(repository_format_partial_clone, real);\n+\t\t\tfetch_object(repository_format_partial_clone, real->hash);\n \t\t\talready_retried = 1;\n \t\t\tcontinue;\n \t\t}\n@@ -1297,8 +1293,8 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi\n \t\treturn 0;\n \trtype = packed_object_info(e.p, e.offset, oi);\n \tif (rtype < 0) {\n-\t\tmark_bad_packed_object(e.p, real);\n-\t\treturn oid_object_info_extended(&realoid, oi, 0);\n+\t\tmark_bad_packed_object(e.p, real->hash);\n+\t\treturn oid_object_info_extended(real, oi, 0);\n \t} else if (oi->whence == OI_PACKED) {\n \t\toi->u.packed.offset = e.offset;\n \t\toi->u.packed.pack = e.p;\n@@ -1372,11 +1368,11 @@ void *read_object_file_extended(const struct object_id *oid,\n \tconst struct packed_git *p;\n \tconst char *path;\n \tstruct stat st;\n-\tconst unsigned char *repl = lookup_replace ? lookup_replace_object(oid->hash)\n-\t\t\t\t\t\t   : oid->hash;\n+\tconst struct object_id *repl = lookup_replace ? lookup_replace_object(oid)\n+\t\t\t\t\t\t      : oid;\n \n \terrno = 0;\n-\tdata = read_object(repl, type, size);\n+\tdata = read_object(repl->hash, type, size);\n \tif (data)\n \t\treturn data;\n \n@@ -1384,17 +1380,17 @@ void *read_object_file_extended(const struct object_id *oid,\n \t\tdie_errno(\"failed to read object %s\", oid_to_hex(oid));\n \n \t/* die if we replaced an object with one that does not exist */\n-\tif (repl != oid->hash)\n+\tif (repl != oid)\n \t\tdie(\"replacement %s not found for %s\",\n-\t\t    sha1_to_hex(repl), oid_to_hex(oid));\n+\t\t    oid_to_hex(repl), oid_to_hex(oid));\n \n-\tif (!stat_sha1_file(repl, &st, &path))\n+\tif (!stat_sha1_file(repl->hash, &st, &path))\n \t\tdie(\"loose object %s (stored in %s) is corrupt\",\n-\t\t    sha1_to_hex(repl), path);\n+\t\t    oid_to_hex(repl), path);\n \n-\tif ((p = has_packed_and_bad(repl)) != NULL)\n+\tif ((p = has_packed_and_bad(repl->hash)) != NULL)\n \t\tdie(\"packed object %s (stored in %s) is corrupt\",\n-\t\t    sha1_to_hex(repl), p->pack_name);\n+\t\t    oid_to_hex(repl), p->pack_name);\n \n \treturn NULL;\n }\ndiff --git a/streaming.c b/streaming.c\nindex 72a3ca8d08..46fabee3aa 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -105,19 +105,16 @@ ssize_t read_istream(struct git_istream *st, void *buf, size_t sz)\n \treturn st->vtbl->read(st, buf, sz);\n }\n \n-static enum input_source istream_source(const unsigned char *sha1,\n+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 \tint status;\n-\tstruct object_id oid;\n-\n-\thashcpy(oid.hash, sha1);\n \n \toi->typep = type;\n \toi->sizep = &size;\n-\tstatus = oid_object_info_extended(&oid, oi, 0);\n+\tstatus = oid_object_info_extended(oid, oi, 0);\n \tif (status < 0)\n \t\treturn stream_error;\n \n@@ -140,18 +137,15 @@ struct git_istream *open_istream(const struct object_id *oid,\n {\n \tstruct git_istream *st;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n-\tconst unsigned char *real = lookup_replace_object(oid->hash);\n+\tconst struct object_id *real = lookup_replace_object(oid);\n \tenum input_source src = istream_source(real, type, &oi);\n-\tstruct object_id realoid;\n-\n-\thashcpy(realoid.hash, real);\n \n \tif (src < 0)\n \t\treturn NULL;\n \n \tst = xmalloc(sizeof(*st));\n-\tif (open_istream_tbl[src](st, &oi, &realoid, type)) {\n-\t\tif (open_istream_incore(st, &oi, &realoid, type)) {\n+\tif (open_istream_tbl[src](st, &oi, real, type)) {\n+\t\tif (open_istream_incore(st, &oi, real, type)) {\n \t\t\tfree(st);\n \t\t\treturn NULL;\n \t\t}\n"},{"id":"339667","messageId":"20180219225927.386065-24-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 23/36] sha1_file: convert retry_bad_packed_offset to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:14Z","receivedAt":"2018-02-19T23:00:44Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n packfile.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/packfile.c b/packfile.c\nindex 5d07f330c8..bfa6438b4e 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1095,13 +1095,13 @@ static int retry_bad_packed_offset(struct packed_git *p, off_t obj_offset)\n {\n \tint type;\n \tstruct revindex_entry *revidx;\n-\tconst unsigned char *sha1;\n+\tstruct object_id oid;\n \trevidx = find_pack_revindex(p, obj_offset);\n \tif (!revidx)\n \t\treturn OBJ_BAD;\n-\tsha1 = nth_packed_object_sha1(p, revidx->nr);\n-\tmark_bad_packed_object(p, sha1);\n-\ttype = sha1_object_info(sha1, NULL);\n+\tnth_packed_object_oid(&oid, p, revidx->nr);\n+\tmark_bad_packed_object(p, oid.hash);\n+\ttype = sha1_object_info(oid.hash, NULL);\n \tif (type <= OBJ_NONE)\n \t\treturn OBJ_BAD;\n \treturn type;\n"},{"id":"339668","messageId":"20180219225927.386065-29-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 28/36] builtin/notes: convert static functions to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:19Z","receivedAt":"2018-02-19T23:00:46Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the remaining static functions to take pointers to struct\nobject_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/notes.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 39304ba743..08ab9d7130 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -118,11 +118,11 @@ static int list_each_note(const struct object_id *object_oid,\n \treturn 0;\n }\n \n-static void copy_obj_to_fd(int fd, const unsigned char *sha1)\n+static void copy_obj_to_fd(int fd, const struct object_id *oid)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = read_sha1_file(sha1, &type, &size);\n+\tchar *buf = read_sha1_file(oid->hash, &type, &size);\n \tif (buf) {\n \t\tif (size)\n \t\t\twrite_or_die(fd, buf, size);\n@@ -162,7 +162,7 @@ static void write_commented_object(int fd, const struct object_id *object)\n }\n \n static void prepare_note_data(const struct object_id *object, struct note_data *d,\n-\t\tconst unsigned char *old_note)\n+\t\tconst struct object_id *old_note)\n {\n \tif (d->use_editor || !d->given) {\n \t\tint fd;\n@@ -457,7 +457,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \t\t\toid_to_hex(&object));\n \t}\n \n-\tprepare_note_data(&object, &d, note ? note->hash : NULL);\n+\tprepare_note_data(&object, &d, note);\n \tif (d.buf.len || allow_empty) {\n \t\twrite_note_data(&d, &new_note);\n \t\tif (add_note(t, &object, &new_note, combine_notes_overwrite))\n@@ -602,7 +602,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \tt = init_notes_check(argv[0], NOTES_INIT_WRITABLE);\n \tnote = get_note(t, &object);\n \n-\tprepare_note_data(&object, &d, edit && note ? note->hash : NULL);\n+\tprepare_note_data(&object, &d, edit && note ? note : NULL);\n \n \tif (note && !edit) {\n \t\t/* Append buf to previous note contents */\n"},{"id":"339669","messageId":"20180219225927.386065-31-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 30/36] streaming: convert istream internals to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:21Z","receivedAt":"2018-02-19T23:00:48Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the various open_istream variants to take a pointer to struct\nobject_id.  Introduce a temporary, which will be removed later, to work\naround the fact that lookup_replace_object still returns a pointer to\nunsigned char.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n streaming.c | 15 +++++++++------\n 1 file changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/streaming.c b/streaming.c\nindex 344678e95f..3f4be1ea2c 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -14,7 +14,7 @@ enum input_source {\n \n typedef int (*open_istream_fn)(struct git_istream *,\n \t\t\t       struct object_info *,\n-\t\t\t       const unsigned char *,\n+\t\t\t       const struct object_id *,\n \t\t\t       enum object_type *);\n typedef int (*close_istream_fn)(struct git_istream *);\n typedef ssize_t (*read_istream_fn)(struct git_istream *, char *, size_t);\n@@ -27,7 +27,7 @@ struct stream_vtbl {\n #define open_method_decl(name) \\\n \tint open_istream_ ##name \\\n \t(struct git_istream *st, struct object_info *oi, \\\n-\t const unsigned char *sha1, \\\n+\t const struct object_id *oid, \\\n \t enum object_type *type)\n \n #define close_method_decl(name) \\\n@@ -142,13 +142,16 @@ struct git_istream *open_istream(const struct object_id *oid,\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tconst unsigned char *real = lookup_replace_object(oid->hash);\n \tenum input_source src = istream_source(real, type, &oi);\n+\tstruct object_id realoid;\n+\n+\thashcpy(realoid.hash, real);\n \n \tif (src < 0)\n \t\treturn NULL;\n \n \tst = xmalloc(sizeof(*st));\n-\tif (open_istream_tbl[src](st, &oi, real, type)) {\n-\t\tif (open_istream_incore(st, &oi, real, type)) {\n+\tif (open_istream_tbl[src](st, &oi, &realoid, type)) {\n+\t\tif (open_istream_incore(st, &oi, &realoid, type)) {\n \t\t\tfree(st);\n \t\t\treturn NULL;\n \t\t}\n@@ -338,7 +341,7 @@ static struct stream_vtbl loose_vtbl = {\n \n static open_method_decl(loose)\n {\n-\tst->u.loose.mapped = map_sha1_file(sha1, &st->u.loose.mapsize);\n+\tst->u.loose.mapped = map_sha1_file(oid->hash, &st->u.loose.mapsize);\n \tif (!st->u.loose.mapped)\n \t\treturn -1;\n \tif ((unpack_sha1_header(&st->z,\n@@ -489,7 +492,7 @@ static struct stream_vtbl incore_vtbl = {\n \n static open_method_decl(incore)\n {\n-\tst->u.incore.buf = read_sha1_file_extended(sha1, type, &st->size, 0);\n+\tst->u.incore.buf = read_sha1_file_extended(oid->hash, type, &st->size, 0);\n \tst->u.incore.read_ptr = 0;\n \tst->vtbl = &incore_vtbl;\n \n"},{"id":"339670","messageId":"20180219225927.386065-37-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 36/36] convert: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:27Z","receivedAt":"2018-02-19T23:00:52Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert convert.c to struct object_id.  Add a use of the_hash_algo to\nreplace hard-coded constants and change a strbuf_add to a strbuf_addstr\nto avoid another hard-coded constant.\n\nNote that a strict conversion using the hexsz constant would cause\nproblems in the future if the internal and user-visible hash algorithms\ndiffered, as anticipated by the hash function transition plan.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n convert.c | 12 ++++++------\n convert.h |  2 +-\n entry.c   |  2 +-\n 3 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex cc562f6509..c480097a2a 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -914,7 +914,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,\n \t\tto_free = strbuf_detach(buf, NULL);\n \thash_object_file(src, len, \"blob\", &oid);\n \n-\tstrbuf_grow(buf, len + cnt * 43);\n+\tstrbuf_grow(buf, len + cnt * (the_hash_algo->hexsz + 3));\n \tfor (;;) {\n \t\t/* step 1: run to the next '$' */\n \t\tdollar = memchr(src, '$', len);\n@@ -1510,7 +1510,7 @@ struct ident_filter {\n \tstruct stream_filter filter;\n \tstruct strbuf left;\n \tint state;\n-\tchar ident[45]; /* \": x40 $\" */\n+\tchar ident[GIT_MAX_HEXSZ + 5]; /* \": x40 $\" */\n };\n \n static int is_foreign_ident(const char *str)\n@@ -1635,12 +1635,12 @@ static struct stream_filter_vtbl ident_vtbl = {\n \tident_free_fn,\n };\n \n-static struct stream_filter *ident_filter(const unsigned char *sha1)\n+static struct stream_filter *ident_filter(const struct object_id *oid)\n {\n \tstruct ident_filter *ident = xmalloc(sizeof(*ident));\n \n \txsnprintf(ident->ident, sizeof(ident->ident),\n-\t\t  \": %s $\", sha1_to_hex(sha1));\n+\t\t  \": %s $\", oid_to_hex(oid));\n \tstrbuf_init(&ident->left, 0);\n \tident->filter.vtbl = &ident_vtbl;\n \tident->state = 0;\n@@ -1655,7 +1655,7 @@ static struct stream_filter *ident_filter(const unsigned char *sha1)\n  * Note that you would be crazy to set CRLF, smuge/clean or ident to a\n  * large binary blob you would want us not to slurp into the memory!\n  */\n-struct stream_filter *get_stream_filter(const char *path, const unsigned char *sha1)\n+struct stream_filter *get_stream_filter(const char *path, const struct object_id *oid)\n {\n \tstruct conv_attrs ca;\n \tstruct stream_filter *filter = NULL;\n@@ -1668,7 +1668,7 @@ struct stream_filter *get_stream_filter(const char *path, const unsigned char *s\n \t\treturn NULL;\n \n \tif (ca.ident)\n-\t\tfilter = ident_filter(sha1);\n+\t\tfilter = ident_filter(oid);\n \n \tif (output_eol(ca.crlf_action) == EOL_CRLF)\n \t\tfilter = cascade_filter(filter, lf_to_crlf_filter());\ndiff --git a/convert.h b/convert.h\nindex 65ab3e5167..2e9b4f49cc 100644\n--- a/convert.h\n+++ b/convert.h\n@@ -93,7 +93,7 @@ extern int would_convert_to_git_filter_fd(const char *path);\n \n struct stream_filter; /* opaque */\n \n-extern struct stream_filter *get_stream_filter(const char *path, const unsigned char *);\n+extern struct stream_filter *get_stream_filter(const char *path, const struct object_id *);\n extern void free_stream_filter(struct stream_filter *);\n extern int is_null_stream_filter(struct stream_filter *);\n \ndiff --git a/entry.c b/entry.c\nindex 3f21d2c913..49b83f4a97 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -266,7 +266,7 @@ static int write_entry(struct cache_entry *ce,\n \n \tif (ce_mode_s_ifmt == S_IFREG) {\n \t\tstruct stream_filter *filter = get_stream_filter(ce->name,\n-\t\t\t\t\t\t\t\t ce->oid.hash);\n+\t\t\t\t\t\t\t\t &ce->oid);\n \t\tif (filter &&\n \t\t    !streaming_write_entry(ce, path, filter,\n \t\t\t\t\t   state, to_tempfile,\n"},{"id":"339671","messageId":"20180219225927.386065-26-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 25/36] Convert remaining callers of sha1_object_info_extended to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:16Z","receivedAt":"2018-02-19T23:00:57Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the remaining caller of sha1_object_info_extended to use struct\nobject_id.  Introduce temporaries, which will be removed later, since\nthere is a dependency loop between sha1_object_info_extended and\nlookup_replace_object_extended.  This allows us to convert the code in a\npiecemeal fashion instead of all at once.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n sha1_file.c | 14 +++++++++++---\n streaming.c |  5 ++++-\n 2 files changed, 15 insertions(+), 4 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex fa69d86309..19995766b6 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1231,6 +1231,9 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,\n \t\t\t\t    lookup_replace_object(sha1) :\n \t\t\t\t    sha1;\n \tint already_retried = 0;\n+\tstruct object_id realoid;\n+\n+\thashcpy(realoid.hash, real);\n \n \tif (is_null_sha1(real))\n \t\treturn -1;\n@@ -1295,7 +1298,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,\n \trtype = packed_object_info(e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real);\n-\t\treturn sha1_object_info_extended(real, oi, 0);\n+\t\treturn sha1_object_info_extended(realoid.hash, oi, 0);\n \t} else if (oi->whence == OI_PACKED) {\n \t\toi->u.packed.offset = e.offset;\n \t\toi->u.packed.pack = e.p;\n@@ -1323,13 +1326,16 @@ int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)\n static void *read_object(const unsigned char *sha1, enum object_type *type,\n \t\t\t unsigned long *size)\n {\n+\tstruct object_id oid;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tvoid *content;\n \toi.typep = type;\n \toi.sizep = size;\n \toi.contentp = &content;\n \n-\tif (sha1_object_info_extended(sha1, &oi, 0) < 0)\n+\thashcpy(oid.hash, sha1);\n+\n+\tif (sha1_object_info_extended(oid.hash, &oi, 0) < 0)\n \t\treturn NULL;\n \treturn content;\n }\n@@ -1723,9 +1729,11 @@ int force_object_loose(const struct object_id *oid, time_t mtime)\n \n int has_sha1_file_with_flags(const unsigned char *sha1, int flags)\n {\n+\tstruct object_id oid;\n \tif (!startup_info->have_repository)\n \t\treturn 0;\n-\treturn sha1_object_info_extended(sha1, NULL,\n+\thashcpy(oid.hash, sha1);\n+\treturn sha1_object_info_extended(oid.hash, NULL,\n \t\t\t\t\t flags | OBJECT_INFO_SKIP_CACHED) >= 0;\n }\n \ndiff --git a/streaming.c b/streaming.c\nindex be85507922..042d6082e8 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -111,10 +111,13 @@ static enum input_source istream_source(const unsigned char *sha1,\n {\n \tunsigned long size;\n \tint status;\n+\tstruct object_id oid;\n+\n+\thashcpy(oid.hash, sha1);\n \n \toi->typep = type;\n \toi->sizep = &size;\n-\tstatus = sha1_object_info_extended(sha1, oi, 0);\n+\tstatus = sha1_object_info_extended(oid.hash, oi, 0);\n \tif (status < 0)\n \t\treturn stream_error;\n \n"},{"id":"339672","messageId":"20180219225927.386065-27-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 26/36] sha1_file: convert sha1_object_info* to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:17Z","receivedAt":"2018-02-19T23:01:00Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert sha1_object_info and sha1_object_info_extended to take pointers\nto struct object_id and rename them to use \"oid\" instead of \"sha1\" in\ntheir names.  Update the declaration and definition and apply the\nfollowing semantic patch, plus the standard object_id transforms:\n\n@@\nexpression E1, E2;\n@@\n- sha1_object_info(E1.hash, E2)\n+ oid_object_info(&E1, E2)\n\n@@\nexpression E1, E2;\n@@\n- sha1_object_info(E1->hash, E2)\n+ oid_object_info(E1, E2)\n\n@@\nexpression E1, E2, E3;\n@@\n- sha1_object_info_extended(E1.hash, E2, E3)\n+ oid_object_info_extended(&E1, E2, E3)\n\n@@\nexpression E1, E2, E3;\n@@\n- sha1_object_info_extended(E1->hash, E2, E3)\n+ oid_object_info_extended(E1, E2, E3)\n---\n archive-tar.c            |  2 +-\n archive-zip.c            |  2 +-\n blame.c                  |  4 ++--\n builtin/blame.c          |  2 +-\n builtin/cat-file.c       | 14 +++++++-------\n builtin/describe.c       |  2 +-\n builtin/fast-export.c    |  2 +-\n builtin/fetch.c          |  2 +-\n builtin/fsck.c           |  2 +-\n builtin/index-pack.c     |  4 ++--\n builtin/ls-tree.c        |  2 +-\n builtin/mktree.c         |  2 +-\n builtin/pack-objects.c   |  7 +++----\n builtin/prune.c          |  2 +-\n builtin/replace.c        | 10 +++++-----\n builtin/tag.c            |  4 ++--\n builtin/unpack-objects.c |  2 +-\n cache.h                  |  6 +++---\n diff.c                   |  2 +-\n fast-import.c            | 10 +++++-----\n list-objects-filter.c    |  2 +-\n object.c                 |  2 +-\n pack-bitmap-write.c      |  3 +--\n packfile.c               |  4 ++--\n reachable.c              |  2 +-\n refs.c                   |  2 +-\n remote.c                 |  2 +-\n sequencer.c              |  3 ++-\n sha1_file.c              | 22 +++++++++++-----------\n sha1_name.c              | 12 ++++++------\n streaming.c              |  2 +-\n submodule.c              |  2 +-\n tag.c                    |  2 +-\n 33 files changed, 71 insertions(+), 72 deletions(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 7a0d31d847..3563bcb9f2 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -276,7 +276,7 @@ static int write_tar_entry(struct archiver_args *args,\n \t\tmemcpy(header.name, path, pathlen);\n \n \tif (S_ISREG(mode) && !args->convert &&\n-\t    sha1_object_info(oid->hash, &size) == OBJ_BLOB &&\n+\t    oid_object_info(oid, &size) == OBJ_BLOB &&\n \t    size > big_file_threshold)\n \t\tbuffer = NULL;\n \telse if (S_ISLNK(mode) || S_ISREG(mode)) {\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 18b951b732..6b20bce4d1 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -325,7 +325,7 @@ static int write_zip_entry(struct archiver_args *args,\n \t\tcompressed_size = 0;\n \t\tbuffer = NULL;\n \t} else if (S_ISREG(mode) || S_ISLNK(mode)) {\n-\t\tenum object_type type = sha1_object_info(oid->hash, &size);\n+\t\tenum object_type type = oid_object_info(oid, &size);\n \n \t\tmethod = 0;\n \t\tattr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :\ndiff --git a/blame.c b/blame.c\nindex 1fc22b304b..c1df10cdd2 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -81,7 +81,7 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)\n \t\tunsigned mode;\n \n \t\tif (!get_tree_entry(commit_oid->hash, path, blob_oid.hash, &mode) &&\n-\t\t    sha1_object_info(blob_oid.hash, NULL) == OBJ_BLOB)\n+\t\t    oid_object_info(&blob_oid, NULL) == OBJ_BLOB)\n \t\t\treturn;\n \t}\n \n@@ -506,7 +506,7 @@ static int fill_blob_sha1_and_mode(struct blame_origin *origin)\n \t\t\t   origin->path,\n \t\t\t   origin->blob_oid.hash, &origin->mode))\n \t\tgoto error_out;\n-\tif (sha1_object_info(origin->blob_oid.hash, NULL) != OBJ_BLOB)\n+\tif (oid_object_info(&origin->blob_oid, NULL) != OBJ_BLOB)\n \t\tgoto error_out;\n \treturn 0;\n  error_out:\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex b980e8a1dd..f1a2fd6702 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -655,7 +655,7 @@ static int is_a_rev(const char *name)\n \n \tif (get_oid(name, &oid))\n \t\treturn 0;\n-\treturn OBJ_NONE < sha1_object_info(oid.hash, NULL);\n+\treturn OBJ_NONE < oid_object_info(&oid, NULL);\n }\n \n int cmd_blame(int argc, const char **argv, const char *prefix)\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex cf9ea5c796..3264bada39 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -77,7 +77,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tswitch (opt) {\n \tcase 't':\n \t\toi.typename = &sb;\n-\t\tif (sha1_object_info_extended(oid.hash, &oi, flags) < 0)\n+\t\tif (oid_object_info_extended(&oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \t\tif (sb.len) {\n \t\t\tprintf(\"%s\\n\", sb.buf);\n@@ -88,7 +88,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \n \tcase 's':\n \t\toi.sizep = &size;\n-\t\tif (sha1_object_info_extended(oid.hash, &oi, flags) < 0)\n+\t\tif (oid_object_info_extended(&oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \t\tprintf(\"%lu\\n\", size);\n \t\treturn 0;\n@@ -116,7 +116,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t/* else fallthrough */\n \n \tcase 'p':\n-\t\ttype = sha1_object_info(oid.hash, NULL);\n+\t\ttype = oid_object_info(&oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Not a valid object name %s\", obj_name);\n \n@@ -140,7 +140,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tcase 0:\n \t\tif (type_from_string(exp_type) == OBJ_BLOB) {\n \t\t\tstruct object_id blob_oid;\n-\t\t\tif (sha1_object_info(oid.hash, NULL) == OBJ_TAG) {\n+\t\t\tif (oid_object_info(&oid, NULL) == OBJ_TAG) {\n \t\t\t\tchar *buffer = read_sha1_file(oid.hash, &type, &size);\n \t\t\t\tconst char *target;\n \t\t\t\tif (!skip_prefix(buffer, \"object \", &target) ||\n@@ -150,7 +150,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\t} else\n \t\t\t\toidcpy(&blob_oid, &oid);\n \n-\t\t\tif (sha1_object_info(blob_oid.hash, NULL) == OBJ_BLOB)\n+\t\t\tif (oid_object_info(&blob_oid, NULL) == OBJ_BLOB)\n \t\t\t\treturn stream_blob_to_fd(1, &blob_oid, NULL, 0);\n \t\t\t/*\n \t\t\t * we attempted to dereference a tag to a blob\n@@ -340,8 +340,8 @@ static void batch_object_write(const char *obj_name, struct batch_options *opt,\n \tstruct strbuf buf = STRBUF_INIT;\n \n \tif (!data->skip_object_info &&\n-\t    sha1_object_info_extended(data->oid.hash, &data->info,\n-\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n+\t    oid_object_info_extended(&data->oid, &data->info,\n+\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n \t\tprintf(\"%s missing\\n\",\n \t\t       obj_name ? obj_name : oid_to_hex(&data->oid));\n \t\tfflush(stdout);\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 7e6535a8bd..de840f96a4 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -502,7 +502,7 @@ static void describe(const char *arg, int last_one)\n \n \tif (cmit)\n \t\tdescribe_commit(&oid, &sb);\n-\telse if (sha1_object_info(oid.hash, NULL) == OBJ_BLOB)\n+\telse if (oid_object_info(&oid, NULL) == OBJ_BLOB)\n \t\tdescribe_blob(oid, &sb);\n \telse\n \t\tdie(_(\"%s is neither a commit nor blob\"), arg);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 293a6615fa..02ec19060d 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -947,7 +947,7 @@ static void import_marks(char *input_file)\n \t\tif (last_idnum < mark)\n \t\t\tlast_idnum = mark;\n \n-\t\ttype = sha1_object_info(oid.hash, NULL);\n+\t\ttype = oid_object_info(&oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(&oid));\n \ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 3b8988e51d..81076d698c 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -626,7 +626,7 @@ static int update_local_ref(struct ref *ref,\n \tstruct branch *current_branch = branch_get(NULL);\n \tconst char *pretty_ref = prettify_refname(ref->name);\n \n-\ttype = sha1_object_info(ref->new_oid.hash, NULL);\n+\ttype = oid_object_info(&ref->new_oid, NULL);\n \tif (type < 0)\n \t\tdie(_(\"object %s not found\"), oid_to_hex(&ref->new_oid));\n \ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 57509a4eac..e57621cf74 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -65,7 +65,7 @@ static const char *printable_type(struct object *obj)\n \tconst char *ret;\n \n \tif (obj->type == OBJ_NONE) {\n-\t\tenum object_type type = sha1_object_info(obj->oid.hash, NULL);\n+\t\tenum object_type type = oid_object_info(&obj->oid, NULL);\n \t\tif (type > 0)\n \t\t\tobject_as_type(obj, type, 0);\n \t}\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex a0ca525e99..27aa50396b 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -221,7 +221,7 @@ static unsigned check_object(struct object *obj)\n \n \tif (!(obj->flags & FLAG_CHECKED)) {\n \t\tunsigned long size;\n-\t\tint type = sha1_object_info(obj->oid.hash, &size);\n+\t\tint type = oid_object_info(&obj->oid, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n \t\t\t      oid_to_hex(&obj->oid));\n@@ -810,7 +810,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\tenum object_type has_type;\n \t\tunsigned long has_size;\n \t\tread_lock();\n-\t\thas_type = sha1_object_info(oid->hash, &has_size);\n+\t\thas_type = oid_object_info(oid, &has_size);\n \t\tif (has_type < 0)\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex c98253adbb..d44b4f9c27 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\t\tchar size_text[24];\n \t\t\tif (!strcmp(type, blob_type)) {\n \t\t\t\tunsigned long size;\n-\t\t\t\tif (sha1_object_info(oid->hash, &size) == OBJ_BAD)\n+\t\t\t\tif (oid_object_info(oid, &size) == OBJ_BAD)\n \t\t\t\t\txsnprintf(size_text, sizeof(size_text),\n \t\t\t\t\t\t  \"BAD\");\n \t\t\t\telse\ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex d6ca19d835..298ad6665a 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -116,7 +116,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss\n \t}\n \n \t/* Check the type of object identified by sha1 */\n-\tobj_type = sha1_object_info(oid.hash, NULL);\n+\tobj_type = oid_object_info(&oid, NULL);\n \tif (obj_type < 0) {\n \t\tif (allow_missing) {\n \t\t\t; /* no problem - missing objects are presumed to be of the right type */\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex ef63aa5878..f8148eb9d5 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1516,7 +1516,7 @@ static void check_object(struct object_entry *entry)\n \t\tunuse_pack(&w_curs);\n \t}\n \n-\tentry->type = sha1_object_info(entry->idx.oid.hash, &entry->size);\n+\tentry->type = oid_object_info(&entry->idx.oid, &entry->size);\n \t/*\n \t * The error condition is checked in prepare_pack().  This is\n \t * to permit a missing preferred base object to be ignored\n@@ -1578,8 +1578,7 @@ static void drop_reused_delta(struct object_entry *entry)\n \t\t * And if that fails, the error will be recorded in entry->type\n \t\t * and dealt with in prepare_pack().\n \t\t */\n-\t\tentry->type = sha1_object_info(entry->idx.oid.hash,\n-\t\t\t\t\t       &entry->size);\n+\t\tentry->type = oid_object_info(&entry->idx.oid, &entry->size);\n \t}\n }\n \n@@ -2708,7 +2707,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)\n static int add_loose_object(const struct object_id *oid, const char *path,\n \t\t\t    void *data)\n {\n-\tenum object_type type = sha1_object_info(oid->hash, NULL);\n+\tenum object_type type = oid_object_info(oid, NULL);\n \n \tif (type < 0) {\n \t\twarning(\"loose object at %s could not be examined\", path);\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 4cfec82f40..f77a4a4379 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -50,7 +50,7 @@ static int prune_object(const struct object_id *oid, const char *fullpath,\n \tif (st.st_mtime > expire)\n \t\treturn 0;\n \tif (show_only || verbose) {\n-\t\tenum object_type type = sha1_object_info(oid->hash, NULL);\n+\t\tenum object_type type = oid_object_info(oid, NULL);\n \t\tprintf(\"%s %s\\n\", oid_to_hex(oid),\n \t\t       (type > 0) ? typename(type) : \"unknown\");\n \t}\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 83d3235721..1fa40039b4 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -53,8 +53,8 @@ static int show_reference(const char *refname, const struct object_id *oid,\n \t\t\tif (get_oid(refname, &object))\n \t\t\t\treturn error(\"Failed to resolve '%s' as a valid ref.\", refname);\n \n-\t\t\tobj_type = sha1_object_info(object.hash, NULL);\n-\t\t\trepl_type = sha1_object_info(oid->hash, NULL);\n+\t\t\tobj_type = oid_object_info(&object, NULL);\n+\t\t\trepl_type = oid_object_info(oid, NULL);\n \n \t\t\tprintf(\"%s (%s) -> %s (%s)\\n\", refname, typename(obj_type),\n \t\t\t       oid_to_hex(oid), typename(repl_type));\n@@ -162,8 +162,8 @@ static int replace_object_oid(const char *object_ref,\n \tstruct ref_transaction *transaction;\n \tstruct strbuf err = STRBUF_INIT;\n \n-\tobj_type = sha1_object_info(object->hash, NULL);\n-\trepl_type = sha1_object_info(repl->hash, NULL);\n+\tobj_type = oid_object_info(object, NULL);\n+\trepl_type = oid_object_info(repl, NULL);\n \tif (!force && obj_type != repl_type)\n \t\tdie(\"Objects must be of the same type.\\n\"\n \t\t    \"'%s' points to a replaced object of type '%s'\\n\"\n@@ -290,7 +290,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)\n \tif (get_oid(object_ref, &old) < 0)\n \t\tdie(\"Not a valid object name: '%s'\", object_ref);\n \n-\ttype = sha1_object_info(old.hash, NULL);\n+\ttype = oid_object_info(&old, NULL);\n \tif (type < 0)\n \t\tdie(\"unable to get object type for %s\", oid_to_hex(&old));\n \ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 17d6bc0836..3340cbedd4 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -211,7 +211,7 @@ static void create_tag(const struct object_id *object, const char *tag,\n \tstruct strbuf header = STRBUF_INIT;\n \tchar *path = NULL;\n \n-\ttype = sha1_object_info(object->hash, NULL);\n+\ttype = oid_object_info(object, NULL);\n \tif (type <= OBJ_NONE)\n \t    die(_(\"bad object type.\"));\n \n@@ -294,7 +294,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t}\n \n \tstrbuf_addstr(sb, \" (\");\n-\ttype = sha1_object_info(oid->hash, NULL);\n+\ttype = oid_object_info(oid, NULL);\n \tswitch (type) {\n \tdefault:\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 7235d2ffbf..6e712081e0 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -198,7 +198,7 @@ static int check_object(struct object *obj, int type, void *data, struct fsck_op\n \n \tif (!(obj->flags & FLAG_OPEN)) {\n \t\tunsigned long size;\n-\t\tint type = sha1_object_info(obj->oid.hash, &size);\n+\t\tint type = oid_object_info(&obj->oid, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n \t\tobj->flags |= FLAG_WRITTEN;\ndiff --git a/cache.h b/cache.h\nindex b1a117e404..b965a073f2 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1212,8 +1212,8 @@ static inline const unsigned char *lookup_replace_object(const unsigned char *sh\n \treturn do_lookup_replace_object(sha1);\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+/* Read and unpack an object file into memory, write memory to an object file */\n+extern int oid_object_info(const struct object_id *, unsigned long *);\n \n extern int hash_object_file(const void *buf, unsigned long len,\n \t\t\t    const char *type, struct object_id *oid);\n@@ -1773,7 +1773,7 @@ struct object_info {\n #define OBJECT_INFO_SKIP_CACHED 4\n /* Do not retry packed storage after checking packed and loose storage */\n #define OBJECT_INFO_QUICK 8\n-extern int sha1_object_info_extended(const unsigned char *, struct object_info *, unsigned flags);\n+extern int oid_object_info_extended(const struct object_id *, struct object_info *, unsigned flags);\n \n /*\n  * Set this to 0 to prevent sha1_object_info_extended() from fetching missing\ndiff --git a/diff.c b/diff.c\nindex 94117bcbbf..d838ee2e9a 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3615,7 +3615,7 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)\n \telse {\n \t\tenum object_type type;\n \t\tif (size_only || (flags & CHECK_BINARY)) {\n-\t\t\ttype = sha1_object_info(s->oid.hash, &s->size);\n+\t\t\ttype = oid_object_info(&s->oid, &s->size);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"unable to read %s\",\n \t\t\t\t    oid_to_hex(&s->oid));\ndiff --git a/fast-import.c b/fast-import.c\nindex 0f818cd932..71b60f9068 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1913,7 +1913,7 @@ static void read_marks(void)\n \t\t\tdie(\"corrupt mark line: %s\", line);\n \t\te = find_object(&oid);\n \t\tif (!e) {\n-\t\t\tenum object_type type = sha1_object_info(oid.hash, NULL);\n+\t\t\tenum object_type type = oid_object_info(&oid, NULL);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"object not found: %s\", oid_to_hex(&oid));\n \t\t\te = insert_object(&oid);\n@@ -2443,7 +2443,7 @@ static void file_change_m(const char *p, struct branch *b)\n \t\tenum object_type expected = S_ISDIR(mode) ?\n \t\t\t\t\t\tOBJ_TREE: OBJ_BLOB;\n \t\tenum object_type type = oe ? oe->type :\n-\t\t\t\t\tsha1_object_info(oid.hash, NULL);\n+\t\t\t\t\toid_object_info(&oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"%s not found: %s\",\n \t\t\t\t\tS_ISDIR(mode) ?  \"Tree\" : \"Blob\",\n@@ -2603,7 +2603,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tdie(\"Not a blob (actually a %s): %s\",\n \t\t\t\ttypename(oe->type), command_buf.buf);\n \t} else if (!is_null_oid(&oid)) {\n-\t\tenum object_type type = sha1_object_info(oid.hash, NULL);\n+\t\tenum object_type type = oid_object_info(&oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Blob not found: %s\", command_buf.buf);\n \t\tif (type != OBJ_BLOB)\n@@ -2890,7 +2890,7 @@ static void parse_new_tag(const char *arg)\n \t} else if (!get_oid(from, &oid)) {\n \t\tstruct object_entry *oe = find_object(&oid);\n \t\tif (!oe) {\n-\t\t\ttype = sha1_object_info(oid.hash, NULL);\n+\t\t\ttype = oid_object_info(&oid, NULL);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"Not a valid object: %s\", from);\n \t\t} else\n@@ -3048,7 +3048,7 @@ static struct object_entry *dereference(struct object_entry *oe,\n \tunsigned long size;\n \tchar *buf = NULL;\n \tif (!oe) {\n-\t\tenum object_type type = sha1_object_info(oid->hash, NULL);\n+\t\tenum object_type type = oid_object_info(oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\t/* cache it! */\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex 4356c45368..0ec83aaf18 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -117,7 +117,7 @@ static enum list_objects_filter_result filter_blobs_limit(\n \t\tassert(obj->type == OBJ_BLOB);\n \t\tassert((obj->flags & SEEN) == 0);\n \n-\t\tt = sha1_object_info(obj->oid.hash, &object_length);\n+\t\tt = oid_object_info(&obj->oid, &object_length);\n \t\tif (t != OBJ_BLOB) { /* probably OBJ_NONE */\n \t\t\t/*\n \t\t\t * We DO NOT have the blob locally, so we cannot\ndiff --git a/object.c b/object.c\nindex c63f02a40f..be8f23271b 100644\n--- a/object.c\n+++ b/object.c\n@@ -254,7 +254,7 @@ struct object *parse_object(const struct object_id *oid)\n \n \tif ((obj && obj->type == OBJ_BLOB && has_object_file(oid)) ||\n \t    (!obj && has_object_file(oid) &&\n-\t     sha1_object_info(oid->hash, NULL) == OBJ_BLOB)) {\n+\t     oid_object_info(oid, NULL) == OBJ_BLOB)) {\n \t\tstruct object_id reploid;\n \t\thashcpy(reploid.hash, repl);\n \ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex e01f992884..41ae27fb19 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -73,8 +73,7 @@ void bitmap_writer_build_type_index(struct pack_idx_entry **index,\n \t\t\tbreak;\n \n \t\tdefault:\n-\t\t\treal_type = sha1_object_info(entry->idx.oid.hash,\n-\t\t\t\t\t\t     NULL);\n+\t\t\treal_type = oid_object_info(&entry->idx.oid, NULL);\n \t\t\tbreak;\n \t\t}\n \ndiff --git a/packfile.c b/packfile.c\nindex ed7b342ebf..9052041e71 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1101,7 +1101,7 @@ static int retry_bad_packed_offset(struct packed_git *p, off_t obj_offset)\n \t\treturn OBJ_BAD;\n \tnth_packed_object_oid(&oid, p, revidx->nr);\n \tmark_bad_packed_object(p, oid.hash);\n-\ttype = sha1_object_info(oid.hash, NULL);\n+\ttype = oid_object_info(&oid, NULL);\n \tif (type <= OBJ_NONE)\n \t\treturn OBJ_BAD;\n \treturn type;\n@@ -1461,7 +1461,7 @@ static void *read_object(const struct object_id *oid, enum object_type *type,\n \toi.sizep = size;\n \toi.contentp = &content;\n \n-\tif (sha1_object_info_extended(oid->hash, &oi, 0) < 0)\n+\tif (oid_object_info_extended(oid, &oi, 0) < 0)\n \t\treturn NULL;\n \treturn content;\n }\ndiff --git a/reachable.c b/reachable.c\nindex 88d7d679da..44c9c0f92c 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -77,7 +77,7 @@ static void add_recent_object(const struct object_id *oid,\n \t * later processing, and the revision machinery expects\n \t * commits and tags to have been parsed.\n \t */\n-\ttype = sha1_object_info(oid->hash, NULL);\n+\ttype = oid_object_info(oid, NULL);\n \tif (type < 0)\n \t\tdie(\"unable to get object info for %s\", oid_to_hex(oid));\n \ndiff --git a/refs.c b/refs.c\nindex 20ba82b434..8b7a77fe5e 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -301,7 +301,7 @@ enum peel_status peel_object(const struct object_id *name, struct object_id *oid\n \tstruct object *o = lookup_unknown_object(name->hash);\n \n \tif (o->type == OBJ_NONE) {\n-\t\tint type = sha1_object_info(name->hash, NULL);\n+\t\tint type = oid_object_info(name, NULL);\n \t\tif (type < 0 || !object_as_type(o, type, 0))\n \t\t\treturn PEEL_INVALID;\n \t}\ndiff --git a/remote.c b/remote.c\nindex 4e93753e19..619ce28a58 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1361,7 +1361,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \t\t\tcontinue; /* not a tag */\n \t\tif (string_list_has_string(&dst_tag, ref->name))\n \t\t\tcontinue; /* they already have it */\n-\t\tif (sha1_object_info(ref->new_oid.hash, NULL) != OBJ_TAG)\n+\t\tif (oid_object_info(&ref->new_oid, NULL) != OBJ_TAG)\n \t\t\tcontinue; /* be conservative */\n \t\titem = string_list_append(&src_tag, ref->name);\n \t\titem->util = ref;\ndiff --git a/sequencer.c b/sequencer.c\nindex ed7c42ba7d..604f3162ed 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2868,7 +2868,8 @@ int sequencer_pick_revisions(struct replay_opts *opts)\n \n \t\tif (!get_oid(name, &oid)) {\n \t\t\tif (!lookup_commit_reference_gently(&oid, 1)) {\n-\t\t\t\tenum object_type type = sha1_object_info(oid.hash, NULL);\n+\t\t\t\tenum object_type type = oid_object_info(&oid,\n+\t\t\t\t\t\t\t\t\tNULL);\n \t\t\t\treturn error(_(\"%s: can't cherry-pick a %s\"),\n \t\t\t\t\tname, typename(type));\n \t\t\t}\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 19995766b6..1719c218e2 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1222,14 +1222,14 @@ static int sha1_loose_object_info(const unsigned char *sha1,\n \n int fetch_if_missing = 1;\n \n-int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi, unsigned flags)\n+int oid_object_info_extended(const struct object_id *oid, struct object_info *oi, unsigned flags)\n {\n \tstatic struct object_info blank_oi = OBJECT_INFO_INIT;\n \tstruct pack_entry e;\n \tint rtype;\n \tconst unsigned char *real = (flags & OBJECT_INFO_LOOKUP_REPLACE) ?\n-\t\t\t\t    lookup_replace_object(sha1) :\n-\t\t\t\t    sha1;\n+\t\t\t\t    lookup_replace_object(oid->hash) :\n+\t\t\t\t    oid->hash;\n \tint already_retried = 0;\n \tstruct object_id realoid;\n \n@@ -1298,7 +1298,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,\n \trtype = packed_object_info(e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real);\n-\t\treturn sha1_object_info_extended(realoid.hash, oi, 0);\n+\t\treturn oid_object_info_extended(&realoid, oi, 0);\n \t} else if (oi->whence == OI_PACKED) {\n \t\toi->u.packed.offset = e.offset;\n \t\toi->u.packed.pack = e.p;\n@@ -1310,15 +1310,15 @@ 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 oid_object_info(const struct object_id *oid, unsigned long *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \n \toi.typep = &type;\n \toi.sizep = sizep;\n-\tif (sha1_object_info_extended(sha1, &oi,\n-\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\tif (oid_object_info_extended(oid, &oi,\n+\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\treturn -1;\n \treturn type;\n }\n@@ -1335,7 +1335,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,\n \n \thashcpy(oid.hash, sha1);\n \n-\tif (sha1_object_info_extended(oid.hash, &oi, 0) < 0)\n+\tif (oid_object_info_extended(&oid, &oi, 0) < 0)\n \t\treturn NULL;\n \treturn content;\n }\n@@ -1733,8 +1733,8 @@ int has_sha1_file_with_flags(const unsigned char *sha1, int flags)\n \tif (!startup_info->have_repository)\n \t\treturn 0;\n \thashcpy(oid.hash, sha1);\n-\treturn sha1_object_info_extended(oid.hash, NULL,\n-\t\t\t\t\t flags | OBJECT_INFO_SKIP_CACHED) >= 0;\n+\treturn oid_object_info_extended(&oid, NULL,\n+\t\t\t\t\tflags | OBJECT_INFO_SKIP_CACHED) >= 0;\n }\n \n int has_object_file(const struct object_id *oid)\n@@ -1976,7 +1976,7 @@ int read_pack_header(int fd, struct pack_header *header)\n \n void assert_oid_type(const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = sha1_object_info(oid->hash, NULL);\n+\tenum object_type type = oid_object_info(oid, NULL);\n \tif (type < 0)\n \t\tdie(\"%s is not a valid object\", oid_to_hex(oid));\n \tif (type != expect)\ndiff --git a/sha1_name.c b/sha1_name.c\nindex dd68e68f45..6d4c6033c8 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -238,7 +238,7 @@ static int finish_object_disambiguation(struct disambiguate_state *ds,\n \n static int disambiguate_commit_only(const struct object_id *oid, void *cb_data_unused)\n {\n-\tint kind = sha1_object_info(oid->hash, NULL);\n+\tint kind = oid_object_info(oid, NULL);\n \treturn kind == OBJ_COMMIT;\n }\n \n@@ -247,7 +247,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = sha1_object_info(oid->hash, NULL);\n+\tkind = oid_object_info(oid, NULL);\n \tif (kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -262,7 +262,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da\n \n static int disambiguate_tree_only(const struct object_id *oid, void *cb_data_unused)\n {\n-\tint kind = sha1_object_info(oid->hash, NULL);\n+\tint kind = oid_object_info(oid, NULL);\n \treturn kind == OBJ_TREE;\n }\n \n@@ -271,7 +271,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = sha1_object_info(oid->hash, NULL);\n+\tkind = oid_object_info(oid, NULL);\n \tif (kind == OBJ_TREE || kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -286,7 +286,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_\n \n static int disambiguate_blob_only(const struct object_id *oid, void *cb_data_unused)\n {\n-\tint kind = sha1_object_info(oid->hash, NULL);\n+\tint kind = oid_object_info(oid, NULL);\n \treturn kind == OBJ_BLOB;\n }\n \n@@ -365,7 +365,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \tif (ds->fn && !ds->fn(oid, ds->cb_data))\n \t\treturn 0;\n \n-\ttype = sha1_object_info(oid->hash, NULL);\n+\ttype = oid_object_info(oid, NULL);\n \tif (type == OBJ_COMMIT) {\n \t\tstruct commit *commit = lookup_commit(oid);\n \t\tif (commit) {\ndiff --git a/streaming.c b/streaming.c\nindex 042d6082e8..344678e95f 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -117,7 +117,7 @@ static enum input_source istream_source(const unsigned char *sha1,\n \n \toi->typep = type;\n \toi->sizep = &size;\n-\tstatus = sha1_object_info_extended(oid.hash, oi, 0);\n+\tstatus = oid_object_info_extended(&oid, oi, 0);\n \tif (status < 0)\n \t\treturn stream_error;\n \ndiff --git a/submodule.c b/submodule.c\nindex d4a482e647..a2c89224a9 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -817,7 +817,7 @@ static int check_has_commit(const struct object_id *oid, void *data)\n {\n \tstruct has_commit_data *cb = data;\n \n-\tenum object_type type = sha1_object_info(oid->hash, NULL);\n+\tenum object_type type = oid_object_info(oid, NULL);\n \n \tswitch (type) {\n \tcase OBJ_COMMIT:\ndiff --git a/tag.c b/tag.c\nindex 0b63c3f1ec..ea963e406a 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 \tunsigned long size;\n \tint ret;\n \n-\ttype = sha1_object_info(oid->hash, NULL);\n+\ttype = oid_object_info(oid, NULL);\n \tif (type != OBJ_TAG)\n \t\treturn error(\"%s: cannot verify a non-tag object of type %s.\",\n \t\t\t\tname_to_report ?\n"},{"id":"339673","messageId":"20180219225927.386065-28-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 27/36] builtin/fmt-merge-msg: convert remaining code to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:18Z","receivedAt":"2018-02-19T23:01:02Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"We were using the util pointer, which is a pointer to void, as an\nunsigned char pointer.  The pointer actually points to a struct\norigin_data, which has a struct object_id as its first member, which in\nturn has an unsigned char array as its first member, so this was valid.\nSince we want to convert this to struct object_id, simply change the\npointer we're using.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/fmt-merge-msg.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 8e8a15ea4a..0bc0dda99c 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -485,10 +485,10 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \tstruct strbuf tagbuf = STRBUF_INIT;\n \n \tfor (i = 0; i < origins.nr; i++) {\n-\t\tunsigned char *sha1 = origins.items[i].util;\n+\t\tstruct object_id *oid = origins.items[i].util;\n \t\tenum object_type type;\n \t\tunsigned long size, len;\n-\t\tchar *buf = read_sha1_file(sha1, &type, &size);\n+\t\tchar *buf = read_sha1_file(oid->hash, &type, &size);\n \t\tstruct strbuf sig = STRBUF_INIT;\n \n \t\tif (!buf || type != OBJ_TAG)\n"},{"id":"339674","messageId":"20180219225927.386065-20-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 19/36] sha1_file: convert check_sha1_signature to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:10Z","receivedAt":"2018-02-19T23:01:07Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert this function to take a pointer to struct object_id and rename\nit check_object_signature.  Introduce temporaries to convert the return\nvalues of lookup_replace_object and lookup_replace_object_extended into\nstruct object_id.\n\nThe temporaries are needed because in order to convert\nlookup_replace_object, open_istream needs to be converted, and\nopen_istream needs check_sha1_signature to be converted, causing a loop\nof dependencies.  The temporaries will be removed in a future patch.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/fast-export.c |  2 +-\n builtin/index-pack.c  |  2 +-\n builtin/mktag.c       |  5 ++++-\n cache.h               |  2 +-\n object.c              | 10 ++++++++--\n pack-check.c          |  4 ++--\n sha1_file.c           | 12 ++++++------\n 7 files changed, 23 insertions(+), 14 deletions(-)\n\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 796d0cd66c..293a6615fa 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -240,7 +240,7 @@ static void export_blob(const struct object_id *oid)\n \t\tbuf = read_sha1_file(oid->hash, &type, &size);\n \t\tif (!buf)\n \t\t\tdie (\"Could not read blob %s\", oid_to_hex(oid));\n-\t\tif (check_sha1_signature(oid->hash, buf, size, typename(type)) < 0)\n+\t\tif (check_object_signature(oid, buf, size, typename(type)) < 0)\n \t\t\tdie(\"sha1 mismatch in blob %s\", oid_to_hex(oid));\n \t\tobject = parse_object_buffer(oid, type, size, buf, &eaten);\n \t}\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 5c7ab47c36..e0a776f1ac 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -1377,7 +1377,7 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \t\tif (!base_obj->data)\n \t\t\tcontinue;\n \n-\t\tif (check_sha1_signature(d->oid.hash, base_obj->data,\n+\t\tif (check_object_signature(&d->oid, base_obj->data,\n \t\t\t\tbase_obj->size, typename(type)))\n \t\t\tdie(_(\"local object %s is corrupt\"), oid_to_hex(&d->oid));\n \t\tbase_obj->obj = append_obj_to_pack(f, d->oid.hash,\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 65bb41e3cd..810b24bef3 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -27,8 +27,11 @@ static int verify_object(const struct object_id *oid, const char *expected_type)\n \tconst unsigned char *repl = lookup_replace_object(oid->hash);\n \n \tif (buffer) {\n+\t\tstruct object_id reploid;\n+\t\thashcpy(reploid.hash, repl);\n+\n \t\tif (type == type_from_string(expected_type))\n-\t\t\tret = check_sha1_signature(repl, buffer, size, expected_type);\n+\t\t\tret = check_object_signature(&reploid, buffer, size, expected_type);\n \t\tfree(buffer);\n \t}\n \treturn ret;\ndiff --git a/cache.h b/cache.h\nindex 8a9055f4e7..f29ff43bbd 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1236,7 +1236,7 @@ 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 \n-extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);\n+extern int check_object_signature(const struct object_id *oid, void *buf, unsigned long size, const char *type);\n \n extern int finalize_object_file(const char *tmpfile, const char *filename);\n \ndiff --git a/object.c b/object.c\nindex 9e6f9ff20b..c63f02a40f 100644\n--- a/object.c\n+++ b/object.c\n@@ -255,7 +255,10 @@ struct object *parse_object(const struct object_id *oid)\n \tif ((obj && obj->type == OBJ_BLOB && has_object_file(oid)) ||\n \t    (!obj && has_object_file(oid) &&\n \t     sha1_object_info(oid->hash, NULL) == OBJ_BLOB)) {\n-\t\tif (check_sha1_signature(repl, NULL, 0, NULL) < 0) {\n+\t\tstruct object_id reploid;\n+\t\thashcpy(reploid.hash, repl);\n+\n+\t\tif (check_object_signature(&reploid, NULL, 0, NULL) < 0) {\n \t\t\terror(\"sha1 mismatch %s\", oid_to_hex(oid));\n \t\t\treturn NULL;\n \t\t}\n@@ -265,7 +268,10 @@ struct object *parse_object(const struct object_id *oid)\n \n \tbuffer = read_sha1_file(oid->hash, &type, &size);\n \tif (buffer) {\n-\t\tif (check_sha1_signature(repl, buffer, size, typename(type)) < 0) {\n+\t\tstruct object_id reploid;\n+\t\thashcpy(reploid.hash, repl);\n+\n+\t\tif (check_object_signature(&reploid, buffer, size, typename(type)) < 0) {\n \t\t\tfree(buffer);\n \t\t\terror(\"sha1 mismatch %s\", sha1_to_hex(repl));\n \t\t\treturn NULL;\ndiff --git a/pack-check.c b/pack-check.c\nindex 403a572567..80ef7c1c63 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -126,7 +126,7 @@ static int verify_packfile(struct packed_git *p,\n \n \t\tif (type == OBJ_BLOB && big_file_threshold <= size) {\n \t\t\t/*\n-\t\t\t * Let check_sha1_signature() check it with\n+\t\t\t * Let check_object_signature() check it with\n \t\t\t * the streaming interface; no point slurping\n \t\t\t * the data in-core only to discard.\n \t\t\t */\n@@ -141,7 +141,7 @@ static int verify_packfile(struct packed_git *p,\n \t\t\terr = error(\"cannot unpack %s from %s at offset %\"PRIuMAX\"\",\n \t\t\t\t    oid_to_hex(entries[i].oid.oid), p->pack_name,\n \t\t\t\t    (uintmax_t)entries[i].offset);\n-\t\telse if (check_sha1_signature(entries[i].oid.hash, data, size, typename(type)))\n+\t\telse if (check_object_signature(entries[i].oid.oid, data, size, typename(type)))\n \t\t\terr = error(\"packed %s from %s is corrupt\",\n \t\t\t\t    oid_to_hex(entries[i].oid.oid), p->pack_name);\n \t\telse if (fn) {\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 69e8d27773..64f0905799 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -784,8 +784,8 @@ void *xmmap(void *start, size_t length,\n  * With \"map\" == NULL, try reading the object named with \"sha1\" using\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+int check_object_signature(const struct object_id *oid, void *map,\n+\t\t\t   unsigned long size, const char *type)\n {\n \tstruct object_id real_oid;\n \tenum object_type obj_type;\n@@ -796,10 +796,10 @@ int check_sha1_signature(const unsigned char *sha1, void *map,\n \n \tif (map) {\n \t\thash_object_file(map, size, type, &real_oid);\n-\t\treturn hashcmp(sha1, real_oid.hash) ? -1 : 0;\n+\t\treturn oidcmp(oid, &real_oid) ? -1 : 0;\n \t}\n \n-\tst = open_istream(sha1, &obj_type, &size, NULL);\n+\tst = open_istream(oid->hash, &obj_type, &size, NULL);\n \tif (!st)\n \t\treturn -1;\n \n@@ -823,7 +823,7 @@ int check_sha1_signature(const unsigned char *sha1, void *map,\n \t}\n \tthe_hash_algo->final_fn(real_oid.hash, &c);\n \tclose_istream(st);\n-\treturn hashcmp(sha1, real_oid.hash) ? -1 : 0;\n+\treturn oidcmp(oid, &real_oid) ? -1 : 0;\n }\n \n int git_open_cloexec(const char *name, int flags)\n@@ -2217,7 +2217,7 @@ int read_loose_object(const char *path,\n \t\t\tgit_inflate_end(&stream);\n \t\t\tgoto out;\n \t\t}\n-\t\tif (check_sha1_signature(expected_oid->hash, *contents,\n+\t\tif (check_object_signature(expected_oid, *contents,\n \t\t\t\t\t *size, typename(*type))) {\n \t\t\terror(\"sha1 mismatch for %s (expected %s)\", path,\n \t\t\t      oid_to_hex(expected_oid));\n"},{"id":"339675","messageId":"20180219225927.386065-18-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 17/36] builtin/index-pack: convert struct ref_delta_entry to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:08Z","receivedAt":"2018-02-19T23:01:09Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert this struct to use a member of type object_id.  Convert various\nstatic functions as well.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/index-pack.c | 34 +++++++++++++++++-----------------\n 1 file changed, 17 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 7e3e1a461c..5c7ab47c36 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -58,7 +58,7 @@ struct ofs_delta_entry {\n };\n \n struct ref_delta_entry {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tint obj_no;\n };\n \n@@ -671,18 +671,18 @@ static void find_ofs_delta_children(off_t offset,\n \t*last_index = last;\n }\n \n-static int compare_ref_delta_bases(const unsigned char *sha1,\n-\t\t\t\t   const unsigned char *sha2,\n+static int compare_ref_delta_bases(const struct object_id *oid1,\n+\t\t\t\t   const struct object_id *oid2,\n \t\t\t\t   enum object_type type1,\n \t\t\t\t   enum object_type type2)\n {\n \tint cmp = type1 - type2;\n \tif (cmp)\n \t\treturn cmp;\n-\treturn hashcmp(sha1, sha2);\n+\treturn oidcmp(oid1, oid2);\n }\n \n-static int find_ref_delta(const unsigned char *sha1, enum object_type type)\n+static int find_ref_delta(const struct object_id *oid, enum object_type type)\n {\n \tint first = 0, last = nr_ref_deltas;\n \n@@ -691,7 +691,7 @@ static int find_ref_delta(const unsigned char *sha1, enum object_type type)\n \t\tstruct ref_delta_entry *delta = &ref_deltas[next];\n \t\tint cmp;\n \n-\t\tcmp = compare_ref_delta_bases(sha1, delta->sha1,\n+\t\tcmp = compare_ref_delta_bases(oid, &delta->oid,\n \t\t\t\t\t      type, objects[delta->obj_no].type);\n \t\tif (!cmp)\n \t\t\treturn next;\n@@ -704,11 +704,11 @@ static int find_ref_delta(const unsigned char *sha1, enum object_type type)\n \treturn -first-1;\n }\n \n-static void find_ref_delta_children(const unsigned char *sha1,\n+static void find_ref_delta_children(const struct object_id *oid,\n \t\t\t\t    int *first_index, int *last_index,\n \t\t\t\t    enum object_type type)\n {\n-\tint first = find_ref_delta(sha1, type);\n+\tint first = find_ref_delta(oid, type);\n \tint last = first;\n \tint end = nr_ref_deltas - 1;\n \n@@ -717,9 +717,9 @@ static void find_ref_delta_children(const unsigned char *sha1,\n \t\t*last_index = -1;\n \t\treturn;\n \t}\n-\twhile (first > 0 && !hashcmp(ref_deltas[first - 1].sha1, sha1))\n+\twhile (first > 0 && !oidcmp(&ref_deltas[first - 1].oid, oid))\n \t\t--first;\n-\twhile (last < end && !hashcmp(ref_deltas[last + 1].sha1, sha1))\n+\twhile (last < end && !oidcmp(&ref_deltas[last + 1].oid, oid))\n \t\t++last;\n \t*first_index = first;\n \t*last_index = last;\n@@ -991,7 +991,7 @@ static struct base_data *find_unresolved_deltas_1(struct base_data *base,\n \t\t\t\t\t\t  struct base_data *prev_base)\n {\n \tif (base->ref_last == -1 && base->ofs_last == -1) {\n-\t\tfind_ref_delta_children(base->obj->idx.oid.hash,\n+\t\tfind_ref_delta_children(&base->obj->idx.oid,\n \t\t\t\t\t&base->ref_first, &base->ref_last,\n \t\t\t\t\tOBJ_REF_DELTA);\n \n@@ -1075,7 +1075,7 @@ static int compare_ref_delta_entry(const void *a, const void *b)\n \tconst struct ref_delta_entry *delta_a = a;\n \tconst struct ref_delta_entry *delta_b = b;\n \n-\treturn hashcmp(delta_a->sha1, delta_b->sha1);\n+\treturn oidcmp(&delta_a->oid, &delta_b->oid);\n }\n \n static void resolve_base(struct object_entry *obj)\n@@ -1141,7 +1141,7 @@ static void parse_pack_objects(unsigned char *hash)\n \t\t\tofs_delta++;\n \t\t} else if (obj->type == OBJ_REF_DELTA) {\n \t\t\tALLOC_GROW(ref_deltas, nr_ref_deltas + 1, ref_deltas_alloc);\n-\t\t\thashcpy(ref_deltas[nr_ref_deltas].sha1, ref_delta_oid.hash);\n+\t\t\toidcpy(&ref_deltas[nr_ref_deltas].oid, &ref_delta_oid);\n \t\t\tref_deltas[nr_ref_deltas].obj_no = i;\n \t\t\tnr_ref_deltas++;\n \t\t} else if (!data) {\n@@ -1373,14 +1373,14 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \n \t\tif (objects[d->obj_no].real_type != OBJ_REF_DELTA)\n \t\t\tcontinue;\n-\t\tbase_obj->data = read_sha1_file(d->sha1, &type, &base_obj->size);\n+\t\tbase_obj->data = read_sha1_file(d->oid.hash, &type, &base_obj->size);\n \t\tif (!base_obj->data)\n \t\t\tcontinue;\n \n-\t\tif (check_sha1_signature(d->sha1, base_obj->data,\n+\t\tif (check_sha1_signature(d->oid.hash, base_obj->data,\n \t\t\t\tbase_obj->size, typename(type)))\n-\t\t\tdie(_(\"local object %s is corrupt\"), sha1_to_hex(d->sha1));\n-\t\tbase_obj->obj = append_obj_to_pack(f, d->sha1,\n+\t\t\tdie(_(\"local object %s is corrupt\"), oid_to_hex(&d->oid));\n+\t\tbase_obj->obj = append_obj_to_pack(f, d->oid.hash,\n \t\t\t\t\tbase_obj->data, base_obj->size, type);\n \t\tfind_unresolved_deltas(base_obj);\n \t\tdisplay_progress(progress, nr_resolved_deltas);\n"},{"id":"339676","messageId":"20180219225927.386065-7-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 06/36] tree: convert read_tree_recursive to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:58:57Z","receivedAt":"2018-02-19T23:01:13Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the callback functions for read_tree_recursive to take a pointer\nto struct object_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n archive.c          |  8 ++++----\n builtin/checkout.c |  4 ++--\n builtin/log.c      |  2 +-\n builtin/ls-tree.c  |  8 ++++----\n merge-recursive.c  |  2 +-\n tree.c             | 14 +++++++-------\n tree.h             |  2 +-\n 7 files changed, 20 insertions(+), 20 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 0b7b62af0c..e664cdb624 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -198,7 +198,7 @@ static int write_directory(struct archiver_context *c)\n \treturn ret ? -1 : 0;\n }\n \n-static int queue_or_write_archive_entry(const unsigned char *sha1,\n+static int queue_or_write_archive_entry(const struct object_id *oid,\n \t\tstruct strbuf *base, const char *filename,\n \t\tunsigned mode, int stage, void *context)\n {\n@@ -224,14 +224,14 @@ static int queue_or_write_archive_entry(const unsigned char *sha1,\n \n \t\tif (check_attr_export_ignore(check))\n \t\t\treturn 0;\n-\t\tqueue_directory(sha1, base, filename,\n+\t\tqueue_directory(oid->hash, base, filename,\n \t\t\t\tmode, stage, c);\n \t\treturn READ_TREE_RECURSIVE;\n \t}\n \n \tif (write_directory(c))\n \t\treturn -1;\n-\treturn write_archive_entry(sha1, base->buf, base->len, filename, mode,\n+\treturn write_archive_entry(oid->hash, base->buf, base->len, filename, mode,\n \t\t\t\t   stage, context);\n }\n \n@@ -303,7 +303,7 @@ static const struct archiver *lookup_archiver(const char *name)\n \treturn NULL;\n }\n \n-static int reject_entry(const unsigned char *sha1, struct strbuf *base,\n+static int reject_entry(const struct object_id *oid, struct strbuf *base,\n \t\t\tconst char *filename, unsigned mode,\n \t\t\tint stage, void *context)\n {\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 191b96c49c..87182aa018 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -66,7 +66,7 @@ static int post_checkout_hook(struct commit *old, struct commit *new,\n \n }\n \n-static int update_some(const unsigned char *sha1, struct strbuf *base,\n+static int update_some(const struct object_id *oid, struct strbuf *base,\n \t\tconst char *pathname, unsigned mode, int stage, void *context)\n {\n \tint len;\n@@ -78,7 +78,7 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,\n \n \tlen = base->len + strlen(pathname);\n \tce = xcalloc(1, cache_entry_size(len));\n-\thashcpy(ce->oid.hash, sha1);\n+\toidcpy(&ce->oid, oid);\n \tmemcpy(ce->name, base->buf, base->len);\n \tmemcpy(ce->name + base->len, pathname, len - base->len);\n \tce->ce_flags = create_ce_flags(0) | CE_UPDATE;\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 94ee177d56..32a744bfd2 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -541,7 +541,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n \treturn 0;\n }\n \n-static int show_tree_object(const unsigned char *sha1,\n+static int show_tree_object(const struct object_id *oid,\n \t\tstruct strbuf *base,\n \t\tconst char *pathname, unsigned mode, int stage, void *context)\n {\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex ef965408e8..c613dd7b82 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -60,7 +60,7 @@ static int show_recursive(const char *base, int baselen, const char *pathname)\n \treturn 0;\n }\n \n-static int show_tree(const unsigned char *sha1, struct strbuf *base,\n+static int show_tree(const struct object_id *oid, struct strbuf *base,\n \t\tconst char *pathname, unsigned mode, int stage, void *context)\n {\n \tint retval = 0;\n@@ -94,7 +94,7 @@ static int show_tree(const unsigned char *sha1, struct strbuf *base,\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\tif (sha1_object_info(sha1, &size) == OBJ_BAD)\n+\t\t\t\tif (sha1_object_info(oid->hash, &size) == OBJ_BAD)\n \t\t\t\t\txsnprintf(size_text, sizeof(size_text),\n \t\t\t\t\t\t  \"BAD\");\n \t\t\t\telse\n@@ -103,11 +103,11 @@ static int show_tree(const unsigned char *sha1, struct strbuf *base,\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,\n-\t\t\t       find_unique_abbrev(sha1, abbrev),\n+\t\t\t       find_unique_abbrev(oid->hash, abbrev),\n \t\t\t       size_text);\n \t\t} else\n \t\t\tprintf(\"%06o %s %s\\t\", mode, type,\n-\t\t\t       find_unique_abbrev(sha1, abbrev));\n+\t\t\t       find_unique_abbrev(oid->hash, abbrev));\n \t}\n \tbaselen = base->len;\n \tstrbuf_addstr(base, pathname);\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 6ff971f9a2..c886f2e9cd 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -335,7 +335,7 @@ struct tree *write_tree_from_memory(struct merge_options *o)\n \treturn result;\n }\n \n-static int save_files_dirs(const unsigned char *sha1,\n+static int save_files_dirs(const struct object_id *oid,\n \t\tstruct strbuf *base, const char *path,\n \t\tunsigned int mode, int stage, void *context)\n {\ndiff --git a/tree.c b/tree.c\nindex b224115e0f..1a0f03f520 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -10,7 +10,7 @@\n const char *tree_type = \"tree\";\n \n static int read_one_entry_opt(struct index_state *istate,\n-\t\t\t      const unsigned char *sha1,\n+\t\t\t      const struct object_id *oid,\n \t\t\t      const char *base, int baselen,\n \t\t\t      const char *pathname,\n \t\t\t      unsigned mode, int stage, int opt)\n@@ -31,16 +31,16 @@ static int read_one_entry_opt(struct index_state *istate,\n \tce->ce_namelen = baselen + len;\n \tmemcpy(ce->name, base, baselen);\n \tmemcpy(ce->name + baselen, pathname, len+1);\n-\thashcpy(ce->oid.hash, sha1);\n+\toidcpy(&ce->oid, oid);\n \treturn add_index_entry(istate, ce, opt);\n }\n \n-static int read_one_entry(const unsigned char *sha1, struct strbuf *base,\n+static int read_one_entry(const struct object_id *oid, struct strbuf *base,\n \t\t\t  const char *pathname, unsigned mode, int stage,\n \t\t\t  void *context)\n {\n \tstruct index_state *istate = context;\n-\treturn read_one_entry_opt(istate, sha1, base->buf, base->len, pathname,\n+\treturn read_one_entry_opt(istate, oid, base->buf, base->len, pathname,\n \t\t\t\t  mode, stage,\n \t\t\t\t  ADD_CACHE_OK_TO_ADD|ADD_CACHE_SKIP_DFCHECK);\n }\n@@ -49,12 +49,12 @@ static int read_one_entry(const unsigned char *sha1, struct strbuf *base,\n  * This is used when the caller knows there is no existing entries at\n  * the stage that will conflict with the entry being added.\n  */\n-static int read_one_entry_quick(const unsigned char *sha1, struct strbuf *base,\n+static int read_one_entry_quick(const struct object_id *oid, struct strbuf *base,\n \t\t\t\tconst char *pathname, unsigned mode, int stage,\n \t\t\t\tvoid *context)\n {\n \tstruct index_state *istate = context;\n-\treturn read_one_entry_opt(istate, sha1, base->buf, base->len, pathname,\n+\treturn read_one_entry_opt(istate, oid, base->buf, base->len, pathname,\n \t\t\t\t  mode, stage,\n \t\t\t\t  ADD_CACHE_JUST_APPEND);\n }\n@@ -83,7 +83,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,\n \t\t\t\tcontinue;\n \t\t}\n \n-\t\tswitch (fn(entry.oid->hash, base,\n+\t\tswitch (fn(entry.oid, base,\n \t\t\t   entry.path, entry.mode, stage, context)) {\n \t\tcase 0:\n \t\t\tcontinue;\ndiff --git a/tree.h b/tree.h\nindex 744e6dc2ac..e2a80be4ef 100644\n--- a/tree.h\n+++ b/tree.h\n@@ -27,7 +27,7 @@ void free_tree_buffer(struct tree *tree);\n struct tree *parse_tree_indirect(const struct object_id *oid);\n \n #define READ_TREE_RECURSIVE 1\n-typedef int (*read_tree_fn_t)(const unsigned char *, struct strbuf *, const char *, unsigned int, int, void *);\n+typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, int, void *);\n \n extern int read_tree_recursive(struct tree *tree,\n \t\t\t       const char *base, int baselen,\n"},{"id":"339677","messageId":"20180219225927.386065-16-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 15/36] archive: convert write_archive_entry_fn_t to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:06Z","receivedAt":"2018-02-19T23:01:16Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the write_archive_entry_fn_t type to use a pointer to struct\nobject_id.  Convert various static functions in the tar and zip\narchivers also.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n archive-tar.c | 28 ++++++++++++++--------------\n archive-zip.c | 16 ++++++++--------\n archive.c     | 12 ++++++------\n archive.h     |  2 +-\n 4 files changed, 29 insertions(+), 29 deletions(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex c6ed96ee74..24b1ccef3a 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -111,7 +111,7 @@ static void write_trailer(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 int stream_blocked(const unsigned char *sha1)\n+static int stream_blocked(const struct object_id *oid)\n {\n \tstruct git_istream *st;\n \tenum object_type type;\n@@ -119,9 +119,9 @@ static int stream_blocked(const unsigned char *sha1)\n \tchar buf[BLOCKSIZE];\n \tssize_t readlen;\n \n-\tst = open_istream(sha1, &type, &sz, NULL);\n+\tst = open_istream(oid->hash, &type, &sz, NULL);\n \tif (!st)\n-\t\treturn error(\"cannot stream blob %s\", sha1_to_hex(sha1));\n+\t\treturn error(\"cannot stream blob %s\", oid_to_hex(oid));\n \tfor (;;) {\n \t\treadlen = read_istream(st, buf, sizeof(buf));\n \t\tif (readlen <= 0)\n@@ -218,7 +218,7 @@ static void prepare_header(struct archiver_args *args,\n }\n \n static void write_extended_header(struct archiver_args *args,\n-\t\t\t\t  const unsigned char *sha1,\n+\t\t\t\t  const struct object_id *oid,\n \t\t\t\t  const void *buffer, unsigned long size)\n {\n \tstruct ustar_header header;\n@@ -226,14 +226,14 @@ static void write_extended_header(struct archiver_args *args,\n \tmemset(&header, 0, sizeof(header));\n \t*header.typeflag = TYPEFLAG_EXT_HEADER;\n \tmode = 0100666;\n-\txsnprintf(header.name, sizeof(header.name), \"%s.paxheader\", sha1_to_hex(sha1));\n+\txsnprintf(header.name, sizeof(header.name), \"%s.paxheader\", oid_to_hex(oid));\n \tprepare_header(args, &header, mode, size);\n \twrite_blocked(&header, sizeof(header));\n \twrite_blocked(buffer, size);\n }\n \n static int write_tar_entry(struct archiver_args *args,\n-\t\t\t   const unsigned char *sha1,\n+\t\t\t   const struct object_id *oid,\n \t\t\t   const char *path, size_t pathlen,\n \t\t\t   unsigned int mode)\n {\n@@ -257,7 +257,7 @@ static int write_tar_entry(struct archiver_args *args,\n \t\tmode = (mode | ((mode & 0100) ? 0777 : 0666)) & ~tar_umask;\n \t} else {\n \t\treturn error(\"unsupported file mode: 0%o (SHA1: %s)\",\n-\t\t\t     mode, sha1_to_hex(sha1));\n+\t\t\t     mode, oid_to_hex(oid));\n \t}\n \tif (pathlen > sizeof(header.name)) {\n \t\tsize_t plen = get_path_prefix(path, pathlen,\n@@ -268,7 +268,7 @@ static int write_tar_entry(struct archiver_args *args,\n \t\t\tmemcpy(header.name, path + plen + 1, rest);\n \t\t} else {\n \t\t\txsnprintf(header.name, sizeof(header.name), \"%s.data\",\n-\t\t\t\t  sha1_to_hex(sha1));\n+\t\t\t\t  oid_to_hex(oid));\n \t\t\tstrbuf_append_ext_header(&ext_header, \"path\",\n \t\t\t\t\t\t path, pathlen);\n \t\t}\n@@ -276,14 +276,14 @@ static int write_tar_entry(struct archiver_args *args,\n \t\tmemcpy(header.name, path, pathlen);\n \n \tif (S_ISREG(mode) && !args->convert &&\n-\t    sha1_object_info(sha1, &size) == OBJ_BLOB &&\n+\t    sha1_object_info(oid->hash, &size) == OBJ_BLOB &&\n \t    size > big_file_threshold)\n \t\tbuffer = NULL;\n \telse if (S_ISLNK(mode) || S_ISREG(mode)) {\n \t\tenum object_type type;\n-\t\tbuffer = sha1_file_to_archive(args, path, sha1, old_mode, &type, &size);\n+\t\tbuffer = sha1_file_to_archive(args, path, oid->hash, old_mode, &type, &size);\n \t\tif (!buffer)\n-\t\t\treturn error(\"cannot read %s\", sha1_to_hex(sha1));\n+\t\t\treturn error(\"cannot read %s\", oid_to_hex(oid));\n \t} else {\n \t\tbuffer = NULL;\n \t\tsize = 0;\n@@ -292,7 +292,7 @@ static int write_tar_entry(struct archiver_args *args,\n \tif (S_ISLNK(mode)) {\n \t\tif (size > sizeof(header.linkname)) {\n \t\t\txsnprintf(header.linkname, sizeof(header.linkname),\n-\t\t\t\t  \"see %s.paxheader\", sha1_to_hex(sha1));\n+\t\t\t\t  \"see %s.paxheader\", oid_to_hex(oid));\n \t\t\tstrbuf_append_ext_header(&ext_header, \"linkpath\",\n \t\t\t                         buffer, size);\n \t\t} else\n@@ -308,7 +308,7 @@ static int write_tar_entry(struct archiver_args *args,\n \tprepare_header(args, &header, mode, size_in_header);\n \n \tif (ext_header.len > 0) {\n-\t\twrite_extended_header(args, sha1, ext_header.buf,\n+\t\twrite_extended_header(args, oid, ext_header.buf,\n \t\t\t\t      ext_header.len);\n \t}\n \tstrbuf_release(&ext_header);\n@@ -317,7 +317,7 @@ static int write_tar_entry(struct archiver_args *args,\n \t\tif (buffer)\n \t\t\twrite_blocked(buffer, size);\n \t\telse\n-\t\t\terr = stream_blocked(sha1);\n+\t\t\terr = stream_blocked(oid);\n \t}\n \tfree(buffer);\n \treturn err;\ndiff --git a/archive-zip.c b/archive-zip.c\nindex e8913e5a26..e2e5513c03 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -276,7 +276,7 @@ static int entry_is_binary(const char *path, const void *buffer, size_t size)\n #define STREAM_BUFFER_SIZE (1024 * 16)\n \n static int write_zip_entry(struct archiver_args *args,\n-\t\t\t   const unsigned char *sha1,\n+\t\t\t   const struct object_id *oid,\n \t\t\t   const char *path, size_t pathlen,\n \t\t\t   unsigned int mode)\n {\n@@ -314,7 +314,7 @@ static int write_zip_entry(struct archiver_args *args,\n \n \tif (pathlen > 0xffff) {\n \t\treturn error(\"path too long (%d chars, SHA1: %s): %s\",\n-\t\t\t\t(int)pathlen, sha1_to_hex(sha1), path);\n+\t\t\t\t(int)pathlen, oid_to_hex(oid), path);\n \t}\n \n \tif (S_ISDIR(mode) || S_ISGITLINK(mode)) {\n@@ -325,7 +325,7 @@ static int write_zip_entry(struct archiver_args *args,\n \t\tcompressed_size = 0;\n \t\tbuffer = NULL;\n \t} else if (S_ISREG(mode) || S_ISLNK(mode)) {\n-\t\tenum object_type type = sha1_object_info(sha1, &size);\n+\t\tenum object_type type = sha1_object_info(oid->hash, &size);\n \n \t\tmethod = 0;\n \t\tattr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :\n@@ -337,18 +337,18 @@ static int write_zip_entry(struct archiver_args *args,\n \n \t\tif (S_ISREG(mode) && type == OBJ_BLOB && !args->convert &&\n \t\t    size > big_file_threshold) {\n-\t\t\tstream = open_istream(sha1, &type, &size, NULL);\n+\t\t\tstream = open_istream(oid->hash, &type, &size, NULL);\n \t\t\tif (!stream)\n \t\t\t\treturn error(\"cannot stream blob %s\",\n-\t\t\t\t\t     sha1_to_hex(sha1));\n+\t\t\t\t\t     oid_to_hex(oid));\n \t\t\tflags |= ZIP_STREAM;\n \t\t\tout = buffer = NULL;\n \t\t} else {\n-\t\t\tbuffer = sha1_file_to_archive(args, path, sha1, mode,\n+\t\t\tbuffer = sha1_file_to_archive(args, path, oid->hash, mode,\n \t\t\t\t\t\t      &type, &size);\n \t\t\tif (!buffer)\n \t\t\t\treturn error(\"cannot read %s\",\n-\t\t\t\t\t     sha1_to_hex(sha1));\n+\t\t\t\t\t     oid_to_hex(oid));\n \t\t\tcrc = crc32(crc, buffer, size);\n \t\t\tis_binary = entry_is_binary(path_without_prefix,\n \t\t\t\t\t\t    buffer, size);\n@@ -357,7 +357,7 @@ static int write_zip_entry(struct archiver_args *args,\n \t\tcompressed_size = (method == 0) ? size : 0;\n \t} else {\n \t\treturn error(\"unsupported file mode: 0%o (SHA1: %s)\", mode,\n-\t\t\t\tsha1_to_hex(sha1));\n+\t\t\t\toid_to_hex(oid));\n \t}\n \n \tif (creator_version > max_creator_version)\ndiff --git a/archive.c b/archive.c\nindex e664cdb624..4942b5632b 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -121,7 +121,7 @@ static int check_attr_export_subst(const struct attr_check *check)\n \treturn check && ATTR_TRUE(check->items[1].value);\n }\n \n-static int write_archive_entry(const unsigned char *sha1, const char *base,\n+static int write_archive_entry(const struct object_id *oid, const char *base,\n \t\tint baselen, const char *filename, unsigned mode, int stage,\n \t\tvoid *context)\n {\n@@ -153,7 +153,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,\n \tif (S_ISDIR(mode) || S_ISGITLINK(mode)) {\n \t\tif (args->verbose)\n \t\t\tfprintf(stderr, \"%.*s\\n\", (int)path.len, path.buf);\n-\t\terr = write_entry(args, sha1, path.buf, path.len, mode);\n+\t\terr = write_entry(args, oid, path.buf, path.len, mode);\n \t\tif (err)\n \t\t\treturn err;\n \t\treturn (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);\n@@ -161,7 +161,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,\n \n \tif (args->verbose)\n \t\tfprintf(stderr, \"%.*s\\n\", (int)path.len, path.buf);\n-\treturn write_entry(args, sha1, path.buf, path.len, mode);\n+\treturn write_entry(args, oid, path.buf, path.len, mode);\n }\n \n static void queue_directory(const unsigned char *sha1,\n@@ -191,7 +191,7 @@ static int write_directory(struct archiver_context *c)\n \td->path[d->len - 1] = '\\0'; /* no trailing slash */\n \tret =\n \t\twrite_directory(c) ||\n-\t\twrite_archive_entry(d->oid.hash, d->path, d->baselen,\n+\t\twrite_archive_entry(&d->oid, d->path, d->baselen,\n \t\t\t\t    d->path + d->baselen, d->mode,\n \t\t\t\t    d->stage, c) != READ_TREE_RECURSIVE;\n \tfree(d);\n@@ -231,7 +231,7 @@ static int queue_or_write_archive_entry(const struct object_id *oid,\n \n \tif (write_directory(c))\n \t\treturn -1;\n-\treturn write_archive_entry(oid->hash, base->buf, base->len, filename, mode,\n+\treturn write_archive_entry(oid, base->buf, base->len, filename, mode,\n \t\t\t\t   stage, context);\n }\n \n@@ -250,7 +250,7 @@ int write_archive_entries(struct archiver_args *args,\n \t\t\tlen--;\n \t\tif (args->verbose)\n \t\t\tfprintf(stderr, \"%.*s\\n\", (int)len, args->base);\n-\t\terr = write_entry(args, args->tree->object.oid.hash, args->base,\n+\t\terr = write_entry(args, &args->tree->object.oid, args->base,\n \t\t\t\t  len, 040777);\n \t\tif (err)\n \t\t\treturn err;\ndiff --git a/archive.h b/archive.h\nindex 62d1d82c1a..741991bfb6 100644\n--- a/archive.h\n+++ b/archive.h\n@@ -31,7 +31,7 @@ extern void init_tar_archiver(void);\n extern void init_zip_archiver(void);\n \n typedef int (*write_archive_entry_fn_t)(struct archiver_args *args,\n-\t\t\t\t\tconst unsigned char *sha1,\n+\t\t\t\t\tconst struct object_id *oid,\n \t\t\t\t\tconst char *path, size_t pathlen,\n \t\t\t\t\tunsigned int mode);\n \n"},{"id":"339678","messageId":"20180219225927.386065-17-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 16/36] archive: convert sha1_file_to_archive to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:07Z","receivedAt":"2018-02-19T23:01:18Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert this function to take a pointer to struct object_id and rename\nit object_file_to_archive.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n archive-tar.c |  2 +-\n archive-zip.c |  4 ++--\n archive.c     | 10 +++++-----\n archive.h     |  8 ++++----\n 4 files changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 24b1ccef3a..fd622eacc0 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -281,7 +281,7 @@ static int write_tar_entry(struct archiver_args *args,\n \t\tbuffer = NULL;\n \telse if (S_ISLNK(mode) || S_ISREG(mode)) {\n \t\tenum object_type type;\n-\t\tbuffer = sha1_file_to_archive(args, path, oid->hash, old_mode, &type, &size);\n+\t\tbuffer = object_file_to_archive(args, path, oid, old_mode, &type, &size);\n \t\tif (!buffer)\n \t\t\treturn error(\"cannot read %s\", oid_to_hex(oid));\n \t} else {\ndiff --git a/archive-zip.c b/archive-zip.c\nindex e2e5513c03..5841a6ceb6 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -344,8 +344,8 @@ static int write_zip_entry(struct archiver_args *args,\n \t\t\tflags |= ZIP_STREAM;\n \t\t\tout = buffer = NULL;\n \t\t} else {\n-\t\t\tbuffer = sha1_file_to_archive(args, path, oid->hash, mode,\n-\t\t\t\t\t\t      &type, &size);\n+\t\t\tbuffer = object_file_to_archive(args, path, oid, mode,\n+\t\t\t\t\t\t\t&type, &size);\n \t\t\tif (!buffer)\n \t\t\t\treturn error(\"cannot read %s\",\n \t\t\t\t\t     oid_to_hex(oid));\ndiff --git a/archive.c b/archive.c\nindex 4942b5632b..da62b2f541 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -63,16 +63,16 @@ static void format_subst(const struct commit *commit,\n \tfree(to_free);\n }\n \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+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 {\n \tvoid *buffer;\n \tconst struct commit *commit = args->convert ? args->commit : NULL;\n \n \tpath += args->baselen;\n-\tbuffer = read_sha1_file(sha1, type, sizep);\n+\tbuffer = read_sha1_file(oid->hash, type, sizep);\n \tif (buffer && S_ISREG(mode)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tsize_t size = 0;\ndiff --git a/archive.h b/archive.h\nindex 741991bfb6..1f9954f7cd 100644\n--- a/archive.h\n+++ b/archive.h\n@@ -39,9 +39,9 @@ extern int write_archive_entries(struct archiver_args *args, write_archive_entry\n extern int write_archive(int argc, const char **argv, const char *prefix, const char *name_hint, int remote);\n \n 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+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 \n #endif\t/* ARCHIVE_H */\n"},{"id":"339679","messageId":"20180219225927.386065-10-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 09/36] wt-status: convert struct wt_status_state to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:00Z","receivedAt":"2018-02-19T23:01:23Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the various *_sha1 members to use struct object_id instead.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n wt-status.c | 12 ++++++------\n wt-status.h |  6 +++---\n 2 files changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 98e558a70b..698fa1d42a 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1349,7 +1349,7 @@ static void show_cherry_pick_in_progress(struct wt_status *s,\n \t\t\t\t\tconst char *color)\n {\n \tstatus_printf_ln(s, color, _(\"You are currently cherry-picking commit %s.\"),\n-\t\t\tfind_unique_abbrev(state->cherry_pick_head_sha1, DEFAULT_ABBREV));\n+\t\t\tfind_unique_abbrev(state->cherry_pick_head_oid.hash, DEFAULT_ABBREV));\n \tif (s->hints) {\n \t\tif (has_unmerged(s))\n \t\t\tstatus_printf_ln(s, color,\n@@ -1368,7 +1368,7 @@ static void show_revert_in_progress(struct wt_status *s,\n \t\t\t\t\tconst char *color)\n {\n \tstatus_printf_ln(s, color, _(\"You are currently reverting commit %s.\"),\n-\t\t\t find_unique_abbrev(state->revert_head_sha1, DEFAULT_ABBREV));\n+\t\t\t find_unique_abbrev(state->revert_head_oid.hash, DEFAULT_ABBREV));\n \tif (s->hints) {\n \t\tif (has_unmerged(s))\n \t\t\tstatus_printf_ln(s, color,\n@@ -1489,9 +1489,9 @@ static void wt_status_get_detached_from(struct wt_status_state *state)\n \t} else\n \t\tstate->detached_from =\n \t\t\txstrdup(find_unique_abbrev(cb.noid.hash, DEFAULT_ABBREV));\n-\thashcpy(state->detached_sha1, cb.noid.hash);\n+\toidcpy(&state->detached_oid, &cb.noid);\n \tstate->detached_at = !get_oid(\"HEAD\", &oid) &&\n-\t\t\t     !hashcmp(oid.hash, state->detached_sha1);\n+\t\t\t     !oidcmp(&oid, &state->detached_oid);\n \n \tfree(ref);\n \tstrbuf_release(&cb.buf);\n@@ -1550,13 +1550,13 @@ void wt_status_get_state(struct wt_status_state *state,\n \t} else if (!stat(git_path_cherry_pick_head(), &st) &&\n \t\t\t!get_oid(\"CHERRY_PICK_HEAD\", &oid)) {\n \t\tstate->cherry_pick_in_progress = 1;\n-\t\thashcpy(state->cherry_pick_head_sha1, oid.hash);\n+\t\toidcpy(&state->cherry_pick_head_oid, &oid);\n \t}\n \twt_status_check_bisect(NULL, state);\n \tif (!stat(git_path_revert_head(), &st) &&\n \t    !get_oid(\"REVERT_HEAD\", &oid)) {\n \t\tstate->revert_in_progress = 1;\n-\t\thashcpy(state->revert_head_sha1, oid.hash);\n+\t\toidcpy(&state->revert_head_oid, &oid);\n \t}\n \n \tif (get_detached_from)\ndiff --git a/wt-status.h b/wt-status.h\nindex 3f84d5c29f..c7ef173284 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -116,9 +116,9 @@ struct wt_status_state {\n \tchar *branch;\n \tchar *onto;\n \tchar *detached_from;\n-\tunsigned char detached_sha1[20];\n-\tunsigned char revert_head_sha1[20];\n-\tunsigned char cherry_pick_head_sha1[20];\n+\tstruct object_id detached_oid;\n+\tstruct object_id revert_head_oid;\n+\tstruct object_id cherry_pick_head_oid;\n };\n \n size_t wt_status_locate_end(const char *s, size_t len);\n"},{"id":"339680","messageId":"20180219225927.386065-13-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 12/36] send-pack: convert remaining functions to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:03Z","receivedAt":"2018-02-19T23:01:24Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the remaining function, feed_object, to use struct object_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n send-pack.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/send-pack.c b/send-pack.c\nindex 8d9190f5e7..19025a7aca 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -37,14 +37,14 @@ int option_parse_push_signed(const struct option *opt,\n \tdie(\"bad %s argument: %s\", opt->long_name, arg);\n }\n \n-static void feed_object(const unsigned char *sha1, FILE *fh, int negative)\n+static void feed_object(const struct object_id *oid, FILE *fh, int negative)\n {\n-\tif (negative && !has_sha1_file(sha1))\n+\tif (negative && !has_sha1_file(oid->hash))\n \t\treturn;\n \n \tif (negative)\n \t\tputc('^', fh);\n-\tfputs(sha1_to_hex(sha1), fh);\n+\tfputs(oid_to_hex(oid), fh);\n \tputc('\\n', fh);\n }\n \n@@ -89,13 +89,13 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc\n \t */\n \tpo_in = xfdopen(po.in, \"w\");\n \tfor (i = 0; i < extra->nr; i++)\n-\t\tfeed_object(extra->oid[i].hash, po_in, 1);\n+\t\tfeed_object(&extra->oid[i], po_in, 1);\n \n \twhile (refs) {\n \t\tif (!is_null_oid(&refs->old_oid))\n-\t\t\tfeed_object(refs->old_oid.hash, po_in, 1);\n+\t\t\tfeed_object(&refs->old_oid, po_in, 1);\n \t\tif (!is_null_oid(&refs->new_oid))\n-\t\t\tfeed_object(refs->new_oid.hash, po_in, 0);\n+\t\t\tfeed_object(&refs->new_oid, po_in, 0);\n \t\trefs = refs->next;\n \t}\n \n"},{"id":"339681","messageId":"20180219225927.386065-9-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 08/36] strbuf: convert strbuf_add_unique_abbrev to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:58:59Z","receivedAt":"2018-02-19T23:01:29Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the declaration and definition of strbuf_add_unique_abbrev to\nmake it take a pointer to struct object_id.  Predeclare the struct in\nstrbuf.h, as cache.h includes strbuf.h before it declares the struct,\nand otherwise the struct declaration would have the wrong scope.\n\nApply the following semantic patch, along with the standard object_id\ntransforms, to adjust the callers:\n\n@@\nexpression E1, E2, E3;\n@@\n- strbuf_add_unique_abbrev(E1, E2.hash, E3);\n+ strbuf_add_unique_abbrev(E1, &E2, E3);\n\n@@\nexpression E1, E2, E3;\n@@\n- strbuf_add_unique_abbrev(E1, E2->hash, E3);\n+ strbuf_add_unique_abbrev(E1, E2, E3);\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/checkout.c | 2 +-\n builtin/fetch.c    | 8 ++++----\n builtin/tag.c      | 2 +-\n merge-recursive.c  | 2 +-\n pretty.c           | 8 ++++----\n strbuf.c           | 4 ++--\n strbuf.h           | 8 +++++++-\n submodule.c        | 4 ++--\n transport.c        | 4 ++--\n wt-status.c        | 6 +++---\n 10 files changed, 27 insertions(+), 21 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 87182aa018..bc68d423e5 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -720,7 +720,7 @@ static int add_pending_uninteresting_ref(const char *refname,\n static void describe_one_orphan(struct strbuf *sb, struct commit *commit)\n {\n \tstrbuf_addstr(sb, \"  \");\n-\tstrbuf_add_unique_abbrev(sb, commit->object.oid.hash, DEFAULT_ABBREV);\n+\tstrbuf_add_unique_abbrev(sb, &commit->object.oid, DEFAULT_ABBREV);\n \tstrbuf_addch(sb, ' ');\n \tif (!parse_commit(commit))\n \t\tpp_commit_easy(CMIT_FMT_ONELINE, commit, sb);\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 8ee998ea2e..3b8988e51d 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -697,9 +697,9 @@ static int update_local_ref(struct ref *ref,\n \tif (in_merge_bases(current, updated)) {\n \t\tstruct strbuf quickref = STRBUF_INIT;\n \t\tint r;\n-\t\tstrbuf_add_unique_abbrev(&quickref, current->object.oid.hash, DEFAULT_ABBREV);\n+\t\tstrbuf_add_unique_abbrev(&quickref, &current->object.oid, DEFAULT_ABBREV);\n \t\tstrbuf_addstr(&quickref, \"..\");\n-\t\tstrbuf_add_unique_abbrev(&quickref, ref->new_oid.hash, DEFAULT_ABBREV);\n+\t\tstrbuf_add_unique_abbrev(&quickref, &ref->new_oid, DEFAULT_ABBREV);\n \t\tif ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&\n \t\t    (recurse_submodules != RECURSE_SUBMODULES_ON))\n \t\t\tcheck_for_new_submodule_commits(&ref->new_oid);\n@@ -712,9 +712,9 @@ static int update_local_ref(struct ref *ref,\n \t} else if (force || ref->force) {\n \t\tstruct strbuf quickref = STRBUF_INIT;\n \t\tint r;\n-\t\tstrbuf_add_unique_abbrev(&quickref, current->object.oid.hash, DEFAULT_ABBREV);\n+\t\tstrbuf_add_unique_abbrev(&quickref, &current->object.oid, DEFAULT_ABBREV);\n \t\tstrbuf_addstr(&quickref, \"...\");\n-\t\tstrbuf_add_unique_abbrev(&quickref, ref->new_oid.hash, DEFAULT_ABBREV);\n+\t\tstrbuf_add_unique_abbrev(&quickref, &ref->new_oid, DEFAULT_ABBREV);\n \t\tif ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&\n \t\t    (recurse_submodules != RECURSE_SUBMODULES_ON))\n \t\t\tcheck_for_new_submodule_commits(&ref->new_oid);\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 8885e21ddc..99dba2d907 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -289,7 +289,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t\tstrbuf_addstr(sb, rla);\n \t} else {\n \t\tstrbuf_addstr(sb, \"tag: tagging \");\n-\t\tstrbuf_add_unique_abbrev(sb, oid->hash, DEFAULT_ABBREV);\n+\t\tstrbuf_add_unique_abbrev(sb, oid, DEFAULT_ABBREV);\n \t}\n \n \tstrbuf_addstr(sb, \" (\");\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex c886f2e9cd..f58f13957e 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -228,7 +228,7 @@ static void output_commit_title(struct merge_options *o, struct commit *commit)\n \t\tstrbuf_addf(&o->obuf, \"virtual %s\\n\",\n \t\t\tmerge_remote_util(commit)->name);\n \telse {\n-\t\tstrbuf_add_unique_abbrev(&o->obuf, commit->object.oid.hash,\n+\t\tstrbuf_add_unique_abbrev(&o->obuf, &commit->object.oid,\n \t\t\t\t\t DEFAULT_ABBREV);\n \t\tstrbuf_addch(&o->obuf, ' ');\n \t\tif (parse_commit(commit) != 0)\ndiff --git a/pretty.c b/pretty.c\nindex f7ce490230..34fe891fc0 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -549,7 +549,7 @@ static void add_merge_info(const struct pretty_print_context *pp,\n \t\tstruct object_id *oidp = &parent->item->object.oid;\n \t\tstrbuf_addch(sb, ' ');\n \t\tif (pp->abbrev)\n-\t\t\tstrbuf_add_unique_abbrev(sb, oidp->hash, pp->abbrev);\n+\t\t\tstrbuf_add_unique_abbrev(sb, oidp, pp->abbrev);\n \t\telse\n \t\t\tstrbuf_addstr(sb, oid_to_hex(oidp));\n \t\tparent = parent->next;\n@@ -1156,7 +1156,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */\n \t\treturn 1;\n \tcase 'h':\t\t/* abbreviated commit hash */\n \t\tstrbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_COMMIT));\n-\t\tstrbuf_add_unique_abbrev(sb, commit->object.oid.hash,\n+\t\tstrbuf_add_unique_abbrev(sb, &commit->object.oid,\n \t\t\t\t\t c->pretty_ctx->abbrev);\n \t\tstrbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_RESET));\n \t\treturn 1;\n@@ -1164,7 +1164,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */\n \t\tstrbuf_addstr(sb, oid_to_hex(&commit->tree->object.oid));\n \t\treturn 1;\n \tcase 't':\t\t/* abbreviated tree hash */\n-\t\tstrbuf_add_unique_abbrev(sb, commit->tree->object.oid.hash,\n+\t\tstrbuf_add_unique_abbrev(sb, &commit->tree->object.oid,\n \t\t\t\t\t c->pretty_ctx->abbrev);\n \t\treturn 1;\n \tcase 'P':\t\t/* parent hashes */\n@@ -1178,7 +1178,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */\n \t\tfor (p = commit->parents; p; p = p->next) {\n \t\t\tif (p != commit->parents)\n \t\t\t\tstrbuf_addch(sb, ' ');\n-\t\t\tstrbuf_add_unique_abbrev(sb, p->item->object.oid.hash,\n+\t\t\tstrbuf_add_unique_abbrev(sb, &p->item->object.oid,\n \t\t\t\t\t\t c->pretty_ctx->abbrev);\n \t\t}\n \t\treturn 1;\ndiff --git a/strbuf.c b/strbuf.c\nindex 1df674e919..128fbec503 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -869,12 +869,12 @@ void strbuf_addftime(struct strbuf *sb, const char *fmt, const struct tm *tm,\n \tstrbuf_setlen(sb, sb->len + len);\n }\n \n-void strbuf_add_unique_abbrev(struct strbuf *sb, const unsigned char *sha1,\n+void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,\n \t\t\t      int abbrev_len)\n {\n \tint r;\n \tstrbuf_grow(sb, GIT_SHA1_HEXSZ + 1);\n-\tr = find_unique_abbrev_r(sb->buf + sb->len, sha1, abbrev_len);\n+\tr = find_unique_abbrev_r(sb->buf + sb->len, oid->hash, abbrev_len);\n \tstrbuf_setlen(sb, sb->len + r);\n }\n \ndiff --git a/strbuf.h b/strbuf.h\nindex 14c8c10d66..cd7ad898eb 100644\n--- a/strbuf.h\n+++ b/strbuf.h\n@@ -70,6 +70,12 @@ struct strbuf {\n extern char strbuf_slopbuf[];\n #define STRBUF_INIT  { .alloc = 0, .len = 0, .buf = strbuf_slopbuf }\n \n+/*\n+ * Predeclare this here, since cache.h includes this file before it defines the\n+ * struct.\n+ */\n+struct object_id;\n+\n /**\n  * Life Cycle Functions\n  * --------------------\n@@ -539,7 +545,7 @@ extern void strbuf_list_free(struct strbuf **);\n  * the strbuf `sb`.\n  */\n extern void strbuf_add_unique_abbrev(struct strbuf *sb,\n-\t\t\t\t     const unsigned char *sha1,\n+\t\t\t\t     const struct object_id *oid,\n \t\t\t\t     int abbrev_len);\n \n /**\ndiff --git a/submodule.c b/submodule.c\nindex 47ddc9b273..d4a482e647 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -540,9 +540,9 @@ static void show_submodule_header(struct diff_options *o, const char *path,\n \n output_header:\n \tstrbuf_addf(&sb, \"Submodule %s \", path);\n-\tstrbuf_add_unique_abbrev(&sb, one->hash, DEFAULT_ABBREV);\n+\tstrbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n \tstrbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n-\tstrbuf_add_unique_abbrev(&sb, two->hash, DEFAULT_ABBREV);\n+\tstrbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n \tif (message)\n \t\tstrbuf_addf(&sb, \" %s\\n\", message);\n \telse\ndiff --git a/transport.c b/transport.c\nindex 00d48b5b56..87de35dd5e 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -367,7 +367,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain, int summary_widt\n \t\tchar type;\n \t\tconst char *msg;\n \n-\t\tstrbuf_add_unique_abbrev(&quickref, ref->old_oid.hash,\n+\t\tstrbuf_add_unique_abbrev(&quickref, &ref->old_oid,\n \t\t\t\t\t DEFAULT_ABBREV);\n \t\tif (ref->forced_update) {\n \t\t\tstrbuf_addstr(&quickref, \"...\");\n@@ -378,7 +378,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain, int summary_widt\n \t\t\ttype = ' ';\n \t\t\tmsg = NULL;\n \t\t}\n-\t\tstrbuf_add_unique_abbrev(&quickref, ref->new_oid.hash,\n+\t\tstrbuf_add_unique_abbrev(&quickref, &ref->new_oid,\n \t\t\t\t\t DEFAULT_ABBREV);\n \n \t\tprint_ref_status(type, quickref.buf, ref, ref->peer_ref, msg,\ndiff --git a/wt-status.c b/wt-status.c\nindex f5debcd2b4..98e558a70b 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1187,7 +1187,7 @@ static void abbrev_sha1_in_line(struct strbuf *line)\n \t\tstrbuf_trim(split[1]);\n \t\tif (!get_oid(split[1]->buf, &oid)) {\n \t\t\tstrbuf_reset(split[1]);\n-\t\t\tstrbuf_add_unique_abbrev(split[1], oid.hash,\n+\t\t\tstrbuf_add_unique_abbrev(split[1], &oid,\n \t\t\t\t\t\t DEFAULT_ABBREV);\n \t\t\tstrbuf_addch(split[1], ' ');\n \t\t\tstrbuf_reset(line);\n@@ -1421,7 +1421,7 @@ static char *get_branch(const struct worktree *wt, const char *path)\n \t\t;\n \telse if (!get_oid_hex(sb.buf, &oid)) {\n \t\tstrbuf_reset(&sb);\n-\t\tstrbuf_add_unique_abbrev(&sb, oid.hash, DEFAULT_ABBREV);\n+\t\tstrbuf_add_unique_abbrev(&sb, &oid, DEFAULT_ABBREV);\n \t} else if (!strcmp(sb.buf, \"detached HEAD\")) /* rebase */\n \t\tgoto got_nothing;\n \telse\t\t\t/* bisect */\n@@ -1458,7 +1458,7 @@ static int grab_1st_switch(struct object_id *ooid, struct object_id *noid,\n \tif (!strcmp(cb->buf.buf, \"HEAD\")) {\n \t\t/* HEAD is relative. Resolve it to the right reflog entry. */\n \t\tstrbuf_reset(&cb->buf);\n-\t\tstrbuf_add_unique_abbrev(&cb->buf, noid->hash, DEFAULT_ABBREV);\n+\t\tstrbuf_add_unique_abbrev(&cb->buf, noid, DEFAULT_ABBREV);\n \t}\n \treturn 1;\n }\n"},{"id":"339682","messageId":"20180219225927.386065-6-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 05/36] resolve-undo: convert struct resolve_undo_info to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:58:56Z","receivedAt":"2018-02-19T23:01:32Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the sha1 member of this struct to be an array of struct\nobject_id instead.  This change is needed to convert find_unique_abbrev.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/ls-files.c | 2 +-\n resolve-undo.c     | 8 ++++----\n resolve-undo.h     | 2 +-\n 3 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex 2fc836e330..9df66ba307 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -271,7 +271,7 @@ static void show_ru_info(const struct index_state *istate)\n \t\t\tif (!ui->mode[i])\n \t\t\t\tcontinue;\n \t\t\tprintf(\"%s%06o %s %d\\t\", tag_resolve_undo, ui->mode[i],\n-\t\t\t       find_unique_abbrev(ui->sha1[i], abbrev),\n+\t\t\t       find_unique_abbrev(ui->oid[i].hash, abbrev),\n \t\t\t       i + 1);\n \t\t\twrite_name(path);\n \t\t}\ndiff --git a/resolve-undo.c b/resolve-undo.c\nindex b40f3173d3..109c658a85 100644\n--- a/resolve-undo.c\n+++ b/resolve-undo.c\n@@ -24,7 +24,7 @@ void record_resolve_undo(struct index_state *istate, struct cache_entry *ce)\n \tif (!lost->util)\n \t\tlost->util = xcalloc(1, sizeof(*ui));\n \tui = lost->util;\n-\thashcpy(ui->sha1[stage - 1], ce->oid.hash);\n+\toidcpy(&ui->oid[stage - 1], &ce->oid);\n \tui->mode[stage - 1] = ce->ce_mode;\n }\n \n@@ -44,7 +44,7 @@ void resolve_undo_write(struct strbuf *sb, struct string_list *resolve_undo)\n \t\tfor (i = 0; i < 3; i++) {\n \t\t\tif (!ui->mode[i])\n \t\t\t\tcontinue;\n-\t\t\tstrbuf_add(sb, ui->sha1[i], 20);\n+\t\t\tstrbuf_add(sb, ui->oid[i].hash, the_hash_algo->rawsz);\n \t\t}\n \t}\n }\n@@ -89,7 +89,7 @@ struct string_list *resolve_undo_read(const char *data, unsigned long size)\n \t\t\t\tcontinue;\n \t\t\tif (size < 20)\n \t\t\t\tgoto error;\n-\t\t\thashcpy(ui->sha1[i], (const unsigned char *)data);\n+\t\t\thashcpy(ui->oid[i].hash, (const unsigned char *)data);\n \t\t\tsize -= 20;\n \t\t\tdata += 20;\n \t\t}\n@@ -145,7 +145,7 @@ int unmerge_index_entry_at(struct index_state *istate, int pos)\n \t\tstruct cache_entry *nce;\n \t\tif (!ru->mode[i])\n \t\t\tcontinue;\n-\t\tnce = make_cache_entry(ru->mode[i], ru->sha1[i],\n+\t\tnce = make_cache_entry(ru->mode[i], ru->oid[i].hash,\n \t\t\t\t       name, i + 1, 0);\n \t\tif (matched)\n \t\t\tnce->ce_flags |= CE_MATCHED;\ndiff --git a/resolve-undo.h b/resolve-undo.h\nindex 46306455ed..87291904bd 100644\n--- a/resolve-undo.h\n+++ b/resolve-undo.h\n@@ -3,7 +3,7 @@\n \n struct resolve_undo_info {\n \tunsigned int mode[3];\n-\tunsigned char sha1[3][20];\n+\tstruct object_id oid[3];\n };\n \n extern void record_resolve_undo(struct index_state *, struct cache_entry *);\n"},{"id":"339683","messageId":"20180219225927.386065-5-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 04/36] cache-tree: convert remnants to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:58:55Z","receivedAt":"2018-02-19T23:01:34Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the remaining portions of cache-tree.c to use struct object_id.\nConvert several instances of 20 to use the_hash_algo instead.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n cache-tree.c | 26 +++++++++++++-------------\n 1 file changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/cache-tree.c b/cache-tree.c\nindex ba07a8067e..601dd1bb1f 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -320,7 +320,7 @@ static int update_one(struct cache_tree *it,\n \t\tstruct cache_tree_sub *sub = NULL;\n \t\tconst char *path, *slash;\n \t\tint pathlen, entlen;\n-\t\tconst unsigned char *sha1;\n+\t\tconst struct object_id *oid;\n \t\tunsigned mode;\n \t\tint expected_missing = 0;\n \t\tint contains_ita = 0;\n@@ -338,7 +338,7 @@ static int update_one(struct cache_tree *it,\n \t\t\t\tdie(\"cache-tree.c: '%.*s' in '%s' not found\",\n \t\t\t\t    entlen, path + baselen, path);\n \t\t\ti += sub->count;\n-\t\t\tsha1 = sub->cache_tree->oid.hash;\n+\t\t\toid = &sub->cache_tree->oid;\n \t\t\tmode = S_IFDIR;\n \t\t\tcontains_ita = sub->cache_tree->entry_count < 0;\n \t\t\tif (contains_ita) {\n@@ -347,19 +347,19 @@ static int update_one(struct cache_tree *it,\n \t\t\t}\n \t\t}\n \t\telse {\n-\t\t\tsha1 = ce->oid.hash;\n+\t\t\toid = &ce->oid;\n \t\t\tmode = ce->ce_mode;\n \t\t\tentlen = pathlen - baselen;\n \t\t\ti++;\n \t\t}\n \n-\t\tif (is_null_sha1(sha1) ||\n-\t\t    (mode != S_IFGITLINK && !missing_ok && !has_sha1_file(sha1))) {\n+\t\tif (is_null_oid(oid) ||\n+\t\t    (mode != S_IFGITLINK && !missing_ok && !has_object_file(oid))) {\n \t\t\tstrbuf_release(&buffer);\n \t\t\tif (expected_missing)\n \t\t\t\treturn -1;\n \t\t\treturn error(\"invalid object %06o %s for '%.*s'\",\n-\t\t\t\tmode, sha1_to_hex(sha1), entlen+baselen, path);\n+\t\t\t\tmode, oid_to_hex(oid), entlen+baselen, path);\n \t\t}\n \n \t\t/*\n@@ -385,12 +385,12 @@ static int update_one(struct cache_tree *it,\n \t\t/*\n \t\t * \"sub\" can be an empty tree if all subentries are i-t-a.\n \t\t */\n-\t\tif (contains_ita && !hashcmp(sha1, EMPTY_TREE_SHA1_BIN))\n+\t\tif (contains_ita && !oidcmp(oid, &empty_tree_oid))\n \t\t\tcontinue;\n \n \t\tstrbuf_grow(&buffer, entlen + 100);\n \t\tstrbuf_addf(&buffer, \"%o %.*s%c\", mode, entlen, path + baselen, '\\0');\n-\t\tstrbuf_add(&buffer, sha1, 20);\n+\t\tstrbuf_add(&buffer, oid->hash, the_hash_algo->rawsz);\n \n #if DEBUG\n \t\tfprintf(stderr, \"cache-tree update-one %o %.*s\\n\",\n@@ -401,7 +401,7 @@ static int update_one(struct cache_tree *it,\n \tif (repair) {\n \t\tstruct object_id oid;\n \t\thash_object_file(buffer.buf, buffer.len, tree_type, &oid);\n-\t\tif (has_sha1_file(oid.hash))\n+\t\tif (has_object_file(&oid))\n \t\t\toidcpy(&it->oid, &oid);\n \t\telse\n \t\t\tto_invalidate = 1;\n@@ -465,7 +465,7 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,\n #endif\n \n \tif (0 <= it->entry_count) {\n-\t\tstrbuf_add(buffer, it->oid.hash, 20);\n+\t\tstrbuf_add(buffer, it->oid.hash, the_hash_algo->rawsz);\n \t}\n \tfor (i = 0; i < it->subtree_nr; i++) {\n \t\tstruct cache_tree_sub *down = it->down[i];\n@@ -520,11 +520,11 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)\n \t\tgoto free_return;\n \tbuf++; size--;\n \tif (0 <= it->entry_count) {\n-\t\tif (size < 20)\n+\t\tif (size < the_hash_algo->rawsz)\n \t\t\tgoto free_return;\n \t\thashcpy(it->oid.hash, (const unsigned char*)buf);\n-\t\tbuf += 20;\n-\t\tsize -= 20;\n+\t\tbuf += the_hash_algo->rawsz;\n+\t\tsize -= the_hash_algo->rawsz;\n \t}\n \n #if DEBUG\n"},{"id":"339684","messageId":"20180219225927.386065-11-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 10/36] Convert find_unique_abbrev* to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:01Z","receivedAt":"2018-02-19T23:01:38Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert find_unique_abbrev and find_unique_abbrev_r to each take a\npointer to struct object_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/blame.c        |  2 +-\n builtin/branch.c       |  2 +-\n builtin/checkout.c     |  6 +++---\n builtin/describe.c     |  4 ++--\n builtin/log.c          |  4 ++--\n builtin/ls-files.c     |  4 ++--\n builtin/ls-tree.c      |  4 ++--\n builtin/merge.c        |  6 +++---\n builtin/name-rev.c     |  2 +-\n builtin/receive-pack.c |  8 ++++----\n builtin/reset.c        |  2 +-\n builtin/rev-list.c     |  2 +-\n builtin/rev-parse.c    |  2 +-\n builtin/show-branch.c  |  2 +-\n builtin/show-ref.c     |  4 ++--\n builtin/tag.c          |  6 ++++--\n builtin/worktree.c     |  4 ++--\n cache.h                |  6 +++---\n combine-diff.c         |  4 ++--\n diff.c                 |  2 +-\n log-tree.c             | 12 ++++++------\n ref-filter.c           |  4 ++--\n sequencer.c            |  2 +-\n sha1_name.c            | 12 ++++++------\n strbuf.c               |  2 +-\n tag.c                  |  4 ++--\n transport.c            |  2 +-\n wt-status.c            |  6 +++---\n 28 files changed, 61 insertions(+), 59 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 9dcb367b90..b980e8a1dd 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -499,7 +499,7 @@ static int read_ancestry(const char *graft_file)\n \n static int update_auto_abbrev(int auto_abbrev, struct blame_origin *suspect)\n {\n-\tconst char *uniq = find_unique_abbrev(suspect->commit->object.oid.hash,\n+\tconst char *uniq = find_unique_abbrev(&suspect->commit->object.oid,\n \t\t\t\t\t      auto_abbrev);\n \tint len = strlen(uniq);\n \tif (auto_abbrev < len)\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 8dcc2ed058..659deb36f3 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -273,7 +273,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,\n \t\t\t       bname.buf,\n \t\t\t       (flags & REF_ISBROKEN) ? \"broken\"\n \t\t\t       : (flags & REF_ISSYMREF) ? target\n-\t\t\t       : find_unique_abbrev(oid.hash, DEFAULT_ABBREV));\n+\t\t\t       : find_unique_abbrev(&oid, DEFAULT_ABBREV));\n \t\t}\n \t\tdelete_branch_config(bname.buf);\n \ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex bc68d423e5..e6ee955671 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -405,10 +405,10 @@ static void describe_detached_head(const char *msg, struct commit *commit)\n \t\tpp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);\n \tif (print_sha1_ellipsis()) {\n \t\tfprintf(stderr, \"%s %s... %s\\n\", msg,\n-\t\t\tfind_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV), sb.buf);\n+\t\t\tfind_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);\n \t} else {\n \t\tfprintf(stderr, \"%s %s %s\\n\", msg,\n-\t\t\tfind_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV), sb.buf);\n+\t\t\tfind_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);\n \t}\n \tstrbuf_release(&sb);\n }\n@@ -778,7 +778,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)\n \t\t\t\" git branch <new-branch-name> %s\\n\\n\",\n \t\t\t/* Give ngettext() the count */\n \t\t\tlost),\n-\t\t\tfind_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV));\n+\t\t\tfind_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));\n }\n \n /*\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex e4869df7b4..7e6535a8bd 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -285,7 +285,7 @@ static void append_name(struct commit_name *n, struct strbuf *dst)\n \n static void append_suffix(int depth, const struct object_id *oid, struct strbuf *dst)\n {\n-\tstrbuf_addf(dst, \"-%d-g%s\", depth, find_unique_abbrev(oid->hash, abbrev));\n+\tstrbuf_addf(dst, \"-%d-g%s\", depth, find_unique_abbrev(oid, abbrev));\n }\n \n static void describe_commit(struct object_id *oid, struct strbuf *dst)\n@@ -383,7 +383,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)\n \tif (!match_cnt) {\n \t\tstruct object_id *cmit_oid = &cmit->object.oid;\n \t\tif (always) {\n-\t\t\tstrbuf_add_unique_abbrev(dst, cmit_oid->hash, abbrev);\n+\t\t\tstrbuf_add_unique_abbrev(dst, cmit_oid, abbrev);\n \t\t\tif (suffix)\n \t\t\t\tstrbuf_addstr(dst, suffix);\n \t\t\treturn;\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 32a744bfd2..411339c1ed 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1873,12 +1873,12 @@ static void print_commit(char sign, struct commit *commit, int verbose,\n {\n \tif (!verbose) {\n \t\tfprintf(file, \"%c %s\\n\", sign,\n-\t\t       find_unique_abbrev(commit->object.oid.hash, abbrev));\n+\t\t       find_unique_abbrev(&commit->object.oid, abbrev));\n \t} else {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tpp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);\n \t\tfprintf(file, \"%c %s %s\\n\", sign,\n-\t\t       find_unique_abbrev(commit->object.oid.hash, abbrev),\n+\t\t       find_unique_abbrev(&commit->object.oid, abbrev),\n \t\t       buf.buf);\n \t\tstrbuf_release(&buf);\n \t}\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex 9df66ba307..a71f6bd088 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -240,7 +240,7 @@ static void show_ce(struct repository *repo, struct dir_struct *dir,\n \t\t\tprintf(\"%s%06o %s %d\\t\",\n \t\t\t       tag,\n \t\t\t       ce->ce_mode,\n-\t\t\t       find_unique_abbrev(ce->oid.hash, abbrev),\n+\t\t\t       find_unique_abbrev(&ce->oid, abbrev),\n \t\t\t       ce_stage(ce));\n \t\t}\n \t\twrite_eolinfo(repo->index, ce, fullname);\n@@ -271,7 +271,7 @@ static void show_ru_info(const struct index_state *istate)\n \t\t\tif (!ui->mode[i])\n \t\t\t\tcontinue;\n \t\t\tprintf(\"%s%06o %s %d\\t\", tag_resolve_undo, ui->mode[i],\n-\t\t\t       find_unique_abbrev(ui->oid[i].hash, abbrev),\n+\t\t\t       find_unique_abbrev(&ui->oid[i], abbrev),\n \t\t\t       i + 1);\n \t\t\twrite_name(path);\n \t\t}\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex c613dd7b82..c98253adbb 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -103,11 +103,11 @@ static int show_tree(const struct object_id *oid, struct strbuf *base,\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,\n-\t\t\t       find_unique_abbrev(oid->hash, abbrev),\n+\t\t\t       find_unique_abbrev(oid, abbrev),\n \t\t\t       size_text);\n \t\t} else\n \t\t\tprintf(\"%06o %s %s\\t\", mode, type,\n-\t\t\t       find_unique_abbrev(oid->hash, abbrev));\n+\t\t\t       find_unique_abbrev(oid, abbrev));\n \t}\n \tbaselen = base->len;\n \tstrbuf_addstr(base, pathname);\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 861b170468..66cdaa5e0b 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -1289,7 +1289,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \n \t\t\tcheck_commit_signature(commit, &signature_check);\n \n-\t\t\tfind_unique_abbrev_r(hex, commit->object.oid.hash, DEFAULT_ABBREV);\n+\t\t\tfind_unique_abbrev_r(hex, &commit->object.oid, DEFAULT_ABBREV);\n \t\t\tswitch (signature_check.result) {\n \t\t\tcase 'G':\n \t\t\t\tbreak;\n@@ -1385,9 +1385,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \n \t\tif (verbosity >= 0) {\n \t\t\tprintf(_(\"Updating %s..%s\\n\"),\n-\t\t\t       find_unique_abbrev(head_commit->object.oid.hash,\n+\t\t\t       find_unique_abbrev(&head_commit->object.oid,\n \t\t\t\t\t\t  DEFAULT_ABBREV),\n-\t\t\t       find_unique_abbrev(remoteheads->item->object.oid.hash,\n+\t\t\t       find_unique_abbrev(&remoteheads->item->object.oid,\n \t\t\t\t\t\t  DEFAULT_ABBREV));\n \t\t}\n \t\tstrbuf_addstr(&msg, \"Fast-forward\");\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 9e088ebd11..387ddf85d2 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -328,7 +328,7 @@ static void show_name(const struct object *obj,\n \telse if (allow_undefined)\n \t\tprintf(\"undefined\\n\");\n \telse if (always)\n-\t\tprintf(\"%s\\n\", find_unique_abbrev(oid->hash, DEFAULT_ABBREV));\n+\t\tprintf(\"%s\\n\", find_unique_abbrev(oid, DEFAULT_ABBREV));\n \telse\n \t\tdie(\"cannot describe '%s'\", oid_to_hex(oid));\n \tstrbuf_release(&buf);\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 75e7f18ace..2bf7f2d1a3 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1242,11 +1242,11 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)\n \trp_error(\"refusing inconsistent update between symref '%s' (%s..%s) and\"\n \t\t \" its target '%s' (%s..%s)\",\n \t\t cmd->ref_name,\n-\t\t find_unique_abbrev(cmd->old_oid.hash, DEFAULT_ABBREV),\n-\t\t find_unique_abbrev(cmd->new_oid.hash, DEFAULT_ABBREV),\n+\t\t find_unique_abbrev(&cmd->old_oid, DEFAULT_ABBREV),\n+\t\t find_unique_abbrev(&cmd->new_oid, DEFAULT_ABBREV),\n \t\t dst_cmd->ref_name,\n-\t\t find_unique_abbrev(dst_cmd->old_oid.hash, DEFAULT_ABBREV),\n-\t\t find_unique_abbrev(dst_cmd->new_oid.hash, DEFAULT_ABBREV));\n+\t\t find_unique_abbrev(&dst_cmd->old_oid, DEFAULT_ABBREV),\n+\t\t find_unique_abbrev(&dst_cmd->new_oid, DEFAULT_ABBREV));\n \n \tcmd->error_string = dst_cmd->error_string =\n \t\t\"inconsistent aliased update\";\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 5da0f75de9..7f1c3f02a3 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -109,7 +109,7 @@ static void print_new_head_line(struct commit *commit)\n \tstruct strbuf buf = STRBUF_INIT;\n \n \tprintf(_(\"HEAD is now at %s\"),\n-\t\tfind_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV));\n+\t\tfind_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));\n \n \tpp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);\n \tif (buf.len > 0)\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex 48300d9e11..71afab5388 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -108,7 +108,7 @@ static void show_commit(struct commit *commit, void *data)\n \tif (!revs->graph)\n \t\tfputs(get_revision_mark(revs, commit), stdout);\n \tif (revs->abbrev_commit && revs->abbrev)\n-\t\tfputs(find_unique_abbrev(commit->object.oid.hash, revs->abbrev),\n+\t\tfputs(find_unique_abbrev(&commit->object.oid, revs->abbrev),\n \t\t      stdout);\n \telse\n \t\tfputs(oid_to_hex(&commit->object.oid), stdout);\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex 96d06a5d01..fd16f9fad8 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -159,7 +159,7 @@ static void show_rev(int type, const struct object_id *oid, const char *name)\n \t\t}\n \t}\n \telse if (abbrev)\n-\t\tshow_with_type(type, find_unique_abbrev(oid->hash, abbrev));\n+\t\tshow_with_type(type, find_unique_abbrev(oid, abbrev));\n \telse\n \t\tshow_with_type(type, oid_to_hex(oid));\n }\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex e8a4aa40cb..6c2148b71d 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -292,7 +292,7 @@ static void show_one_commit(struct commit *commit, int no_name)\n \t\t}\n \t\telse\n \t\t\tprintf(\"[%s] \",\n-\t\t\t       find_unique_abbrev(commit->object.oid.hash,\n+\t\t\t       find_unique_abbrev(&commit->object.oid,\n \t\t\t\t\t\t  DEFAULT_ABBREV));\n \t}\n \tputs(pretty_str);\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 41e5e71cad..f2eb1a7724 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -29,7 +29,7 @@ static void show_one(const char *refname, const struct object_id *oid)\n \tif (quiet)\n \t\treturn;\n \n-\thex = find_unique_abbrev(oid->hash, abbrev);\n+\thex = find_unique_abbrev(oid, abbrev);\n \tif (hash_only)\n \t\tprintf(\"%s\\n\", hex);\n \telse\n@@ -39,7 +39,7 @@ static void show_one(const char *refname, const struct object_id *oid)\n \t\treturn;\n \n \tif (!peel_ref(refname, &peeled)) {\n-\t\thex = find_unique_abbrev(peeled.hash, abbrev);\n+\t\thex = find_unique_abbrev(&peeled, abbrev);\n \t\tprintf(\"%s %s^{}\\n\", hex, refname);\n \t}\n }\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 99dba2d907..17d6bc0836 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -99,7 +99,8 @@ static int delete_tag(const char *name, const char *ref,\n {\n \tif (delete_ref(NULL, ref, oid, 0))\n \t\treturn 1;\n-\tprintf(_(\"Deleted tag '%s' (was %s)\\n\"), name, find_unique_abbrev(oid->hash, DEFAULT_ABBREV));\n+\tprintf(_(\"Deleted tag '%s' (was %s)\\n\"), name,\n+\t       find_unique_abbrev(oid, DEFAULT_ABBREV));\n \treturn 0;\n }\n \n@@ -551,7 +552,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\tdie(\"%s\", err.buf);\n \tref_transaction_free(transaction);\n \tif (force && !is_null_oid(&prev) && oidcmp(&prev, &object))\n-\t\tprintf(_(\"Updated tag '%s' (was %s)\\n\"), tag, find_unique_abbrev(prev.hash, DEFAULT_ABBREV));\n+\t\tprintf(_(\"Updated tag '%s' (was %s)\\n\"), tag,\n+\t\t       find_unique_abbrev(&prev, DEFAULT_ABBREV));\n \n \tUNLEAK(buf);\n \tUNLEAK(ref);\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 9efdc22466..dba1f90111 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -484,7 +484,7 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)\n \t\tstrbuf_addstr(&sb, \"(bare)\");\n \telse {\n \t\tstrbuf_addf(&sb, \"%-*s \", abbrev_len,\n-\t\t\t\tfind_unique_abbrev(wt->head_oid.hash, DEFAULT_ABBREV));\n+\t\t\t\tfind_unique_abbrev(&wt->head_oid, DEFAULT_ABBREV));\n \t\tif (wt->is_detached)\n \t\t\tstrbuf_addstr(&sb, \"(detached HEAD)\");\n \t\telse if (wt->head_ref) {\n@@ -509,7 +509,7 @@ static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen)\n \n \t\tif (path_len > *maxlen)\n \t\t\t*maxlen = path_len;\n-\t\tsha1_len = strlen(find_unique_abbrev(wt[i]->head_oid.hash, *abbrev));\n+\t\tsha1_len = strlen(find_unique_abbrev(&wt[i]->head_oid, *abbrev));\n \t\tif (sha1_len > *abbrev)\n \t\t\t*abbrev = sha1_len;\n \t}\ndiff --git a/cache.h b/cache.h\nindex 21fbcc2414..09cd994bcc 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -951,14 +951,14 @@ extern void sha1_file_name(struct strbuf *buf, const unsigned char *sha1);\n  * more calls to find_unique_abbrev are made.\n  *\n  * The `_r` variant writes to a buffer supplied by the caller, which must be at\n- * least `GIT_SHA1_HEXSZ + 1` bytes. The return value is the number of bytes\n+ * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes\n  * written (excluding the NUL terminator).\n  *\n  * Note that while this version avoids the static buffer, it is not fully\n  * reentrant, as it calls into other non-reentrant git code.\n  */\n-extern const char *find_unique_abbrev(const unsigned char *sha1, int len);\n-extern int find_unique_abbrev_r(char *hex, const unsigned char *sha1, int len);\n+extern const char *find_unique_abbrev(const struct object_id *oid, int len);\n+extern int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len);\n \n extern const unsigned char null_sha1[GIT_MAX_RAWSZ];\n extern const struct object_id null_oid;\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 18c74dad51..3d86304c5a 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -915,11 +915,11 @@ static void show_combined_header(struct combine_diff_path *elem,\n \t\t\t \"\", elem->path, line_prefix, c_meta, c_reset);\n \tprintf(\"%s%sindex \", line_prefix, c_meta);\n \tfor (i = 0; i < num_parent; i++) {\n-\t\tabb = find_unique_abbrev(elem->parent[i].oid.hash,\n+\t\tabb = find_unique_abbrev(&elem->parent[i].oid,\n \t\t\t\t\t abbrev);\n \t\tprintf(\"%s%s\", i ? \",\" : \"\", abb);\n \t}\n-\tabb = find_unique_abbrev(elem->oid.hash, abbrev);\n+\tabb = find_unique_abbrev(&elem->oid, abbrev);\n \tprintf(\"..%s%s\\n\", abb, c_reset);\n \n \tif (mode_differs) {\ndiff --git a/diff.c b/diff.c\nindex 21c3838b25..94117bcbbf 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3811,7 +3811,7 @@ static int similarity_index(struct diff_filepair *p)\n static const char *diff_abbrev_oid(const struct object_id *oid, int abbrev)\n {\n \tif (startup_info->have_repository)\n-\t\treturn find_unique_abbrev(oid->hash, abbrev);\n+\t\treturn find_unique_abbrev(oid, abbrev);\n \telse {\n \t\tchar *hex = oid_to_hex(oid);\n \t\tif (abbrev < 0)\ndiff --git a/log-tree.c b/log-tree.c\nindex fc0cc0d6d1..8bd398b18d 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -177,7 +177,7 @@ static void show_parents(struct commit *commit, int abbrev, FILE *file)\n \tstruct commit_list *p;\n \tfor (p = commit->parents; p ; p = p->next) {\n \t\tstruct commit *parent = p->item;\n-\t\tfprintf(file, \" %s\", find_unique_abbrev(parent->object.oid.hash, abbrev));\n+\t\tfprintf(file, \" %s\", find_unique_abbrev(&parent->object.oid, abbrev));\n \t}\n }\n \n@@ -185,7 +185,7 @@ static void show_children(struct rev_info *opt, struct commit *commit, int abbre\n {\n \tstruct commit_list *p = lookup_decoration(&opt->children, &commit->object);\n \tfor ( ; p; p = p->next) {\n-\t\tfprintf(opt->diffopt.file, \" %s\", find_unique_abbrev(p->item->object.oid.hash, abbrev));\n+\t\tfprintf(opt->diffopt.file, \" %s\", find_unique_abbrev(&p->item->object.oid, abbrev));\n \t}\n }\n \n@@ -558,7 +558,7 @@ void show_log(struct rev_info *opt)\n \n \t\tif (!opt->graph)\n \t\t\tput_revision_mark(opt, commit);\n-\t\tfputs(find_unique_abbrev(commit->object.oid.hash, abbrev_commit), opt->diffopt.file);\n+\t\tfputs(find_unique_abbrev(&commit->object.oid, abbrev_commit), opt->diffopt.file);\n \t\tif (opt->print_parents)\n \t\t\tshow_parents(commit, abbrev_commit, opt->diffopt.file);\n \t\tif (opt->children.name)\n@@ -620,7 +620,8 @@ void show_log(struct rev_info *opt)\n \n \t\tif (!opt->graph)\n \t\t\tput_revision_mark(opt, commit);\n-\t\tfputs(find_unique_abbrev(commit->object.oid.hash, abbrev_commit),\n+\t\tfputs(find_unique_abbrev(&commit->object.oid,\n+\t\t\t\t\t abbrev_commit),\n \t\t      opt->diffopt.file);\n \t\tif (opt->print_parents)\n \t\t\tshow_parents(commit, abbrev_commit, opt->diffopt.file);\n@@ -628,8 +629,7 @@ void show_log(struct rev_info *opt)\n \t\t\tshow_children(opt, commit, abbrev_commit);\n \t\tif (parent)\n \t\t\tfprintf(opt->diffopt.file, \" (from %s)\",\n-\t\t\t       find_unique_abbrev(parent->object.oid.hash,\n-\t\t\t\t\t\t  abbrev_commit));\n+\t\t\t       find_unique_abbrev(&parent->object.oid, abbrev_commit));\n \t\tfputs(diff_get_color_opt(&opt->diffopt, DIFF_RESET), opt->diffopt.file);\n \t\tshow_decorations(opt, commit);\n \t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 9cbd92611c..62834f7153 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -742,13 +742,13 @@ static int grab_objectname(const char *name, const struct object_id *oid,\n {\n \tif (starts_with(name, \"objectname\")) {\n \t\tif (atom->u.objectname.option == O_SHORT) {\n-\t\t\tv->s = xstrdup(find_unique_abbrev(oid->hash, DEFAULT_ABBREV));\n+\t\t\tv->s = xstrdup(find_unique_abbrev(oid, DEFAULT_ABBREV));\n \t\t\treturn 1;\n \t\t} else if (atom->u.objectname.option == O_FULL) {\n \t\t\tv->s = xstrdup(oid_to_hex(oid));\n \t\t\treturn 1;\n \t\t} else if (atom->u.objectname.option == O_LENGTH) {\n-\t\t\tv->s = xstrdup(find_unique_abbrev(oid->hash, atom->u.objectname.length));\n+\t\t\tv->s = xstrdup(find_unique_abbrev(oid, atom->u.objectname.length));\n \t\t\treturn 1;\n \t\t} else\n \t\t\tdie(\"BUG: unknown %%(objectname) option\");\ndiff --git a/sequencer.c b/sequencer.c\nindex d2fc1871ed..ed7c42ba7d 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -282,7 +282,7 @@ struct commit_message {\n \n static const char *short_commit_name(struct commit *commit)\n {\n-\treturn find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV);\n+\treturn find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV);\n }\n \n static int get_message(struct commit *commit, struct commit_message *out)\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 611c7d24dd..dd68e68f45 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -380,7 +380,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \t}\n \n \tadvise(\"  %s %s%s\",\n-\t       find_unique_abbrev(oid->hash, DEFAULT_ABBREV),\n+\t       find_unique_abbrev(oid, DEFAULT_ABBREV),\n \t       typename(type) ? typename(type) : \"unknown type\",\n \t       desc.buf);\n \n@@ -569,7 +569,7 @@ static void find_abbrev_len_packed(struct min_abbrev_data *mad)\n \t\tfind_abbrev_len_for_pack(p, mad);\n }\n \n-int find_unique_abbrev_r(char *hex, const unsigned char *sha1, int len)\n+int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len)\n {\n \tstruct disambiguate_state ds;\n \tstruct min_abbrev_data mad;\n@@ -596,14 +596,14 @@ int find_unique_abbrev_r(char *hex, const unsigned char *sha1, int len)\n \t\t\tlen = FALLBACK_DEFAULT_ABBREV;\n \t}\n \n-\tsha1_to_hex_r(hex, sha1);\n+\toid_to_hex_r(hex, oid);\n \tif (len == GIT_SHA1_HEXSZ || !len)\n \t\treturn GIT_SHA1_HEXSZ;\n \n \tmad.init_len = len;\n \tmad.cur_len = len;\n \tmad.hex = hex;\n-\tmad.hash = sha1;\n+\tmad.hash = oid->hash;\n \n \tfind_abbrev_len_packed(&mad);\n \n@@ -621,13 +621,13 @@ int find_unique_abbrev_r(char *hex, const unsigned char *sha1, int len)\n \treturn mad.cur_len;\n }\n \n-const char *find_unique_abbrev(const unsigned char *sha1, int len)\n+const char *find_unique_abbrev(const struct object_id *oid, int len)\n {\n \tstatic int bufno;\n \tstatic char hexbuffer[4][GIT_MAX_HEXSZ + 1];\n \tchar *hex = hexbuffer[bufno];\n \tbufno = (bufno + 1) % ARRAY_SIZE(hexbuffer);\n-\tfind_unique_abbrev_r(hex, sha1, len);\n+\tfind_unique_abbrev_r(hex, oid, len);\n \treturn hex;\n }\n \ndiff --git a/strbuf.c b/strbuf.c\nindex 128fbec503..3099c39f79 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -874,7 +874,7 @@ void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,\n {\n \tint r;\n \tstrbuf_grow(sb, GIT_SHA1_HEXSZ + 1);\n-\tr = find_unique_abbrev_r(sb->buf + sb->len, oid->hash, abbrev_len);\n+\tr = find_unique_abbrev_r(sb->buf + sb->len, oid, abbrev_len);\n \tstrbuf_setlen(sb, sb->len + r);\n }\n \ndiff --git a/tag.c b/tag.c\nindex fcbe012f7a..0b63c3f1ec 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -46,7 +46,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \t\treturn error(\"%s: cannot verify a non-tag object of type %s.\",\n \t\t\t\tname_to_report ?\n \t\t\t\tname_to_report :\n-\t\t\t\tfind_unique_abbrev(oid->hash, DEFAULT_ABBREV),\n+\t\t\t\tfind_unique_abbrev(oid, DEFAULT_ABBREV),\n \t\t\t\ttypename(type));\n \n \tbuf = read_sha1_file(oid->hash, &type, &size);\n@@ -54,7 +54,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \t\treturn error(\"%s: unable to read file.\",\n \t\t\t\tname_to_report ?\n \t\t\t\tname_to_report :\n-\t\t\t\tfind_unique_abbrev(oid->hash, DEFAULT_ABBREV));\n+\t\t\t\tfind_unique_abbrev(oid, DEFAULT_ABBREV));\n \n \tret = run_gpg_verify(buf, size, flags);\n \ndiff --git a/transport.c b/transport.c\nindex 87de35dd5e..b9dfa11bd2 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -461,7 +461,7 @@ static int print_one_push_status(struct ref *ref, const char *dest, int count,\n static int measure_abbrev(const struct object_id *oid, int sofar)\n {\n \tchar hex[GIT_MAX_HEXSZ + 1];\n-\tint w = find_unique_abbrev_r(hex, oid->hash, DEFAULT_ABBREV);\n+\tint w = find_unique_abbrev_r(hex, oid, DEFAULT_ABBREV);\n \n \treturn (w < sofar) ? sofar : w;\n }\ndiff --git a/wt-status.c b/wt-status.c\nindex 698fa1d42a..e3e75e99a9 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1349,7 +1349,7 @@ static void show_cherry_pick_in_progress(struct wt_status *s,\n \t\t\t\t\tconst char *color)\n {\n \tstatus_printf_ln(s, color, _(\"You are currently cherry-picking commit %s.\"),\n-\t\t\tfind_unique_abbrev(state->cherry_pick_head_oid.hash, DEFAULT_ABBREV));\n+\t\t\tfind_unique_abbrev(&state->cherry_pick_head_oid, DEFAULT_ABBREV));\n \tif (s->hints) {\n \t\tif (has_unmerged(s))\n \t\t\tstatus_printf_ln(s, color,\n@@ -1368,7 +1368,7 @@ static void show_revert_in_progress(struct wt_status *s,\n \t\t\t\t\tconst char *color)\n {\n \tstatus_printf_ln(s, color, _(\"You are currently reverting commit %s.\"),\n-\t\t\t find_unique_abbrev(state->revert_head_oid.hash, DEFAULT_ABBREV));\n+\t\t\t find_unique_abbrev(&state->revert_head_oid, DEFAULT_ABBREV));\n \tif (s->hints) {\n \t\tif (has_unmerged(s))\n \t\t\tstatus_printf_ln(s, color,\n@@ -1488,7 +1488,7 @@ static void wt_status_get_detached_from(struct wt_status_state *state)\n \t\tstate->detached_from = xstrdup(from);\n \t} else\n \t\tstate->detached_from =\n-\t\t\txstrdup(find_unique_abbrev(cb.noid.hash, DEFAULT_ABBREV));\n+\t\t\txstrdup(find_unique_abbrev(&cb.noid, DEFAULT_ABBREV));\n \toidcpy(&state->detached_oid, &cb.noid);\n \tstate->detached_at = !get_oid(\"HEAD\", &oid) &&\n \t\t\t     !oidcmp(&oid, &state->detached_oid);\n"},{"id":"339685","messageId":"20180219225927.386065-12-sandals@crustytoothpaste.net","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"[PATCH 11/36] http-walker: convert struct object_request to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-19T22:59:02Z","receivedAt":"2018-02-19T23:01:42Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert struct object_request to use struct object_id by updating the\ndefinition and applying the following semantic patch, plus the standard\nobject_id transforms:\n\n@@\nstruct object_request E1;\n@@\n- E1.sha1\n+ E1.oid.hash\n\n@@\nstruct object_request *E1;\n@@\n- E1->sha1\n+ E1->oid.hash\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n http-walker.c | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/http-walker.c b/http-walker.c\nindex 07c2b1af82..f506f394ac 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -22,7 +22,7 @@ enum object_request_state {\n \n struct object_request {\n \tstruct walker *walker;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct alt_base *repo;\n \tenum object_request_state state;\n \tstruct http_object_request *req;\n@@ -56,7 +56,7 @@ static void start_object_request(struct walker *walker,\n \tstruct active_request_slot *slot;\n \tstruct http_object_request *req;\n \n-\treq = new_http_object_request(obj_req->repo->base, obj_req->sha1);\n+\treq = new_http_object_request(obj_req->repo->base, obj_req->oid.hash);\n \tif (req == NULL) {\n \t\tobj_req->state = ABORTED;\n \t\treturn;\n@@ -82,7 +82,7 @@ static void finish_object_request(struct object_request *obj_req)\n \t\treturn;\n \n \tif (obj_req->req->rename == 0)\n-\t\twalker_say(obj_req->walker, \"got %s\\n\", sha1_to_hex(obj_req->sha1));\n+\t\twalker_say(obj_req->walker, \"got %s\\n\", oid_to_hex(&obj_req->oid));\n }\n \n static void process_object_response(void *callback_data)\n@@ -129,7 +129,7 @@ static int fill_active_slot(struct walker *walker)\n \tlist_for_each_safe(pos, tmp, head) {\n \t\tobj_req = list_entry(pos, struct object_request, node);\n \t\tif (obj_req->state == WAITING) {\n-\t\t\tif (has_sha1_file(obj_req->sha1))\n+\t\t\tif (has_sha1_file(obj_req->oid.hash))\n \t\t\t\tobj_req->state = COMPLETE;\n \t\t\telse {\n \t\t\t\tstart_object_request(walker, obj_req);\n@@ -148,7 +148,7 @@ static void prefetch(struct walker *walker, unsigned char *sha1)\n \n \tnewreq = xmalloc(sizeof(*newreq));\n \tnewreq->walker = walker;\n-\thashcpy(newreq->sha1, sha1);\n+\thashcpy(newreq->oid.hash, sha1);\n \tnewreq->repo = data->alt;\n \tnewreq->state = WAITING;\n \tnewreq->req = NULL;\n@@ -481,13 +481,13 @@ static int fetch_object(struct walker *walker, unsigned char *sha1)\n \n \tlist_for_each(pos, head) {\n \t\tobj_req = list_entry(pos, struct object_request, node);\n-\t\tif (!hashcmp(obj_req->sha1, sha1))\n+\t\tif (!hashcmp(obj_req->oid.hash, sha1))\n \t\t\tbreak;\n \t}\n \tif (obj_req == NULL)\n \t\treturn error(\"Couldn't find request for %s in the queue\", hex);\n \n-\tif (has_sha1_file(obj_req->sha1)) {\n+\tif (has_sha1_file(obj_req->oid.hash)) {\n \t\tif (obj_req->req != NULL)\n \t\t\tabort_http_object_request(obj_req->req);\n \t\tabort_object_request(obj_req);\n@@ -541,7 +541,7 @@ static int fetch_object(struct walker *walker, unsigned char *sha1)\n \t} else if (req->zret != Z_STREAM_END) {\n \t\twalker->corrupt_object_found++;\n \t\tret = error(\"File %s (%s) corrupt\", hex, req->url);\n-\t} else if (hashcmp(obj_req->sha1, req->real_sha1)) {\n+\t} else if (hashcmp(obj_req->oid.hash, req->real_sha1)) {\n \t\tret = error(\"File %s has bad hash\", hex);\n \t} else if (req->rename < 0) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n"},{"id":"339818","messageId":"xmqqh8qayybs.fsf@gitster-ct.c.googlers.com","threadId":"47878","inReplyTo":"20180219225927.386065-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH 00/36] object_id part 12","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-02-21T18:47:19Z","receivedAt":"2018-02-21T18:47:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> This is the twelfth in a series of patches to convert from unsigned char\n> [20] to struct object_id.  This series is based on next.\n>\n> Included in this series are conversions for find_unique_abbrev and\n> lookup_replace_object, as well as parts of the sha1_file code.\n>\n> Conflicts with pu are average in number but minor, mostly because of the\n> type_name conversion.  None of them are tricky, except that the\n> introduction of get_tree_entry_if_blob requires a conversion of that\n> function.\n\nAnd the reason why this is based on 'next' is...?  Which topic(s) do\nwe have to wait for until we can queue this series, in other words?\n\nThanks for working on this, though.\n"},{"id":"339879","messageId":"20180222002408.GH6619@genre.crustytoothpaste.net","threadId":"47878","inReplyTo":"xmqqh8qayybs.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH 00/36] object_id part 12","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-02-22T00:24:08Z","receivedAt":"2018-02-22T00:24:22Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Wed, Feb 21, 2018 at 10:47:19AM -0800, Junio C Hamano wrote:\n> \"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n> \n> > This is the twelfth in a series of patches to convert from unsigned char\n> > [20] to struct object_id.  This series is based on next.\n> >\n> > Included in this series are conversions for find_unique_abbrev and\n> > lookup_replace_object, as well as parts of the sha1_file code.\n> >\n> > Conflicts with pu are average in number but minor, mostly because of the\n> > type_name conversion.  None of them are tricky, except that the\n> > introduction of get_tree_entry_if_blob requires a conversion of that\n> > function.\n> \n> And the reason why this is based on 'next' is...?  Which topic(s) do\n> we have to wait for until we can queue this series, in other words?\n> \n> Thanks for working on this, though.\n\nIt was waiting on the hash_algo changes I had submitted, and I don't\nbelieve they'd made it into master.  When they have, I'll rebase and\nsend a v2.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\nhttps://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"}]}