{"thread":{"id":"48026","subject":"[PATCH v3 01/36] bulk-checkin: convert index_bulk_checkin to struct object_id","startedAt":"2018-03-12T02:28:21Z","lastAt":"2018-03-15T01:05:50Z","messageCount":42,"participants":["brian m. carlson","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":36},"messages":[{"id":"341432","messageId":"20180312022756.483934-2-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 01/36] bulk-checkin: convert index_bulk_checkin to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:21Z","receivedAt":"2018-03-12T02:28:21Z","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 9d87eac07b..e5ce2a7954 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 1b94f39c4c..6b887f8aaf 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":"341433","messageId":"20180312022756.483934-4-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 03/36] cache-tree: convert write_*_as_tree to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:23Z","receivedAt":"2018-03-12T02:28:24Z","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 1151b5c73a..1bcc3606c5 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1550,7 +1550,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@@ -1575,7 +1575,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@@ -1626,7 +1626,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@@ -2004,7 +2004,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 e8d9d4383e..0c7437f536 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -639,7 +639,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 969755b7e0..c8160e974d 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":"341434","messageId":"20180312022756.483934-5-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 04/36] cache-tree: convert remnants to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:24Z","receivedAt":"2018-03-12T02:28:25Z","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 | 29 +++++++++++++++--------------\n 1 file changed, 15 insertions(+), 14 deletions(-)\n\ndiff --git a/cache-tree.c b/cache-tree.c\nindex ba07a8067e..6a555f4d43 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@@ -492,6 +492,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)\n \tchar *ep;\n \tstruct cache_tree *it;\n \tint i, subtree_nr;\n+\tconst unsigned rawsz = the_hash_algo->rawsz;\n \n \tit = NULL;\n \t/* skip name, but make sure name exists */\n@@ -520,11 +521,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 < 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\tmemcpy(it->oid.hash, (const unsigned char*)buf, rawsz);\n+\t\tbuf += rawsz;\n+\t\tsize -= rawsz;\n \t}\n \n #if DEBUG\n"},{"id":"341435","messageId":"20180312022756.483934-7-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 06/36] tree: convert read_tree_recursive to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:26Z","receivedAt":"2018-03-12T02:28:27Z","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 8f4dfb1046..8eb118201d 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -66,7 +66,7 @@ static int post_checkout_hook(struct commit *old_commit, struct commit *new_comm\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":"341436","messageId":"20180312022756.483934-9-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 08/36] strbuf: convert strbuf_add_unique_abbrev to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:28Z","receivedAt":"2018-03-12T02:28:30Z","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 8eb118201d..5981e1a3ed 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 d32d94692c..aeafe63ba6 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -708,9 +708,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@@ -723,9 +723,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 8c493a569f..a5fc6c090f 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -293,7 +293,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 5f138ed3c8..07309045ef 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -873,12 +873,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 12a2503fda..c210640d35 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 66f4234af1..5c685b6165 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1188,7 +1188,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@@ -1422,7 +1422,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@@ -1459,7 +1459,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":"341437","messageId":"20180312022756.483934-8-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 07/36] ref-filter: convert grab_objectname to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:27Z","receivedAt":"2018-03-12T02:28:32Z","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 45fc56216a..dbe554dffa 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@@ -1455,7 +1455,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":"341438","messageId":"20180312022756.483934-14-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 13/36] replace_object: convert struct replace_object to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:33Z","receivedAt":"2018-03-12T02:28:33Z","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":"341439","messageId":"20180312022756.483934-17-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 16/36] archive: convert sha1_file_to_archive to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:36Z","receivedAt":"2018-03-12T02:28:39Z","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":"341440","messageId":"20180312022756.483934-21-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 20/36] streaming: convert open_istream to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:40Z","receivedAt":"2018-03-12T02:28:42Z","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 b28ebfadd4..ae11d2a610 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 a197926eaa..8307cc9b04 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 e4cb840661..cdcba4483b 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":"341441","messageId":"20180312022756.483934-23-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 22/36] sha1_file: convert assert_sha1_type to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:42Z","receivedAt":"2018-03-12T02:28:45Z","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 27b5fd8a39..67a04fcd12 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 00c99c7272..6d77787af9 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 cdcba4483b..a307037e88 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    type_name(expect));\n }\n \n"},{"id":"341442","messageId":"20180312022756.483934-24-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 23/36] sha1_file: convert retry_bad_packed_offset to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:43Z","receivedAt":"2018-03-12T02:28:46Z","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 7c1a2519fc..5f08aa0a14 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":"341443","messageId":"20180312022756.483934-26-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 25/36] Convert remaining callers of sha1_object_info_extended to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:45Z","receivedAt":"2018-03-12T02:28:50Z","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 a307037e88..eafb0733e5 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":"341444","messageId":"20180312022756.483934-28-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 27/36] builtin/fmt-merge-msg: convert remaining code to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:47Z","receivedAt":"2018-03-12T02:28:51Z","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":"341445","messageId":"20180312022756.483934-31-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 30/36] streaming: convert istream internals to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:50Z","receivedAt":"2018-03-12T02:28:54Z","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":"341446","messageId":"20180312022756.483934-27-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 26/36] sha1_file: convert sha1_object_info* to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:46Z","receivedAt":"2018-03-12T02:29: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 200e0ad9a2..00b97c1898 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 d90170f070..27f4f235f6 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.type_name = &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 9b049e9d08..d75a3a45d3 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 aeafe63ba6..90bb659390 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -637,7 +637,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 eae018e3fb..0922558683 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 ae11d2a610..32a98f3102 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 e39fe5d423..263c530315 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 8307cc9b04..66bc0057fe 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 4394d01c93..38ced18dad 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) ? type_name(type) : \"unknown\");\n \t}\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 9f01f3fc7f..19006e52bc 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, type_name(obj_type),\n \t\t\t       oid_to_hex(oid), type_name(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_oid) < 0)\n \t\tdie(\"Not a valid object name: '%s'\", object_ref);\n \n-\ttype = sha1_object_info(old_oid.hash, NULL);\n+\ttype = oid_object_info(&old_oid, NULL);\n \tif (type < 0)\n \t\tdie(\"unable to get object type for %s\", oid_to_hex(&old_oid));\n \ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 644e6888be..11a9883d27 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -212,7 +212,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@@ -298,7 +298,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 9f96949bc0..6d553374c0 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 67a04fcd12..66f41af56e 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 8184ecfc2a..b463078d57 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 58ef360da4..af3a211ec3 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\ttype_name(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 68bcf35d95..4063e955db 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 3e31ad7a0c..f26395ecab 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 191ebe3e6a..404e1440e9 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 c10d87c246..91eb010ca9 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1376,7 +1376,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 c994392caf..47b050edfb 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2881,7 +2881,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, type_name(type));\n \t\t\t}\ndiff --git a/sha1_file.c b/sha1_file.c\nindex eafb0733e5..e1292c11fd 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 b59f3ed748..d129dc4f31 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 c210640d35..a05c544e8d 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 a6e0abce67..db3e31034c 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":"341447","messageId":"20180312022756.483934-29-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 28/36] builtin/notes: convert static functions to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:48Z","receivedAt":"2018-03-12T02:29:02Z","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":"341448","messageId":"20180312022756.483934-35-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 34/36] Convert lookup_replace_object to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:54Z","receivedAt":"2018-03-12T02:29:04Z","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      | 42 ++++++++++++++++++++----------------------\n streaming.c      | 16 +++++-----------\n 6 files changed, 42 insertions(+), 59 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 3c9718cc8c..0491f0cbc4 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 8e32f0d33b..2c909385a7 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, type_name(type)) < 0) {\n+\t\tif (check_object_signature(repl, buffer, size, type_name(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 cdd49e5274..60418da10b 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1227,22 +1227,20 @@ 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 = oid;\n \tint already_retried = 0;\n-\tstruct object_id realoid;\n \n-\thashcpy(realoid.hash, real);\n+\tif (flags & OBJECT_INFO_LOOKUP_REPLACE)\n+\t\treal = lookup_replace_object(oid);\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 +1260,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 +1279,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 +1295,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 +1370,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 +1382,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":"341449","messageId":"20180312022756.483934-34-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 33/36] sha1_file: convert read_sha1_file to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:53Z","receivedAt":"2018-03-12T02:29:08Z","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 f8f15edc7c..b1e1bd58bf 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 cc2cc92944..78c9808bd1 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@@ -1829,8 +1829,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 4382b4447e..2c46d257cd 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 d75a3a45d3..a15898d641 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, type_name(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 386a86b66e..bf50bab6f8 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -306,7 +306,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 32a98f3102..7873e7243f 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 a0ccbf6699..a1d674608a 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 ac3dcd7a51..25f7c5ef0b 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 11a9883d27..86450bae05 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@@ -304,7 +304,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 6d553374c0..af02e1bc6b 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 05315ea7c9..dcdaada111 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 9293c14564..3c9718cc8c 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 cf55f03b75..2ef495963f 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 6d77787af9..ca474a7c11 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 b463078d57..5c8f3e16e8 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 dedbf5d476..63a917be45 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 6c33112aea..d3f26ec8ca 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 *blob_data = read_sha1_file(ce->oid.hash, &type, size);\n+\tvoid *blob_data = read_object_file(&ce->oid, &type, size);\n \n \tif (blob_data) {\n \t\tif (type == OBJ_BLOB)\ndiff --git a/fast-import.c b/fast-import.c\nindex dc63af1eb6..b300e4416d 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 5c8c12dde3..9218c2a643 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 834b8eb439..65b90c10a3 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -2015,7 +2015,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 7dcd9daf62..ff82b63133 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\", type_name(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 4063e955db..8e32f0d33b 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 977921d90c..3f0246fe88 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 ca2bc7e6b2..9a333e21b5 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 e2b8e7694e..cdd49e5274 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 db3e31034c..86b1dcbb82 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\ttype_name(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":"341450","messageId":"20180312022756.483934-37-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 36/36] convert: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:56Z","receivedAt":"2018-03-12T02:29:10Z","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 d3f26ec8ca..2101201a11 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":"341451","messageId":"20180312022756.483934-30-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 29/36] tree-walk: convert get_tree_entry_follow_symlinks internals to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:49Z","receivedAt":"2018-03-12T02:29:14Z","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":"341452","messageId":"20180312022756.483934-33-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 32/36] sha1_file: convert read_object_with_reference to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:52Z","receivedAt":"2018-03-12T02:29:16Z","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 27f4f235f6..4382b4447e 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 9a0973e8f1..386a86b66e 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -452,7 +452,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@@ -614,7 +614,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 66bc0057fe..a0ccbf6699 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 66f41af56e..9293c14564 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 af3a211ec3..dc63af1eb6 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 e1292c11fd..e2b8e7694e 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":"341453","messageId":"20180312022756.483934-36-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 35/36] sha1_file: introduce a constant for max header length","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:55Z","receivedAt":"2018-03-12T02:29:19Z","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 60418da10b..581a9dc522 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@@ -1514,7 +1517,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@@ -1669,7 +1672,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@@ -1689,7 +1692,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@@ -1709,7 +1712,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@@ -2191,7 +2194,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":"341454","messageId":"20180312022756.483934-25-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 24/36] packfile: convert unpack_entry to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:44Z","receivedAt":"2018-03-12T02:29:23Z","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 5f08aa0a14..3e31ad7a0c 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":"341455","messageId":"20180312022756.483934-32-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 31/36] tree-walk: convert tree entry functions to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:51Z","receivedAt":"2018-03-12T02:29:25Z","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 00b97c1898..cc2cc92944 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 cdc2257db5..ecdce08c4b 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 d129dc4f31..39e911c8ba 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":"341456","messageId":"20180312022756.483934-20-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 19/36] sha1_file: convert check_sha1_signature to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:39Z","receivedAt":"2018-03-12T02:29:30Z","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 27b2cc138e..9b049e9d08 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, type_name(type)) < 0)\n+\t\tif (check_object_signature(oid, buf, size, type_name(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 9744175e23..b28ebfadd4 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, type_name(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 5a28e94318..27b5fd8a39 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 e6ad3f61f0..68bcf35d95 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, type_name(type)) < 0) {\n+\t\tstruct object_id reploid;\n+\t\thashcpy(reploid.hash, repl);\n+\n+\t\tif (check_object_signature(&reploid, buffer, size, type_name(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 8fc7dd1694..d0591dd5e8 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, type_name(type)))\n+\t\telse if (check_object_signature(entries[i].oid.oid, data, size, type_name(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 5081d585a2..e4cb840661 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, type_name(*type))) {\n \t\t\terror(\"sha1 mismatch for %s (expected %s)\", path,\n \t\t\t      oid_to_hex(expected_oid));\n"},{"id":"341457","messageId":"20180312022756.483934-22-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 21/36] builtin/mktree: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:41Z","receivedAt":"2018-03-12T02:29:31Z","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 f5f3c0eea1..e39fe5d423 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), type_name(obj_type), type_name(mode_type));\n+\t\t\t\tpath, oid_to_hex(&oid), type_name(obj_type), type_name(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":"341458","messageId":"20180312022756.483934-15-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 14/36] builtin/mktag: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:34Z","receivedAt":"2018-03-12T02:29:35Z","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":"341459","messageId":"20180312022756.483934-19-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 18/36] sha1_file: convert read_loose_object to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:38Z","receivedAt":"2018-03-12T02:29:37Z","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 ef78c6c00c..eae018e3fb 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 fe8b2c2676..5a28e94318 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 6b887f8aaf..5081d585a2 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, type_name(*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":"341460","messageId":"20180312022756.483934-13-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 12/36] send-pack: convert remaining functions to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:32Z","receivedAt":"2018-03-12T02:29:41Z","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":"341461","messageId":"20180312022756.483934-16-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 15/36] archive: convert write_archive_entry_fn_t to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:35Z","receivedAt":"2018-03-12T02:29:43Z","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":"341462","messageId":"20180312022756.483934-18-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 17/36] builtin/index-pack: convert struct ref_delta_entry to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:37Z","receivedAt":"2018-03-12T02:29:45Z","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 59878e70b8..9744175e23 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, type_name(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":"341463","messageId":"20180312022756.483934-10-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 09/36] wt-status: convert struct wt_status_state to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:29Z","receivedAt":"2018-03-12T02:29:49Z","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 5c685b6165..78be89a422 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1350,7 +1350,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@@ -1369,7 +1369,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@@ -1490,9 +1490,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@@ -1551,13 +1551,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 ea2456daf2..430770b854 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -118,9 +118,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":"341464","messageId":"20180312022756.483934-12-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 11/36] http-walker: convert struct object_request to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:31Z","receivedAt":"2018-03-12T02:29:50Z","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":"341465","messageId":"20180312022756.483934-6-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 05/36] resolve-undo: convert struct resolve_undo_info to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:25Z","receivedAt":"2018-03-12T02:29:56Z","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\nConvert some instances of hard-coded constants to use the_hash_algo as\nwell.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/ls-files.c |  2 +-\n resolve-undo.c     | 15 ++++++++-------\n resolve-undo.h     |  2 +-\n 3 files changed, 10 insertions(+), 9 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..aed95b4b35 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@@ -55,6 +55,7 @@ struct string_list *resolve_undo_read(const char *data, unsigned long size)\n \tsize_t len;\n \tchar *endptr;\n \tint i;\n+\tconst unsigned rawsz = the_hash_algo->rawsz;\n \n \tresolve_undo = xcalloc(1, sizeof(*resolve_undo));\n \tresolve_undo->strdup_strings = 1;\n@@ -87,11 +88,11 @@ struct string_list *resolve_undo_read(const char *data, unsigned long size)\n \t\tfor (i = 0; i < 3; i++) {\n \t\t\tif (!ui->mode[i])\n \t\t\t\tcontinue;\n-\t\t\tif (size < 20)\n+\t\t\tif (size < rawsz)\n \t\t\t\tgoto error;\n-\t\t\thashcpy(ui->sha1[i], (const unsigned char *)data);\n-\t\t\tsize -= 20;\n-\t\t\tdata += 20;\n+\t\t\tmemcpy(ui->oid[i].hash, (const unsigned char *)data, rawsz);\n+\t\t\tsize -= rawsz;\n+\t\t\tdata += rawsz;\n \t\t}\n \t}\n \treturn resolve_undo;\n@@ -145,7 +146,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":"341466","messageId":"20180312022756.483934-11-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 10/36] Convert find_unique_abbrev* to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:30Z","receivedAt":"2018-03-12T02:30:00Z","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 5981e1a3ed..45968c2d85 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 0c7437f536..b4f32105b5 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -1327,7 +1327,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@@ -1420,9 +1420,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 d320b6f1e3..2fd72c0be5 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 a1e680b5e9..36b2087782 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 a5fc6c090f..644e6888be 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@@ -558,7 +559,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 4e7c98758f..3442f257b7 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -498,7 +498,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@@ -523,7 +523,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 d06932ed0b..fe8b2c2676 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 1ec9af1f81..cf55f03b75 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 915f4d6e9f..8184ecfc2a 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 bdf23c5f7b..d1c0bedf24 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 dbe554dffa..ca2bc7e6b2 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 c8160e974d..c994392caf 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 735c1c0b8e..b59f3ed748 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       type_name(type) ? type_name(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 07309045ef..aa97ad0919 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -878,7 +878,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 66210fd477..a6e0abce67 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\ttype_name(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 78be89a422..50815e5faf 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1350,7 +1350,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@@ -1369,7 +1369,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@@ -1489,7 +1489,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":"341467","messageId":"20180312022756.483934-1-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":null,"subject":"[PATCH v3 00/36] object_id part 12","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:20Z","receivedAt":"2018-03-12T02:30:02Z","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 various parts of\nthe code to struct object_id.\n\nChanges from v2:\n* Rebase onto master (to fix \"typename\" → \"type_name\" changes).\n* Replace some uses of hashcpy with memcpy.\n* Replace some instances of \"20\" with references to the_hash_algo.\n\nChanges from v1:\n* Rebase onto master.\n\ntbdiff output below.\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             |  39 +++++------\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           |  15 +++--\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, 600 insertions(+), 585 deletions(-)\n\ngit tbdiff output between v2 and v3:\n\n 1: fb5a482ad6 =  1: 034342eba3 bulk-checkin: convert index_bulk_checkin to struct object_id\n 2: 6d91ba00b2 =  2: 61e7e3192e builtin/write-tree: convert to struct object_id\n 3: 9b7bb4b8de =  3: 934ebd4399 cache-tree: convert write_*_as_tree to object_id\n 4: 62cd33ae27 !  4: 4ecefd666a cache-tree: convert remnants to struct object_id\n    @@ -86,17 +86,26 @@\n      \tfor (i = 0; i < it->subtree_nr; i++) {\n      \t\tstruct cache_tree_sub *down = it->down[i];\n     @@\n    + \tchar *ep;\n    + \tstruct cache_tree *it;\n    + \tint i, subtree_nr;\n    ++\tconst unsigned rawsz = the_hash_algo->rawsz;\n    + \n    + \tit = NULL;\n    + \t/* skip name, but make sure name exists */\n    +@@\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\tif (size < rawsz)\n      \t\t\tgoto free_return;\n    - \t\thashcpy(it->oid.hash, (const unsigned char*)buf);\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\tmemcpy(it->oid.hash, (const unsigned char*)buf, rawsz);\n    ++\t\tbuf += rawsz;\n    ++\t\tsize -= rawsz;\n      \t}\n      \n      #if DEBUG\n 5: ff2f8a8106 !  5: 61c309cfbd resolve-undo: convert struct resolve_undo_info to object_id\n    @@ -4,6 +4,9 @@\n         \n         Convert the sha1 member of this struct to be an array of struct\n         object_id instead.  This change is needed to convert find_unique_abbrev.\n    +    \n    +    Convert some instances of hard-coded constants to use the_hash_algo as\n    +    well.\n         \n         Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n     \n    @@ -42,14 +45,29 @@\n      \t}\n      }\n     @@\n    + \tsize_t len;\n    + \tchar *endptr;\n    + \tint i;\n    ++\tconst unsigned rawsz = the_hash_algo->rawsz;\n    + \n    + \tresolve_undo = xcalloc(1, sizeof(*resolve_undo));\n    + \tresolve_undo->strdup_strings = 1;\n    +@@\n    + \t\tfor (i = 0; i < 3; i++) {\n    + \t\t\tif (!ui->mode[i])\n      \t\t\t\tcontinue;\n    - \t\t\tif (size < 20)\n    +-\t\t\tif (size < 20)\n    ++\t\t\tif (size < rawsz)\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\tsize -= 20;\n    +-\t\t\tdata += 20;\n    ++\t\t\tmemcpy(ui->oid[i].hash, (const unsigned char *)data, rawsz);\n    ++\t\t\tsize -= rawsz;\n    ++\t\t\tdata += rawsz;\n      \t\t}\n    + \t}\n    + \treturn resolve_undo;\n     @@\n      \t\tstruct cache_entry *nce;\n      \t\tif (!ru->mode[i])\n 6: 62757785a8 =  6: 6637a7cce4 tree: convert read_tree_recursive to struct object_id\n 7: 5f4f67befa =  7: ce96caf197 ref-filter: convert grab_objectname to struct object_id\n 8: 9e33fff56c =  8: b9743c9980 strbuf: convert strbuf_add_unique_abbrev to use struct object_id\n 9: fee46a7ee4 =  9: 146483c174 wt-status: convert struct wt_status_state to object_id\n10: 30a455ac10 ! 10: 5b0a4fc66e Convert find_unique_abbrev* to struct object_id\n    @@ -464,7 +464,7 @@\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       type_name(type) ? type_name(type) : \"unknown type\",\n      \t       desc.buf);\n      \n     @@\n    @@ -532,7 +532,7 @@\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    + \t\t\t\ttype_name(type));\n      \n      \tbuf = read_sha1_file(oid->hash, &type, &size);\n     @@\n11: f3b86deb27 = 11: 781ae2e76c http-walker: convert struct object_request to use struct object_id\n12: 7dcf103bc0 = 12: 0f4746b4e2 send-pack: convert remaining functions to struct object_id\n13: 07abaa5a35 = 13: 884218b4fb replace_object: convert struct replace_object to object_id\n14: 891fc02851 = 14: d726dff9e6 builtin/mktag: convert to struct object_id\n15: d1bcf86847 = 15: 5b7d02b408 archive: convert write_archive_entry_fn_t to object_id\n16: e42d7bc122 = 16: 0c7b33a72b archive: convert sha1_file_to_archive to struct object_id\n17: d626f4f65b ! 17: 296eb04a77 builtin/index-pack: convert struct ref_delta_entry to object_id\n    @@ -115,7 +115,7 @@\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\t\tbase_obj->size, type_name(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));\n18: 351cdb6231 ! 18: 1cf89780db sha1_file: convert read_loose_object to use struct object_id\n    @@ -67,7 +67,7 @@\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\t\t\t *size, type_name(*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));\n19: 59865169a2 ! 19: 20a40e304f sha1_file: convert check_sha1_signature to struct object_id\n    @@ -21,8 +21,8 @@\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\tif (check_sha1_signature(oid->hash, buf, size, type_name(type)) < 0)\n    ++\t\tif (check_object_signature(oid, buf, size, type_name(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}\n    @@ -36,7 +36,7 @@\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\t\tbase_obj->size, type_name(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,\n     \n    @@ -89,11 +89,11 @@\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\tif (check_sha1_signature(repl, buffer, size, type_name(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\tif (check_object_signature(&reploid, buffer, size, type_name(type)) < 0) {\n      \t\t\tfree(buffer);\n      \t\t\terror(\"sha1 mismatch %s\", sha1_to_hex(repl));\n      \t\t\treturn NULL;\n    @@ -114,8 +114,8 @@\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\telse if (check_sha1_signature(entries[i].oid.hash, data, size, type_name(type)))\n    ++\t\telse if (check_object_signature(entries[i].oid.oid, data, size, type_name(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) {\n    @@ -162,6 +162,6 @@\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\t\t\t *size, type_name(*type))) {\n      \t\t\terror(\"sha1 mismatch for %s (expected %s)\", path,\n      \t\t\t      oid_to_hex(expected_oid));\n20: ea0c6804de = 20: 808277ddfd streaming: convert open_istream to use struct object_id\n21: b14dd69baf ! 21: 17bb9e5947 builtin/mktree: convert to struct object_id\n    @@ -90,8 +90,8 @@\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\t\tpath, sha1_to_hex(sha1), type_name(obj_type), type_name(mode_type));\n    ++\t\t\t\tpath, oid_to_hex(&oid), type_name(obj_type), type_name(mode_type));\n      \t\t}\n      \t}\n      \n22: 8d54506a22 ! 22: 3ac824fdcc sha1_file: convert assert_sha1_type to object_id\n    @@ -64,6 +64,6 @@\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    + \t\t    type_name(expect));\n      }\n      \n23: 9e162450c4 = 23: c65ffc3955 sha1_file: convert retry_bad_packed_offset to struct object_id\n24: 4f9b84dc45 = 24: c4a4f9a98e packfile: convert unpack_entry to struct object_id\n25: c7a2206ff9 = 25: 3d92a7ac4b Convert remaining callers of sha1_object_info_extended to object_id\n26: 4f148256d4 ! 26: ae7dbea778 sha1_file: convert sha1_object_info* to object_id\n    @@ -79,13 +79,26 @@\n      \treturn 0;\n       error_out:\n     \n    +diff --git a/builtin/blame.c b/builtin/blame.c\n    +--- a/builtin/blame.c\n    ++++ b/builtin/blame.c\n    +@@\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)\n    +\n     diff --git a/builtin/cat-file.c b/builtin/cat-file.c\n     --- a/builtin/cat-file.c\n     +++ b/builtin/cat-file.c\n     @@\n      \tswitch (opt) {\n      \tcase 't':\n    - \t\toi.typename = &sb;\n    + \t\toi.type_name = &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    @@ -139,6 +152,19 @@\n      \t\t       obj_name ? obj_name : oid_to_hex(&data->oid));\n      \t\tfflush(stdout);\n     \n    +diff --git a/builtin/describe.c b/builtin/describe.c\n    +--- a/builtin/describe.c\n    ++++ b/builtin/describe.c\n    +@@\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);\n    +\n     diff --git a/builtin/fast-export.c b/builtin/fast-export.c\n     --- a/builtin/fast-export.c\n     +++ b/builtin/fast-export.c\n    @@ -268,7 +294,7 @@\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\t       (type > 0) ? type_name(type) : \"unknown\");\n      \t}\n     \n     diff --git a/builtin/replace.c b/builtin/replace.c\n    @@ -283,8 +309,8 @@\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    + \t\t\tprintf(\"%s (%s) -> %s (%s)\\n\", refname, type_name(obj_type),\n    + \t\t\t       oid_to_hex(oid), type_name(repl_type));\n     @@\n      \tstruct ref_transaction *transaction;\n      \tstruct strbuf err = STRBUF_INIT;\n    @@ -297,13 +323,13 @@\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     @@\n    - \tif (get_oid(object_ref, &old) < 0)\n    + \tif (get_oid(object_ref, &old_oid) < 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    +-\ttype = sha1_object_info(old_oid.hash, NULL);\n    ++\ttype = oid_object_info(&old_oid, NULL);\n      \tif (type < 0)\n    - \t\tdie(\"unable to get object type for %s\", oid_to_hex(&old));\n    + \t\tdie(\"unable to get object type for %s\", oid_to_hex(&old_oid));\n      \n     \n     diff --git a/builtin/tag.c b/builtin/tag.c\n    @@ -401,7 +427,7 @@\n      \t\t\t\t\tS_ISDIR(mode) ?  \"Tree\" : \"Blob\",\n     @@\n      \t\t\tdie(\"Not a blob (actually a %s): %s\",\n    - \t\t\t\ttypename(oe->type), command_buf.buf);\n    + \t\t\t\ttype_name(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    @@ -539,7 +565,7 @@\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\t\tname, type_name(type));\n      \t\t\t}\n     \n     diff --git a/sha1_file.c b/sha1_file.c\n27: a2c063aac7 = 27: 7621154915 builtin/fmt-merge-msg: convert remaining code to object_id\n28: 981277d812 = 28: a7245b9137 builtin/notes: convert static functions to object_id\n29: b856198f19 = 29: 1bd6edfaa4 tree-walk: convert get_tree_entry_follow_symlinks internals to object_id\n30: bf15b40528 = 30: 5107f04efe streaming: convert istream internals to struct object_id\n31: 1f3a02f2ef = 31: f616bf9ce1 tree-walk: convert tree entry functions to object_id\n32: 55f95e2765 = 32: 093f6e92f9 sha1_file: convert read_object_with_reference to object_id\n33: 09e4ac139e ! 33: e0e0f888c6 sha1_file: convert read_sha1_file to struct object_id\n    @@ -189,7 +189,7 @@\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    + \t\tif (check_object_signature(oid, buf, size, type_name(type)) < 0)\n     @@\n      \t\treturn;\n      \t}\n    @@ -585,10 +585,10 @@\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    +-\tvoid *blob_data = read_sha1_file(ce->oid.hash, &type, size);\n    ++\tvoid *blob_data = read_object_file(&ce->oid, &type, size);\n    + \n    + \tif (blob_data) {\n      \t\tif (type == OBJ_BLOB)\n     \n     diff --git a/fast-import.c b/fast-import.c\n    @@ -657,7 +657,7 @@\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    + \thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %lu\", type_name(type), len) + 1;\n      \n      \t/* Set it up */\n     \n    @@ -973,7 +973,7 @@\n     +++ b/tag.c\n     @@\n      \t\t\t\tfind_unique_abbrev(oid, DEFAULT_ABBREV),\n    - \t\t\t\ttypename(type));\n    + \t\t\t\ttype_name(type));\n      \n     -\tbuf = read_sha1_file(oid->hash, &type, &size);\n     +\tbuf = read_object_file(oid, &type, &size);\n34: d5f315fd57 ! 34: 42aef22217 Convert lookup_replace_object to struct object_id\n    @@ -88,8 +88,8 @@\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\tif (check_object_signature(&reploid, buffer, size, type_name(type)) < 0) {\n    ++\t\tif (check_object_signature(repl, buffer, size, type_name(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    @@ -147,14 +147,14 @@\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    ++\tconst struct object_id *real = oid;\n      \tint already_retried = 0;\n     -\tstruct object_id realoid;\n    --\n    + \n     -\thashcpy(realoid.hash, real);\n    --\n    ++\tif (flags & OBJECT_INFO_LOOKUP_REPLACE)\n    ++\t\treal = lookup_replace_object(oid);\n    + \n     -\tif (is_null_sha1(real))\n     +\tif (is_null_oid(real))\n      \t\treturn -1;\n35: c7db0519ee = 35: 3cc49890bd sha1_file: introduce a constant for max header length\n36: 2c6a3f6d11 = 36: 919dba36a5 convert: convert to struct object_id\n"},{"id":"341468","messageId":"20180312022756.483934-3-sandals@crustytoothpaste.net","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 02/36] builtin/write-tree: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-12T02:27:22Z","receivedAt":"2018-03-12T02:30:04Z","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":"341639","messageId":"xmqqtvtizjq9.fsf@gitster-ct.c.googlers.com","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH v3 00/36] object_id part 12","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-03-14T16:48:30Z","receivedAt":"2018-03-14T16:48:39Z","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 various parts of\n> the code to struct object_id.\n>\n> Changes from v2:\n> * Rebase onto master (to fix \"typename\" → \"type_name\" changes).\n> * Replace some uses of hashcpy with memcpy.\n> * Replace some instances of \"20\" with references to the_hash_algo.\n>\n> Changes from v1:\n> * Rebase onto master.\n>\n> tbdiff output below.\n>\n> brian 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\nAs always, thanks for working on this.  \n\nAfter this series, what jumps at me out of output from\n\n    git grep -e '[^0-9A-Za-z_][24]0[^0-9A-Za-z_]' -- '*.[ch]' \\\n\t\t':!*sha1*' ':!contrib/' ':!compat/'\n\nare code that parses the incoming patch in apply.c (where the full\nblob object names used for binary patches are assumed to be in\nSHA-1), builtin/pack-objects.c (where it has to know the current\nfile format of a packfile intimately) and diff.c (where it clips the\nlength to which the blob object names on the \"index\" lines are\nabbreviated to).  Changing 40 in the last one to \"the hex length of\nthe currently deployed hash\" should be relatively uncontroversial.\n"},{"id":"341644","messageId":"xmqqlgeuzhqe.fsf@gitster-ct.c.googlers.com","threadId":"48026","inReplyTo":"20180312022756.483934-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH v3 00/36] object_id part 12","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-03-14T17:31:37Z","receivedAt":"2018-03-14T17:31:45Z","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>     -+\t\tbuf += the_hash_algo->rawsz;\n>     -+\t\tsize -= the_hash_algo->rawsz;\n>     ++\t\tmemcpy(it->oid.hash, (const unsigned char*)buf, rawsz);\n>     ++\t\tbuf += rawsz;\n>     ++\t\tsize -= rawsz;\n>       \t}\n\nUsing memcpy() to stuff the hash[] field of oid structure with a\nbare byte array of rawsz bytes appears twice as a pattern in these\npatches.  I wonder if this is something we want to abstract behind\nthe API, e.g.\n\n\tsize_t oidstuff_(struct object_id *oid, const unsigned char *buf)\n\t{\n\t\tsize_t rawsz = the_hash_algo->rawsz;\n\t\tmemcpy(oid->hash, buf, rawsz);\n                return rawsz;\n\t}\n\nIt just felt a bit uneven to be using a bare-metal memcpy() when\noidcpy() abstraction releaves the callers from having to be aware of\nthe rawsz all the time.\n\n"},{"id":"341707","messageId":"xmqqd106zbgy.fsf@gitster-ct.c.googlers.com","threadId":"48026","inReplyTo":"xmqqtvtizjq9.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3 00/36] object_id part 12","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-03-14T19:46:53Z","receivedAt":"2018-03-14T19:47:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> \"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n>\n>> This is the twelfth in a series of patches to convert various parts of\n>> the code to struct object_id.\n>>\n>> brian m. carlson (36):\n>>   ...\n> As always, thanks for working on this.  \n\nThere are a few topics that add new callsites to functions that are\nupdated (e.g. find_unique_abbrev()), so I'll need to do a bit of the\nusual evil merging to coax this topic in.  Please holler if you spot\nmy screw-up in what I'll push out in a few hours.\n\nThanks.\n"},{"id":"341730","messageId":"20180315005314.GB330384@genre.crustytoothpaste.net","threadId":"48026","inReplyTo":"xmqqlgeuzhqe.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3 00/36] object_id part 12","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-15T00:53:14Z","receivedAt":"2018-03-15T00:53:27Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Wed, Mar 14, 2018 at 10:31:37AM -0700, Junio C Hamano wrote:\n> \"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n> \n> >     -+\t\tbuf += the_hash_algo->rawsz;\n> >     -+\t\tsize -= the_hash_algo->rawsz;\n> >     ++\t\tmemcpy(it->oid.hash, (const unsigned char*)buf, rawsz);\n> >     ++\t\tbuf += rawsz;\n> >     ++\t\tsize -= rawsz;\n> >       \t}\n> \n> Using memcpy() to stuff the hash[] field of oid structure with a\n> bare byte array of rawsz bytes appears twice as a pattern in these\n> patches.  I wonder if this is something we want to abstract behind\n> the API, e.g.\n> \n> \tsize_t oidstuff_(struct object_id *oid, const unsigned char *buf)\n> \t{\n> \t\tsize_t rawsz = the_hash_algo->rawsz;\n> \t\tmemcpy(oid->hash, buf, rawsz);\n>                 return rawsz;\n> \t}\n> \n> It just felt a bit uneven to be using a bare-metal memcpy() when\n> oidcpy() abstraction releaves the callers from having to be aware of\n> the rawsz all the time.\n\nDuy suggested oidread and oidwrite, which I can certainly implement.\nI'm also comfortable with just keeping hashcpy around for these cases if\nwe want.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\nhttps://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"341731","messageId":"20180315010538.GC330384@genre.crustytoothpaste.net","threadId":"48026","inReplyTo":"xmqqtvtizjq9.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3 00/36] object_id part 12","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-03-15T01:05:39Z","receivedAt":"2018-03-15T01:05:50Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Wed, Mar 14, 2018 at 09:48:30AM -0700, Junio C Hamano wrote:\n> As always, thanks for working on this.  \n> \n> After this series, what jumps at me out of output from\n> \n>     git grep -e '[^0-9A-Za-z_][24]0[^0-9A-Za-z_]' -- '*.[ch]' \\\n> \t\t':!*sha1*' ':!contrib/' ':!compat/'\n> \n> are code that parses the incoming patch in apply.c (where the full\n> blob object names used for binary patches are assumed to be in\n> SHA-1), builtin/pack-objects.c (where it has to know the current\n> file format of a packfile intimately) and diff.c (where it clips the\n> length to which the blob object names on the \"index\" lines are\n> abbreviated to).  Changing 40 in the last one to \"the hex length of\n> the currently deployed hash\" should be relatively uncontroversial.\n\nI have patches that hit several of these places, but not diff.c.  I'll\nprobably pick that piece up next.\n\nBy the way, thanks for a useful regex.  It's a little bit different\nthan what I've been using, but provides a nice overview.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\nhttps://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"}]}