{"thread":{"id":"45782","subject":"[PATCH 02/53] Clean up outstanding object_id transforms.","startedAt":"2017-04-23T21:35:41Z","lastAt":"2017-04-28T01:15:07Z","messageCount":67,"participants":["brian m. carlson","Junio C Hamano","Brandon Williams","Stefan Beller","Michael Haggerty","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":53},"messages":[{"id":"317567","messageId":"20170423213453.253425-3-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 02/53] Clean up outstanding object_id transforms.","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:02Z","receivedAt":"2017-04-23T21:35:41Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"The semantic patch for standard object_id transforms found two\noutstanding places where we could make a transformation automatically.\nApply these changes.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/diff.c | 2 +-\n reflog-walk.c  | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex d184aafab..a25b4e4ae 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -408,7 +408,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\t} else if (obj->type == OBJ_BLOB) {\n \t\t\tif (2 <= blobs)\n \t\t\t\tdie(_(\"more than two blobs given: '%s'\"), name);\n-\t\t\thashcpy(blob[blobs].oid.hash, obj->oid.hash);\n+\t\t\toidcpy(&blob[blobs].oid, &obj->oid);\n \t\t\tblob[blobs].name = name;\n \t\t\tblob[blobs].mode = entry->mode;\n \t\t\tblobs++;\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex 99679f582..c8fdf051d 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -241,7 +241,7 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)\n \t\tlogobj = parse_object(reflog->ooid.hash);\n \t} while (commit_reflog->recno && (logobj && logobj->type != OBJ_COMMIT));\n \n-\tif (!logobj && commit_reflog->recno >= 0 && is_null_sha1(reflog->ooid.hash)) {\n+\tif (!logobj && commit_reflog->recno >= 0 && is_null_oid(&reflog->ooid)) {\n \t\t/* a root commit, but there are still more entries to show */\n \t\treflog = &commit_reflog->reflogs->items[commit_reflog->recno];\n \t\tlogobj = parse_object(reflog->noid.hash);\n"},{"id":"317568","messageId":"20170423213453.253425-1-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":null,"subject":"[PATCH 00/53] object_id part 8","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:00Z","receivedAt":"2017-04-23T21:35:42Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is the eighth series of patches to convert unsigned char [20] to\nstruct object_id.  This series converts lookup_commit, lookup_blob,\nlookup_tree, lookup_tag, and finally parse_object to struct object_id.\n\nA small number of functions have temporaries inserted during the\nconversion in order to allow conversion of functions that still need to\ntake unsigned char *; they are removed either later in the series or\nwill be in a future series.\n\nThis series can be fetched from the object-id-part8 branch from either\nof the follwing:\n\nhttps://github.com/bk2204/git\nhttps://git.crustytoothpaste.net/git/bmc/git.git\n\nbrian m. carlson (53):\n  fetch-pack: convert to struct object_id\n  Clean up outstanding object_id transforms.\n  Convert struct cache_tree to use struct object_id\n  builtin/name-rev: convert to struct object_id\n  builtin/prune: convert to struct object_id\n  bundle: convert to struct object_id\n  branch: convert to struct object_id\n  builtin/blame: convert static function to struct object_id\n  builtin/rev-parse: convert to struct object_id\n  fast-import: convert internal structs to struct object_id\n  fast-import: convert to struct object_id\n  submodule: convert merge_submodule to use struct object_id\n  notes-cache: convert to struct object_id\n  parse-options-cb: convert to struct object_id\n  reflog_expire: convert to struct object_id\n  builtin/verify-commit: convert to struct object_id\n  tag: convert parse_tag_buffer to struct object_id\n  http-push: convert some static functions to struct object_id\n  notes-utils: convert internals to struct object_id\n  revision: convert prepare_show_merge to struct object_id\n  shallow: convert shallow registration functions to object_id\n  sequencer: convert some functions to struct object_id\n  builtin/tag: convert to struct object_id\n  Convert remaining callers of lookup_commit_reference* to object_id\n  Convert lookup_commit* to struct object_id\n  pack: convert struct pack_idx_entry to struct object_id\n  builtin/unpack-objects: convert to struct object_id\n  Convert remaining callers of lookup_blob to object_id\n  Convert lookup_blob to struct object_id\n  tree: convert read_tree_1 to use struct object_id internally\n  builtin/reflog: convert tree_is_complete to take struct object_id\n  Convert lookup_tree to struct object_id\n  log-tree: convert to struct object_id\n  Convert lookup_tag to struct object_id\n  Convert the verify_pack callback to struct object_id\n  Convert struct ref_array_item to struct object_id\n  ref-filter: convert some static functions to struct object_id\n  refs: convert struct ref_update to use struct object_id\n  refs/files-backend: convert many internals to struct object_id\n  http-push: convert process_ls_object and descendants to object_id\n  revision: rename add_pending_sha1 to add_pending_oid\n  revision: convert remaining parse_object callers to object_id\n  upload-pack: convert remaining parse_object callers to object_id\n  sha1_name: convert internals of peel_onion to object_id\n  builtin/read-tree: convert to struct object_id\n  builtin/ls-files: convert overlay_tree_on_cache to object_id\n  sequencer: convert fast_forward_to to struct object_id\n  merge: convert checkout_fast_forward to struct object_id\n  builtin/ls-tree: convert to struct object_id\n  diff-lib: convert do_diff_cache to struct object_id\n  sequencer: convert do_recursive_merge to struct object_id\n  tree: convert parse_tree_indirect to struct object_id\n  object: convert parse_object* to take struct object_id\n\n archive.c                       |   6 +-\n bisect.c                        |   2 +-\n blob.c                          |   6 +-\n blob.h                          |   2 +-\n branch.c                        |  16 +-\n builtin/am.c                    |  18 +-\n builtin/blame.c                 |  14 +-\n builtin/branch.c                |   6 +-\n builtin/checkout.c              |  18 +-\n builtin/clone.c                 |   4 +-\n builtin/commit-tree.c           |   2 +-\n builtin/commit.c                |   8 +-\n builtin/describe.c              |  10 +-\n builtin/diff-tree.c             |   8 +-\n builtin/diff.c                  |   6 +-\n builtin/fast-export.c           |   8 +-\n builtin/fetch.c                 |   7 +-\n builtin/fmt-merge-msg.c         |   8 +-\n builtin/fsck.c                  |  16 +-\n builtin/grep.c                  |   2 +-\n builtin/index-pack.c            |  56 ++---\n builtin/log.c                   |  10 +-\n builtin/ls-files.c              |   6 +-\n builtin/ls-tree.c               |   6 +-\n builtin/merge-base.c            |   6 +-\n builtin/merge-tree.c            |  10 +-\n builtin/merge.c                 |  12 +-\n builtin/name-rev.c              |  32 +--\n builtin/notes.c                 |   2 +-\n builtin/pack-objects.c          |  71 ++++---\n builtin/prune.c                 |   7 +-\n builtin/pull.c                  |  14 +-\n builtin/read-tree.c             |  10 +-\n builtin/receive-pack.c          |   8 +-\n builtin/reflog.c                |  36 ++--\n builtin/replace.c               |   6 +-\n builtin/reset.c                 |  10 +-\n builtin/rev-list.c              |   2 +-\n builtin/rev-parse.c             |  56 ++---\n builtin/show-branch.c           |   4 +-\n builtin/tag.c                   |  66 +++---\n builtin/unpack-objects.c        |  65 +++---\n builtin/verify-commit.c         |  12 +-\n bulk-checkin.c                  |   4 +-\n bundle.c                        |  39 ++--\n bundle.h                        |   4 +-\n cache-tree.c                    |  33 +--\n cache-tree.h                    |   3 +-\n cache.h                         |   4 +-\n commit.c                        |  38 ++--\n commit.h                        |  16 +-\n diff-lib.c                      |  12 +-\n diff.c                          |   4 +-\n diff.h                          |   2 +-\n fast-import.c                   | 441 ++++++++++++++++++++--------------------\n fetch-pack.c                    |  97 ++++-----\n fsck.c                          |   6 +-\n http-backend.c                  |   2 +-\n http-push.c                     |  55 ++---\n list-objects.c                  |   4 +-\n log-tree.c                      |  26 +--\n merge-recursive.c               |  16 +-\n merge.c                         |   4 +-\n notes-cache.c                   |  29 ++-\n notes-cache.h                   |   4 +-\n notes-merge.c                   |  26 +--\n notes-utils.c                   |  18 +-\n object.c                        |  38 ++--\n object.h                        |   8 +-\n pack-bitmap-write.c             |   8 +-\n pack-bitmap.c                   |   4 +-\n pack-check.c                    |  26 ++-\n pack-objects.c                  |   8 +-\n pack-write.c                    |  10 +-\n pack.h                          |   4 +-\n parse-options-cb.c              |   6 +-\n pretty.c                        |   2 +-\n reachable.c                     |   8 +-\n ref-filter.c                    |  38 ++--\n ref-filter.h                    |   2 +-\n reflog-walk.c                   |   6 +-\n refs.c                          |   4 +-\n refs.h                          |   6 +-\n refs/files-backend.c            | 163 +++++++--------\n refs/refs-internal.h            |   4 +-\n remote.c                        |  17 +-\n revision.c                      |  76 +++----\n revision.h                      |   6 +-\n sequencer.c                     |  59 +++---\n server-info.c                   |   2 +-\n sha1_name.c                     |  38 ++--\n shallow.c                       |  34 ++--\n submodule.c                     |  32 +--\n submodule.h                     |   8 +-\n t/helper/test-dump-cache-tree.c |   4 +-\n t/helper/test-match-trees.c     |   4 +-\n tag.c                           |  25 ++-\n tag.h                           |   2 +-\n transport.c                     |   2 +-\n tree.c                          |  22 +-\n tree.h                          |   4 +-\n upload-pack.c                   |  60 +++---\n walker.c                        |   8 +-\n wt-status.c                     |   2 +-\n 104 files changed, 1174 insertions(+), 1137 deletions(-)\n\n"},{"id":"317569","messageId":"20170423213453.253425-2-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 01/53] fetch-pack: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:01Z","receivedAt":"2017-04-23T21:35:43Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert all uses of unsigned char [20] to struct object_id.  Switch one\nuse of get_sha1_hex to parse_oid_hex to avoid the need for a constant.\nThis change is necessary in order to convert parse_object.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n fetch-pack.c | 89 ++++++++++++++++++++++++++++++------------------------------\n 1 file changed, 45 insertions(+), 44 deletions(-)\n\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 42969353d..1e6b03b6b 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -118,9 +118,9 @@ static void rev_list_push(struct commit *commit, int mark)\n \t}\n }\n \n-static int rev_list_insert_ref(const char *refname, const unsigned char *sha1)\n+static int rev_list_insert_ref(const char *refname, const struct object_id *oid)\n {\n-\tstruct object *o = deref_tag(parse_object(sha1), refname, 0);\n+\tstruct object *o = deref_tag(parse_object(oid->hash), refname, 0);\n \n \tif (o && o->type == OBJ_COMMIT)\n \t\trev_list_push((struct commit *)o, SEEN);\n@@ -131,7 +131,7 @@ static int rev_list_insert_ref(const char *refname, const unsigned char *sha1)\n static int rev_list_insert_ref_oid(const char *refname, const struct object_id *oid,\n \t\t\t\t   int flag, void *cb_data)\n {\n-\treturn rev_list_insert_ref(refname, oid->hash);\n+\treturn rev_list_insert_ref(refname, oid);\n }\n \n static int clear_marks(const char *refname, const struct object_id *oid,\n@@ -183,7 +183,7 @@ static void mark_common(struct commit *commit,\n   Get the next rev to send, ignoring the common.\n */\n \n-static const unsigned char *get_rev(void)\n+static const struct object_id *get_rev(void)\n {\n \tstruct commit *commit = NULL;\n \n@@ -222,7 +222,7 @@ static const unsigned char *get_rev(void)\n \t\t}\n \t}\n \n-\treturn commit->object.oid.hash;\n+\treturn &commit->object.oid;\n }\n \n enum ack_type {\n@@ -251,7 +251,7 @@ static void consume_shallow_list(struct fetch_pack_args *args, int fd)\n \t}\n }\n \n-static enum ack_type get_ack(int fd, unsigned char *result_sha1)\n+static enum ack_type get_ack(int fd, struct object_id *result_oid)\n {\n \tint len;\n \tchar *line = packet_read_line(fd, &len);\n@@ -262,7 +262,7 @@ static enum ack_type get_ack(int fd, unsigned char *result_sha1)\n \tif (!strcmp(line, \"NAK\"))\n \t\treturn NAK;\n \tif (skip_prefix(line, \"ACK \", &arg)) {\n-\t\tif (!get_sha1_hex(arg, result_sha1)) {\n+\t\tif (!get_oid_hex(arg, result_oid)) {\n \t\t\targ += 40;\n \t\t\tlen -= arg - line;\n \t\t\tif (len < 1)\n@@ -291,7 +291,7 @@ static void send_request(struct fetch_pack_args *args,\n \n static void insert_one_alternate_object(struct object *obj)\n {\n-\trev_list_insert_ref(NULL, obj->oid.hash);\n+\trev_list_insert_ref(NULL, &obj->oid);\n }\n \n #define INITIAL_FLUSH 16\n@@ -315,12 +315,12 @@ static int next_flush(struct fetch_pack_args *args, int count)\n }\n \n static int find_common(struct fetch_pack_args *args,\n-\t\t       int fd[2], unsigned char *result_sha1,\n+\t\t       int fd[2], struct object_id *result_oid,\n \t\t       struct ref *refs)\n {\n \tint fetching;\n \tint count = 0, flushes = 0, flush_at = INITIAL_FLUSH, retval;\n-\tconst unsigned char *sha1;\n+\tconst struct object_id *oid;\n \tunsigned in_vain = 0;\n \tint got_continue = 0;\n \tint got_ready = 0;\n@@ -338,7 +338,7 @@ static int find_common(struct fetch_pack_args *args,\n \n \tfetching = 0;\n \tfor ( ; refs ; refs = refs->next) {\n-\t\tunsigned char *remote = refs->old_oid.hash;\n+\t\tstruct object_id *remote = &refs->old_oid;\n \t\tconst char *remote_hex;\n \t\tstruct object *o;\n \n@@ -352,12 +352,12 @@ static int find_common(struct fetch_pack_args *args,\n \t\t * interested in the case we *know* the object is\n \t\t * reachable and we have already scanned it.\n \t\t */\n-\t\tif (((o = lookup_object(remote)) != NULL) &&\n+\t\tif (((o = lookup_object(remote->hash)) != NULL) &&\n \t\t\t\t(o->flags & COMPLETE)) {\n \t\t\tcontinue;\n \t\t}\n \n-\t\tremote_hex = sha1_to_hex(remote);\n+\t\tremote_hex = oid_to_hex(remote);\n \t\tif (!fetching) {\n \t\t\tstruct strbuf c = STRBUF_INIT;\n \t\t\tif (multi_ack == 2)     strbuf_addstr(&c, \" multi_ack_detailed\");\n@@ -408,25 +408,25 @@ static int find_common(struct fetch_pack_args *args,\n \tif (args->deepen) {\n \t\tchar *line;\n \t\tconst char *arg;\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \n \t\tsend_request(args, fd[1], &req_buf);\n \t\twhile ((line = packet_read_line(fd[0], NULL))) {\n \t\t\tif (skip_prefix(line, \"shallow \", &arg)) {\n-\t\t\t\tif (get_sha1_hex(arg, sha1))\n+\t\t\t\tif (get_oid_hex(arg, &oid))\n \t\t\t\t\tdie(_(\"invalid shallow line: %s\"), line);\n-\t\t\t\tregister_shallow(sha1);\n+\t\t\t\tregister_shallow(oid.hash);\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (skip_prefix(line, \"unshallow \", &arg)) {\n-\t\t\t\tif (get_sha1_hex(arg, sha1))\n+\t\t\t\tif (get_oid_hex(arg, &oid))\n \t\t\t\t\tdie(_(\"invalid unshallow line: %s\"), line);\n-\t\t\t\tif (!lookup_object(sha1))\n+\t\t\t\tif (!lookup_object(oid.hash))\n \t\t\t\t\tdie(_(\"object not found: %s\"), line);\n \t\t\t\t/* make sure that it is parsed as shallow */\n-\t\t\t\tif (!parse_object(sha1))\n+\t\t\t\tif (!parse_object(oid.hash))\n \t\t\t\t\tdie(_(\"error in object: %s\"), line);\n-\t\t\t\tif (unregister_shallow(sha1))\n+\t\t\t\tif (unregister_shallow(oid.hash))\n \t\t\t\t\tdie(_(\"no shallow found: %s\"), line);\n \t\t\t\tcontinue;\n \t\t\t}\n@@ -445,9 +445,9 @@ static int find_common(struct fetch_pack_args *args,\n \n \tflushes = 0;\n \tretval = -1;\n-\twhile ((sha1 = get_rev())) {\n-\t\tpacket_buf_write(&req_buf, \"have %s\\n\", sha1_to_hex(sha1));\n-\t\tprint_verbose(args, \"have %s\", sha1_to_hex(sha1));\n+\twhile ((oid = get_rev())) {\n+\t\tpacket_buf_write(&req_buf, \"have %s\\n\", oid_to_hex(oid));\n+\t\tprint_verbose(args, \"have %s\", oid_to_hex(oid));\n \t\tin_vain++;\n \t\tif (flush_at <= ++count) {\n \t\t\tint ack;\n@@ -467,10 +467,10 @@ static int find_common(struct fetch_pack_args *args,\n \n \t\t\tconsume_shallow_list(args, fd[0]);\n \t\t\tdo {\n-\t\t\t\tack = get_ack(fd[0], result_sha1);\n+\t\t\t\tack = get_ack(fd[0], result_oid);\n \t\t\t\tif (ack)\n \t\t\t\t\tprint_verbose(args, _(\"got %s %d %s\"), \"ack\",\n-\t\t\t\t\t\t      ack, sha1_to_hex(result_sha1));\n+\t\t\t\t\t\t      ack, oid_to_hex(result_oid));\n \t\t\t\tswitch (ack) {\n \t\t\t\tcase ACK:\n \t\t\t\t\tflushes = 0;\n@@ -481,9 +481,9 @@ static int find_common(struct fetch_pack_args *args,\n \t\t\t\tcase ACK_ready:\n \t\t\t\tcase ACK_continue: {\n \t\t\t\t\tstruct commit *commit =\n-\t\t\t\t\t\tlookup_commit(result_sha1);\n+\t\t\t\t\t\tlookup_commit(result_oid->hash);\n \t\t\t\t\tif (!commit)\n-\t\t\t\t\t\tdie(_(\"invalid commit %s\"), sha1_to_hex(result_sha1));\n+\t\t\t\t\t\tdie(_(\"invalid commit %s\"), oid_to_hex(result_oid));\n \t\t\t\t\tif (args->stateless_rpc\n \t\t\t\t\t && ack == ACK_common\n \t\t\t\t\t && !(commit->object.flags & COMMON)) {\n@@ -491,7 +491,7 @@ static int find_common(struct fetch_pack_args *args,\n \t\t\t\t\t\t * on the next RPC request so the peer knows\n \t\t\t\t\t\t * it is in common with us.\n \t\t\t\t\t\t */\n-\t\t\t\t\t\tconst char *hex = sha1_to_hex(result_sha1);\n+\t\t\t\t\t\tconst char *hex = oid_to_hex(result_oid);\n \t\t\t\t\t\tpacket_buf_write(&req_buf, \"have %s\\n\", hex);\n \t\t\t\t\t\tstate_len = req_buf.len;\n \t\t\t\t\t\t/*\n@@ -536,10 +536,10 @@ static int find_common(struct fetch_pack_args *args,\n \tif (!got_ready || !no_done)\n \t\tconsume_shallow_list(args, fd[0]);\n \twhile (flushes || multi_ack) {\n-\t\tint ack = get_ack(fd[0], result_sha1);\n+\t\tint ack = get_ack(fd[0], result_oid);\n \t\tif (ack) {\n \t\t\tprint_verbose(args, _(\"got %s (%d) %s\"), \"ack\",\n-\t\t\t\t      ack, sha1_to_hex(result_sha1));\n+\t\t\t\t      ack, oid_to_hex(result_oid));\n \t\t\tif (ack == ACK)\n \t\t\t\treturn 0;\n \t\t\tmulti_ack = 1;\n@@ -553,9 +553,9 @@ static int find_common(struct fetch_pack_args *args,\n \n static struct commit_list *complete;\n \n-static int mark_complete(const unsigned char *sha1)\n+static int mark_complete(const struct object_id *oid)\n {\n-\tstruct object *o = parse_object(sha1);\n+\tstruct object *o = parse_object(oid->hash);\n \n \twhile (o && o->type == OBJ_TAG) {\n \t\tstruct tag *t = (struct tag *) o;\n@@ -577,7 +577,7 @@ static int mark_complete(const unsigned char *sha1)\n static int mark_complete_oid(const char *refname, const struct object_id *oid,\n \t\t\t     int flag, void *cb_data)\n {\n-\treturn mark_complete(oid->hash);\n+\treturn mark_complete(oid);\n }\n \n static void mark_recent_complete_commits(struct fetch_pack_args *args,\n@@ -635,14 +635,15 @@ static void filter_refs(struct fetch_pack_args *args,\n \n \t/* Append unmatched requests to the list */\n \tfor (i = 0; i < nr_sought; i++) {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n+\t\tconst char *p;\n \n \t\tref = sought[i];\n \t\tif (ref->match_status != REF_NOT_MATCHED)\n \t\t\tcontinue;\n-\t\tif (get_sha1_hex(ref->name, sha1) ||\n-\t\t    ref->name[40] != '\\0' ||\n-\t\t    hashcmp(sha1, ref->old_oid.hash))\n+\t\tif (parse_oid_hex(ref->name, &oid, &p) ||\n+\t\t    *p != '\\0' ||\n+\t\t    oidcmp(&oid, &ref->old_oid))\n \t\t\tcontinue;\n \n \t\tif ((allow_unadvertised_object_request &\n@@ -659,7 +660,7 @@ static void filter_refs(struct fetch_pack_args *args,\n \n static void mark_alternate_complete(struct object *obj)\n {\n-\tmark_complete(obj->oid.hash);\n+\tmark_complete(&obj->oid);\n }\n \n static int everything_local(struct fetch_pack_args *args,\n@@ -722,17 +723,17 @@ static int everything_local(struct fetch_pack_args *args,\n \tfilter_refs(args, refs, sought, nr_sought);\n \n \tfor (retval = 1, ref = *refs; ref ; ref = ref->next) {\n-\t\tconst unsigned char *remote = ref->old_oid.hash;\n+\t\tconst struct object_id *remote = &ref->old_oid;\n \t\tstruct object *o;\n \n-\t\to = lookup_object(remote);\n+\t\to = lookup_object(remote->hash);\n \t\tif (!o || !(o->flags & COMPLETE)) {\n \t\t\tretval = 0;\n-\t\t\tprint_verbose(args, \"want %s (%s)\", sha1_to_hex(remote),\n+\t\t\tprint_verbose(args, \"want %s (%s)\", oid_to_hex(remote),\n \t\t\t\t      ref->name);\n \t\t\tcontinue;\n \t\t}\n-\t\tprint_verbose(args, _(\"already have %s (%s)\"), sha1_to_hex(remote),\n+\t\tprint_verbose(args, _(\"already have %s (%s)\"), oid_to_hex(remote),\n \t\t\t      ref->name);\n \t}\n \treturn retval;\n@@ -871,7 +872,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,\n \t\t\t\t char **pack_lockfile)\n {\n \tstruct ref *ref = copy_ref_list(orig_ref);\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tconst char *agent_feature;\n \tint agent_len;\n \n@@ -943,7 +944,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,\n \t\tpacket_flush(fd[1]);\n \t\tgoto all_done;\n \t}\n-\tif (find_common(args, fd, sha1, ref) < 0)\n+\tif (find_common(args, fd, &oid, ref) < 0)\n \t\tif (!args->keep_pack)\n \t\t\t/* When cloning, it is not unusual to have\n \t\t\t * no common commit.\n"},{"id":"317570","messageId":"20170423213453.253425-4-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 03/53] Convert struct cache_tree to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:03Z","receivedAt":"2017-04-23T21:35:46Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the sha1 member of struct cache_tree to struct object_id by\nchanging the definition and applying the following semantic patch, plus\nthe standard object_id transforms:\n\n@@\nstruct cache_tree E1;\n@@\n- E1.sha1\n+ E1.oid.hash\n\n@@\nstruct cache_tree *E1;\n@@\n- E1->sha1\n+ E1->oid.hash\n\nFix up one reference to active_cache_tree which was not automatically\ncaught by Coccinelle.  These changes are prerequisites for converting\nparse_object.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/commit.c                |  2 +-\n builtin/fsck.c                  |  4 ++--\n cache-tree.c                    | 31 ++++++++++++++++---------------\n cache-tree.h                    |  3 ++-\n merge-recursive.c               |  2 +-\n revision.c                      |  2 +-\n sequencer.c                     |  3 ++-\n t/helper/test-dump-cache-tree.c |  4 ++--\n 8 files changed, 27 insertions(+), 24 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 4e288bc51..05a0b609e 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1758,7 +1758,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tappend_merge_tag_headers(parents, &tail);\n \t}\n \n-\tif (commit_tree_extended(sb.buf, sb.len, active_cache_tree->sha1,\n+\tif (commit_tree_extended(sb.buf, sb.len, active_cache_tree->oid.hash,\n \t\t\t parents, oid.hash, author_ident.buf, sign_commit, extra)) {\n \t\trollback_index_files();\n \t\tdie(_(\"failed to write commit object\"));\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex f76e4163a..543122f04 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -599,10 +599,10 @@ static int fsck_cache_tree(struct cache_tree *it)\n \t\tfprintf(stderr, \"Checking cache tree\\n\");\n \n \tif (0 <= it->entry_count) {\n-\t\tstruct object *obj = parse_object(it->sha1);\n+\t\tstruct object *obj = parse_object(it->oid.hash);\n \t\tif (!obj) {\n \t\t\terror(\"%s: invalid sha1 pointer in cache-tree\",\n-\t\t\t      sha1_to_hex(it->sha1));\n+\t\t\t      oid_to_hex(&it->oid));\n \t\t\terrors_found |= ERROR_REFS;\n \t\t\treturn 1;\n \t\t}\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 345ea3596..35d507ed7 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -225,7 +225,7 @@ int cache_tree_fully_valid(struct cache_tree *it)\n \tint i;\n \tif (!it)\n \t\treturn 0;\n-\tif (it->entry_count < 0 || !has_sha1_file(it->sha1))\n+\tif (it->entry_count < 0 || !has_sha1_file(it->oid.hash))\n \t\treturn 0;\n \tfor (i = 0; i < it->subtree_nr; i++) {\n \t\tif (!cache_tree_fully_valid(it->down[i]->cache_tree))\n@@ -253,7 +253,7 @@ static int update_one(struct cache_tree *it,\n \n \t*skip_count = 0;\n \n-\tif (0 <= it->entry_count && has_sha1_file(it->sha1))\n+\tif (0 <= it->entry_count && has_sha1_file(it->oid.hash))\n \t\treturn it->entry_count;\n \n \t/*\n@@ -340,7 +340,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->sha1;\n+\t\t\tsha1 = sub->cache_tree->oid.hash;\n \t\t\tmode = S_IFDIR;\n \t\t\tcontains_ita = sub->cache_tree->entry_count < 0;\n \t\t\tif (contains_ita) {\n@@ -402,12 +402,13 @@ static int update_one(struct cache_tree *it,\n \t\tunsigned char sha1[20];\n \t\thash_sha1_file(buffer.buf, buffer.len, tree_type, sha1);\n \t\tif (has_sha1_file(sha1))\n-\t\t\thashcpy(it->sha1, sha1);\n+\t\t\thashcpy(it->oid.hash, sha1);\n \t\telse\n \t\t\tto_invalidate = 1;\n \t} else if (dryrun)\n-\t\thash_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1);\n-\telse if (write_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1)) {\n+\t\thash_sha1_file(buffer.buf, buffer.len, tree_type,\n+\t\t\t       it->oid.hash);\n+\telse if (write_sha1_file(buffer.buf, buffer.len, tree_type, it->oid.hash)) {\n \t\tstrbuf_release(&buffer);\n \t\treturn -1;\n \t}\n@@ -417,7 +418,7 @@ static int update_one(struct cache_tree *it,\n #if DEBUG\n \tfprintf(stderr, \"cache-tree update-one (%d ent, %d subtree) %s\\n\",\n \t\tit->entry_count, it->subtree_nr,\n-\t\tsha1_to_hex(it->sha1));\n+\t\toid_to_hex(&it->oid));\n #endif\n \treturn i;\n }\n@@ -457,14 +458,14 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,\n \tif (0 <= it->entry_count)\n \t\tfprintf(stderr, \"cache-tree <%.*s> (%d ent, %d subtree) %s\\n\",\n \t\t\tpathlen, path, it->entry_count, it->subtree_nr,\n-\t\t\tsha1_to_hex(it->sha1));\n+\t\t\toid_to_hex(&it->oid));\n \telse\n \t\tfprintf(stderr, \"cache-tree <%.*s> (%d subtree) invalid\\n\",\n \t\t\tpathlen, path, it->subtree_nr);\n #endif\n \n \tif (0 <= it->entry_count) {\n-\t\tstrbuf_add(buffer, it->sha1, 20);\n+\t\tstrbuf_add(buffer, it->oid.hash, 20);\n \t}\n \tfor (i = 0; i < it->subtree_nr; i++) {\n \t\tstruct cache_tree_sub *down = it->down[i];\n@@ -521,7 +522,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)\n \tif (0 <= it->entry_count) {\n \t\tif (size < 20)\n \t\t\tgoto free_return;\n-\t\thashcpy(it->sha1, (const unsigned char*)buf);\n+\t\thashcpy(it->oid.hash, (const unsigned char*)buf);\n \t\tbuf += 20;\n \t\tsize -= 20;\n \t}\n@@ -530,7 +531,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)\n \tif (0 <= it->entry_count)\n \t\tfprintf(stderr, \"cache-tree <%s> (%d ent, %d subtree) %s\\n\",\n \t\t\t*buffer, it->entry_count, subtree_nr,\n-\t\t\tsha1_to_hex(it->sha1));\n+\t\t\toid_to_hex(&it->oid));\n \telse\n \t\tfprintf(stderr, \"cache-tree <%s> (%d subtrees) invalid\\n\",\n \t\t\t*buffer, subtree_nr);\n@@ -641,10 +642,10 @@ int write_index_as_tree(unsigned char *sha1, struct index_state *index_state, co\n \t\tsubtree = cache_tree_find(index_state->cache_tree, prefix);\n \t\tif (!subtree)\n \t\t\treturn WRITE_TREE_PREFIX_ERROR;\n-\t\thashcpy(sha1, subtree->sha1);\n+\t\thashcpy(sha1, subtree->oid.hash);\n \t}\n \telse\n-\t\thashcpy(sha1, index_state->cache_tree->sha1);\n+\t\thashcpy(sha1, index_state->cache_tree->oid.hash);\n \n \tif (0 <= newfd)\n \t\trollback_lock_file(lock_file);\n@@ -663,7 +664,7 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)\n \tstruct name_entry entry;\n \tint cnt;\n \n-\thashcpy(it->sha1, tree->object.oid.hash);\n+\toidcpy(&it->oid, &tree->object.oid);\n \tinit_tree_desc(&desc, tree->buffer, tree->size);\n \tcnt = 0;\n \twhile (tree_entry(&desc, &entry)) {\n@@ -718,7 +719,7 @@ int cache_tree_matches_traversal(struct cache_tree *root,\n \n \tit = find_cache_tree_from_traversal(root, info);\n \tit = cache_tree_find(it, ent->path);\n-\tif (it && it->entry_count > 0 && !hashcmp(ent->oid->hash, it->sha1))\n+\tif (it && it->entry_count > 0 && !oidcmp(ent->oid, &it->oid))\n \t\treturn it->entry_count;\n \treturn 0;\n }\ndiff --git a/cache-tree.h b/cache-tree.h\nindex 41c574663..f7b9cab7e 100644\n--- a/cache-tree.h\n+++ b/cache-tree.h\n@@ -1,6 +1,7 @@\n #ifndef CACHE_TREE_H\n #define CACHE_TREE_H\n \n+#include \"cache.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\n \n@@ -15,7 +16,7 @@ struct cache_tree_sub {\n \n struct cache_tree {\n \tint entry_count; /* negative means \"invalid\" */\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tint subtree_nr;\n \tint subtree_alloc;\n \tstruct cache_tree_sub **down;\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 62decd51c..9d6fd577e 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -304,7 +304,7 @@ struct tree *write_tree_from_memory(struct merge_options *o)\n \t\treturn NULL;\n \t}\n \n-\tresult = lookup_tree(active_cache_tree->sha1);\n+\tresult = lookup_tree(active_cache_tree->oid.hash);\n \n \treturn result;\n }\ndiff --git a/revision.c b/revision.c\nindex 7ff61ff5f..2b56c3baf 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1249,7 +1249,7 @@ static void add_cache_tree(struct cache_tree *it, struct rev_info *revs,\n \tint i;\n \n \tif (it->entry_count >= 0) {\n-\t\tstruct tree *tree = lookup_tree(it->sha1);\n+\t\tstruct tree *tree = lookup_tree(it->oid.hash);\n \t\tadd_pending_object_with_path(revs, &tree->object, \"\",\n \t\t\t\t\t     040000, path->buf);\n \t}\ndiff --git a/sequencer.c b/sequencer.c\nindex 77afecaeb..e13a25b91 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -508,7 +508,8 @@ static int is_index_unchanged(void)\n \t\tif (cache_tree_update(&the_index, 0))\n \t\t\treturn error(_(\"unable to update cache tree\\n\"));\n \n-\treturn !hashcmp(active_cache_tree->sha1, head_commit->tree->object.oid.hash);\n+\treturn !oidcmp(&active_cache_tree->oid,\n+\t\t       &head_commit->tree->object.oid);\n }\n \n static int write_author_script(const char *message)\ndiff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c\nindex 7af116d49..ebf3aab22 100644\n--- a/t/helper/test-dump-cache-tree.c\n+++ b/t/helper/test-dump-cache-tree.c\n@@ -10,7 +10,7 @@ static void dump_one(struct cache_tree *it, const char *pfx, const char *x)\n \t\t       \"invalid\", x, pfx, it->subtree_nr);\n \telse\n \t\tprintf(\"%s %s%s (%d entries, %d subtrees)\\n\",\n-\t\t       sha1_to_hex(it->sha1), x, pfx,\n+\t\t       oid_to_hex(&it->oid), x, pfx,\n \t\t       it->entry_count, it->subtree_nr);\n }\n \n@@ -32,7 +32,7 @@ static int dump_cache_tree(struct cache_tree *it,\n \t}\n \telse {\n \t\tdump_one(it, pfx, \"\");\n-\t\tif (hashcmp(it->sha1, ref->sha1) ||\n+\t\tif (oidcmp(&it->oid, &ref->oid) ||\n \t\t    ref->entry_count != it->entry_count ||\n \t\t    ref->subtree_nr != it->subtree_nr) {\n \t\t\t/* claims to be valid but is lying */\n"},{"id":"317571","messageId":"20170423213453.253425-5-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 04/53] builtin/name-rev: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:04Z","receivedAt":"2017-04-23T21:35:48Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert all the uses of unsigned char [20] to struct object_id.  Also,\nconvert some hard-coded integers into constants.\n\nname_rev_line accepts a wide variety of free-form input and only\ninterprets 40-character hex values, passing through everything else.\nConsequently, it is not a good candidate for parse_oid_hex, which is\nmuch stricter.\n\nThis change is a prerequisite for converting parse_object.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/name-rev.c | 28 ++++++++++++++--------------\n 1 file changed, 14 insertions(+), 14 deletions(-)\n\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 92a5d8a5d..00760ecc6 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -114,7 +114,7 @@ struct name_ref_data {\n \n static struct tip_table {\n \tstruct tip_table_entry {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tconst char *refname;\n \t} *table;\n \tint nr;\n@@ -122,13 +122,13 @@ static struct tip_table {\n \tint sorted;\n } tip_table;\n \n-static void add_to_tip_table(const unsigned char *sha1, const char *refname,\n+static void add_to_tip_table(const struct object_id *oid, const char *refname,\n \t\t\t     int shorten_unambiguous)\n {\n \trefname = name_ref_abbrev(refname, shorten_unambiguous);\n \n \tALLOC_GROW(tip_table.table, tip_table.nr + 1, tip_table.alloc);\n-\thashcpy(tip_table.table[tip_table.nr].sha1, sha1);\n+\toidcpy(&tip_table.table[tip_table.nr].oid, oid);\n \ttip_table.table[tip_table.nr].refname = xstrdup(refname);\n \ttip_table.nr++;\n \ttip_table.sorted = 0;\n@@ -137,7 +137,7 @@ static void add_to_tip_table(const unsigned char *sha1, const char *refname,\n static int tipcmp(const void *a_, const void *b_)\n {\n \tconst struct tip_table_entry *a = a_, *b = b_;\n-\treturn hashcmp(a->sha1, b->sha1);\n+\treturn oidcmp(&a->oid, &b->oid);\n }\n \n static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)\n@@ -194,7 +194,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo\n \t\t\treturn 0;\n \t}\n \n-\tadd_to_tip_table(oid->hash, path, can_abbreviate_output);\n+\tadd_to_tip_table(oid, path, can_abbreviate_output);\n \n \twhile (o && o->type == OBJ_TAG) {\n \t\tstruct tag *t = (struct tag *) o;\n@@ -216,7 +216,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo\n static const unsigned char *nth_tip_table_ent(size_t ix, void *table_)\n {\n \tstruct tip_table_entry *table = table_;\n-\treturn table[ix].sha1;\n+\treturn table[ix].oid.hash;\n }\n \n static const char *get_exact_ref_match(const struct object *o)\n@@ -301,9 +301,9 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n #define ishex(x) (isdigit((x)) || ((x) >= 'a' && (x) <= 'f'))\n \t\tif (!ishex(*p))\n \t\t\tforty = 0;\n-\t\telse if (++forty == 40 &&\n+\t\telse if (++forty == GIT_SHA1_HEXSZ &&\n \t\t\t !ishex(*(p+1))) {\n-\t\t\tunsigned char sha1[40];\n+\t\t\tstruct object_id oid;\n \t\t\tconst char *name = NULL;\n \t\t\tchar c = *(p+1);\n \t\t\tint p_len = p - p_start + 1;\n@@ -311,9 +311,9 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n \t\t\tforty = 0;\n \n \t\t\t*(p+1) = 0;\n-\t\t\tif (!get_sha1(p - 39, sha1)) {\n+\t\t\tif (!get_oid(p - (GIT_SHA1_HEXSZ - 1), &oid)) {\n \t\t\t\tstruct object *o =\n-\t\t\t\t\tlookup_object(sha1);\n+\t\t\t\t\tlookup_object(oid.hash);\n \t\t\t\tif (o)\n \t\t\t\t\tname = get_rev_name(o, &buf);\n \t\t\t}\n@@ -323,7 +323,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n \t\t\t\tcontinue;\n \n \t\t\tif (data->name_only)\n-\t\t\t\tprintf(\"%.*s%s\", p_len - 40, p_start, name);\n+\t\t\t\tprintf(\"%.*s%s\", p_len - GIT_SHA1_HEXSZ, p_start, name);\n \t\t\telse\n \t\t\t\tprintf(\"%.*s (%s)\", p_len, p_start, name);\n \t\t\tp_start = p + 1;\n@@ -374,18 +374,18 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\tcutoff = 0;\n \n \tfor (; argc; argc--, argv++) {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tstruct object *object;\n \t\tstruct commit *commit;\n \n-\t\tif (get_sha1(*argv, sha1)) {\n+\t\tif (get_oid(*argv, &oid)) {\n \t\t\tfprintf(stderr, \"Could not get sha1 for %s. Skipping.\\n\",\n \t\t\t\t\t*argv);\n \t\t\tcontinue;\n \t\t}\n \n \t\tcommit = NULL;\n-\t\tobject = parse_object(sha1);\n+\t\tobject = parse_object(oid.hash);\n \t\tif (object) {\n \t\t\tstruct object *peeled = deref_tag(object, *argv, 0);\n \t\t\tif (peeled && peeled->type == OBJ_COMMIT)\n"},{"id":"317572","messageId":"20170423213453.253425-6-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 05/53] builtin/prune: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:05Z","receivedAt":"2017-04-23T21:35:59Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the sole instance of unsigned char [20] to struct object_id.\ncmd_prune is a caller of parse_object, which we will convert later.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/prune.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 42633e0c6..96dca7d58 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -123,11 +123,11 @@ int cmd_prune(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"cannot prune in a precious-objects repo\"));\n \n \twhile (argc--) {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tconst char *name = *argv++;\n \n-\t\tif (!get_sha1(name, sha1)) {\n-\t\t\tstruct object *object = parse_object_or_die(sha1, name);\n+\t\tif (!get_oid(name, &oid)) {\n+\t\t\tstruct object *object = parse_object_or_die(oid.hash, name);\n \t\t\tadd_pending_object(&revs, object, \"\");\n \t\t}\n \t\telse\n"},{"id":"317573","messageId":"20170423213453.253425-7-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 06/53] bundle: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:06Z","receivedAt":"2017-04-23T21:36:01Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the bundle code, plus the sole external user of struct\nref_list_entry, to use struct object_id.  Include cache.h from within\nbundle.h to provide the definition.  Convert some of the hash parsing\ncode to use parse_oid_hex to avoid needing to hard-code constant values.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n bundle.c    | 33 +++++++++++++++++----------------\n bundle.h    |  4 +++-\n transport.c |  2 +-\n 3 files changed, 21 insertions(+), 18 deletions(-)\n\ndiff --git a/bundle.c b/bundle.c\nindex bbf4efa0a..6e181bb3d 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -12,11 +12,11 @@\n \n static const char bundle_signature[] = \"# v2 git bundle\\n\";\n \n-static void add_to_ref_list(const unsigned char *sha1, const char *name,\n+static void add_to_ref_list(const struct object_id *oid, const char *name,\n \t\tstruct ref_list *list)\n {\n \tALLOC_GROW(list->list, list->nr + 1, list->alloc);\n-\thashcpy(list->list[list->nr].sha1, sha1);\n+\toidcpy(&list->list[list->nr].oid, oid);\n \tlist->list[list->nr].name = xstrdup(name);\n \tlist->nr++;\n }\n@@ -40,8 +40,9 @@ static int parse_bundle_header(int fd, struct bundle_header *header,\n \t/* The bundle header ends with an empty line */\n \twhile (!strbuf_getwholeline_fd(&buf, fd, '\\n') &&\n \t       buf.len && buf.buf[0] != '\\n') {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tint is_prereq = 0;\n+\t\tconst char *p;\n \n \t\tif (*buf.buf == '-') {\n \t\t\tis_prereq = 1;\n@@ -54,9 +55,9 @@ static int parse_bundle_header(int fd, struct bundle_header *header,\n \t\t * Prerequisites have object name that is optionally\n \t\t * followed by SP and subject line.\n \t\t */\n-\t\tif (get_sha1_hex(buf.buf, sha1) ||\n-\t\t    (buf.len > 40 && !isspace(buf.buf[40])) ||\n-\t\t    (!is_prereq && buf.len <= 40)) {\n+\t\tif (parse_oid_hex(buf.buf, &oid, &p) ||\n+\t\t    (*p && !isspace(*p)) ||\n+\t\t    (!is_prereq && !*p)) {\n \t\t\tif (report_path)\n \t\t\t\terror(_(\"unrecognized header: %s%s (%d)\"),\n \t\t\t\t      (is_prereq ? \"-\" : \"\"), buf.buf, (int)buf.len);\n@@ -64,9 +65,9 @@ static int parse_bundle_header(int fd, struct bundle_header *header,\n \t\t\tbreak;\n \t\t} else {\n \t\t\tif (is_prereq)\n-\t\t\t\tadd_to_ref_list(sha1, \"\", &header->prerequisites);\n+\t\t\t\tadd_to_ref_list(&oid, \"\", &header->prerequisites);\n \t\t\telse\n-\t\t\t\tadd_to_ref_list(sha1, buf.buf + 41, &header->references);\n+\t\t\t\tadd_to_ref_list(&oid, p + 1, &header->references);\n \t\t}\n \t}\n \n@@ -115,7 +116,7 @@ static int list_refs(struct ref_list *r, int argc, const char **argv)\n \t\t\tif (j == argc)\n \t\t\t\tcontinue;\n \t\t}\n-\t\tprintf(\"%s %s\\n\", sha1_to_hex(r->list[i].sha1),\n+\t\tprintf(\"%s %s\\n\", oid_to_hex(&r->list[i].oid),\n \t\t\t\tr->list[i].name);\n \t}\n \treturn 0;\n@@ -141,7 +142,7 @@ int verify_bundle(struct bundle_header *header, int verbose)\n \tinit_revisions(&revs, NULL);\n \tfor (i = 0; i < p->nr; i++) {\n \t\tstruct ref_list_entry *e = p->list + i;\n-\t\tstruct object *o = parse_object(e->sha1);\n+\t\tstruct object *o = parse_object(e->oid.hash);\n \t\tif (o) {\n \t\t\to->flags |= PREREQ_MARK;\n \t\t\tadd_pending_object(&revs, o, e->name);\n@@ -149,7 +150,7 @@ int verify_bundle(struct bundle_header *header, int verbose)\n \t\t}\n \t\tif (++ret == 1)\n \t\t\terror(\"%s\", message);\n-\t\terror(\"%s %s\", sha1_to_hex(e->sha1), e->name);\n+\t\terror(\"%s %s\", oid_to_hex(&e->oid), e->name);\n \t}\n \tif (revs.pending.nr != p->nr)\n \t\treturn ret;\n@@ -285,16 +286,16 @@ static int compute_and_write_prerequisites(int bundle_fd,\n \t\treturn -1;\n \trls_fout = xfdopen(rls.out, \"r\");\n \twhile (strbuf_getwholeline(&buf, rls_fout, '\\n') != EOF) {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tif (buf.len > 0 && buf.buf[0] == '-') {\n \t\t\twrite_or_die(bundle_fd, buf.buf, buf.len);\n-\t\t\tif (!get_sha1_hex(buf.buf + 1, sha1)) {\n-\t\t\t\tstruct object *object = parse_object_or_die(sha1, buf.buf);\n+\t\t\tif (!get_oid_hex(buf.buf + 1, &oid)) {\n+\t\t\t\tstruct object *object = parse_object_or_die(oid.hash, buf.buf);\n \t\t\t\tobject->flags |= UNINTERESTING;\n \t\t\t\tadd_pending_object(revs, object, buf.buf);\n \t\t\t}\n-\t\t} else if (!get_sha1_hex(buf.buf, sha1)) {\n-\t\t\tstruct object *object = parse_object_or_die(sha1, buf.buf);\n+\t\t} else if (!get_oid_hex(buf.buf, &oid)) {\n+\t\t\tstruct object *object = parse_object_or_die(oid.hash, buf.buf);\n \t\t\tobject->flags |= SHOWN;\n \t\t}\n \t}\ndiff --git a/bundle.h b/bundle.h\nindex 1584e4d82..e9a4cb6a7 100644\n--- a/bundle.h\n+++ b/bundle.h\n@@ -1,10 +1,12 @@\n #ifndef BUNDLE_H\n #define BUNDLE_H\n \n+#include \"cache.h\"\n+\n struct ref_list {\n \tunsigned int nr, alloc;\n \tstruct ref_list_entry {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tchar *name;\n \t} *list;\n };\ndiff --git a/transport.c b/transport.c\nindex 4d33138a7..9bfcf870f 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -87,7 +87,7 @@ static struct ref *get_refs_from_bundle(struct transport *transport, int for_pus\n \tfor (i = 0; i < data->header.references.nr; i++) {\n \t\tstruct ref_list_entry *e = data->header.references.list + i;\n \t\tstruct ref *ref = alloc_ref(e->name);\n-\t\thashcpy(ref->old_oid.hash, e->sha1);\n+\t\toidcpy(&ref->old_oid, &e->oid);\n \t\tref->next = result;\n \t\tresult = ref;\n \t}\n"},{"id":"317574","messageId":"20170423213453.253425-9-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 08/53] builtin/blame: convert static function to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:08Z","receivedAt":"2017-04-23T21:36:02Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This function is a caller of lookup_commit_reference_gently, which we\nwill convert later.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/blame.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 07506a3e4..7d644d092 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -2461,7 +2461,7 @@ static const char *dwim_reverse_initial(struct scoreboard *sb)\n \t */\n \tstruct object *obj;\n \tstruct commit *head_commit;\n-\tunsigned char head_sha1[20];\n+\tstruct object_id head_oid;\n \n \tif (sb->revs->pending.nr != 1)\n \t\treturn NULL;\n@@ -2473,9 +2473,9 @@ static const char *dwim_reverse_initial(struct scoreboard *sb)\n \t\treturn NULL;\n \n \t/* Do we have HEAD? */\n-\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, head_sha1, NULL))\n+\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, head_oid.hash, NULL))\n \t\treturn NULL;\n-\thead_commit = lookup_commit_reference_gently(head_sha1, 1);\n+\thead_commit = lookup_commit_reference_gently(head_oid.hash, 1);\n \tif (!head_commit)\n \t\treturn NULL;\n \n"},{"id":"317575","messageId":"20170423213453.253425-8-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 07/53] branch: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:07Z","receivedAt":"2017-04-23T21:36:04Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This change is required to convert lookup_commit_reference later.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n branch.c | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex ad5a2299b..1758c9708 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -191,9 +191,9 @@ int validate_new_branchname(const char *name, struct strbuf *ref,\n \n \tif (!attr_only) {\n \t\tconst char *head;\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \n-\t\thead = resolve_ref_unsafe(\"HEAD\", 0, sha1, NULL);\n+\t\thead = resolve_ref_unsafe(\"HEAD\", 0, oid.hash, NULL);\n \t\tif (!is_bare_repository() && head && !strcmp(head, ref->buf))\n \t\t\tdie(_(\"Cannot force update the current branch.\"));\n \t}\n@@ -233,7 +233,7 @@ void create_branch(const char *name, const char *start_name,\n \t\t   int quiet, enum branch_track track)\n {\n \tstruct commit *commit;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tchar *real_ref;\n \tstruct strbuf ref = STRBUF_INIT;\n \tint forcing = 0;\n@@ -253,7 +253,7 @@ void create_branch(const char *name, const char *start_name,\n \t}\n \n \treal_ref = NULL;\n-\tif (get_sha1(start_name, sha1)) {\n+\tif (get_oid(start_name, &oid)) {\n \t\tif (explicit_tracking) {\n \t\t\tif (advice_set_upstream_failure) {\n \t\t\t\terror(_(upstream_missing), start_name);\n@@ -265,7 +265,7 @@ void create_branch(const char *name, const char *start_name,\n \t\tdie(_(\"Not a valid object name: '%s'.\"), start_name);\n \t}\n \n-\tswitch (dwim_ref(start_name, strlen(start_name), sha1, &real_ref)) {\n+\tswitch (dwim_ref(start_name, strlen(start_name), oid.hash, &real_ref)) {\n \tcase 0:\n \t\t/* Not branching from any existing branch */\n \t\tif (explicit_tracking)\n@@ -286,9 +286,9 @@ void create_branch(const char *name, const char *start_name,\n \t\tbreak;\n \t}\n \n-\tif ((commit = lookup_commit_reference(sha1)) == NULL)\n+\tif ((commit = lookup_commit_reference(oid.hash)) == NULL)\n \t\tdie(_(\"Not a valid branch point: '%s'.\"), start_name);\n-\thashcpy(sha1, commit->object.oid.hash);\n+\toidcpy(&oid, &commit->object.oid);\n \n \tif (reflog)\n \t\tlog_all_ref_updates = LOG_REFS_NORMAL;\n@@ -306,7 +306,7 @@ void create_branch(const char *name, const char *start_name,\n \t\ttransaction = ref_transaction_begin(&err);\n \t\tif (!transaction ||\n \t\t    ref_transaction_update(transaction, ref.buf,\n-\t\t\t\t\t   sha1, forcing ? NULL : null_sha1,\n+\t\t\t\t\t   oid.hash, forcing ? NULL : null_sha1,\n \t\t\t\t\t   0, msg, &err) ||\n \t\t    ref_transaction_commit(transaction, &err))\n \t\t\tdie(\"%s\", err.buf);\n"},{"id":"317576","messageId":"20170423213453.253425-11-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 10/53] fast-import: convert internal structs to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:10Z","receivedAt":"2017-04-23T21:36:06Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert struct tree_entry_ms, struct branch, struct tag, and struct\nhash_list to use struct object_id by changing the definition and\napplying the following semantic patch, plus the standard object_id\ntransforms:\n\n@@\nstruct tree_entry_ms E1;\n@@\n- E1.sha1\n+ E1.oid.hash\n\n@@\nstruct tree_entry_ms *E1;\n@@\n- E1->sha1\n+ E1->oid.hash\n\n@@\nstruct branch E1;\n@@\n- E1.sha1\n+ E1.oid.hash\n\n@@\nstruct branch *E1;\n@@\n- E1->sha1\n+ E1->oid.hash\n\n@@\nstruct tag E1;\n@@\n- E1.sha1\n+ E1.oid.hash\n\n@@\nstruct tag *E1;\n@@\n- E1->sha1\n+ E1->oid.hash\n\n@@\nstruct hash_list E1;\n@@\n- E1.sha1\n+ E1.oid.hash\n\n@@\nstruct hash_list *E1;\n@@\n- E1->sha1\n+ E1->oid.hash\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n fast-import.c | 182 +++++++++++++++++++++++++++++++---------------------------\n 1 file changed, 96 insertions(+), 86 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 1ea3a0860..052c59d82 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -226,7 +226,7 @@ struct tree_entry {\n \tstruct atom_str *name;\n \tstruct tree_entry_ms {\n \t\tuint16_t mode;\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t} versions[2];\n };\n \n@@ -252,19 +252,19 @@ struct branch {\n \tunsigned active : 1;\n \tunsigned delete : 1;\n \tunsigned pack_id : PACK_ID_BITS;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n };\n \n struct tag {\n \tstruct tag *next_tag;\n \tconst char *name;\n \tunsigned int pack_id;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n };\n \n struct hash_list {\n \tstruct hash_list *next;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n };\n \n typedef enum {\n@@ -386,13 +386,15 @@ static void write_branch_report(FILE *rpt, struct branch *b)\n \t\tfputs(\" active\", rpt);\n \tif (b->branch_tree.tree)\n \t\tfputs(\" loaded\", rpt);\n-\tif (is_null_sha1(b->branch_tree.versions[1].sha1))\n+\tif (is_null_oid(&b->branch_tree.versions[1].oid))\n \t\tfputs(\" dirty\", rpt);\n \tfputc('\\n', rpt);\n \n-\tfprintf(rpt, \"  tip commit  : %s\\n\", sha1_to_hex(b->sha1));\n-\tfprintf(rpt, \"  old tree    : %s\\n\", sha1_to_hex(b->branch_tree.versions[0].sha1));\n-\tfprintf(rpt, \"  cur tree    : %s\\n\", sha1_to_hex(b->branch_tree.versions[1].sha1));\n+\tfprintf(rpt, \"  tip commit  : %s\\n\", oid_to_hex(&b->oid));\n+\tfprintf(rpt, \"  old tree    : %s\\n\",\n+\t\toid_to_hex(&b->branch_tree.versions[0].oid));\n+\tfprintf(rpt, \"  cur tree    : %s\\n\",\n+\t\toid_to_hex(&b->branch_tree.versions[1].oid));\n \tfprintf(rpt, \"  commit clock: %\" PRIuMAX \"\\n\", b->last_commit);\n \n \tfputs(\"  last pack   : \", rpt);\n@@ -470,7 +472,7 @@ static void write_crash_report(const char *err)\n \t\tfputs(\"Annotated Tags\\n\", rpt);\n \t\tfputs(\"--------------\\n\", rpt);\n \t\tfor (tg = first_tag; tg; tg = tg->next_tag) {\n-\t\t\tfputs(sha1_to_hex(tg->sha1), rpt);\n+\t\t\tfputs(oid_to_hex(&tg->oid), rpt);\n \t\t\tfputc(' ', rpt);\n \t\t\tfputs(tg->name, rpt);\n \t\t\tfputc('\\n', rpt);\n@@ -876,7 +878,7 @@ static struct tree_content *dup_tree_content(struct tree_content *s)\n \t\ta = s->entries[i];\n \t\tb = new_tree_entry();\n \t\tmemcpy(b, a, sizeof(*a));\n-\t\tif (a->tree && is_null_sha1(b->versions[1].sha1))\n+\t\tif (a->tree && is_null_oid(&b->versions[1].oid))\n \t\t\tb->tree = dup_tree_content(a->tree);\n \t\telse\n \t\t\tb->tree = NULL;\n@@ -1041,12 +1043,14 @@ static void end_packfile(void)\n \t\t\tfor (i = 0; i < branch_table_sz; i++) {\n \t\t\t\tfor (b = branch_table[i]; b; b = b->table_next_branch) {\n \t\t\t\t\tif (b->pack_id == pack_id)\n-\t\t\t\t\t\tfprintf(pack_edges, \" %s\", sha1_to_hex(b->sha1));\n+\t\t\t\t\t\tfprintf(pack_edges, \" %s\",\n+\t\t\t\t\t\t\toid_to_hex(&b->oid));\n \t\t\t\t}\n \t\t\t}\n \t\t\tfor (t = first_tag; t; t = t->next_tag) {\n \t\t\t\tif (t->pack_id == pack_id)\n-\t\t\t\t\tfprintf(pack_edges, \" %s\", sha1_to_hex(t->sha1));\n+\t\t\t\t\tfprintf(pack_edges, \" %s\",\n+\t\t\t\t\t\toid_to_hex(&t->oid));\n \t\t\t}\n \t\t\tfputc('\\n', pack_edges);\n \t\t\tfflush(pack_edges);\n@@ -1385,7 +1389,7 @@ static const char *get_mode(const char *str, uint16_t *modep)\n \n static void load_tree(struct tree_entry *root)\n {\n-\tunsigned char *sha1 = root->versions[1].sha1;\n+\tunsigned char *sha1 = root->versions[1].oid.hash;\n \tstruct object_entry *myoe;\n \tstruct tree_content *t;\n \tunsigned long size;\n@@ -1426,8 +1430,8 @@ static void load_tree(struct tree_entry *root)\n \t\te->versions[0].mode = e->versions[1].mode;\n \t\te->name = to_atom(c, strlen(c));\n \t\tc += e->name->str_len + 1;\n-\t\thashcpy(e->versions[0].sha1, (unsigned char *)c);\n-\t\thashcpy(e->versions[1].sha1, (unsigned char *)c);\n+\t\thashcpy(e->versions[0].oid.hash, (unsigned char *)c);\n+\t\thashcpy(e->versions[1].oid.hash, (unsigned char *)c);\n \t\tc += 20;\n \t}\n \tfree(buf);\n@@ -1475,7 +1479,7 @@ static void mktree(struct tree_content *t, int v, struct strbuf *b)\n \t\tstrbuf_addf(b, \"%o %s%c\",\n \t\t\t(unsigned int)(e->versions[v].mode & ~NO_DELTA),\n \t\t\te->name->str_dat, '\\0');\n-\t\tstrbuf_add(b, e->versions[v].sha1, 20);\n+\t\tstrbuf_add(b, e->versions[v].oid.hash, 20);\n \t}\n }\n \n@@ -1486,7 +1490,7 @@ static void store_tree(struct tree_entry *root)\n \tstruct last_object lo = { STRBUF_INIT, 0, 0, /* no_swap */ 1 };\n \tstruct object_entry *le = NULL;\n \n-\tif (!is_null_sha1(root->versions[1].sha1))\n+\tif (!is_null_oid(&root->versions[1].oid))\n \t\treturn;\n \n \tif (!root->tree)\n@@ -1499,7 +1503,7 @@ static void store_tree(struct tree_entry *root)\n \t}\n \n \tif (!(root->versions[0].mode & NO_DELTA))\n-\t\tle = find_object(root->versions[0].sha1);\n+\t\tle = find_object(root->versions[0].oid.hash);\n \tif (S_ISDIR(root->versions[0].mode) && le && le->pack_id == pack_id) {\n \t\tmktree(t, 0, &old_tree);\n \t\tlo.data = old_tree;\n@@ -1508,14 +1512,14 @@ static void store_tree(struct tree_entry *root)\n \t}\n \n \tmktree(t, 1, &new_tree);\n-\tstore_object(OBJ_TREE, &new_tree, &lo, root->versions[1].sha1, 0);\n+\tstore_object(OBJ_TREE, &new_tree, &lo, root->versions[1].oid.hash, 0);\n \n \tt->delta_depth = lo.depth;\n \tfor (i = 0, j = 0, del = 0; i < t->entry_count; i++) {\n \t\tstruct tree_entry *e = t->entries[i];\n \t\tif (e->versions[1].mode) {\n \t\t\te->versions[0].mode = e->versions[1].mode;\n-\t\t\thashcpy(e->versions[0].sha1, e->versions[1].sha1);\n+\t\t\toidcpy(&e->versions[0].oid, &e->versions[1].oid);\n \t\t\tt->entries[j++] = e;\n \t\t} else {\n \t\t\trelease_tree_entry(e);\n@@ -1533,8 +1537,8 @@ static void tree_content_replace(\n {\n \tif (!S_ISDIR(mode))\n \t\tdie(\"Root cannot be a non-directory\");\n-\thashclr(root->versions[0].sha1);\n-\thashcpy(root->versions[1].sha1, sha1);\n+\toidclr(&root->versions[0].oid);\n+\thashcpy(root->versions[1].oid.hash, sha1);\n \tif (root->tree)\n \t\trelease_tree_content_recursive(root->tree);\n \troot->tree = newtree;\n@@ -1568,10 +1572,10 @@ static int tree_content_set(\n \t\t\tif (!*slash1) {\n \t\t\t\tif (!S_ISDIR(mode)\n \t\t\t\t\t\t&& e->versions[1].mode == mode\n-\t\t\t\t\t\t&& !hashcmp(e->versions[1].sha1, sha1))\n+\t\t\t\t\t\t&& !hashcmp(e->versions[1].oid.hash, sha1))\n \t\t\t\t\treturn 0;\n \t\t\t\te->versions[1].mode = mode;\n-\t\t\t\thashcpy(e->versions[1].sha1, sha1);\n+\t\t\t\thashcpy(e->versions[1].oid.hash, sha1);\n \t\t\t\tif (e->tree)\n \t\t\t\t\trelease_tree_content_recursive(e->tree);\n \t\t\t\te->tree = subtree;\n@@ -1592,7 +1596,7 @@ static int tree_content_set(\n \t\t\t\tif (S_ISDIR(e->versions[0].mode))\n \t\t\t\t\te->versions[0].mode |= NO_DELTA;\n \n-\t\t\t\thashclr(root->versions[1].sha1);\n+\t\t\t\toidclr(&root->versions[1].oid);\n \t\t\t\treturn 1;\n \t\t\t}\n \t\t\tif (!S_ISDIR(e->versions[1].mode)) {\n@@ -1602,7 +1606,7 @@ static int tree_content_set(\n \t\t\tif (!e->tree)\n \t\t\t\tload_tree(e);\n \t\t\tif (tree_content_set(e, slash1 + 1, sha1, mode, subtree)) {\n-\t\t\t\thashclr(root->versions[1].sha1);\n+\t\t\t\toidclr(&root->versions[1].oid);\n \t\t\t\treturn 1;\n \t\t\t}\n \t\t\treturn 0;\n@@ -1614,7 +1618,7 @@ static int tree_content_set(\n \te = new_tree_entry();\n \te->name = to_atom(p, n);\n \te->versions[0].mode = 0;\n-\thashclr(e->versions[0].sha1);\n+\toidclr(&e->versions[0].oid);\n \tt->entries[t->entry_count++] = e;\n \tif (*slash1) {\n \t\te->tree = new_tree_content(8);\n@@ -1623,9 +1627,9 @@ static int tree_content_set(\n \t} else {\n \t\te->tree = subtree;\n \t\te->versions[1].mode = mode;\n-\t\thashcpy(e->versions[1].sha1, sha1);\n+\t\thashcpy(e->versions[1].oid.hash, sha1);\n \t}\n-\thashclr(root->versions[1].sha1);\n+\toidclr(&root->versions[1].oid);\n \treturn 1;\n }\n \n@@ -1670,7 +1674,7 @@ static int tree_content_remove(\n \t\t\tif (tree_content_remove(e, slash1 + 1, backup_leaf, 0)) {\n \t\t\t\tfor (n = 0; n < e->tree->entry_count; n++) {\n \t\t\t\t\tif (e->tree->entries[n]->versions[1].mode) {\n-\t\t\t\t\t\thashclr(root->versions[1].sha1);\n+\t\t\t\t\t\toidclr(&root->versions[1].oid);\n \t\t\t\t\t\treturn 1;\n \t\t\t\t\t}\n \t\t\t\t}\n@@ -1689,8 +1693,8 @@ static int tree_content_remove(\n \t\trelease_tree_content_recursive(e->tree);\n \te->tree = NULL;\n \te->versions[1].mode = 0;\n-\thashclr(e->versions[1].sha1);\n-\thashclr(root->versions[1].sha1);\n+\toidclr(&e->versions[1].oid);\n+\toidclr(&root->versions[1].oid);\n \treturn 1;\n }\n \n@@ -1735,7 +1739,7 @@ static int tree_content_get(\n \n found_entry:\n \tmemcpy(leaf, e, sizeof(*leaf));\n-\tif (e->tree && is_null_sha1(e->versions[1].sha1))\n+\tif (e->tree && is_null_oid(&e->versions[1].oid))\n \t\tleaf->tree = dup_tree_content(e->tree);\n \telse\n \t\tleaf->tree = NULL;\n@@ -1749,7 +1753,7 @@ static int update_branch(struct branch *b)\n \tunsigned char old_sha1[20];\n \tstruct strbuf err = STRBUF_INIT;\n \n-\tif (is_null_sha1(b->sha1)) {\n+\tif (is_null_oid(&b->oid)) {\n \t\tif (b->delete)\n \t\t\tdelete_ref(NULL, b->name, NULL, 0);\n \t\treturn 0;\n@@ -1760,20 +1764,21 @@ static int update_branch(struct branch *b)\n \t\tstruct commit *old_cmit, *new_cmit;\n \n \t\told_cmit = lookup_commit_reference_gently(old_sha1, 0);\n-\t\tnew_cmit = lookup_commit_reference_gently(b->sha1, 0);\n+\t\tnew_cmit = lookup_commit_reference_gently(b->oid.hash, 0);\n \t\tif (!old_cmit || !new_cmit)\n \t\t\treturn error(\"Branch %s is missing commits.\", b->name);\n \n \t\tif (!in_merge_bases(old_cmit, new_cmit)) {\n \t\t\twarning(\"Not updating %s\"\n \t\t\t\t\" (new tip %s does not contain %s)\",\n-\t\t\t\tb->name, sha1_to_hex(b->sha1), sha1_to_hex(old_sha1));\n+\t\t\t\tb->name, oid_to_hex(&b->oid),\n+\t\t\t\tsha1_to_hex(old_sha1));\n \t\t\treturn -1;\n \t\t}\n \t}\n \ttransaction = ref_transaction_begin(&err);\n \tif (!transaction ||\n-\t    ref_transaction_update(transaction, b->name, b->sha1, old_sha1,\n+\t    ref_transaction_update(transaction, b->name, b->oid.hash, old_sha1,\n \t\t\t\t   0, msg, &err) ||\n \t    ref_transaction_commit(transaction, &err)) {\n \t\tref_transaction_free(transaction);\n@@ -1815,7 +1820,7 @@ static void dump_tags(void)\n \t\tstrbuf_addf(&ref_name, \"refs/tags/%s\", t->name);\n \n \t\tif (ref_transaction_update(transaction, ref_name.buf,\n-\t\t\t\t\t   t->sha1, NULL, 0, msg, &err)) {\n+\t\t\t\t\t   t->oid.hash, NULL, 0, msg, &err)) {\n \t\t\tfailure |= error(\"%s\", err.buf);\n \t\t\tgoto cleanup;\n \t\t}\n@@ -2274,7 +2279,7 @@ static uintmax_t do_change_note_fanout(\n \t\t\tif (!tree_content_remove(orig_root, fullpath, &leaf, 0))\n \t\t\t\tdie(\"Failed to remove path %s\", fullpath);\n \t\t\ttree_content_set(orig_root, realpath,\n-\t\t\t\tleaf.versions[1].sha1,\n+\t\t\t\tleaf.versions[1].oid.hash,\n \t\t\t\tleaf.versions[1].mode,\n \t\t\t\tleaf.tree);\n \t\t} else if (S_ISDIR(e->versions[1].mode)) {\n@@ -2504,13 +2509,13 @@ static void file_change_cr(const char *s, struct branch *b, int rename)\n \t\tdie(\"Path %s not in branch\", s);\n \tif (!*d) {\t/* C \"path/to/subdir\" \"\" */\n \t\ttree_content_replace(&b->branch_tree,\n-\t\t\tleaf.versions[1].sha1,\n+\t\t\tleaf.versions[1].oid.hash,\n \t\t\tleaf.versions[1].mode,\n \t\t\tleaf.tree);\n \t\treturn;\n \t}\n \ttree_content_set(&b->branch_tree, d,\n-\t\tleaf.versions[1].sha1,\n+\t\tleaf.versions[1].oid.hash,\n \t\tleaf.versions[1].mode,\n \t\tleaf.tree);\n }\n@@ -2561,9 +2566,9 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t/* <commit-ish> */\n \ts = lookup_branch(p);\n \tif (s) {\n-\t\tif (is_null_sha1(s->sha1))\n+\t\tif (is_null_oid(&s->oid))\n \t\t\tdie(\"Can't add a note on empty branch.\");\n-\t\thashcpy(commit_sha1, s->sha1);\n+\t\thashcpy(commit_sha1, s->oid.hash);\n \t} else if (*p == ':') {\n \t\tuintmax_t commit_mark = parse_mark_ref_eol(p);\n \t\tstruct object_entry *commit_oe = find_mark(commit_mark);\n@@ -2616,8 +2621,8 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n static void file_change_deleteall(struct branch *b)\n {\n \trelease_tree_content_recursive(b->branch_tree.tree);\n-\thashclr(b->branch_tree.versions[0].sha1);\n-\thashclr(b->branch_tree.versions[1].sha1);\n+\toidclr(&b->branch_tree.versions[0].oid);\n+\toidclr(&b->branch_tree.versions[1].oid);\n \tload_tree(&b->branch_tree);\n \tb->num_notes = 0;\n }\n@@ -2625,25 +2630,26 @@ static void file_change_deleteall(struct branch *b)\n static void parse_from_commit(struct branch *b, char *buf, unsigned long size)\n {\n \tif (!buf || size < 46)\n-\t\tdie(\"Not a valid commit: %s\", sha1_to_hex(b->sha1));\n+\t\tdie(\"Not a valid commit: %s\", oid_to_hex(&b->oid));\n \tif (memcmp(\"tree \", buf, 5)\n-\t\t|| get_sha1_hex(buf + 5, b->branch_tree.versions[1].sha1))\n-\t\tdie(\"The commit %s is corrupt\", sha1_to_hex(b->sha1));\n-\thashcpy(b->branch_tree.versions[0].sha1,\n-\t\tb->branch_tree.versions[1].sha1);\n+\t\t|| get_sha1_hex(buf + 5, b->branch_tree.versions[1].oid.hash))\n+\t\tdie(\"The commit %s is corrupt\", oid_to_hex(&b->oid));\n+\toidcpy(&b->branch_tree.versions[0].oid,\n+\t       &b->branch_tree.versions[1].oid);\n }\n \n static void parse_from_existing(struct branch *b)\n {\n-\tif (is_null_sha1(b->sha1)) {\n-\t\thashclr(b->branch_tree.versions[0].sha1);\n-\t\thashclr(b->branch_tree.versions[1].sha1);\n+\tif (is_null_oid(&b->oid)) {\n+\t\toidclr(&b->branch_tree.versions[0].oid);\n+\t\toidclr(&b->branch_tree.versions[1].oid);\n \t} else {\n \t\tunsigned long size;\n \t\tchar *buf;\n \n-\t\tbuf = read_object_with_reference(b->sha1,\n-\t\t\tcommit_type, &size, b->sha1);\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\tparse_from_commit(b, buf, size);\n \t\tfree(buf);\n \t}\n@@ -2658,23 +2664,23 @@ static int parse_from(struct branch *b)\n \tif (!skip_prefix(command_buf.buf, \"from \", &from))\n \t\treturn 0;\n \n-\thashcpy(sha1, b->branch_tree.versions[1].sha1);\n+\thashcpy(sha1, b->branch_tree.versions[1].oid.hash);\n \n \ts = lookup_branch(from);\n \tif (b == s)\n \t\tdie(\"Can't create a branch from itself: %s\", b->name);\n \telse if (s) {\n-\t\tunsigned char *t = s->branch_tree.versions[1].sha1;\n-\t\thashcpy(b->sha1, s->sha1);\n-\t\thashcpy(b->branch_tree.versions[0].sha1, t);\n-\t\thashcpy(b->branch_tree.versions[1].sha1, t);\n+\t\tunsigned char *t = s->branch_tree.versions[1].oid.hash;\n+\t\toidcpy(&b->oid, &s->oid);\n+\t\thashcpy(b->branch_tree.versions[0].oid.hash, t);\n+\t\thashcpy(b->branch_tree.versions[1].oid.hash, t);\n \t} else if (*from == ':') {\n \t\tuintmax_t idnum = parse_mark_ref_eol(from);\n \t\tstruct object_entry *oe = find_mark(idnum);\n \t\tif (oe->type != OBJ_COMMIT)\n \t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", idnum);\n-\t\tif (hashcmp(b->sha1, oe->idx.sha1)) {\n-\t\t\thashcpy(b->sha1, oe->idx.sha1);\n+\t\tif (hashcmp(b->oid.hash, oe->idx.sha1)) {\n+\t\t\thashcpy(b->oid.hash, oe->idx.sha1);\n \t\t\tif (oe->pack_id != MAX_PACK_ID) {\n \t\t\t\tunsigned long size;\n \t\t\t\tchar *buf = gfi_unpack_entry(oe, &size);\n@@ -2683,15 +2689,15 @@ static int parse_from(struct branch *b)\n \t\t\t} else\n \t\t\t\tparse_from_existing(b);\n \t\t}\n-\t} else if (!get_sha1(from, b->sha1)) {\n+\t} else if (!get_sha1(from, b->oid.hash)) {\n \t\tparse_from_existing(b);\n-\t\tif (is_null_sha1(b->sha1))\n+\t\tif (is_null_oid(&b->oid))\n \t\t\tb->delete = 1;\n \t}\n \telse\n \t\tdie(\"Invalid ref name or SHA1 expression: %s\", from);\n \n-\tif (b->branch_tree.tree && hashcmp(sha1, b->branch_tree.versions[1].sha1)) {\n+\tif (b->branch_tree.tree && hashcmp(sha1, b->branch_tree.versions[1].oid.hash)) {\n \t\trelease_tree_content_recursive(b->branch_tree.tree);\n \t\tb->branch_tree.tree = NULL;\n \t}\n@@ -2711,17 +2717,19 @@ static struct hash_list *parse_merge(unsigned int *count)\n \t\tn = xmalloc(sizeof(*n));\n \t\ts = lookup_branch(from);\n \t\tif (s)\n-\t\t\thashcpy(n->sha1, s->sha1);\n+\t\t\toidcpy(&n->oid, &s->oid);\n \t\telse if (*from == ':') {\n \t\t\tuintmax_t idnum = parse_mark_ref_eol(from);\n \t\t\tstruct object_entry *oe = find_mark(idnum);\n \t\t\tif (oe->type != OBJ_COMMIT)\n \t\t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", idnum);\n-\t\t\thashcpy(n->sha1, oe->idx.sha1);\n-\t\t} else if (!get_sha1(from, n->sha1)) {\n+\t\t\thashcpy(n->oid.hash, oe->idx.sha1);\n+\t\t} else if (!get_sha1(from, n->oid.hash)) {\n \t\t\tunsigned long size;\n-\t\t\tchar *buf = read_object_with_reference(n->sha1,\n-\t\t\t\tcommit_type, &size, n->sha1);\n+\t\t\tchar *buf = read_object_with_reference(n->oid.hash,\n+\t\t\t\t\t\t\t       commit_type,\n+\t\t\t\t\t\t\t       &size,\n+\t\t\t\t\t\t\t       n->oid.hash);\n \t\t\tif (!buf || size < 46)\n \t\t\t\tdie(\"Not a valid commit: %s\", from);\n \t\t\tfree(buf);\n@@ -2808,17 +2816,19 @@ static void parse_new_commit(const char *arg)\n \n \t/* build the tree and the commit */\n \tstore_tree(&b->branch_tree);\n-\thashcpy(b->branch_tree.versions[0].sha1,\n-\t\tb->branch_tree.versions[1].sha1);\n+\toidcpy(&b->branch_tree.versions[0].oid,\n+\t       &b->branch_tree.versions[1].oid);\n \n \tstrbuf_reset(&new_data);\n \tstrbuf_addf(&new_data, \"tree %s\\n\",\n-\t\tsha1_to_hex(b->branch_tree.versions[1].sha1));\n-\tif (!is_null_sha1(b->sha1))\n-\t\tstrbuf_addf(&new_data, \"parent %s\\n\", sha1_to_hex(b->sha1));\n+\t\toid_to_hex(&b->branch_tree.versions[1].oid));\n+\tif (!is_null_oid(&b->oid))\n+\t\tstrbuf_addf(&new_data, \"parent %s\\n\",\n+\t\t\t    oid_to_hex(&b->oid));\n \twhile (merge_list) {\n \t\tstruct hash_list *next = merge_list->next;\n-\t\tstrbuf_addf(&new_data, \"parent %s\\n\", sha1_to_hex(merge_list->sha1));\n+\t\tstrbuf_addf(&new_data, \"parent %s\\n\",\n+\t\t\t    oid_to_hex(&merge_list->oid));\n \t\tfree(merge_list);\n \t\tmerge_list = next;\n \t}\n@@ -2831,7 +2841,7 @@ static void parse_new_commit(const char *arg)\n \tfree(author);\n \tfree(committer);\n \n-\tif (!store_object(OBJ_COMMIT, &new_data, NULL, b->sha1, next_mark))\n+\tif (!store_object(OBJ_COMMIT, &new_data, NULL, b->oid.hash, next_mark))\n \t\tb->pack_id = pack_id;\n \tb->last_commit = object_count_by_type[OBJ_COMMIT];\n }\n@@ -2863,9 +2873,9 @@ static void parse_new_tag(const char *arg)\n \t\tdie(\"Expected from command, got %s\", command_buf.buf);\n \ts = lookup_branch(from);\n \tif (s) {\n-\t\tif (is_null_sha1(s->sha1))\n+\t\tif (is_null_oid(&s->oid))\n \t\t\tdie(\"Can't tag an empty branch.\");\n-\t\thashcpy(sha1, s->sha1);\n+\t\thashcpy(sha1, s->oid.hash);\n \t\ttype = OBJ_COMMIT;\n \t} else if (*from == ':') {\n \t\tstruct object_entry *oe;\n@@ -2910,7 +2920,7 @@ static void parse_new_tag(const char *arg)\n \tstrbuf_addbuf(&new_data, &msg);\n \tfree(tagger);\n \n-\tif (store_object(OBJ_TAG, &new_data, NULL, t->sha1, 0))\n+\tif (store_object(OBJ_TAG, &new_data, NULL, t->oid.hash, 0))\n \t\tt->pack_id = MAX_PACK_ID;\n \telse\n \t\tt->pack_id = pack_id;\n@@ -2922,9 +2932,9 @@ static void parse_reset_branch(const char *arg)\n \n \tb = lookup_branch(arg);\n \tif (b) {\n-\t\thashclr(b->sha1);\n-\t\thashclr(b->branch_tree.versions[0].sha1);\n-\t\thashclr(b->branch_tree.versions[1].sha1);\n+\t\toidclr(&b->oid);\n+\t\toidclr(&b->branch_tree.versions[0].oid);\n+\t\toidclr(&b->branch_tree.versions[1].oid);\n \t\tif (b->branch_tree.tree) {\n \t\t\trelease_tree_content_recursive(b->branch_tree.tree);\n \t\t\tb->branch_tree.tree = NULL;\n@@ -3143,8 +3153,8 @@ static void parse_ls(const char *p, struct branch *b)\n \t} else {\n \t\tstruct object_entry *e = parse_treeish_dataref(&p);\n \t\troot = new_tree_entry();\n-\t\thashcpy(root->versions[1].sha1, e->idx.sha1);\n-\t\tif (!is_null_sha1(root->versions[1].sha1))\n+\t\thashcpy(root->versions[1].oid.hash, e->idx.sha1);\n+\t\tif (!is_null_oid(&root->versions[1].oid))\n \t\t\troot->versions[1].mode = S_IFDIR;\n \t\tload_tree(root);\n \t}\n@@ -3166,7 +3176,7 @@ static void parse_ls(const char *p, struct branch *b)\n \tif (S_ISDIR(leaf.versions[1].mode))\n \t\tstore_tree(&leaf);\n \n-\tprint_ls(leaf.versions[1].mode, leaf.versions[1].sha1, p);\n+\tprint_ls(leaf.versions[1].mode, leaf.versions[1].oid.hash, p);\n \tif (leaf.tree)\n \t\trelease_tree_content_recursive(leaf.tree);\n \tif (!b || root != &b->branch_tree)\n"},{"id":"317577","messageId":"20170423213453.253425-10-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 09/53] builtin/rev-parse: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:09Z","receivedAt":"2017-04-23T21:36:11Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Some of the functions converted are callers of lookup_commit_reference.\nHowever, the changes involved in converting the entire thing are not too\nlarge, so we might as well convert it all.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/rev-parse.c | 56 ++++++++++++++++++++++++++---------------------------\n 1 file changed, 28 insertions(+), 28 deletions(-)\n\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex 051333091..272bb13a0 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -121,7 +121,7 @@ static void show_with_type(int type, const char *arg)\n }\n \n /* Output a revision, only if filter allows it */\n-static void show_rev(int type, const unsigned char *sha1, const char *name)\n+static void show_rev(int type, const struct object_id *oid, const char *name)\n {\n \tif (!(filter & DO_REVS))\n \t\treturn;\n@@ -129,10 +129,10 @@ static void show_rev(int type, const unsigned char *sha1, const char *name)\n \n \tif ((symbolic || abbrev_ref) && name) {\n \t\tif (symbolic == SHOW_SYMBOLIC_FULL || abbrev_ref) {\n-\t\t\tunsigned char discard[20];\n+\t\t\tstruct object_id discard;\n \t\t\tchar *full;\n \n-\t\t\tswitch (dwim_ref(name, strlen(name), discard, &full)) {\n+\t\t\tswitch (dwim_ref(name, strlen(name), discard.hash, &full)) {\n \t\t\tcase 0:\n \t\t\t\t/*\n \t\t\t\t * Not found -- not a ref.  We could\n@@ -158,9 +158,9 @@ static void show_rev(int type, const unsigned char *sha1, const char *name)\n \t\t}\n \t}\n \telse if (abbrev)\n-\t\tshow_with_type(type, find_unique_abbrev(sha1, abbrev));\n+\t\tshow_with_type(type, find_unique_abbrev(oid->hash, abbrev));\n \telse\n-\t\tshow_with_type(type, sha1_to_hex(sha1));\n+\t\tshow_with_type(type, oid_to_hex(oid));\n }\n \n /* Output a flag, only if filter allows it. */\n@@ -180,11 +180,11 @@ static int show_default(void)\n \tconst char *s = def;\n \n \tif (s) {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \n \t\tdef = NULL;\n-\t\tif (!get_sha1(s, sha1)) {\n-\t\t\tshow_rev(NORMAL, sha1, s);\n+\t\tif (!get_oid(s, &oid)) {\n+\t\t\tshow_rev(NORMAL, &oid, s);\n \t\t\treturn 1;\n \t\t}\n \t}\n@@ -195,19 +195,19 @@ static int show_reference(const char *refname, const struct object_id *oid, int\n {\n \tif (ref_excluded(ref_excludes, refname))\n \t\treturn 0;\n-\tshow_rev(NORMAL, oid->hash, refname);\n+\tshow_rev(NORMAL, oid, refname);\n \treturn 0;\n }\n \n static int anti_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)\n {\n-\tshow_rev(REVERSED, oid->hash, refname);\n+\tshow_rev(REVERSED, oid, refname);\n \treturn 0;\n }\n \n static int show_abbrev(const struct object_id *oid, void *cb_data)\n {\n-\tshow_rev(NORMAL, oid->hash, NULL);\n+\tshow_rev(NORMAL, oid, NULL);\n \treturn 0;\n }\n \n@@ -242,8 +242,8 @@ static int show_file(const char *arg, int output_prefix)\n static int try_difference(const char *arg)\n {\n \tchar *dotdot;\n-\tunsigned char sha1[20];\n-\tunsigned char end[20];\n+\tstruct object_id oid;\n+\tstruct object_id end;\n \tconst char *next;\n \tconst char *this;\n \tint symmetric;\n@@ -273,18 +273,18 @@ static int try_difference(const char *arg)\n \t\treturn 0;\n \t}\n \n-\tif (!get_sha1_committish(this, sha1) && !get_sha1_committish(next, end)) {\n-\t\tshow_rev(NORMAL, end, next);\n-\t\tshow_rev(symmetric ? NORMAL : REVERSED, sha1, this);\n+\tif (!get_sha1_committish(this, oid.hash) && !get_sha1_committish(next, end.hash)) {\n+\t\tshow_rev(NORMAL, &end, next);\n+\t\tshow_rev(symmetric ? NORMAL : REVERSED, &oid, this);\n \t\tif (symmetric) {\n \t\t\tstruct commit_list *exclude;\n \t\t\tstruct commit *a, *b;\n-\t\t\ta = lookup_commit_reference(sha1);\n-\t\t\tb = lookup_commit_reference(end);\n+\t\t\ta = lookup_commit_reference(oid.hash);\n+\t\t\tb = lookup_commit_reference(end.hash);\n \t\t\texclude = get_merge_bases(a, b);\n \t\t\twhile (exclude) {\n \t\t\t\tstruct commit *commit = pop_commit(&exclude);\n-\t\t\t\tshow_rev(REVERSED, commit->object.oid.hash, NULL);\n+\t\t\t\tshow_rev(REVERSED, &commit->object.oid, NULL);\n \t\t\t}\n \t\t}\n \t\t*dotdot = '.';\n@@ -297,7 +297,7 @@ static int try_difference(const char *arg)\n static int try_parent_shorthands(const char *arg)\n {\n \tchar *dotdot;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct commit *commit;\n \tstruct commit_list *parents;\n \tint parent_number;\n@@ -327,12 +327,12 @@ static int try_parent_shorthands(const char *arg)\n \t\treturn 0;\n \n \t*dotdot = 0;\n-\tif (get_sha1_committish(arg, sha1)) {\n+\tif (get_sha1_committish(arg, oid.hash)) {\n \t\t*dotdot = '^';\n \t\treturn 0;\n \t}\n \n-\tcommit = lookup_commit_reference(sha1);\n+\tcommit = lookup_commit_reference(oid.hash);\n \tif (exclude_parent &&\n \t    exclude_parent > commit_list_count(commit->parents)) {\n \t\t*dotdot = '^';\n@@ -340,7 +340,7 @@ static int try_parent_shorthands(const char *arg)\n \t}\n \n \tif (include_rev)\n-\t\tshow_rev(NORMAL, sha1, arg);\n+\t\tshow_rev(NORMAL, &oid, arg);\n \tfor (parents = commit->parents, parent_number = 1;\n \t     parents;\n \t     parents = parents->next, parent_number++) {\n@@ -352,7 +352,7 @@ static int try_parent_shorthands(const char *arg)\n \t\tif (symbolic)\n \t\t\tname = xstrfmt(\"%s^%d\", arg, parent_number);\n \t\tshow_rev(include_parents ? NORMAL : REVERSED,\n-\t\t\t parents->item->object.oid.hash, name);\n+\t\t\t& parents->item->object.oid, name);\n \t\tfree(name);\n \t}\n \n@@ -571,7 +571,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \tint did_repo_setup = 0;\n \tint has_dashdash = 0;\n \tint output_prefix = 0;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tunsigned int flags = 0;\n \tconst char *name = NULL;\n \tstruct object_context unused;\n@@ -910,11 +910,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\tname++;\n \t\t\ttype = REVERSED;\n \t\t}\n-\t\tif (!get_sha1_with_context(name, flags, sha1, &unused)) {\n+\t\tif (!get_sha1_with_context(name, flags, oid.hash, &unused)) {\n \t\t\tif (verify)\n \t\t\t\trevs_count++;\n \t\t\telse\n-\t\t\t\tshow_rev(type, sha1, name);\n+\t\t\t\tshow_rev(type, &oid, name);\n \t\t\tcontinue;\n \t\t}\n \t\tif (verify)\n@@ -929,7 +929,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \tstrbuf_release(&buf);\n \tif (verify) {\n \t\tif (revs_count == 1) {\n-\t\t\tshow_rev(type, sha1, name);\n+\t\t\tshow_rev(type, &oid, name);\n \t\t\treturn 0;\n \t\t} else if (revs_count == 0 && show_default())\n \t\t\treturn 0;\n"},{"id":"317578","messageId":"20170423213453.253425-13-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 12/53] submodule: convert merge_submodule to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:12Z","receivedAt":"2017-04-23T21:36:13Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is a caller of lookup_commit_reference, which we will convert\nlater.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n merge-recursive.c |  8 ++++----\n submodule.c       | 24 ++++++++++++------------\n submodule.h       |  8 ++++----\n 3 files changed, 20 insertions(+), 20 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 9d6fd577e..1315a45b9 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -994,11 +994,11 @@ static int merge_file_1(struct merge_options *o,\n \t\t\t\treturn ret;\n \t\t\tresult->clean = (merge_status == 0);\n \t\t} else if (S_ISGITLINK(a->mode)) {\n-\t\t\tresult->clean = merge_submodule(result->oid.hash,\n+\t\t\tresult->clean = merge_submodule(&result->oid,\n \t\t\t\t\t\t       one->path,\n-\t\t\t\t\t\t       one->oid.hash,\n-\t\t\t\t\t\t       a->oid.hash,\n-\t\t\t\t\t\t       b->oid.hash,\n+\t\t\t\t\t\t       &one->oid,\n+\t\t\t\t\t\t       &a->oid,\n+\t\t\t\t\t\t       &b->oid,\n \t\t\t\t\t\t       !o->call_depth);\n \t\t} else if (S_ISLNK(a->mode)) {\n \t\t\toidcpy(&result->oid, &a->oid);\ndiff --git a/submodule.c b/submodule.c\nindex 5615d7392..fb782c412 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -1567,9 +1567,9 @@ static void print_commit(struct commit *commit)\n #define MERGE_WARNING(path, msg) \\\n \twarning(\"Failed to merge submodule %s (%s)\", path, msg);\n \n-int merge_submodule(unsigned char result[20], const char *path,\n-\t\t    const unsigned char base[20], const unsigned char a[20],\n-\t\t    const unsigned char b[20], int search)\n+int merge_submodule(struct object_id *result, const char *path,\n+\t\t    const struct object_id *base, const struct object_id *a,\n+\t\t    const struct object_id *b, int search)\n {\n \tstruct commit *commit_base, *commit_a, *commit_b;\n \tint parent_count;\n@@ -1578,14 +1578,14 @@ int merge_submodule(unsigned char result[20], const char *path,\n \tint i;\n \n \t/* store a in result in case we fail */\n-\thashcpy(result, a);\n+\toidcpy(result, a);\n \n \t/* we can not handle deletion conflicts */\n-\tif (is_null_sha1(base))\n+\tif (is_null_oid(base))\n \t\treturn 0;\n-\tif (is_null_sha1(a))\n+\tif (is_null_oid(a))\n \t\treturn 0;\n-\tif (is_null_sha1(b))\n+\tif (is_null_oid(b))\n \t\treturn 0;\n \n \tif (add_submodule_odb(path)) {\n@@ -1593,9 +1593,9 @@ int merge_submodule(unsigned char result[20], const char *path,\n \t\treturn 0;\n \t}\n \n-\tif (!(commit_base = lookup_commit_reference(base)) ||\n-\t    !(commit_a = lookup_commit_reference(a)) ||\n-\t    !(commit_b = lookup_commit_reference(b))) {\n+\tif (!(commit_base = lookup_commit_reference(base->hash)) ||\n+\t    !(commit_a = lookup_commit_reference(a->hash)) ||\n+\t    !(commit_b = lookup_commit_reference(b->hash))) {\n \t\tMERGE_WARNING(path, \"commits not present\");\n \t\treturn 0;\n \t}\n@@ -1609,11 +1609,11 @@ int merge_submodule(unsigned char result[20], const char *path,\n \n \t/* Case #1: a is contained in b or vice versa */\n \tif (in_merge_bases(commit_a, commit_b)) {\n-\t\thashcpy(result, b);\n+\t\toidcpy(result, b);\n \t\treturn 1;\n \t}\n \tif (in_merge_bases(commit_b, commit_a)) {\n-\t\thashcpy(result, a);\n+\t\toidcpy(result, a);\n \t\treturn 1;\n \t}\n \ndiff --git a/submodule.h b/submodule.h\nindex 1277480ad..89c2ed219 100644\n--- a/submodule.h\n+++ b/submodule.h\n@@ -84,10 +84,10 @@ extern int submodule_uses_gitfile(const char *path);\n #define SUBMODULE_REMOVAL_IGNORE_UNTRACKED (1<<1)\n #define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<2)\n extern int bad_to_remove_submodule(const char *path, unsigned flags);\n-extern int merge_submodule(unsigned char result[20], const char *path,\n-\t\t\t   const unsigned char base[20],\n-\t\t\t   const unsigned char a[20],\n-\t\t\t   const unsigned char b[20], int search);\n+extern int merge_submodule(struct object_id *result, const char *path,\n+\t\t\t   const struct object_id *base,\n+\t\t\t   const struct object_id *a,\n+\t\t\t   const struct object_id *b, int search);\n extern int find_unpushed_submodules(struct oid_array *commits,\n \t\t\t\t    const char *remotes_name,\n \t\t\t\t    struct string_list *needs_pushing);\n"},{"id":"317579","messageId":"20170423213453.253425-14-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 13/53] notes-cache: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:13Z","receivedAt":"2017-04-23T21:36:14Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert as many instances of unsigned char [20] as possible,  Update the\ncallers of notes_cache_get and notes_cache_put to use the new interface.\nAmong the functions updated are callers of\nlookup_commit_reference_gently, which we will soon convert.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n diff.c        |  4 ++--\n notes-cache.c | 29 ++++++++++++++---------------\n notes-cache.h |  4 ++--\n 3 files changed, 18 insertions(+), 19 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 11eef1c85..3bd23ae4c 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5244,7 +5244,7 @@ size_t fill_textconv(struct userdiff_driver *driver,\n \n \tif (driver->textconv_cache && df->oid_valid) {\n \t\t*outbuf = notes_cache_get(driver->textconv_cache,\n-\t\t\t\t\t  df->oid.hash,\n+\t\t\t\t\t  &df->oid,\n \t\t\t\t\t  &size);\n \t\tif (*outbuf)\n \t\t\treturn size;\n@@ -5256,7 +5256,7 @@ size_t fill_textconv(struct userdiff_driver *driver,\n \n \tif (driver->textconv_cache && df->oid_valid) {\n \t\t/* ignore errors, as we might be in a readonly repository */\n-\t\tnotes_cache_put(driver->textconv_cache, df->oid.hash, *outbuf,\n+\t\tnotes_cache_put(driver->textconv_cache, &df->oid, *outbuf,\n \t\t\t\tsize);\n \t\t/*\n \t\t * we could save up changes and flush them all at the end,\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 5dfc5cbd0..1cdd4984a 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -5,16 +5,16 @@\n \n static int notes_cache_match_validity(const char *ref, const char *validity)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct commit *commit;\n \tstruct pretty_print_context pretty_ctx;\n \tstruct strbuf msg = STRBUF_INIT;\n \tint ret;\n \n-\tif (read_ref(ref, sha1) < 0)\n+\tif (read_ref(ref, oid.hash) < 0)\n \t\treturn 0;\n \n-\tcommit = lookup_commit_reference_gently(sha1, 1);\n+\tcommit = lookup_commit_reference_gently(oid.hash, 1);\n \tif (!commit)\n \t\treturn 0;\n \n@@ -46,8 +46,7 @@ void notes_cache_init(struct notes_cache *c, const char *name,\n \n int notes_cache_write(struct notes_cache *c)\n {\n-\tunsigned char tree_sha1[20];\n-\tunsigned char commit_sha1[20];\n+\tstruct object_id tree_oid, commit_oid;\n \n \tif (!c || !c->tree.initialized || !c->tree.update_ref ||\n \t    !*c->tree.update_ref)\n@@ -55,19 +54,19 @@ int notes_cache_write(struct notes_cache *c)\n \tif (!c->tree.dirty)\n \t\treturn 0;\n \n-\tif (write_notes_tree(&c->tree, tree_sha1))\n+\tif (write_notes_tree(&c->tree, tree_oid.hash))\n \t\treturn -1;\n-\tif (commit_tree(c->validity, strlen(c->validity), tree_sha1, NULL,\n-\t\t\tcommit_sha1, NULL, NULL) < 0)\n+\tif (commit_tree(c->validity, strlen(c->validity), tree_oid.hash, NULL,\n+\t\t\tcommit_oid.hash, NULL, NULL) < 0)\n \t\treturn -1;\n-\tif (update_ref(\"update notes cache\", c->tree.update_ref, commit_sha1,\n+\tif (update_ref(\"update notes cache\", c->tree.update_ref, commit_oid.hash,\n \t\t       NULL, 0, UPDATE_REFS_QUIET_ON_ERR) < 0)\n \t\treturn -1;\n \n \treturn 0;\n }\n \n-char *notes_cache_get(struct notes_cache *c, unsigned char key_sha1[20],\n+char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \t\t      size_t *outsize)\n {\n \tconst unsigned char *value_sha1;\n@@ -75,7 +74,7 @@ char *notes_cache_get(struct notes_cache *c, unsigned char key_sha1[20],\n \tchar *value;\n \tunsigned long size;\n \n-\tvalue_sha1 = get_note(&c->tree, key_sha1);\n+\tvalue_sha1 = get_note(&c->tree, key_oid->hash);\n \tif (!value_sha1)\n \t\treturn NULL;\n \tvalue = read_sha1_file(value_sha1, &type, &size);\n@@ -84,12 +83,12 @@ char *notes_cache_get(struct notes_cache *c, unsigned char key_sha1[20],\n \treturn value;\n }\n \n-int notes_cache_put(struct notes_cache *c, unsigned char key_sha1[20],\n+int notes_cache_put(struct notes_cache *c, struct object_id *key_oid,\n \t\t    const char *data, size_t size)\n {\n-\tunsigned char value_sha1[20];\n+\tstruct object_id value_oid;\n \n-\tif (write_sha1_file(data, size, \"blob\", value_sha1) < 0)\n+\tif (write_sha1_file(data, size, \"blob\", value_oid.hash) < 0)\n \t\treturn -1;\n-\treturn add_note(&c->tree, key_sha1, value_sha1, NULL);\n+\treturn add_note(&c->tree, key_oid->hash, value_oid.hash, NULL);\n }\ndiff --git a/notes-cache.h b/notes-cache.h\nindex 356f88fb3..aeeee8409 100644\n--- a/notes-cache.h\n+++ b/notes-cache.h\n@@ -12,9 +12,9 @@ void notes_cache_init(struct notes_cache *c, const char *name,\n \t\t     const char *validity);\n int notes_cache_write(struct notes_cache *c);\n \n-char *notes_cache_get(struct notes_cache *c, unsigned char sha1[20], size_t\n+char *notes_cache_get(struct notes_cache *c, struct object_id *oid, size_t\n \t\t      *outsize);\n-int notes_cache_put(struct notes_cache *c, unsigned char sha1[20],\n+int notes_cache_put(struct notes_cache *c, struct object_id *oid,\n \t\t    const char *data, size_t size);\n \n #endif /* NOTES_CACHE_H */\n"},{"id":"317580","messageId":"20170423213453.253425-12-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 11/53] fast-import: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:11Z","receivedAt":"2017-04-23T21:36:17Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the remaining parts of fast-import.c to use struct object_id.\nConvert several instances of get_sha1_hex to parse_oid_hex to avoid\nneeding to specify constants.  Convert other hardcoded values to named\nconstants.  Finally, use the is_empty_tree_oid function instead of a\ndirect comparison against a fixed string.\n\nNote that the odd computation with GIT_MAX_HEXSZ is due to the insertion\nof a slash between every two hex digits in the path, plus one for the\nterminating NUL.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n fast-import.c | 327 +++++++++++++++++++++++++++++-----------------------------\n 1 file changed, 161 insertions(+), 166 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 052c59d82..6b0117e51 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -391,10 +391,8 @@ static void write_branch_report(FILE *rpt, struct branch *b)\n \tfputc('\\n', rpt);\n \n \tfprintf(rpt, \"  tip commit  : %s\\n\", oid_to_hex(&b->oid));\n-\tfprintf(rpt, \"  old tree    : %s\\n\",\n-\t\toid_to_hex(&b->branch_tree.versions[0].oid));\n-\tfprintf(rpt, \"  cur tree    : %s\\n\",\n-\t\toid_to_hex(&b->branch_tree.versions[1].oid));\n+\tfprintf(rpt, \"  old tree    : %s\\n\", oid_to_hex(&b->branch_tree.versions[0].oid));\n+\tfprintf(rpt, \"  cur tree    : %s\\n\", oid_to_hex(&b->branch_tree.versions[1].oid));\n \tfprintf(rpt, \"  commit clock: %\" PRIuMAX \"\\n\", b->last_commit);\n \n \tfputs(\"  last pack   : \", rpt);\n@@ -557,7 +555,7 @@ static void alloc_objects(unsigned int cnt)\n \talloc_count += cnt;\n }\n \n-static struct object_entry *new_object(unsigned char *sha1)\n+static struct object_entry *new_object(struct object_id *oid)\n {\n \tstruct object_entry *e;\n \n@@ -565,32 +563,32 @@ static struct object_entry *new_object(unsigned char *sha1)\n \t\talloc_objects(object_entry_alloc);\n \n \te = blocks->next_free++;\n-\thashcpy(e->idx.sha1, sha1);\n+\thashcpy(e->idx.sha1, oid->hash);\n \treturn e;\n }\n \n-static struct object_entry *find_object(unsigned char *sha1)\n+static struct object_entry *find_object(struct object_id *oid)\n {\n-\tunsigned int h = sha1[0] << 8 | sha1[1];\n+\tunsigned int h = oid->hash[0] << 8 | oid->hash[1];\n \tstruct object_entry *e;\n \tfor (e = object_table[h]; e; e = e->next)\n-\t\tif (!hashcmp(sha1, e->idx.sha1))\n+\t\tif (!hashcmp(oid->hash, e->idx.sha1))\n \t\t\treturn e;\n \treturn NULL;\n }\n \n-static struct object_entry *insert_object(unsigned char *sha1)\n+static struct object_entry *insert_object(struct object_id *oid)\n {\n-\tunsigned int h = sha1[0] << 8 | sha1[1];\n+\tunsigned int h = oid->hash[0] << 8 | oid->hash[1];\n \tstruct object_entry *e = object_table[h];\n \n \twhile (e) {\n-\t\tif (!hashcmp(sha1, e->idx.sha1))\n+\t\tif (!hashcmp(oid->hash, e->idx.sha1))\n \t\t\treturn e;\n \t\te = e->next;\n \t}\n \n-\te = new_object(sha1);\n+\te = new_object(oid);\n \te->next = object_table[h];\n \te->idx.offset = 0;\n \tobject_table[h] = e;\n@@ -1007,17 +1005,17 @@ static void end_packfile(void)\n \tclear_delta_base_cache();\n \tif (object_count) {\n \t\tstruct packed_git *new_p;\n-\t\tunsigned char cur_pack_sha1[20];\n+\t\tstruct object_id cur_pack_oid;\n \t\tchar *idx_name;\n \t\tint i;\n \t\tstruct branch *b;\n \t\tstruct tag *t;\n \n \t\tclose_pack_windows(pack_data);\n-\t\tsha1close(pack_file, cur_pack_sha1, 0);\n+\t\tsha1close(pack_file, cur_pack_oid.hash, 0);\n \t\tfixup_pack_header_footer(pack_data->pack_fd, pack_data->sha1,\n \t\t\t\t    pack_data->pack_name, object_count,\n-\t\t\t\t    cur_pack_sha1, pack_size);\n+\t\t\t\t    cur_pack_oid.hash, pack_size);\n \n \t\tif (object_count <= unpack_limit) {\n \t\t\tif (!loosen_small_pack(pack_data)) {\n@@ -1083,13 +1081,13 @@ static int store_object(\n \tenum object_type type,\n \tstruct strbuf *dat,\n \tstruct last_object *last,\n-\tunsigned char *sha1out,\n+\tstruct object_id *oidout,\n \tuintmax_t mark)\n {\n \tvoid *out, *delta;\n \tstruct object_entry *e;\n \tunsigned char hdr[96];\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tunsigned long hdrlen, deltalen;\n \tgit_SHA_CTX c;\n \tgit_zstream s;\n@@ -1099,17 +1097,17 @@ static int store_object(\n \tgit_SHA1_Init(&c);\n \tgit_SHA1_Update(&c, hdr, hdrlen);\n \tgit_SHA1_Update(&c, dat->buf, dat->len);\n-\tgit_SHA1_Final(sha1, &c);\n-\tif (sha1out)\n-\t\thashcpy(sha1out, sha1);\n+\tgit_SHA1_Final(oid.hash, &c);\n+\tif (oidout)\n+\t\toidcpy(oidout, &oid);\n \n-\te = insert_object(sha1);\n+\te = insert_object(&oid);\n \tif (mark)\n \t\tinsert_mark(mark, e);\n \tif (e->idx.offset) {\n \t\tduplicate_count_by_type[type]++;\n \t\treturn 1;\n-\t} else if (find_sha1_pack(sha1, packed_git)) {\n+\t} else if (find_sha1_pack(oid.hash, packed_git)) {\n \t\te->type = type;\n \t\te->pack_id = MAX_PACK_ID;\n \t\te->idx.offset = 1; /* just not zero! */\n@@ -1222,13 +1220,13 @@ static void truncate_pack(struct sha1file_checkpoint *checkpoint)\n \tpack_size = checkpoint->offset;\n }\n \n-static void stream_blob(uintmax_t len, unsigned char *sha1out, uintmax_t mark)\n+static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)\n {\n \tsize_t in_sz = 64 * 1024, out_sz = 64 * 1024;\n \tunsigned char *in_buf = xmalloc(in_sz);\n \tunsigned char *out_buf = xmalloc(out_sz);\n \tstruct object_entry *e;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tunsigned long hdrlen;\n \toff_t offset;\n \tgit_SHA_CTX c;\n@@ -1291,12 +1289,12 @@ static void stream_blob(uintmax_t len, unsigned char *sha1out, uintmax_t mark)\n \t\t}\n \t}\n \tgit_deflate_end(&s);\n-\tgit_SHA1_Final(sha1, &c);\n+\tgit_SHA1_Final(oid.hash, &c);\n \n-\tif (sha1out)\n-\t\thashcpy(sha1out, sha1);\n+\tif (oidout)\n+\t\toidcpy(oidout, &oid);\n \n-\te = insert_object(sha1);\n+\te = insert_object(&oid);\n \n \tif (mark)\n \t\tinsert_mark(mark, e);\n@@ -1305,7 +1303,7 @@ static void stream_blob(uintmax_t len, unsigned char *sha1out, uintmax_t mark)\n \t\tduplicate_count_by_type[OBJ_BLOB]++;\n \t\ttruncate_pack(&checkpoint);\n \n-\t} else if (find_sha1_pack(sha1, packed_git)) {\n+\t} else if (find_sha1_pack(oid.hash, packed_git)) {\n \t\te->type = OBJ_BLOB;\n \t\te->pack_id = MAX_PACK_ID;\n \t\te->idx.offset = 1; /* just not zero! */\n@@ -1389,7 +1387,7 @@ static const char *get_mode(const char *str, uint16_t *modep)\n \n static void load_tree(struct tree_entry *root)\n {\n-\tunsigned char *sha1 = root->versions[1].oid.hash;\n+\tstruct object_id *oid = &root->versions[1].oid;\n \tstruct object_entry *myoe;\n \tstruct tree_content *t;\n \tunsigned long size;\n@@ -1397,22 +1395,22 @@ static void load_tree(struct tree_entry *root)\n \tconst char *c;\n \n \troot->tree = t = new_tree_content(8);\n-\tif (is_null_sha1(sha1))\n+\tif (is_null_oid(oid))\n \t\treturn;\n \n-\tmyoe = find_object(sha1);\n+\tmyoe = find_object(oid);\n \tif (myoe && myoe->pack_id != MAX_PACK_ID) {\n \t\tif (myoe->type != OBJ_TREE)\n-\t\t\tdie(\"Not a tree: %s\", sha1_to_hex(sha1));\n+\t\t\tdie(\"Not a tree: %s\", oid_to_hex(oid));\n \t\tt->delta_depth = myoe->depth;\n \t\tbuf = gfi_unpack_entry(myoe, &size);\n \t\tif (!buf)\n-\t\t\tdie(\"Can't load tree %s\", sha1_to_hex(sha1));\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(sha1, &type, &size);\n+\t\tbuf = read_sha1_file(oid->hash, &type, &size);\n \t\tif (!buf || type != OBJ_TREE)\n-\t\t\tdie(\"Can't load tree %s\", sha1_to_hex(sha1));\n+\t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t}\n \n \tc = buf;\n@@ -1426,13 +1424,13 @@ static void load_tree(struct tree_entry *root)\n \t\te->tree = NULL;\n \t\tc = get_mode(c, &e->versions[1].mode);\n \t\tif (!c)\n-\t\t\tdie(\"Corrupt mode in %s\", sha1_to_hex(sha1));\n+\t\t\tdie(\"Corrupt mode in %s\", oid_to_hex(oid));\n \t\te->versions[0].mode = e->versions[1].mode;\n \t\te->name = to_atom(c, strlen(c));\n \t\tc += e->name->str_len + 1;\n \t\thashcpy(e->versions[0].oid.hash, (unsigned char *)c);\n \t\thashcpy(e->versions[1].oid.hash, (unsigned char *)c);\n-\t\tc += 20;\n+\t\tc += GIT_SHA1_RAWSZ;\n \t}\n \tfree(buf);\n }\n@@ -1479,7 +1477,7 @@ static void mktree(struct tree_content *t, int v, struct strbuf *b)\n \t\tstrbuf_addf(b, \"%o %s%c\",\n \t\t\t(unsigned int)(e->versions[v].mode & ~NO_DELTA),\n \t\t\te->name->str_dat, '\\0');\n-\t\tstrbuf_add(b, e->versions[v].oid.hash, 20);\n+\t\tstrbuf_add(b, e->versions[v].oid.hash, GIT_SHA1_RAWSZ);\n \t}\n }\n \n@@ -1503,7 +1501,7 @@ static void store_tree(struct tree_entry *root)\n \t}\n \n \tif (!(root->versions[0].mode & NO_DELTA))\n-\t\tle = find_object(root->versions[0].oid.hash);\n+\t\tle = find_object(&root->versions[0].oid);\n \tif (S_ISDIR(root->versions[0].mode) && le && le->pack_id == pack_id) {\n \t\tmktree(t, 0, &old_tree);\n \t\tlo.data = old_tree;\n@@ -1512,7 +1510,7 @@ static void store_tree(struct tree_entry *root)\n \t}\n \n \tmktree(t, 1, &new_tree);\n-\tstore_object(OBJ_TREE, &new_tree, &lo, root->versions[1].oid.hash, 0);\n+\tstore_object(OBJ_TREE, &new_tree, &lo, &root->versions[1].oid, 0);\n \n \tt->delta_depth = lo.depth;\n \tfor (i = 0, j = 0, del = 0; i < t->entry_count; i++) {\n@@ -1531,14 +1529,14 @@ static void store_tree(struct tree_entry *root)\n \n static void tree_content_replace(\n \tstruct tree_entry *root,\n-\tconst unsigned char *sha1,\n+\tconst struct object_id *oid,\n \tconst uint16_t mode,\n \tstruct tree_content *newtree)\n {\n \tif (!S_ISDIR(mode))\n \t\tdie(\"Root cannot be a non-directory\");\n \toidclr(&root->versions[0].oid);\n-\thashcpy(root->versions[1].oid.hash, sha1);\n+\toidcpy(&root->versions[1].oid, oid);\n \tif (root->tree)\n \t\trelease_tree_content_recursive(root->tree);\n \troot->tree = newtree;\n@@ -1547,7 +1545,7 @@ static void tree_content_replace(\n static int tree_content_set(\n \tstruct tree_entry *root,\n \tconst char *p,\n-\tconst unsigned char *sha1,\n+\tconst struct object_id *oid,\n \tconst uint16_t mode,\n \tstruct tree_content *subtree)\n {\n@@ -1572,10 +1570,10 @@ static int tree_content_set(\n \t\t\tif (!*slash1) {\n \t\t\t\tif (!S_ISDIR(mode)\n \t\t\t\t\t\t&& e->versions[1].mode == mode\n-\t\t\t\t\t\t&& !hashcmp(e->versions[1].oid.hash, sha1))\n+\t\t\t\t\t\t&& !oidcmp(&e->versions[1].oid, oid))\n \t\t\t\t\treturn 0;\n \t\t\t\te->versions[1].mode = mode;\n-\t\t\t\thashcpy(e->versions[1].oid.hash, sha1);\n+\t\t\t\toidcpy(&e->versions[1].oid, oid);\n \t\t\t\tif (e->tree)\n \t\t\t\t\trelease_tree_content_recursive(e->tree);\n \t\t\t\te->tree = subtree;\n@@ -1605,7 +1603,7 @@ static int tree_content_set(\n \t\t\t}\n \t\t\tif (!e->tree)\n \t\t\t\tload_tree(e);\n-\t\t\tif (tree_content_set(e, slash1 + 1, sha1, mode, subtree)) {\n+\t\t\tif (tree_content_set(e, slash1 + 1, oid, mode, subtree)) {\n \t\t\t\toidclr(&root->versions[1].oid);\n \t\t\t\treturn 1;\n \t\t\t}\n@@ -1623,11 +1621,11 @@ static int tree_content_set(\n \tif (*slash1) {\n \t\te->tree = new_tree_content(8);\n \t\te->versions[1].mode = S_IFDIR;\n-\t\ttree_content_set(e, slash1 + 1, sha1, mode, subtree);\n+\t\ttree_content_set(e, slash1 + 1, oid, mode, subtree);\n \t} else {\n \t\te->tree = subtree;\n \t\te->versions[1].mode = mode;\n-\t\thashcpy(e->versions[1].oid.hash, sha1);\n+\t\toidcpy(&e->versions[1].oid, oid);\n \t}\n \toidclr(&root->versions[1].oid);\n \treturn 1;\n@@ -1750,7 +1748,7 @@ static int update_branch(struct branch *b)\n {\n \tstatic const char *msg = \"fast-import\";\n \tstruct ref_transaction *transaction;\n-\tunsigned char old_sha1[20];\n+\tstruct object_id old_oid;\n \tstruct strbuf err = STRBUF_INIT;\n \n \tif (is_null_oid(&b->oid)) {\n@@ -1758,12 +1756,12 @@ static int update_branch(struct branch *b)\n \t\t\tdelete_ref(NULL, b->name, NULL, 0);\n \t\treturn 0;\n \t}\n-\tif (read_ref(b->name, old_sha1))\n-\t\thashclr(old_sha1);\n-\tif (!force_update && !is_null_sha1(old_sha1)) {\n+\tif (read_ref(b->name, old_oid.hash))\n+\t\toidclr(&old_oid);\n+\tif (!force_update && !is_null_oid(&old_oid)) {\n \t\tstruct commit *old_cmit, *new_cmit;\n \n-\t\told_cmit = lookup_commit_reference_gently(old_sha1, 0);\n+\t\told_cmit = lookup_commit_reference_gently(old_oid.hash, 0);\n \t\tnew_cmit = lookup_commit_reference_gently(b->oid.hash, 0);\n \t\tif (!old_cmit || !new_cmit)\n \t\t\treturn error(\"Branch %s is missing commits.\", b->name);\n@@ -1772,13 +1770,13 @@ static int update_branch(struct branch *b)\n \t\t\twarning(\"Not updating %s\"\n \t\t\t\t\" (new tip %s does not contain %s)\",\n \t\t\t\tb->name, oid_to_hex(&b->oid),\n-\t\t\t\tsha1_to_hex(old_sha1));\n+\t\t\t\toid_to_hex(&old_oid));\n \t\t\treturn -1;\n \t\t}\n \t}\n \ttransaction = ref_transaction_begin(&err);\n \tif (!transaction ||\n-\t    ref_transaction_update(transaction, b->name, b->oid.hash, old_sha1,\n+\t    ref_transaction_update(transaction, b->name, b->oid.hash, old_oid.hash,\n \t\t\t\t   0, msg, &err) ||\n \t    ref_transaction_commit(transaction, &err)) {\n \t\tref_transaction_free(transaction);\n@@ -1898,7 +1896,7 @@ static void read_marks(void)\n \twhile (fgets(line, sizeof(line), f)) {\n \t\tuintmax_t mark;\n \t\tchar *end;\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tstruct object_entry *e;\n \n \t\tend = strchr(line, '\\n');\n@@ -1907,14 +1905,14 @@ static void read_marks(void)\n \t\t*end = 0;\n \t\tmark = strtoumax(line + 1, &end, 10);\n \t\tif (!mark || end == line + 1\n-\t\t\t|| *end != ' ' || get_sha1_hex(end + 1, sha1))\n+\t\t\t|| *end != ' ' || get_oid_hex(end + 1, &oid))\n \t\t\tdie(\"corrupt mark line: %s\", line);\n-\t\te = find_object(sha1);\n+\t\te = find_object(&oid);\n \t\tif (!e) {\n-\t\t\tenum object_type type = sha1_object_info(sha1, NULL);\n+\t\t\tenum object_type type = sha1_object_info(oid.hash, NULL);\n \t\t\tif (type < 0)\n-\t\t\t\tdie(\"object not found: %s\", sha1_to_hex(sha1));\n-\t\t\te = insert_object(sha1);\n+\t\t\t\tdie(\"object not found: %s\", oid_to_hex(&oid));\n+\t\t\te = insert_object(&oid);\n \t\t\te->type = type;\n \t\t\te->pack_id = MAX_PACK_ID;\n \t\t\te->idx.offset = 1; /* just not zero! */\n@@ -2122,21 +2120,21 @@ static char *parse_ident(const char *buf)\n \n static void parse_and_store_blob(\n \tstruct last_object *last,\n-\tunsigned char *sha1out,\n+\tstruct object_id *oidout,\n \tuintmax_t mark)\n {\n \tstatic struct strbuf buf = STRBUF_INIT;\n \tuintmax_t len;\n \n \tif (parse_data(&buf, big_file_threshold, &len))\n-\t\tstore_object(OBJ_BLOB, &buf, last, sha1out, mark);\n+\t\tstore_object(OBJ_BLOB, &buf, last, oidout, mark);\n \telse {\n \t\tif (last) {\n \t\t\tstrbuf_release(&last->data);\n \t\t\tlast->offset = 0;\n \t\t\tlast->depth = 0;\n \t\t}\n-\t\tstream_blob(len, sha1out, mark);\n+\t\tstream_blob(len, oidout, mark);\n \t\tskip_optional_lf();\n \t}\n }\n@@ -2212,21 +2210,21 @@ static void construct_path_with_fanout(const char *hex_sha1,\n \t\tpath[i++] = '/';\n \t\tfanout--;\n \t}\n-\tmemcpy(path + i, hex_sha1 + j, 40 - j);\n-\tpath[i + 40 - j] = '\\0';\n+\tmemcpy(path + i, hex_sha1 + j, GIT_SHA1_HEXSZ - j);\n+\tpath[i + GIT_SHA1_HEXSZ - j] = '\\0';\n }\n \n static uintmax_t do_change_note_fanout(\n \t\tstruct tree_entry *orig_root, struct tree_entry *root,\n-\t\tchar *hex_sha1, unsigned int hex_sha1_len,\n+\t\tchar *hex_oid, unsigned int hex_oid_len,\n \t\tchar *fullpath, unsigned int fullpath_len,\n \t\tunsigned char fanout)\n {\n \tstruct tree_content *t;\n \tstruct tree_entry *e, leaf;\n-\tunsigned int i, tmp_hex_sha1_len, tmp_fullpath_len;\n+\tunsigned int i, tmp_hex_oid_len, tmp_fullpath_len;\n \tuintmax_t num_notes = 0;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tchar realpath[60];\n \n \tif (!root->tree)\n@@ -2235,7 +2233,7 @@ static uintmax_t do_change_note_fanout(\n \n \tfor (i = 0; t && i < t->entry_count; i++) {\n \t\te = t->entries[i];\n-\t\ttmp_hex_sha1_len = hex_sha1_len + e->name->str_len;\n+\t\ttmp_hex_oid_len = hex_oid_len + e->name->str_len;\n \t\ttmp_fullpath_len = fullpath_len;\n \n \t\t/*\n@@ -2247,12 +2245,12 @@ static uintmax_t do_change_note_fanout(\n \t\t * of 2 chars.\n \t\t */\n \t\tif (!e->versions[1].mode ||\n-\t\t    tmp_hex_sha1_len > 40 ||\n+\t\t    tmp_hex_oid_len > GIT_SHA1_HEXSZ ||\n \t\t    e->name->str_len % 2)\n \t\t\tcontinue;\n \n \t\t/* This _may_ be a note entry, or a subdir containing notes */\n-\t\tmemcpy(hex_sha1 + hex_sha1_len, e->name->str_dat,\n+\t\tmemcpy(hex_oid + hex_oid_len, e->name->str_dat,\n \t\t       e->name->str_len);\n \t\tif (tmp_fullpath_len)\n \t\t\tfullpath[tmp_fullpath_len++] = '/';\n@@ -2261,14 +2259,14 @@ static uintmax_t do_change_note_fanout(\n \t\ttmp_fullpath_len += e->name->str_len;\n \t\tfullpath[tmp_fullpath_len] = '\\0';\n \n-\t\tif (tmp_hex_sha1_len == 40 && !get_sha1_hex(hex_sha1, sha1)) {\n+\t\tif (tmp_hex_oid_len == GIT_SHA1_HEXSZ && !get_oid_hex(hex_oid, &oid)) {\n \t\t\t/* This is a note entry */\n \t\t\tif (fanout == 0xff) {\n \t\t\t\t/* Counting mode, no rename */\n \t\t\t\tnum_notes++;\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tconstruct_path_with_fanout(hex_sha1, fanout, realpath);\n+\t\t\tconstruct_path_with_fanout(hex_oid, fanout, realpath);\n \t\t\tif (!strcmp(fullpath, realpath)) {\n \t\t\t\t/* Note entry is in correct location */\n \t\t\t\tnum_notes++;\n@@ -2279,13 +2277,13 @@ static uintmax_t do_change_note_fanout(\n \t\t\tif (!tree_content_remove(orig_root, fullpath, &leaf, 0))\n \t\t\t\tdie(\"Failed to remove path %s\", fullpath);\n \t\t\ttree_content_set(orig_root, realpath,\n-\t\t\t\tleaf.versions[1].oid.hash,\n+\t\t\t\t&leaf.versions[1].oid,\n \t\t\t\tleaf.versions[1].mode,\n \t\t\t\tleaf.tree);\n \t\t} else if (S_ISDIR(e->versions[1].mode)) {\n \t\t\t/* This is a subdir that may contain note entries */\n \t\t\tnum_notes += do_change_note_fanout(orig_root, e,\n-\t\t\t\thex_sha1, tmp_hex_sha1_len,\n+\t\t\t\thex_oid, tmp_hex_oid_len,\n \t\t\t\tfullpath, tmp_fullpath_len, fanout);\n \t\t}\n \n@@ -2298,8 +2296,12 @@ static uintmax_t do_change_note_fanout(\n static uintmax_t change_note_fanout(struct tree_entry *root,\n \t\tunsigned char fanout)\n {\n-\tchar hex_sha1[40], path[60];\n-\treturn do_change_note_fanout(root, root, hex_sha1, 0, path, 0, fanout);\n+\t/*\n+\t * The size of path is due to one slash between every two hex digits,\n+\t * plus the terminating NUL.\n+\t */\n+\tchar hex_oid[GIT_MAX_HEXSZ], path[GIT_MAX_HEXSZ * 3 / 2];\n+\treturn do_change_note_fanout(root, root, hex_oid, 0, path, 0, fanout);\n }\n \n /*\n@@ -2360,7 +2362,7 @@ static void file_change_m(const char *p, struct branch *b)\n \tstatic struct strbuf uq = STRBUF_INIT;\n \tconst char *endp;\n \tstruct object_entry *oe;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tuint16_t mode, inline_data = 0;\n \n \tp = get_mode(p, &mode);\n@@ -2383,15 +2385,14 @@ static void file_change_m(const char *p, struct branch *b)\n \n \tif (*p == ':') {\n \t\toe = find_mark(parse_mark_ref_space(&p));\n-\t\thashcpy(sha1, oe->idx.sha1);\n+\t\thashcpy(oid.hash, oe->idx.sha1);\n \t} else if (skip_prefix(p, \"inline \", &p)) {\n \t\tinline_data = 1;\n \t\toe = NULL; /* not used with inline_data, but makes gcc happy */\n \t} else {\n-\t\tif (get_sha1_hex(p, sha1))\n+\t\tif (parse_oid_hex(p, &oid, &p))\n \t\t\tdie(\"Invalid dataref: %s\", command_buf.buf);\n-\t\toe = find_object(sha1);\n-\t\tp += 40;\n+\t\toe = find_object(&oid);\n \t\tif (*p++ != ' ')\n \t\t\tdie(\"Missing space after SHA1: %s\", command_buf.buf);\n \t}\n@@ -2404,7 +2405,7 @@ static void file_change_m(const char *p, struct branch *b)\n \t}\n \n \t/* Git does not track empty, non-toplevel directories. */\n-\tif (S_ISDIR(mode) && !hashcmp(sha1, EMPTY_TREE_SHA1_BIN) && *p) {\n+\tif (S_ISDIR(mode) && is_empty_tree_oid(&oid) && *p) {\n \t\ttree_content_remove(&b->branch_tree, p, NULL, 0);\n \t\treturn;\n \t}\n@@ -2431,12 +2432,12 @@ static void file_change_m(const char *p, struct branch *b)\n \t\t\tp = uq.buf;\n \t\t}\n \t\tread_next_command();\n-\t\tparse_and_store_blob(&last_blob, sha1, 0);\n+\t\tparse_and_store_blob(&last_blob, &oid, 0);\n \t} else {\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(sha1, NULL);\n+\t\t\t\t\tsha1_object_info(oid.hash, 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@@ -2448,10 +2449,10 @@ static void file_change_m(const char *p, struct branch *b)\n \t}\n \n \tif (!*p) {\n-\t\ttree_content_replace(&b->branch_tree, sha1, mode, NULL);\n+\t\ttree_content_replace(&b->branch_tree, &oid, mode, NULL);\n \t\treturn;\n \t}\n-\ttree_content_set(&b->branch_tree, p, sha1, mode, NULL);\n+\ttree_content_set(&b->branch_tree, p, &oid, mode, NULL);\n }\n \n static void file_change_d(const char *p, struct branch *b)\n@@ -2509,13 +2510,13 @@ static void file_change_cr(const char *s, struct branch *b, int rename)\n \t\tdie(\"Path %s not in branch\", s);\n \tif (!*d) {\t/* C \"path/to/subdir\" \"\" */\n \t\ttree_content_replace(&b->branch_tree,\n-\t\t\tleaf.versions[1].oid.hash,\n+\t\t\t&leaf.versions[1].oid,\n \t\t\tleaf.versions[1].mode,\n \t\t\tleaf.tree);\n \t\treturn;\n \t}\n \ttree_content_set(&b->branch_tree, d,\n-\t\tleaf.versions[1].oid.hash,\n+\t\t&leaf.versions[1].oid,\n \t\tleaf.versions[1].mode,\n \t\tleaf.tree);\n }\n@@ -2525,7 +2526,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \tstatic struct strbuf uq = STRBUF_INIT;\n \tstruct object_entry *oe;\n \tstruct branch *s;\n-\tunsigned char sha1[20], commit_sha1[20];\n+\tstruct object_id oid, commit_oid;\n \tchar path[60];\n \tuint16_t inline_data = 0;\n \tunsigned char new_fanout;\n@@ -2550,15 +2551,14 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t/* <dataref> or 'inline' */\n \tif (*p == ':') {\n \t\toe = find_mark(parse_mark_ref_space(&p));\n-\t\thashcpy(sha1, oe->idx.sha1);\n+\t\thashcpy(oid.hash, oe->idx.sha1);\n \t} else if (skip_prefix(p, \"inline \", &p)) {\n \t\tinline_data = 1;\n \t\toe = NULL; /* not used with inline_data, but makes gcc happy */\n \t} else {\n-\t\tif (get_sha1_hex(p, sha1))\n+\t\tif (parse_oid_hex(p, &oid, &p))\n \t\t\tdie(\"Invalid dataref: %s\", command_buf.buf);\n-\t\toe = find_object(sha1);\n-\t\tp += 40;\n+\t\toe = find_object(&oid);\n \t\tif (*p++ != ' ')\n \t\t\tdie(\"Missing space after SHA1: %s\", command_buf.buf);\n \t}\n@@ -2568,17 +2568,17 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \tif (s) {\n \t\tif (is_null_oid(&s->oid))\n \t\t\tdie(\"Can't add a note on empty branch.\");\n-\t\thashcpy(commit_sha1, s->oid.hash);\n+\t\toidcpy(&commit_oid, &s->oid);\n \t} else if (*p == ':') {\n \t\tuintmax_t commit_mark = parse_mark_ref_eol(p);\n \t\tstruct object_entry *commit_oe = find_mark(commit_mark);\n \t\tif (commit_oe->type != OBJ_COMMIT)\n \t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", commit_mark);\n-\t\thashcpy(commit_sha1, commit_oe->idx.sha1);\n-\t} else if (!get_sha1(p, commit_sha1)) {\n+\t\thashcpy(commit_oid.hash, commit_oe->idx.sha1);\n+\t} else if (!get_oid(p, &commit_oid)) {\n \t\tunsigned long size;\n-\t\tchar *buf = read_object_with_reference(commit_sha1,\n-\t\t\tcommit_type, &size, commit_sha1);\n+\t\tchar *buf = read_object_with_reference(commit_oid.hash,\n+\t\t\tcommit_type, &size, commit_oid.hash);\n \t\tif (!buf || size < 46)\n \t\t\tdie(\"Not a valid commit: %s\", p);\n \t\tfree(buf);\n@@ -2591,13 +2591,13 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tp = uq.buf;\n \t\t}\n \t\tread_next_command();\n-\t\tparse_and_store_blob(&last_blob, sha1, 0);\n+\t\tparse_and_store_blob(&last_blob, &oid, 0);\n \t} else if (oe) {\n \t\tif (oe->type != OBJ_BLOB)\n \t\t\tdie(\"Not a blob (actually a %s): %s\",\n \t\t\t\ttypename(oe->type), command_buf.buf);\n-\t} else if (!is_null_sha1(sha1)) {\n-\t\tenum object_type type = sha1_object_info(sha1, NULL);\n+\t} else if (!is_null_oid(&oid)) {\n+\t\tenum object_type type = sha1_object_info(oid.hash, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Blob not found: %s\", command_buf.buf);\n \t\tif (type != OBJ_BLOB)\n@@ -2605,17 +2605,17 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\t    typename(type), command_buf.buf);\n \t}\n \n-\tconstruct_path_with_fanout(sha1_to_hex(commit_sha1), *old_fanout, path);\n+\tconstruct_path_with_fanout(oid_to_hex(&commit_oid), *old_fanout, path);\n \tif (tree_content_remove(&b->branch_tree, path, NULL, 0))\n \t\tb->num_notes--;\n \n-\tif (is_null_sha1(sha1))\n+\tif (is_null_oid(&oid))\n \t\treturn; /* nothing to insert */\n \n \tb->num_notes++;\n \tnew_fanout = convert_num_notes_to_fanout(b->num_notes);\n-\tconstruct_path_with_fanout(sha1_to_hex(commit_sha1), new_fanout, path);\n-\ttree_content_set(&b->branch_tree, path, sha1, S_IFREG | 0644, NULL);\n+\tconstruct_path_with_fanout(oid_to_hex(&commit_oid), new_fanout, path);\n+\ttree_content_set(&b->branch_tree, path, &oid, S_IFREG | 0644, NULL);\n }\n \n static void file_change_deleteall(struct branch *b)\n@@ -2629,10 +2629,10 @@ static void file_change_deleteall(struct branch *b)\n \n static void parse_from_commit(struct branch *b, char *buf, unsigned long size)\n {\n-\tif (!buf || size < 46)\n+\tif (!buf || size < GIT_SHA1_HEXSZ + 6)\n \t\tdie(\"Not a valid commit: %s\", oid_to_hex(&b->oid));\n \tif (memcmp(\"tree \", buf, 5)\n-\t\t|| get_sha1_hex(buf + 5, b->branch_tree.versions[1].oid.hash))\n+\t\t|| get_oid_hex(buf + 5, &b->branch_tree.versions[1].oid))\n \t\tdie(\"The commit %s is corrupt\", oid_to_hex(&b->oid));\n \toidcpy(&b->branch_tree.versions[0].oid,\n \t       &b->branch_tree.versions[1].oid);\n@@ -2659,21 +2659,21 @@ static int parse_from(struct branch *b)\n {\n \tconst char *from;\n \tstruct branch *s;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \n \tif (!skip_prefix(command_buf.buf, \"from \", &from))\n \t\treturn 0;\n \n-\thashcpy(sha1, b->branch_tree.versions[1].oid.hash);\n+\toidcpy(&oid, &b->branch_tree.versions[1].oid);\n \n \ts = lookup_branch(from);\n \tif (b == s)\n \t\tdie(\"Can't create a branch from itself: %s\", b->name);\n \telse if (s) {\n-\t\tunsigned char *t = s->branch_tree.versions[1].oid.hash;\n+\t\tstruct object_id *t = &s->branch_tree.versions[1].oid;\n \t\toidcpy(&b->oid, &s->oid);\n-\t\thashcpy(b->branch_tree.versions[0].oid.hash, t);\n-\t\thashcpy(b->branch_tree.versions[1].oid.hash, t);\n+\t\toidcpy(&b->branch_tree.versions[0].oid, t);\n+\t\toidcpy(&b->branch_tree.versions[1].oid, t);\n \t} else if (*from == ':') {\n \t\tuintmax_t idnum = parse_mark_ref_eol(from);\n \t\tstruct object_entry *oe = find_mark(idnum);\n@@ -2689,7 +2689,7 @@ static int parse_from(struct branch *b)\n \t\t\t} else\n \t\t\t\tparse_from_existing(b);\n \t\t}\n-\t} else if (!get_sha1(from, b->oid.hash)) {\n+\t} else if (!get_oid(from, &b->oid)) {\n \t\tparse_from_existing(b);\n \t\tif (is_null_oid(&b->oid))\n \t\t\tb->delete = 1;\n@@ -2697,7 +2697,7 @@ static int parse_from(struct branch *b)\n \telse\n \t\tdie(\"Invalid ref name or SHA1 expression: %s\", from);\n \n-\tif (b->branch_tree.tree && hashcmp(sha1, b->branch_tree.versions[1].oid.hash)) {\n+\tif (b->branch_tree.tree && oidcmp(&oid, &b->branch_tree.versions[1].oid)) {\n \t\trelease_tree_content_recursive(b->branch_tree.tree);\n \t\tb->branch_tree.tree = NULL;\n \t}\n@@ -2724,12 +2724,10 @@ static struct hash_list *parse_merge(unsigned int *count)\n \t\t\tif (oe->type != OBJ_COMMIT)\n \t\t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", idnum);\n \t\t\thashcpy(n->oid.hash, oe->idx.sha1);\n-\t\t} else if (!get_sha1(from, n->oid.hash)) {\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\t\t\t\t       commit_type,\n-\t\t\t\t\t\t\t       &size,\n-\t\t\t\t\t\t\t       n->oid.hash);\n+\t\t\t\tcommit_type, &size, n->oid.hash);\n \t\t\tif (!buf || size < 46)\n \t\t\t\tdie(\"Not a valid commit: %s\", from);\n \t\t\tfree(buf);\n@@ -2823,12 +2821,10 @@ static void parse_new_commit(const char *arg)\n \tstrbuf_addf(&new_data, \"tree %s\\n\",\n \t\toid_to_hex(&b->branch_tree.versions[1].oid));\n \tif (!is_null_oid(&b->oid))\n-\t\tstrbuf_addf(&new_data, \"parent %s\\n\",\n-\t\t\t    oid_to_hex(&b->oid));\n+\t\tstrbuf_addf(&new_data, \"parent %s\\n\", oid_to_hex(&b->oid));\n \twhile (merge_list) {\n \t\tstruct hash_list *next = merge_list->next;\n-\t\tstrbuf_addf(&new_data, \"parent %s\\n\",\n-\t\t\t    oid_to_hex(&merge_list->oid));\n+\t\tstrbuf_addf(&new_data, \"parent %s\\n\", oid_to_hex(&merge_list->oid));\n \t\tfree(merge_list);\n \t\tmerge_list = next;\n \t}\n@@ -2841,7 +2837,7 @@ static void parse_new_commit(const char *arg)\n \tfree(author);\n \tfree(committer);\n \n-\tif (!store_object(OBJ_COMMIT, &new_data, NULL, b->oid.hash, next_mark))\n+\tif (!store_object(OBJ_COMMIT, &new_data, NULL, &b->oid, next_mark))\n \t\tb->pack_id = pack_id;\n \tb->last_commit = object_count_by_type[OBJ_COMMIT];\n }\n@@ -2854,7 +2850,7 @@ static void parse_new_tag(const char *arg)\n \tstruct branch *s;\n \tstruct tag *t;\n \tuintmax_t from_mark = 0;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tenum object_type type;\n \tconst char *v;\n \n@@ -2875,18 +2871,18 @@ static void parse_new_tag(const char *arg)\n \tif (s) {\n \t\tif (is_null_oid(&s->oid))\n \t\t\tdie(\"Can't tag an empty branch.\");\n-\t\thashcpy(sha1, s->oid.hash);\n+\t\toidcpy(&oid, &s->oid);\n \t\ttype = OBJ_COMMIT;\n \t} else if (*from == ':') {\n \t\tstruct object_entry *oe;\n \t\tfrom_mark = parse_mark_ref_eol(from);\n \t\toe = find_mark(from_mark);\n \t\ttype = oe->type;\n-\t\thashcpy(sha1, oe->idx.sha1);\n-\t} else if (!get_sha1(from, sha1)) {\n-\t\tstruct object_entry *oe = find_object(sha1);\n+\t\thashcpy(oid.hash, oe->idx.sha1);\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(sha1, NULL);\n+\t\t\ttype = sha1_object_info(oid.hash, NULL);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"Not a valid object: %s\", from);\n \t\t} else\n@@ -2912,7 +2908,7 @@ static void parse_new_tag(const char *arg)\n \t\t    \"object %s\\n\"\n \t\t    \"type %s\\n\"\n \t\t    \"tag %s\\n\",\n-\t\t    sha1_to_hex(sha1), typename(type), t->name);\n+\t\t    oid_to_hex(&oid), typename(type), t->name);\n \tif (tagger)\n \t\tstrbuf_addf(&new_data,\n \t\t\t    \"tagger %s\\n\", tagger);\n@@ -2920,7 +2916,7 @@ static void parse_new_tag(const char *arg)\n \tstrbuf_addbuf(&new_data, &msg);\n \tfree(tagger);\n \n-\tif (store_object(OBJ_TAG, &new_data, NULL, t->oid.hash, 0))\n+\tif (store_object(OBJ_TAG, &new_data, NULL, &t->oid, 0))\n \t\tt->pack_id = MAX_PACK_ID;\n \telse\n \t\tt->pack_id = pack_id;\n@@ -2954,7 +2950,7 @@ static void cat_blob_write(const char *buf, unsigned long size)\n \t\tdie_errno(\"Write to frontend failed\");\n }\n \n-static void cat_blob(struct object_entry *oe, unsigned char sha1[20])\n+static void cat_blob(struct object_entry *oe, struct object_id *oid)\n {\n \tstruct strbuf line = STRBUF_INIT;\n \tunsigned long size;\n@@ -2962,7 +2958,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20])\n \tchar *buf;\n \n \tif (!oe || oe->pack_id == MAX_PACK_ID) {\n-\t\tbuf = read_sha1_file(sha1, &type, &size);\n+\t\tbuf = read_sha1_file(oid->hash, &type, &size);\n \t} else {\n \t\ttype = oe->type;\n \t\tbuf = gfi_unpack_entry(oe, &size);\n@@ -2973,19 +2969,19 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20])\n \t */\n \tif (type <= 0) {\n \t\tstrbuf_reset(&line);\n-\t\tstrbuf_addf(&line, \"%s missing\\n\", sha1_to_hex(sha1));\n+\t\tstrbuf_addf(&line, \"%s missing\\n\", oid_to_hex(oid));\n \t\tcat_blob_write(line.buf, line.len);\n \t\tstrbuf_release(&line);\n \t\tfree(buf);\n \t\treturn;\n \t}\n \tif (!buf)\n-\t\tdie(\"Can't read object %s\", sha1_to_hex(sha1));\n+\t\tdie(\"Can't read object %s\", oid_to_hex(oid));\n \tif (type != OBJ_BLOB)\n \t\tdie(\"Object %s is a %s but a blob was expected.\",\n-\t\t    sha1_to_hex(sha1), typename(type));\n+\t\t    oid_to_hex(oid), typename(type));\n \tstrbuf_reset(&line);\n-\tstrbuf_addf(&line, \"%s %s %lu\\n\", sha1_to_hex(sha1),\n+\tstrbuf_addf(&line, \"%s %s %lu\\n\", oid_to_hex(oid),\n \t\t\t\t\t\ttypename(type), size);\n \tcat_blob_write(line.buf, line.len);\n \tstrbuf_release(&line);\n@@ -3002,7 +2998,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20])\n static void parse_get_mark(const char *p)\n {\n \tstruct object_entry *oe = oe;\n-\tchar output[42];\n+\tchar output[GIT_MAX_HEXSZ + 2];\n \n \t/* get-mark SP <object> LF */\n \tif (*p != ':')\n@@ -3013,42 +3009,42 @@ static void parse_get_mark(const char *p)\n \t\tdie(\"Unknown mark: %s\", command_buf.buf);\n \n \txsnprintf(output, sizeof(output), \"%s\\n\", sha1_to_hex(oe->idx.sha1));\n-\tcat_blob_write(output, 41);\n+\tcat_blob_write(output, GIT_SHA1_HEXSZ + 1);\n }\n \n static void parse_cat_blob(const char *p)\n {\n \tstruct object_entry *oe = oe;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \n \t/* cat-blob SP <object> LF */\n \tif (*p == ':') {\n \t\toe = find_mark(parse_mark_ref_eol(p));\n \t\tif (!oe)\n \t\t\tdie(\"Unknown mark: %s\", command_buf.buf);\n-\t\thashcpy(sha1, oe->idx.sha1);\n+\t\thashcpy(oid.hash, oe->idx.sha1);\n \t} else {\n-\t\tif (get_sha1_hex(p, sha1))\n+\t\tif (parse_oid_hex(p, &oid, &p))\n \t\t\tdie(\"Invalid dataref: %s\", command_buf.buf);\n-\t\tif (p[40])\n+\t\tif (*p)\n \t\t\tdie(\"Garbage after SHA1: %s\", command_buf.buf);\n-\t\toe = find_object(sha1);\n+\t\toe = find_object(&oid);\n \t}\n \n-\tcat_blob(oe, sha1);\n+\tcat_blob(oe, &oid);\n }\n \n static struct object_entry *dereference(struct object_entry *oe,\n-\t\t\t\t\tunsigned char sha1[20])\n+\t\t\t\t\tstruct object_id *oid)\n {\n \tunsigned long size;\n \tchar *buf = NULL;\n \tif (!oe) {\n-\t\tenum object_type type = sha1_object_info(sha1, NULL);\n+\t\tenum object_type type = sha1_object_info(oid->hash, NULL);\n \t\tif (type < 0)\n-\t\t\tdie(\"object not found: %s\", sha1_to_hex(sha1));\n+\t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\t/* cache it! */\n-\t\toe = insert_object(sha1);\n+\t\toe = insert_object(oid);\n \t\toe->type = type;\n \t\toe->pack_id = MAX_PACK_ID;\n \t\toe->idx.offset = 1;\n@@ -3067,49 +3063,48 @@ 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(sha1, &unused, &size);\n+\t\tbuf = read_sha1_file(oid->hash, &unused, &size);\n \t}\n \tif (!buf)\n-\t\tdie(\"Can't load object %s\", sha1_to_hex(sha1));\n+\t\tdie(\"Can't load object %s\", oid_to_hex(oid));\n \n \t/* Peel one layer. */\n \tswitch (oe->type) {\n \tcase OBJ_TAG:\n-\t\tif (size < 40 + strlen(\"object \") ||\n-\t\t    get_sha1_hex(buf + strlen(\"object \"), sha1))\n+\t\tif (size < GIT_SHA1_HEXSZ + strlen(\"object \") ||\n+\t\t    get_oid_hex(buf + strlen(\"object \"), oid))\n \t\t\tdie(\"Invalid SHA1 in tag: %s\", command_buf.buf);\n \t\tbreak;\n \tcase OBJ_COMMIT:\n-\t\tif (size < 40 + strlen(\"tree \") ||\n-\t\t    get_sha1_hex(buf + strlen(\"tree \"), sha1))\n+\t\tif (size < GIT_SHA1_HEXSZ + strlen(\"tree \") ||\n+\t\t    get_oid_hex(buf + strlen(\"tree \"), oid))\n \t\t\tdie(\"Invalid SHA1 in commit: %s\", command_buf.buf);\n \t}\n \n \tfree(buf);\n-\treturn find_object(sha1);\n+\treturn find_object(oid);\n }\n \n static struct object_entry *parse_treeish_dataref(const char **p)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct object_entry *e;\n \n \tif (**p == ':') {\t/* <mark> */\n \t\te = find_mark(parse_mark_ref_space(p));\n \t\tif (!e)\n \t\t\tdie(\"Unknown mark: %s\", command_buf.buf);\n-\t\thashcpy(sha1, e->idx.sha1);\n+\t\thashcpy(oid.hash, e->idx.sha1);\n \t} else {\t/* <sha1> */\n-\t\tif (get_sha1_hex(*p, sha1))\n+\t\tif (parse_oid_hex(*p, &oid, p))\n \t\t\tdie(\"Invalid dataref: %s\", command_buf.buf);\n-\t\te = find_object(sha1);\n-\t\t*p += 40;\n+\t\te = find_object(&oid);\n \t\tif (*(*p)++ != ' ')\n \t\t\tdie(\"Missing space after tree-ish: %s\", command_buf.buf);\n \t}\n \n \twhile (!e || e->type != OBJ_TREE)\n-\t\te = dereference(e, sha1);\n+\t\te = dereference(e, &oid);\n \treturn e;\n }\n \n"},{"id":"317581","messageId":"20170423213453.253425-15-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 14/53] parse-options-cb: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:14Z","receivedAt":"2017-04-23T21:36:18Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is a caller of lookup_commit_reference, which we will soon convert.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n parse-options-cb.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/parse-options-cb.c b/parse-options-cb.c\nindex 7419780a9..35a941fdd 100644\n--- a/parse-options-cb.c\n+++ b/parse-options-cb.c\n@@ -80,14 +80,14 @@ int parse_opt_verbosity_cb(const struct option *opt, const char *arg,\n \n int parse_opt_commits(const struct option *opt, const char *arg, int unset)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct commit *commit;\n \n \tif (!arg)\n \t\treturn -1;\n-\tif (get_sha1(arg, sha1))\n+\tif (get_oid(arg, &oid))\n \t\treturn error(\"malformed object name %s\", arg);\n-\tcommit = lookup_commit_reference(sha1);\n+\tcommit = lookup_commit_reference(oid.hash);\n \tif (!commit)\n \t\treturn error(\"no such commit %s\", arg);\n \tcommit_list_insert(commit, opt->value);\n"},{"id":"317582","messageId":"20170423213453.253425-18-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 17/53] tag: convert parse_tag_buffer to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:17Z","receivedAt":"2017-04-23T21:36:20Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Specify some constants in terms of GIT_SHA1_HEXSZ, and convert a\nget_sha1_hex into parse_oid_hex to avoid needing to specify additional\nconstants.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n tag.c | 15 +++++++--------\n 1 file changed, 7 insertions(+), 8 deletions(-)\n\ndiff --git a/tag.c b/tag.c\nindex 243d1fdbb..625f5cd71 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -116,7 +116,7 @@ static unsigned long parse_tag_date(const char *buf, const char *tail)\n \n int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tchar type[20];\n \tconst char *bufptr = data;\n \tconst char *tail = bufptr + size;\n@@ -126,11 +126,10 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n \t\treturn 0;\n \titem->object.parsed = 1;\n \n-\tif (size < 64)\n+\tif (size < GIT_SHA1_HEXSZ + 24)\n \t\treturn -1;\n-\tif (memcmp(\"object \", bufptr, 7) || get_sha1_hex(bufptr + 7, sha1) || bufptr[47] != '\\n')\n+\tif (memcmp(\"object \", bufptr, 7) || parse_oid_hex(bufptr + 7, &oid, &bufptr) || *bufptr++ != '\\n')\n \t\treturn -1;\n-\tbufptr += 48; /* \"object \" + sha1 + \"\\n\" */\n \n \tif (!starts_with(bufptr, \"type \"))\n \t\treturn -1;\n@@ -143,13 +142,13 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n \tbufptr = nl + 1;\n \n \tif (!strcmp(type, blob_type)) {\n-\t\titem->tagged = &lookup_blob(sha1)->object;\n+\t\titem->tagged = &lookup_blob(oid.hash)->object;\n \t} else if (!strcmp(type, tree_type)) {\n-\t\titem->tagged = &lookup_tree(sha1)->object;\n+\t\titem->tagged = &lookup_tree(oid.hash)->object;\n \t} else if (!strcmp(type, commit_type)) {\n-\t\titem->tagged = &lookup_commit(sha1)->object;\n+\t\titem->tagged = &lookup_commit(oid.hash)->object;\n \t} else if (!strcmp(type, tag_type)) {\n-\t\titem->tagged = &lookup_tag(sha1)->object;\n+\t\titem->tagged = &lookup_tag(oid.hash)->object;\n \t} else {\n \t\terror(\"Unknown type %s\", type);\n \t\titem->tagged = NULL;\n"},{"id":"317583","messageId":"20170423213453.253425-16-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 15/53] reflog_expire: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:15Z","receivedAt":"2017-04-23T21:36:21Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Adjust the callback functions to take struct object_id * instead of\nunsigned char *, and modify related static functions accordingly.\n\nIntroduce a temporary object_id instance into files_reflog_expire and\ncopy the SHA-1 value passed in.  This is necessary because the sha1\nparameter can come indirectly from get_sha1.  Without the temporary, it\nwould require much more refactoring to be able to convert this function.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/reflog.c     | 22 +++++++++++-----------\n refs.h               |  6 +++---\n refs/files-backend.c |  7 +++++--\n 3 files changed, 19 insertions(+), 16 deletions(-)\n\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 747277577..d6718d326 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -186,13 +186,13 @@ static int commit_is_complete(struct commit *commit)\n \treturn !is_incomplete;\n }\n \n-static int keep_entry(struct commit **it, unsigned char *sha1)\n+static int keep_entry(struct commit **it, struct object_id *oid)\n {\n \tstruct commit *commit;\n \n-\tif (is_null_sha1(sha1))\n+\tif (is_null_oid(oid))\n \t\treturn 1;\n-\tcommit = lookup_commit_reference_gently(sha1, 1);\n+\tcommit = lookup_commit_reference_gently(oid->hash, 1);\n \tif (!commit)\n \t\treturn 0;\n \n@@ -251,17 +251,17 @@ static void mark_reachable(struct expire_reflog_policy_cb *cb)\n \tcb->mark_list = leftover;\n }\n \n-static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit, unsigned char *sha1)\n+static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit, struct object_id *oid)\n {\n \t/*\n \t * We may or may not have the commit yet - if not, look it\n \t * up using the supplied sha1.\n \t */\n \tif (!commit) {\n-\t\tif (is_null_sha1(sha1))\n+\t\tif (is_null_oid(oid))\n \t\t\treturn 0;\n \n-\t\tcommit = lookup_commit_reference_gently(sha1, 1);\n+\t\tcommit = lookup_commit_reference_gently(oid->hash, 1);\n \n \t\t/* Not a commit -- keep it */\n \t\tif (!commit)\n@@ -283,7 +283,7 @@ static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit\n /*\n  * Return true iff the specified reflog entry should be expired.\n  */\n-static int should_expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,\n+static int should_expire_reflog_ent(struct object_id *ooid, struct object_id *noid,\n \t\t\t\t    const char *email, unsigned long timestamp, int tz,\n \t\t\t\t    const char *message, void *cb_data)\n {\n@@ -295,13 +295,13 @@ static int should_expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,\n \n \told = new = NULL;\n \tif (cb->cmd.stalefix &&\n-\t    (!keep_entry(&old, osha1) || !keep_entry(&new, nsha1)))\n+\t    (!keep_entry(&old, ooid) || !keep_entry(&new, noid)))\n \t\treturn 1;\n \n \tif (timestamp < cb->cmd.expire_unreachable) {\n \t\tif (cb->unreachable_expire_kind == UE_ALWAYS)\n \t\t\treturn 1;\n-\t\tif (unreachable(cb, old, osha1) || unreachable(cb, new, nsha1))\n+\t\tif (unreachable(cb, old, ooid) || unreachable(cb, new, noid))\n \t\t\treturn 1;\n \t}\n \n@@ -326,7 +326,7 @@ static int push_tip_to_list(const char *refname, const struct object_id *oid,\n }\n \n static void reflog_expiry_prepare(const char *refname,\n-\t\t\t\t  const unsigned char *sha1,\n+\t\t\t\t  const struct object_id *oid,\n \t\t\t\t  void *cb_data)\n {\n \tstruct expire_reflog_policy_cb *cb = cb_data;\n@@ -335,7 +335,7 @@ static void reflog_expiry_prepare(const char *refname,\n \t\tcb->tip_commit = NULL;\n \t\tcb->unreachable_expire_kind = UE_HEAD;\n \t} else {\n-\t\tcb->tip_commit = lookup_commit_reference_gently(sha1, 1);\n+\t\tcb->tip_commit = lookup_commit_reference_gently(oid->hash, 1);\n \t\tif (!cb->tip_commit)\n \t\t\tcb->unreachable_expire_kind = UE_ALWAYS;\n \t\telse\ndiff --git a/refs.h b/refs.h\nindex 49e97d7d5..bbe16740f 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -611,10 +611,10 @@ enum expire_reflog_flags {\n  *     unlocked again.\n  */\n typedef void reflog_expiry_prepare_fn(const char *refname,\n-\t\t\t\t      const unsigned char *sha1,\n+\t\t\t\t      const struct object_id *oid,\n \t\t\t\t      void *cb_data);\n-typedef int reflog_expiry_should_prune_fn(unsigned char *osha1,\n-\t\t\t\t\t  unsigned char *nsha1,\n+typedef int reflog_expiry_should_prune_fn(struct object_id *ooid,\n+\t\t\t\t\t  struct object_id *noid,\n \t\t\t\t\t  const char *email,\n \t\t\t\t\t  unsigned long timestamp, int tz,\n \t\t\t\t\t  const char *message, void *cb_data);\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 4d705b403..238a046e6 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -4123,7 +4123,7 @@ static int expire_reflog_ent(struct object_id *ooid, struct object_id *noid,\n \tif (cb->flags & EXPIRE_REFLOGS_REWRITE)\n \t\tooid = &cb->last_kept_oid;\n \n-\tif ((*cb->should_prune_fn)(ooid->hash, noid->hash, email, timestamp, tz,\n+\tif ((*cb->should_prune_fn)(ooid, noid, email, timestamp, tz,\n \t\t\t\t   message, policy_cb)) {\n \t\tif (!cb->newlog)\n \t\t\tprintf(\"would prune %s\", message);\n@@ -4160,6 +4160,7 @@ static int files_reflog_expire(struct ref_store *ref_store,\n \tint status = 0;\n \tint type;\n \tstruct strbuf err = STRBUF_INIT;\n+\tstruct object_id oid;\n \n \tmemset(&cb, 0, sizeof(cb));\n \tcb.flags = flags;\n@@ -4209,7 +4210,9 @@ static int files_reflog_expire(struct ref_store *ref_store,\n \t\t}\n \t}\n \n-\t(*prepare_fn)(refname, sha1, cb.policy_cb);\n+\thashcpy(oid.hash, sha1);\n+\n+\t(*prepare_fn)(refname, &oid, cb.policy_cb);\n \trefs_for_each_reflog_ent(ref_store, refname, expire_reflog_ent, &cb);\n \t(*cleanup_fn)(cb.policy_cb);\n \n"},{"id":"317584","messageId":"20170423213453.253425-17-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 16/53] builtin/verify-commit: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:16Z","receivedAt":"2017-04-23T21:36:24Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is a prerequisite to convert to lookup_commit, which we will\nconvert later.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/verify-commit.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/verify-commit.c b/builtin/verify-commit.c\nindex 38bedf8f9..a5db1c427 100644\n--- a/builtin/verify-commit.c\n+++ b/builtin/verify-commit.c\n@@ -18,14 +18,14 @@ static const char * const verify_commit_usage[] = {\n \t\tNULL\n };\n \n-static int run_gpg_verify(const unsigned char *sha1, const char *buf, unsigned long size, unsigned flags)\n+static int run_gpg_verify(const struct object_id *oid, const char *buf, unsigned long size, unsigned flags)\n {\n \tstruct signature_check signature_check;\n \tint ret;\n \n \tmemset(&signature_check, 0, sizeof(signature_check));\n \n-\tret = check_commit_signature(lookup_commit(sha1), &signature_check);\n+\tret = check_commit_signature(lookup_commit(oid->hash), &signature_check);\n \tprint_signature_buffer(&signature_check, flags);\n \n \tsignature_check_clear(&signature_check);\n@@ -35,22 +35,22 @@ static int run_gpg_verify(const unsigned char *sha1, const char *buf, unsigned l\n static int verify_commit(const char *name, unsigned flags)\n {\n \tenum object_type type;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tchar *buf;\n \tunsigned long size;\n \tint ret;\n \n-\tif (get_sha1(name, sha1))\n+\tif (get_oid(name, &oid))\n \t\treturn error(\"commit '%s' not found.\", name);\n \n-\tbuf = read_sha1_file(sha1, &type, &size);\n+\tbuf = read_sha1_file(oid.hash, &type, &size);\n \tif (!buf)\n \t\treturn error(\"%s: unable to read file.\", name);\n \tif (type != OBJ_COMMIT)\n \t\treturn error(\"%s: cannot verify a non-commit object of type %s.\",\n \t\t\t\tname, typename(type));\n \n-\tret = run_gpg_verify(sha1, buf, size, flags);\n+\tret = run_gpg_verify(&oid, buf, size, flags);\n \n \tfree(buf);\n \treturn ret;\n"},{"id":"317585","messageId":"20170423213453.253425-20-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 19/53] notes-utils: convert internals to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:19Z","receivedAt":"2017-04-23T21:36:26Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the internals of create_notes_comit and commit_notes to use\nstruct object_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n notes-utils.c | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/notes-utils.c b/notes-utils.c\nindex 24a33616a..36c1490aa 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -7,18 +7,18 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,\n \t\t\t const char *msg, size_t msg_len,\n \t\t\t unsigned char *result_sha1)\n {\n-\tunsigned char tree_sha1[20];\n+\tstruct object_id tree_oid;\n \n \tassert(t->initialized);\n \n-\tif (write_notes_tree(t, tree_sha1))\n+\tif (write_notes_tree(t, tree_oid.hash))\n \t\tdie(\"Failed to write notes tree to database\");\n \n \tif (!parents) {\n \t\t/* Deduce parent commit from t->ref */\n-\t\tunsigned char parent_sha1[20];\n-\t\tif (!read_ref(t->ref, parent_sha1)) {\n-\t\t\tstruct commit *parent = lookup_commit(parent_sha1);\n+\t\tstruct object_id parent_oid;\n+\t\tif (!read_ref(t->ref, parent_oid.hash)) {\n+\t\t\tstruct commit *parent = lookup_commit(parent_oid.hash);\n \t\t\tif (parse_commit(parent))\n \t\t\t\tdie(\"Failed to find/parse commit %s\", t->ref);\n \t\t\tcommit_list_insert(parent, &parents);\n@@ -26,14 +26,14 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,\n \t\t/* else: t->ref points to nothing, assume root/orphan commit */\n \t}\n \n-\tif (commit_tree(msg, msg_len, tree_sha1, parents, result_sha1, NULL, NULL))\n+\tif (commit_tree(msg, msg_len, tree_oid.hash, parents, result_sha1, NULL, NULL))\n \t\tdie(\"Failed to commit notes tree to database\");\n }\n \n void commit_notes(struct notes_tree *t, const char *msg)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n-\tunsigned char commit_sha1[20];\n+\tstruct object_id commit_oid;\n \n \tif (!t)\n \t\tt = &default_notes_tree;\n@@ -46,9 +46,9 @@ void commit_notes(struct notes_tree *t, const char *msg)\n \tstrbuf_addstr(&buf, msg);\n \tstrbuf_complete_line(&buf);\n \n-\tcreate_notes_commit(t, NULL, buf.buf, buf.len, commit_sha1);\n+\tcreate_notes_commit(t, NULL, buf.buf, buf.len, commit_oid.hash);\n \tstrbuf_insert(&buf, 0, \"notes: \", 7); /* commit message starts at index 7 */\n-\tupdate_ref(buf.buf, t->update_ref, commit_sha1, NULL, 0,\n+\tupdate_ref(buf.buf, t->update_ref, commit_oid.hash, NULL, 0,\n \t\t   UPDATE_REFS_DIE_ON_ERR);\n \n \tstrbuf_release(&buf);\n"},{"id":"317586","messageId":"20170423213453.253425-19-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 18/53] http-push: convert some static functions to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:18Z","receivedAt":"2017-04-23T21:36:31Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Among the functions converted is a caller of lookup_commit_or_die, which\nwe will convert later on.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n http-push.c | 24 ++++++++++++------------\n 1 file changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex f0e3108f7..f3dd0a560 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1536,7 +1536,7 @@ static int remote_exists(const char *path)\n \treturn ret;\n }\n \n-static void fetch_symref(const char *path, char **symref, unsigned char *sha1)\n+static void fetch_symref(const char *path, char **symref, struct object_id *oid)\n {\n \tchar *url = xstrfmt(\"%s%s\", repo->url, path);\n \tstruct strbuf buffer = STRBUF_INIT;\n@@ -1549,7 +1549,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)\n \n \tfree(*symref);\n \t*symref = NULL;\n-\thashclr(sha1);\n+\toidclr(oid);\n \n \tif (buffer.len == 0)\n \t\treturn;\n@@ -1561,15 +1561,15 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)\n \tif (skip_prefix(buffer.buf, \"ref: \", &name)) {\n \t\t*symref = xmemdupz(name, buffer.len - (name - buffer.buf));\n \t} else {\n-\t\tget_sha1_hex(buffer.buf, sha1);\n+\t\tget_oid_hex(buffer.buf, oid);\n \t}\n \n \tstrbuf_release(&buffer);\n }\n \n-static int verify_merge_base(unsigned char *head_sha1, struct ref *remote)\n+static int verify_merge_base(struct object_id *head_oid, struct ref *remote)\n {\n-\tstruct commit *head = lookup_commit_or_die(head_sha1, \"HEAD\");\n+\tstruct commit *head = lookup_commit_or_die(head_oid->hash, \"HEAD\");\n \tstruct commit *branch = lookup_commit_or_die(remote->old_oid.hash, remote->name);\n \n \treturn in_merge_bases(branch, head);\n@@ -1579,7 +1579,7 @@ static int delete_remote_branch(const char *pattern, int force)\n {\n \tstruct ref *refs = remote_refs;\n \tstruct ref *remote_ref = NULL;\n-\tunsigned char head_sha1[20];\n+\tstruct object_id head_oid;\n \tchar *symref = NULL;\n \tint match;\n \tint patlen = strlen(pattern);\n@@ -1610,7 +1610,7 @@ static int delete_remote_branch(const char *pattern, int force)\n \t * Remote HEAD must be a symref (not exactly foolproof; a remote\n \t * symlink to a symref will look like a symref)\n \t */\n-\tfetch_symref(\"HEAD\", &symref, head_sha1);\n+\tfetch_symref(\"HEAD\", &symref, &head_oid);\n \tif (!symref)\n \t\treturn error(\"Remote HEAD is not a symref\");\n \n@@ -1619,7 +1619,7 @@ static int delete_remote_branch(const char *pattern, int force)\n \t\tif (!strcmp(remote_ref->name, symref))\n \t\t\treturn error(\"Remote branch %s is the current HEAD\",\n \t\t\t\t     remote_ref->name);\n-\t\tfetch_symref(symref, &symref, head_sha1);\n+\t\tfetch_symref(symref, &symref, &head_oid);\n \t}\n \n \t/* Run extra sanity checks if delete is not forced */\n@@ -1627,10 +1627,10 @@ static int delete_remote_branch(const char *pattern, int force)\n \t\t/* Remote HEAD must resolve to a known object */\n \t\tif (symref)\n \t\t\treturn error(\"Remote HEAD symrefs too deep\");\n-\t\tif (is_null_sha1(head_sha1))\n+\t\tif (is_null_oid(&head_oid))\n \t\t\treturn error(\"Unable to resolve remote HEAD\");\n-\t\tif (!has_sha1_file(head_sha1))\n-\t\t\treturn error(\"Remote HEAD resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", sha1_to_hex(head_sha1));\n+\t\tif (!has_object_file(&head_oid))\n+\t\t\treturn error(\"Remote HEAD resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", oid_to_hex(&head_oid));\n \n \t\t/* Remote branch must resolve to a known object */\n \t\tif (is_null_oid(&remote_ref->old_oid))\n@@ -1640,7 +1640,7 @@ static int delete_remote_branch(const char *pattern, int force)\n \t\t\treturn error(\"Remote branch %s resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", remote_ref->name, oid_to_hex(&remote_ref->old_oid));\n \n \t\t/* Remote branch must be an ancestor of remote HEAD */\n-\t\tif (!verify_merge_base(head_sha1, remote_ref)) {\n+\t\tif (!verify_merge_base(&head_oid, remote_ref)) {\n \t\t\treturn error(\"The branch '%s' is not an ancestor \"\n \t\t\t\t     \"of your current HEAD.\\n\"\n \t\t\t\t     \"If you are sure you want to delete it,\"\n"},{"id":"317587","messageId":"20170423213453.253425-23-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 22/53] sequencer: convert some functions to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:22Z","receivedAt":"2017-04-23T21:36:34Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert update_squash_messages and is_index_unchanged to struct\nobject_id.  These are callers of lookup_commit and\nlookup_commit_reference, which we want to convert.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n sequencer.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex e13a25b91..0562d7b9a 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -482,13 +482,13 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n \n static int is_index_unchanged(void)\n {\n-\tunsigned char head_sha1[20];\n+\tstruct object_id head_oid;\n \tstruct commit *head_commit;\n \n-\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, head_sha1, NULL))\n+\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, head_oid.hash, NULL))\n \t\treturn error(_(\"could not resolve HEAD commit\\n\"));\n \n-\thead_commit = lookup_commit(head_sha1);\n+\thead_commit = lookup_commit(head_oid.hash);\n \n \t/*\n \t * If head_commit is NULL, check_commit, called from\n@@ -835,13 +835,13 @@ static int update_squash_messages(enum todo_command command,\n \t\tstrbuf_splice(&buf, 0, eol - buf.buf, header.buf, header.len);\n \t\tstrbuf_release(&header);\n \t} else {\n-\t\tunsigned char head[20];\n+\t\tstruct object_id head;\n \t\tstruct commit *head_commit;\n \t\tconst char *head_message, *body;\n \n-\t\tif (get_sha1(\"HEAD\", head))\n+\t\tif (get_oid(\"HEAD\", &head))\n \t\t\treturn error(_(\"need a HEAD to fixup\"));\n-\t\tif (!(head_commit = lookup_commit_reference(head)))\n+\t\tif (!(head_commit = lookup_commit_reference(head.hash)))\n \t\t\treturn error(_(\"could not read HEAD\"));\n \t\tif (!(head_message = get_commit_buffer(head_commit, NULL)))\n \t\t\treturn error(_(\"could not read HEAD's commit message\"));\n"},{"id":"317588","messageId":"20170423213453.253425-21-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 20/53] revision: convert prepare_show_merge to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:20Z","receivedAt":"2017-04-23T21:36:38Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is a caller of lookup_commit_or_die, which we will convert later\non.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n revision.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 2b56c3baf..945367034 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1389,16 +1389,16 @@ static void prepare_show_merge(struct rev_info *revs)\n {\n \tstruct commit_list *bases;\n \tstruct commit *head, *other;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tconst char **prune = NULL;\n \tint i, prune_num = 1; /* counting terminating NULL */\n \n-\tif (get_sha1(\"HEAD\", sha1))\n+\tif (get_oid(\"HEAD\", &oid))\n \t\tdie(\"--merge without HEAD?\");\n-\thead = lookup_commit_or_die(sha1, \"HEAD\");\n-\tif (get_sha1(\"MERGE_HEAD\", sha1))\n+\thead = lookup_commit_or_die(oid.hash, \"HEAD\");\n+\tif (get_oid(\"MERGE_HEAD\", &oid))\n \t\tdie(\"--merge without MERGE_HEAD?\");\n-\tother = lookup_commit_or_die(sha1, \"MERGE_HEAD\");\n+\tother = lookup_commit_or_die(oid.hash, \"MERGE_HEAD\");\n \tadd_pending_object(revs, &head->object, \"HEAD\");\n \tadd_pending_object(revs, &other->object, \"MERGE_HEAD\");\n \tbases = get_merge_bases(head, other);\n"},{"id":"317589","messageId":"20170423213453.253425-22-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 21/53] shallow: convert shallow registration functions to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:21Z","receivedAt":"2017-04-23T21:36:41Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert register_shallow and unregister_shallow to take struct\nobject_id.  register_shallow is a caller of lookup_commit, which we will\nconvert later.  It doesn't make sense for the registration and\nunregistration functions to have incompatible interfaces, so convert\nthem both.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/pack-objects.c |  6 +++---\n builtin/receive-pack.c |  2 +-\n commit.c               |  4 ++--\n commit.h               |  4 ++--\n fetch-pack.c           |  4 ++--\n shallow.c              | 12 ++++++------\n upload-pack.c          |  8 ++++----\n 7 files changed, 20 insertions(+), 20 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 0fe35d1b5..477070806 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2777,10 +2777,10 @@ static void get_object_list(int ac, const char **av)\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (starts_with(line, \"--shallow \")) {\n-\t\t\t\tunsigned char sha1[20];\n-\t\t\t\tif (get_sha1_hex(line + 10, sha1))\n+\t\t\t\tstruct object_id oid;\n+\t\t\t\tif (get_oid_hex(line + 10, &oid))\n \t\t\t\t\tdie(\"not an SHA-1 '%s'\", line + 10);\n-\t\t\t\tregister_shallow(sha1);\n+\t\t\t\tregister_shallow(&oid);\n \t\t\t\tuse_bitmap_index = 0;\n \t\t\t\tcontinue;\n \t\t\t}\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 3cba3fd27..38e5164f6 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -859,7 +859,7 @@ static int update_shallow_ref(struct command *cmd, struct shallow_info *si)\n \t * not lose these new roots..\n \t */\n \tfor (i = 0; i < extra.nr; i++)\n-\t\tregister_shallow(extra.oid[i].hash);\n+\t\tregister_shallow(&extra.oid[i]);\n \n \tsi->shallow_ref[cmd->index] = 0;\n \toid_array_clear(&extra);\ndiff --git a/commit.c b/commit.c\nindex 73c78c2b8..ec41ba5e0 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -216,9 +216,9 @@ int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data)\n \treturn ret;\n }\n \n-int unregister_shallow(const unsigned char *sha1)\n+int unregister_shallow(const struct object_id *oid)\n {\n-\tint pos = commit_graft_pos(sha1);\n+\tint pos = commit_graft_pos(oid->hash);\n \tif (pos < 0)\n \t\treturn -1;\n \tif (pos + 1 < commit_graft_nr)\ndiff --git a/commit.h b/commit.h\nindex 7b1986d5c..884177b8f 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -263,8 +263,8 @@ extern struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n,\n \n struct oid_array;\n struct ref;\n-extern int register_shallow(const unsigned char *sha1);\n-extern int unregister_shallow(const unsigned char *sha1);\n+extern int register_shallow(const struct object_id *oid);\n+extern int unregister_shallow(const struct object_id *oid);\n extern int for_each_commit_graft(each_commit_graft_fn, void *);\n extern int is_repository_shallow(void);\n extern struct commit_list *get_shallow_commits(struct object_array *heads,\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 1e6b03b6b..f3aae85d5 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -415,7 +415,7 @@ static int find_common(struct fetch_pack_args *args,\n \t\t\tif (skip_prefix(line, \"shallow \", &arg)) {\n \t\t\t\tif (get_oid_hex(arg, &oid))\n \t\t\t\t\tdie(_(\"invalid shallow line: %s\"), line);\n-\t\t\t\tregister_shallow(oid.hash);\n+\t\t\t\tregister_shallow(&oid);\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (skip_prefix(line, \"unshallow \", &arg)) {\n@@ -426,7 +426,7 @@ static int find_common(struct fetch_pack_args *args,\n \t\t\t\t/* make sure that it is parsed as shallow */\n \t\t\t\tif (!parse_object(oid.hash))\n \t\t\t\t\tdie(_(\"error in object: %s\"), line);\n-\t\t\t\tif (unregister_shallow(oid.hash))\n+\t\t\t\tif (unregister_shallow(&oid))\n \t\t\t\t\tdie(_(\"no shallow found: %s\"), line);\n \t\t\t\tcontinue;\n \t\t\t}\ndiff --git a/shallow.c b/shallow.c\nindex 25b6db989..c520ae3ae 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -27,13 +27,13 @@ void set_alternate_shallow_file(const char *path, int override)\n \talternate_shallow_file = xstrdup_or_null(path);\n }\n \n-int register_shallow(const unsigned char *sha1)\n+int register_shallow(const struct object_id *oid)\n {\n \tstruct commit_graft *graft =\n \t\txmalloc(sizeof(struct commit_graft));\n-\tstruct commit *commit = lookup_commit(sha1);\n+\tstruct commit *commit = lookup_commit(oid->hash);\n \n-\thashcpy(graft->oid.hash, sha1);\n+\toidcpy(&graft->oid, oid);\n \tgraft->nr_parent = -1;\n \tif (commit && commit->object.parsed)\n \t\tcommit->parents = NULL;\n@@ -65,10 +65,10 @@ int is_repository_shallow(void)\n \tis_shallow = 1;\n \n \twhile (fgets(buf, sizeof(buf), fp)) {\n-\t\tunsigned char sha1[20];\n-\t\tif (get_sha1_hex(buf, sha1))\n+\t\tstruct object_id oid;\n+\t\tif (get_oid_hex(buf, &oid))\n \t\t\tdie(\"bad shallow line: %s\", buf);\n-\t\tregister_shallow(sha1);\n+\t\tregister_shallow(&oid);\n \t}\n \tfclose(fp);\n \treturn is_shallow;\ndiff --git a/upload-pack.c b/upload-pack.c\nindex ffb028d62..20f87cd38 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -642,7 +642,7 @@ static void send_shallow(struct commit_list *result)\n \t\tif (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {\n \t\t\tpacket_write_fmt(1, \"shallow %s\",\n \t\t\t\t\t oid_to_hex(&object->oid));\n-\t\t\tregister_shallow(object->oid.hash);\n+\t\t\tregister_shallow(&object->oid);\n \t\t\tshallow_nr++;\n \t\t}\n \t\tresult = result->next;\n@@ -667,7 +667,7 @@ static void send_unshallow(const struct object_array *shallows)\n \t\t\t * parse and add the parents to the want list, then\n \t\t\t * re-register it.\n \t\t\t */\n-\t\t\tunregister_shallow(object->oid.hash);\n+\t\t\tunregister_shallow(&object->oid);\n \t\t\tobject->parsed = 0;\n \t\t\tparse_commit_or_die((struct commit *)object);\n \t\t\tparents = ((struct commit *)object)->parents;\n@@ -679,7 +679,7 @@ static void send_unshallow(const struct object_array *shallows)\n \t\t\tadd_object_array(object, NULL, &extra_edge_obj);\n \t\t}\n \t\t/* make sure commit traversal conforms to client */\n-\t\tregister_shallow(object->oid.hash);\n+\t\tregister_shallow(&object->oid);\n \t}\n }\n \n@@ -883,7 +883,7 @@ static void receive_needs(void)\n \t\tif (shallows.nr > 0) {\n \t\t\tint i;\n \t\t\tfor (i = 0; i < shallows.nr; i++)\n-\t\t\t\tregister_shallow(shallows.objects[i].item->oid.hash);\n+\t\t\t\tregister_shallow(&shallows.objects[i].item->oid);\n \t\t}\n \n \tshallow_nr += shallows.nr;\n"},{"id":"317590","messageId":"20170423213453.253425-24-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 23/53] builtin/tag: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:23Z","receivedAt":"2017-04-23T21:36:43Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Parts of this module call lookup_commit_reference, which we want to\nconvert.  The module is small and mostly self-contained, so convert the\nrest of it while we're at it.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/tag.c | 66 +++++++++++++++++++++++++++++------------------------------\n 1 file changed, 33 insertions(+), 33 deletions(-)\n\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 222404522..597c925e3 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -66,7 +66,7 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, con\n }\n \n typedef int (*each_tag_name_fn)(const char *name, const char *ref,\n-\t\t\t\tconst unsigned char *sha1, const void *cb_data);\n+\t\t\t\tconst struct object_id *oid, const void *cb_data);\n \n static int for_each_tag_name(const char **argv, each_tag_name_fn fn,\n \t\t\t     const void *cb_data)\n@@ -74,17 +74,17 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn,\n \tconst char **p;\n \tstruct strbuf ref = STRBUF_INIT;\n \tint had_error = 0;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \n \tfor (p = argv; *p; p++) {\n \t\tstrbuf_reset(&ref);\n \t\tstrbuf_addf(&ref, \"refs/tags/%s\", *p);\n-\t\tif (read_ref(ref.buf, sha1)) {\n+\t\tif (read_ref(ref.buf, oid.hash)) {\n \t\t\terror(_(\"tag '%s' not found.\"), *p);\n \t\t\thad_error = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (fn(*p, ref.buf, sha1, cb_data))\n+\t\tif (fn(*p, ref.buf, &oid, cb_data))\n \t\t\thad_error = 1;\n \t}\n \tstrbuf_release(&ref);\n@@ -92,16 +92,16 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn,\n }\n \n static int delete_tag(const char *name, const char *ref,\n-\t\t      const unsigned char *sha1, const void *cb_data)\n+\t\t      const struct object_id *oid, const void *cb_data)\n {\n-\tif (delete_ref(NULL, ref, sha1, 0))\n+\tif (delete_ref(NULL, ref, oid->hash, 0))\n \t\treturn 1;\n-\tprintf(_(\"Deleted tag '%s' (was %s)\\n\"), name, find_unique_abbrev(sha1, DEFAULT_ABBREV));\n+\tprintf(_(\"Deleted tag '%s' (was %s)\\n\"), name, find_unique_abbrev(oid->hash, DEFAULT_ABBREV));\n \treturn 0;\n }\n \n static int verify_tag(const char *name, const char *ref,\n-\t\t      const unsigned char *sha1, const void *cb_data)\n+\t\t      const struct object_id *oid, const void *cb_data)\n {\n \tint flags;\n \tconst char *fmt_pretty = cb_data;\n@@ -110,11 +110,11 @@ static int verify_tag(const char *name, const char *ref,\n \tif (fmt_pretty)\n \t\tflags = GPG_VERIFY_OMIT_STATUS;\n \n-\tif (gpg_verify_tag(sha1, name, flags))\n+\tif (gpg_verify_tag(oid->hash, name, flags))\n \t\treturn -1;\n \n \tif (fmt_pretty)\n-\t\tpretty_print_ref(name, sha1, fmt_pretty);\n+\t\tpretty_print_ref(name, oid->hash, fmt_pretty);\n \n \treturn 0;\n }\n@@ -182,13 +182,13 @@ static int git_tag_config(const char *var, const char *value, void *cb)\n \treturn git_default_config(var, value, cb);\n }\n \n-static void write_tag_body(int fd, const unsigned char *sha1)\n+static void write_tag_body(int fd, const struct object_id *oid)\n {\n \tunsigned long size;\n \tenum object_type type;\n \tchar *buf, *sp;\n \n-\tbuf = read_sha1_file(sha1, &type, &size);\n+\tbuf = read_sha1_file(oid->hash, &type, &size);\n \tif (!buf)\n \t\treturn;\n \t/* skip header */\n@@ -204,11 +204,11 @@ static void write_tag_body(int fd, const unsigned char *sha1)\n \tfree(buf);\n }\n \n-static int build_tag_object(struct strbuf *buf, int sign, unsigned char *result)\n+static int build_tag_object(struct strbuf *buf, int sign, struct object_id *result)\n {\n \tif (sign && do_sign(buf) < 0)\n \t\treturn error(_(\"unable to sign the tag\"));\n-\tif (write_sha1_file(buf->buf, buf->len, tag_type, result) < 0)\n+\tif (write_sha1_file(buf->buf, buf->len, tag_type, result->hash) < 0)\n \t\treturn error(_(\"unable to write tag file\"));\n \treturn 0;\n }\n@@ -223,15 +223,15 @@ struct create_tag_options {\n \t} cleanup_mode;\n };\n \n-static void create_tag(const unsigned char *object, const char *tag,\n+static void create_tag(const struct object_id *object, const char *tag,\n \t\t       struct strbuf *buf, struct create_tag_options *opt,\n-\t\t       unsigned char *prev, unsigned char *result)\n+\t\t       struct object_id *prev, struct object_id *result)\n {\n \tenum object_type type;\n \tstruct strbuf header = STRBUF_INIT;\n \tchar *path = NULL;\n \n-\ttype = sha1_object_info(object, NULL);\n+\ttype = sha1_object_info(object->hash, NULL);\n \tif (type <= OBJ_NONE)\n \t    die(_(\"bad object type.\"));\n \n@@ -240,7 +240,7 @@ static void create_tag(const unsigned char *object, const char *tag,\n \t\t    \"type %s\\n\"\n \t\t    \"tag %s\\n\"\n \t\t    \"tagger %s\\n\\n\",\n-\t\t    sha1_to_hex(object),\n+\t\t    oid_to_hex(object),\n \t\t    typename(type),\n \t\t    tag,\n \t\t    git_committer_info(IDENT_STRICT));\n@@ -254,7 +254,7 @@ static void create_tag(const unsigned char *object, const char *tag,\n \t\tif (fd < 0)\n \t\t\tdie_errno(_(\"could not create file '%s'\"), path);\n \n-\t\tif (!is_null_sha1(prev)) {\n+\t\tif (!is_null_oid(prev)) {\n \t\t\twrite_tag_body(fd, prev);\n \t\t} else {\n \t\t\tstruct strbuf buf = STRBUF_INIT;\n@@ -296,7 +296,7 @@ static void create_tag(const unsigned char *object, const char *tag,\n \t}\n }\n \n-static void create_reflog_msg(const unsigned char *sha1, struct strbuf *sb)\n+static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n {\n \tenum object_type type;\n \tstruct commit *c;\n@@ -310,17 +310,17 @@ static void create_reflog_msg(const unsigned char *sha1, 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, sha1, DEFAULT_ABBREV);\n+\t\tstrbuf_add_unique_abbrev(sb, oid->hash, DEFAULT_ABBREV);\n \t}\n \n \tstrbuf_addstr(sb, \" (\");\n-\ttype = sha1_object_info(sha1, NULL);\n+\ttype = sha1_object_info(oid->hash, NULL);\n \tswitch (type) {\n \tdefault:\n \t\tstrbuf_addstr(sb, _(\"object of unknown type\"));\n \t\tbreak;\n \tcase OBJ_COMMIT:\n-\t\tif ((buf = read_sha1_file(sha1, &type, &size)) != NULL) {\n+\t\tif ((buf = read_sha1_file(oid->hash, &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 {\n@@ -328,7 +328,7 @@ static void create_reflog_msg(const unsigned char *sha1, struct strbuf *sb)\n \t\t}\n \t\tfree(buf);\n \n-\t\tif ((c = lookup_commit_reference(sha1)) != NULL)\n+\t\tif ((c = lookup_commit_reference(oid->hash)) != NULL)\n \t\t\tstrbuf_addf(sb, \", %s\", show_date(c->date, 0, DATE_MODE(SHORT)));\n \t\tbreak;\n \tcase OBJ_TREE:\n@@ -378,7 +378,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct strbuf ref = STRBUF_INIT;\n \tstruct strbuf reflog_msg = STRBUF_INIT;\n-\tunsigned char object[20], prev[20];\n+\tstruct object_id object, prev;\n \tconst char *object_ref, *tag;\n \tstruct create_tag_options opt;\n \tchar *cleanup_arg = NULL;\n@@ -528,14 +528,14 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \tif (argc > 2)\n \t\tdie(_(\"too many params\"));\n \n-\tif (get_sha1(object_ref, object))\n+\tif (get_oid(object_ref, &object))\n \t\tdie(_(\"Failed to resolve '%s' as a valid ref.\"), object_ref);\n \n \tif (strbuf_check_tag_ref(&ref, tag))\n \t\tdie(_(\"'%s' is not a valid tag name.\"), tag);\n \n-\tif (read_ref(ref.buf, prev))\n-\t\thashclr(prev);\n+\tif (read_ref(ref.buf, prev.hash))\n+\t\toidclr(&prev);\n \telse if (!force)\n \t\tdie(_(\"tag '%s' already exists\"), tag);\n \n@@ -550,24 +550,24 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \telse\n \t\tdie(_(\"Invalid cleanup mode %s\"), cleanup_arg);\n \n-\tcreate_reflog_msg(object, &reflog_msg);\n+\tcreate_reflog_msg(&object, &reflog_msg);\n \n \tif (create_tag_object) {\n \t\tif (force_sign_annotate && !annotate)\n \t\t\topt.sign = 1;\n-\t\tcreate_tag(object, tag, &buf, &opt, prev, object);\n+\t\tcreate_tag(&object, tag, &buf, &opt, &prev, &object);\n \t}\n \n \ttransaction = ref_transaction_begin(&err);\n \tif (!transaction ||\n-\t    ref_transaction_update(transaction, ref.buf, object, prev,\n+\t    ref_transaction_update(transaction, ref.buf, object.hash, prev.hash,\n \t\t\t\t   create_reflog ? REF_FORCE_CREATE_REFLOG : 0,\n \t\t\t\t   reflog_msg.buf, &err) ||\n \t    ref_transaction_commit(transaction, &err))\n \t\tdie(\"%s\", err.buf);\n \tref_transaction_free(transaction);\n-\tif (force && !is_null_sha1(prev) && hashcmp(prev, object))\n-\t\tprintf(_(\"Updated tag '%s' (was %s)\\n\"), tag, find_unique_abbrev(prev, DEFAULT_ABBREV));\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 \n \tstrbuf_release(&err);\n \tstrbuf_release(&buf);\n"},{"id":"317591","messageId":"20170423213453.253425-25-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 24/53] Convert remaining callers of lookup_commit_reference* to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:24Z","receivedAt":"2017-04-23T21:36:47Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"There are a small number of remaining callers of lookup_commit_reference\nand lookup_commit_reference_gently that still need to be converted to\nstruct object_id.  Convert these.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n notes-merge.c | 26 +++++++++++++-------------\n ref-filter.c  |  6 +++---\n sequencer.c   | 20 ++++++++++----------\n sha1_name.c   | 12 ++++++------\n shallow.c     |  6 +++---\n submodule.c   |  8 ++++----\n 6 files changed, 39 insertions(+), 39 deletions(-)\n\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 5998605ac..7ac9bb9a4 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -535,7 +535,7 @@ int notes_merge(struct notes_merge_options *o,\n \t\tstruct notes_tree *local_tree,\n \t\tunsigned char *result_sha1)\n {\n-\tunsigned char local_sha1[20], remote_sha1[20];\n+\tstruct object_id local_oid, remote_oid;\n \tstruct commit *local, *remote;\n \tstruct commit_list *bases = NULL;\n \tconst unsigned char *base_sha1, *base_tree_sha1;\n@@ -549,46 +549,46 @@ int notes_merge(struct notes_merge_options *o,\n \t       o->local_ref, o->remote_ref);\n \n \t/* Dereference o->local_ref into local_sha1 */\n-\tif (read_ref_full(o->local_ref, 0, local_sha1, NULL))\n+\tif (read_ref_full(o->local_ref, 0, local_oid.hash, NULL))\n \t\tdie(\"Failed to resolve local notes ref '%s'\", o->local_ref);\n \telse if (!check_refname_format(o->local_ref, 0) &&\n-\t\tis_null_sha1(local_sha1))\n+\t\tis_null_oid(&local_oid))\n \t\tlocal = NULL; /* local_sha1 == null_sha1 indicates unborn ref */\n-\telse if (!(local = lookup_commit_reference(local_sha1)))\n+\telse if (!(local = lookup_commit_reference(local_oid.hash)))\n \t\tdie(\"Could not parse local commit %s (%s)\",\n-\t\t    sha1_to_hex(local_sha1), o->local_ref);\n-\ttrace_printf(\"\\tlocal commit: %.7s\\n\", sha1_to_hex(local_sha1));\n+\t\t    oid_to_hex(&local_oid), o->local_ref);\n+\ttrace_printf(\"\\tlocal commit: %.7s\\n\", oid_to_hex(&local_oid));\n \n \t/* Dereference o->remote_ref into remote_sha1 */\n-\tif (get_sha1(o->remote_ref, remote_sha1)) {\n+\tif (get_oid(o->remote_ref, &remote_oid)) {\n \t\t/*\n \t\t * Failed to get remote_sha1. If o->remote_ref looks like an\n \t\t * unborn ref, perform the merge using an empty notes tree.\n \t\t */\n \t\tif (!check_refname_format(o->remote_ref, 0)) {\n-\t\t\thashclr(remote_sha1);\n+\t\t\toidclr(&remote_oid);\n \t\t\tremote = NULL;\n \t\t} else {\n \t\t\tdie(\"Failed to resolve remote notes ref '%s'\",\n \t\t\t    o->remote_ref);\n \t\t}\n-\t} else if (!(remote = lookup_commit_reference(remote_sha1))) {\n+\t} else if (!(remote = lookup_commit_reference(remote_oid.hash))) {\n \t\tdie(\"Could not parse remote commit %s (%s)\",\n-\t\t    sha1_to_hex(remote_sha1), o->remote_ref);\n+\t\t    oid_to_hex(&remote_oid), o->remote_ref);\n \t}\n-\ttrace_printf(\"\\tremote commit: %.7s\\n\", sha1_to_hex(remote_sha1));\n+\ttrace_printf(\"\\tremote commit: %.7s\\n\", oid_to_hex(&remote_oid));\n \n \tif (!local && !remote)\n \t\tdie(\"Cannot merge empty notes ref (%s) into empty notes ref \"\n \t\t    \"(%s)\", o->remote_ref, o->local_ref);\n \tif (!local) {\n \t\t/* result == remote commit */\n-\t\thashcpy(result_sha1, remote_sha1);\n+\t\thashcpy(result_sha1, remote_oid.hash);\n \t\tgoto found_result;\n \t}\n \tif (!remote) {\n \t\t/* result == local commit */\n-\t\thashcpy(result_sha1, local_sha1);\n+\t\thashcpy(result_sha1, local_oid.hash);\n \t\tgoto found_result;\n \t}\n \tassert(local && remote);\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 3a640448f..47cce0a18 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -2090,7 +2090,7 @@ int parse_opt_ref_sorting(const struct option *opt, const char *arg, int unset)\n int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)\n {\n \tstruct ref_filter *rf = opt->value;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tint no_merged = starts_with(opt->long_name, \"no\");\n \n \tif (rf->merge) {\n@@ -2105,10 +2105,10 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)\n \t\t? REF_FILTER_MERGED_OMIT\n \t\t: REF_FILTER_MERGED_INCLUDE;\n \n-\tif (get_sha1(arg, sha1))\n+\tif (get_oid(arg, &oid))\n \t\tdie(_(\"malformed object name %s\"), arg);\n \n-\trf->merge_commit = lookup_commit_reference_gently(sha1, 0);\n+\trf->merge_commit = lookup_commit_reference_gently(oid.hash, 0);\n \tif (!rf->merge_commit)\n \t\treturn opterror(opt, \"must point to a commit\", 0);\n \ndiff --git a/sequencer.c b/sequencer.c\nindex 0562d7b9a..cfa544ab9 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1221,7 +1221,7 @@ static struct todo_item *append_new_todo(struct todo_list *todo_list)\n \n static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)\n {\n-\tunsigned char commit_sha1[20];\n+\tstruct object_id commit_oid;\n \tchar *end_of_object_name;\n \tint i, saved, status, padding;\n \n@@ -1270,7 +1270,7 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)\n \tend_of_object_name = (char *) bol + strcspn(bol, \" \\t\\n\");\n \tsaved = *end_of_object_name;\n \t*end_of_object_name = '\\0';\n-\tstatus = get_sha1(bol, commit_sha1);\n+\tstatus = get_oid(bol, &commit_oid);\n \t*end_of_object_name = saved;\n \n \titem->arg = end_of_object_name + strspn(end_of_object_name, \" \\t\");\n@@ -1279,7 +1279,7 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)\n \tif (status < 0)\n \t\treturn -1;\n \n-\titem->commit = lookup_commit_reference(commit_sha1);\n+\titem->commit = lookup_commit_reference(commit_oid.hash);\n \treturn !item->commit;\n }\n \n@@ -2259,7 +2259,7 @@ static int single_pick(struct commit *cmit, struct replay_opts *opts)\n int sequencer_pick_revisions(struct replay_opts *opts)\n {\n \tstruct todo_list todo_list = TODO_LIST_INIT;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tint i, res;\n \n \tassert(opts->revs);\n@@ -2267,16 +2267,16 @@ int sequencer_pick_revisions(struct replay_opts *opts)\n \t\treturn -1;\n \n \tfor (i = 0; i < opts->revs->pending.nr; i++) {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tconst char *name = opts->revs->pending.objects[i].name;\n \n \t\t/* This happens when using --stdin. */\n \t\tif (!strlen(name))\n \t\t\tcontinue;\n \n-\t\tif (!get_sha1(name, sha1)) {\n-\t\t\tif (!lookup_commit_reference_gently(sha1, 1)) {\n-\t\t\t\tenum object_type type = sha1_object_info(sha1, NULL);\n+\t\tif (!get_oid(name, &oid)) {\n+\t\t\tif (!lookup_commit_reference_gently(oid.hash, 1)) {\n+\t\t\t\tenum object_type type = sha1_object_info(oid.hash, NULL);\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}\n@@ -2313,9 +2313,9 @@ int sequencer_pick_revisions(struct replay_opts *opts)\n \tif (walk_revs_populate_todo(&todo_list, opts) ||\n \t\t\tcreate_seq_dir() < 0)\n \t\treturn -1;\n-\tif (get_sha1(\"HEAD\", sha1) && (opts->action == REPLAY_REVERT))\n+\tif (get_oid(\"HEAD\", &oid) && (opts->action == REPLAY_REVERT))\n \t\treturn error(_(\"can't revert as initial commit\"));\n-\tif (save_head(sha1_to_hex(sha1)))\n+\tif (save_head(oid_to_hex(&oid)))\n \t\treturn -1;\n \tif (save_opts(opts))\n \t\treturn -1;\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 8eec9f7c1..8889190a9 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -722,14 +722,14 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1,\n static int get_parent(const char *name, int len,\n \t\t      unsigned char *result, int idx)\n {\n-\tunsigned char sha1[20];\n-\tint ret = get_sha1_1(name, len, sha1, GET_SHA1_COMMITTISH);\n+\tstruct object_id oid;\n+\tint ret = get_sha1_1(name, len, oid.hash, GET_SHA1_COMMITTISH);\n \tstruct commit *commit;\n \tstruct commit_list *p;\n \n \tif (ret)\n \t\treturn ret;\n-\tcommit = lookup_commit_reference(sha1);\n+\tcommit = lookup_commit_reference(oid.hash);\n \tif (parse_commit(commit))\n \t\treturn -1;\n \tif (!idx) {\n@@ -750,14 +750,14 @@ static int get_parent(const char *name, int len,\n static int get_nth_ancestor(const char *name, int len,\n \t\t\t    unsigned char *result, int generation)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct commit *commit;\n \tint ret;\n \n-\tret = get_sha1_1(name, len, sha1, GET_SHA1_COMMITTISH);\n+\tret = get_sha1_1(name, len, oid.hash, GET_SHA1_COMMITTISH);\n \tif (ret)\n \t\treturn ret;\n-\tcommit = lookup_commit_reference(sha1);\n+\tcommit = lookup_commit_reference(oid.hash);\n \tif (!commit)\n \t\treturn -1;\n \ndiff --git a/shallow.c b/shallow.c\nindex c520ae3ae..1327ee16f 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -466,7 +466,7 @@ static uint32_t *paint_alloc(struct paint_info *info)\n  * UNINTERESTING or BOTTOM is hit. Set the id-th bit in ref_bitmap for\n  * all walked commits.\n  */\n-static void paint_down(struct paint_info *info, const unsigned char *sha1,\n+static void paint_down(struct paint_info *info, const struct object_id *oid,\n \t\t       unsigned int id)\n {\n \tunsigned int i, nr;\n@@ -475,7 +475,7 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1,\n \tsize_t bitmap_size = st_mult(sizeof(uint32_t), bitmap_nr);\n \tuint32_t *tmp = xmalloc(bitmap_size); /* to be freed before return */\n \tuint32_t *bitmap = paint_alloc(info);\n-\tstruct commit *c = lookup_commit_reference_gently(sha1, 1);\n+\tstruct commit *c = lookup_commit_reference_gently(oid->hash, 1);\n \tif (!c)\n \t\treturn;\n \tmemset(bitmap, 0, bitmap_size);\n@@ -604,7 +604,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,\n \t}\n \n \tfor (i = 0; i < ref->nr; i++)\n-\t\tpaint_down(&pi, ref->oid[i].hash, i);\n+\t\tpaint_down(&pi, ref->oid + i, i);\n \n \tif (used) {\n \t\tint bitmap_size = ((pi.nr_bits + 31) / 32) * sizeof(uint32_t);\ndiff --git a/submodule.c b/submodule.c\nindex fb782c412..ebbf66d31 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -896,17 +896,17 @@ int push_unpushed_submodules(struct oid_array *commits,\n \treturn ret;\n }\n \n-static int is_submodule_commit_present(const char *path, unsigned char sha1[20])\n+static int is_submodule_commit_present(const char *path, struct object_id *oid)\n {\n \tint is_present = 0;\n-\tif (!add_submodule_odb(path) && lookup_commit_reference(sha1)) {\n+\tif (!add_submodule_odb(path) && lookup_commit_reference(oid->hash)) {\n \t\t/* Even if the submodule is checked out and the commit is\n \t\t * present, make sure it is reachable from a ref. */\n \t\tstruct child_process cp = CHILD_PROCESS_INIT;\n \t\tconst char *argv[] = {\"rev-list\", \"-n\", \"1\", NULL, \"--not\", \"--all\", NULL};\n \t\tstruct strbuf buf = STRBUF_INIT;\n \n-\t\targv[3] = sha1_to_hex(sha1);\n+\t\targv[3] = oid_to_hex(oid);\n \t\tcp.argv = argv;\n \t\tprepare_submodule_repo_env(&cp.env_array);\n \t\tcp.git_cmd = 1;\n@@ -937,7 +937,7 @@ static void submodule_collect_changed_cb(struct diff_queue_struct *q,\n \t\t\t * being moved around. */\n \t\t\tstruct string_list_item *path;\n \t\t\tpath = unsorted_string_list_lookup(&changed_submodule_paths, p->two->path);\n-\t\t\tif (!path && !is_submodule_commit_present(p->two->path, p->two->oid.hash))\n+\t\t\tif (!path && !is_submodule_commit_present(p->two->path, &p->two->oid))\n \t\t\t\tstring_list_append(&changed_submodule_paths, xstrdup(p->two->path));\n \t\t} else {\n \t\t\t/* Submodule is new or was moved here */\n"},{"id":"317592","messageId":"20170423213453.253425-27-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 26/53] pack: convert struct pack_idx_entry to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:26Z","receivedAt":"2017-04-23T21:36:52Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert struct pack_idx_entry to use struct object_id by changing the\ndefinition and applying the following semantic patch, plus the standard\nobject_id transforms:\n\n@@\nstruct pack_idx_entry E1;\n@@\n- E1.sha1\n+ E1.oid.hash\n\n@@\nstruct pack_idx_entry *E1;\n@@\n- E1->sha1\n+ E1->oid.hash\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/index-pack.c   | 33 +++++++++++++++-----------\n builtin/pack-objects.c | 63 +++++++++++++++++++++++++++++---------------------\n bulk-checkin.c         |  4 ++--\n fast-import.c          | 30 ++++++++++++------------\n pack-bitmap-write.c    |  8 ++++---\n pack-objects.c         |  8 ++++---\n pack-write.c           | 10 ++++----\n pack.h                 |  2 +-\n 8 files changed, 89 insertions(+), 69 deletions(-)\n\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 4ff567db4..fef0025e4 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -747,13 +747,13 @@ static int compare_objects(const unsigned char *buf, unsigned long size,\n \t\tssize_t len = read_istream(data->st, data->buf, size);\n \t\tif (len == 0)\n \t\t\tdie(_(\"SHA1 COLLISION FOUND WITH %s !\"),\n-\t\t\t    sha1_to_hex(data->entry->idx.sha1));\n+\t\t\t    oid_to_hex(&data->entry->idx.oid));\n \t\tif (len < 0)\n \t\t\tdie(_(\"unable to read %s\"),\n-\t\t\t    sha1_to_hex(data->entry->idx.sha1));\n+\t\t\t    oid_to_hex(&data->entry->idx.oid));\n \t\tif (memcmp(buf, data->buf, len))\n \t\t\tdie(_(\"SHA1 COLLISION FOUND WITH %s !\"),\n-\t\t\t    sha1_to_hex(data->entry->idx.sha1));\n+\t\t\t    oid_to_hex(&data->entry->idx.oid));\n \t\tsize -= len;\n \t\tbuf += len;\n \t}\n@@ -771,12 +771,12 @@ 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.sha1, &type, &size, NULL);\n+\tdata.st = open_istream(entry->idx.oid.hash, &type, &size, NULL);\n \tif (!data.st)\n \t\treturn -1;\n \tif (size != entry->size || type != entry->type)\n \t\tdie(_(\"SHA1 COLLISION FOUND WITH %s !\"),\n-\t\t    sha1_to_hex(entry->idx.sha1));\n+\t\t    oid_to_hex(&entry->idx.oid));\n \tunpack_data(entry, compare_objects, &data);\n \tclose_istream(data.st);\n \tfree(data.buf);\n@@ -957,9 +957,10 @@ static void resolve_delta(struct object_entry *delta_obj,\n \tif (!result->data)\n \t\tbad_object(delta_obj->idx.offset, _(\"failed to apply delta\"));\n \thash_sha1_file(result->data, result->size,\n-\t\t       typename(delta_obj->real_type), delta_obj->idx.sha1);\n+\t\t       typename(delta_obj->real_type),\n+\t\t       delta_obj->idx.oid.hash);\n \tsha1_object(result->data, NULL, result->size, delta_obj->real_type,\n-\t\t    delta_obj->idx.sha1);\n+\t\t    delta_obj->idx.oid.hash);\n \tcounter_lock();\n \tnr_resolved_deltas++;\n \tcounter_unlock();\n@@ -989,7 +990,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.sha1,\n+\t\tfind_ref_delta_children(base->obj->idx.oid.hash,\n \t\t\t\t\t&base->ref_first, &base->ref_last,\n \t\t\t\t\tOBJ_REF_DELTA);\n \n@@ -1130,7 +1131,8 @@ static void parse_pack_objects(unsigned char *sha1)\n \tfor (i = 0; i < nr_objects; i++) {\n \t\tstruct object_entry *obj = &objects[i];\n \t\tvoid *data = unpack_raw_entry(obj, &ofs_delta->offset,\n-\t\t\t\t\t      ref_delta_sha1, obj->idx.sha1);\n+\t\t\t\t\t      ref_delta_sha1,\n+\t\t\t\t\t      obj->idx.oid.hash);\n \t\tobj->real_type = obj->type;\n \t\tif (obj->type == OBJ_OFS_DELTA) {\n \t\t\tnr_ofs_deltas++;\n@@ -1146,7 +1148,8 @@ static void parse_pack_objects(unsigned char *sha1)\n \t\t\tobj->real_type = OBJ_BAD;\n \t\t\tnr_delays++;\n \t\t} else\n-\t\t\tsha1_object(data, NULL, obj->size, obj->type, obj->idx.sha1);\n+\t\t\tsha1_object(data, NULL, obj->size, obj->type,\n+\t\t\t\t    obj->idx.oid.hash);\n \t\tfree(data);\n \t\tdisplay_progress(progress, i+1);\n \t}\n@@ -1172,7 +1175,8 @@ static void parse_pack_objects(unsigned char *sha1)\n \t\tif (obj->real_type != OBJ_BAD)\n \t\t\tcontinue;\n \t\tobj->real_type = obj->type;\n-\t\tsha1_object(NULL, obj, obj->size, obj->type, obj->idx.sha1);\n+\t\tsha1_object(NULL, obj, obj->size, obj->type,\n+\t\t\t    obj->idx.oid.hash);\n \t\tnr_delays--;\n \t}\n \tif (nr_delays)\n@@ -1330,7 +1334,7 @@ static struct object_entry *append_obj_to_pack(struct sha1file *f,\n \tobj[1].idx.offset += write_compressed(f, buf, size);\n \tobj[0].idx.crc32 = crc32_end(f);\n \tsha1flush(f);\n-\thashcpy(obj->idx.sha1, sha1);\n+\thashcpy(obj->idx.oid.hash, sha1);\n \treturn obj;\n }\n \n@@ -1581,13 +1585,14 @@ static void show_pack_info(int stat_only)\n \t\tif (stat_only)\n \t\t\tcontinue;\n \t\tprintf(\"%s %-6s %lu %lu %\"PRIuMAX,\n-\t\t       sha1_to_hex(obj->idx.sha1),\n+\t\t       oid_to_hex(&obj->idx.oid),\n \t\t       typename(obj->real_type), obj->size,\n \t\t       (unsigned long)(obj[1].idx.offset - obj->idx.offset),\n \t\t       (uintmax_t)obj->idx.offset);\n \t\tif (is_delta_type(obj->type)) {\n \t\t\tstruct object_entry *bobj = &objects[obj_stat[i].base_object_no];\n-\t\t\tprintf(\" %u %s\", obj_stat[i].delta_depth, sha1_to_hex(bobj->idx.sha1));\n+\t\t\tprintf(\" %u %s\", obj_stat[i].delta_depth,\n+\t\t\t       oid_to_hex(&bobj->idx.oid));\n \t\t}\n \t\tputchar('\\n');\n \t}\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 477070806..d76ff0542 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -106,12 +106,14 @@ 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.sha1, &type, &size);\n+\tbuf = read_sha1_file(entry->idx.oid.hash, &type, &size);\n \tif (!buf)\n-\t\tdie(\"unable to read %s\", sha1_to_hex(entry->idx.sha1));\n-\tbase_buf = read_sha1_file(entry->delta->idx.sha1, &type, &base_size);\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 \tif (!base_buf)\n-\t\tdie(\"unable to read %s\", sha1_to_hex(entry->delta->idx.sha1));\n+\t\tdie(\"unable to read %s\",\n+\t\t    oid_to_hex(&entry->delta->idx.oid));\n \tdelta_buf = diff_delta(base_buf, base_size,\n \t\t\t       buf, size, &delta_size, 0);\n \tif (!delta_buf || delta_size != entry->delta_size)\n@@ -249,12 +251,14 @@ static unsigned long write_no_reuse_object(struct sha1file *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.sha1, &type, &size, NULL)) != NULL)\n+\t\t    (st = open_istream(entry->idx.oid.hash, &type, &size, NULL)) != NULL)\n \t\t\tbuf = NULL;\n \t\telse {\n-\t\t\tbuf = read_sha1_file(entry->idx.sha1, &type, &size);\n+\t\t\tbuf = read_sha1_file(entry->idx.oid.hash, &type,\n+\t\t\t\t\t     &size);\n \t\t\tif (!buf)\n-\t\t\t\tdie(_(\"unable to read %s\"), sha1_to_hex(entry->idx.sha1));\n+\t\t\t\tdie(_(\"unable to read %s\"),\n+\t\t\t\t    oid_to_hex(&entry->idx.oid));\n \t\t}\n \t\t/*\n \t\t * make sure no cached delta data remains from a\n@@ -322,7 +326,7 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent\n \t\t\treturn 0;\n \t\t}\n \t\tsha1write(f, header, hdrlen);\n-\t\tsha1write(f, entry->delta->idx.sha1, 20);\n+\t\tsha1write(f, entry->delta->idx.oid.hash, 20);\n \t\thdrlen += 20;\n \t} else {\n \t\tif (limit && hdrlen + datalen + 20 >= limit) {\n@@ -334,7 +338,7 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent\n \t\tsha1write(f, header, hdrlen);\n \t}\n \tif (st) {\n-\t\tdatalen = write_large_blob_data(st, f, entry->idx.sha1);\n+\t\tdatalen = write_large_blob_data(st, f, entry->idx.oid.hash);\n \t\tclose_istream(st);\n \t} else {\n \t\tsha1write(f, buf, datalen);\n@@ -369,7 +373,8 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,\n \tdatalen = revidx[1].offset - offset;\n \tif (!pack_to_stdout && p->index_version > 1 &&\n \t    check_pack_crc(p, &w_curs, offset, datalen, revidx->nr)) {\n-\t\terror(\"bad packed object CRC for %s\", sha1_to_hex(entry->idx.sha1));\n+\t\terror(\"bad packed object CRC for %s\",\n+\t\t      oid_to_hex(&entry->idx.oid));\n \t\tunuse_pack(&w_curs);\n \t\treturn write_no_reuse_object(f, entry, limit, usable_delta);\n \t}\n@@ -379,7 +384,8 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,\n \n \tif (!pack_to_stdout && p->index_version == 1 &&\n \t    check_pack_inflate(p, &w_curs, offset, datalen, entry->size)) {\n-\t\terror(\"corrupt packed object for %s\", sha1_to_hex(entry->idx.sha1));\n+\t\terror(\"corrupt packed object for %s\",\n+\t\t      oid_to_hex(&entry->idx.oid));\n \t\tunuse_pack(&w_curs);\n \t\treturn write_no_reuse_object(f, entry, limit, usable_delta);\n \t}\n@@ -404,7 +410,7 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,\n \t\t\treturn 0;\n \t\t}\n \t\tsha1write(f, header, hdrlen);\n-\t\tsha1write(f, entry->delta->idx.sha1, 20);\n+\t\tsha1write(f, entry->delta->idx.oid.hash, 20);\n \t\thdrlen += 20;\n \t\treused_delta++;\n \t} else {\n@@ -509,7 +515,7 @@ static enum write_one_status write_one(struct sha1file *f,\n \trecursing = (e->idx.offset == 1);\n \tif (recursing) {\n \t\twarning(\"recursive delta detected for object %s\",\n-\t\t\tsha1_to_hex(e->idx.sha1));\n+\t\t\toid_to_hex(&e->idx.oid));\n \t\treturn WRITE_ONE_RECURSIVE;\n \t} else if (e->idx.offset || e->preferred_base) {\n \t\t/* offset is non zero if object is written already. */\n@@ -1432,7 +1438,7 @@ static void check_object(struct object_entry *entry)\n \t\t\t\tofs += 1;\n \t\t\t\tif (!ofs || MSB(ofs, 7)) {\n \t\t\t\t\terror(\"delta base offset overflow in pack for %s\",\n-\t\t\t\t\t      sha1_to_hex(entry->idx.sha1));\n+\t\t\t\t\t      oid_to_hex(&entry->idx.oid));\n \t\t\t\t\tgoto give_up;\n \t\t\t\t}\n \t\t\t\tc = buf[used_0++];\n@@ -1441,7 +1447,7 @@ static void check_object(struct object_entry *entry)\n \t\t\tofs = entry->in_pack_offset - ofs;\n \t\t\tif (ofs <= 0 || ofs >= entry->in_pack_offset) {\n \t\t\t\terror(\"delta base offset out of bound for %s\",\n-\t\t\t\t      sha1_to_hex(entry->idx.sha1));\n+\t\t\t\t      oid_to_hex(&entry->idx.oid));\n \t\t\t\tgoto give_up;\n \t\t\t}\n \t\t\tif (reuse_delta && !entry->preferred_base) {\n@@ -1498,7 +1504,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.sha1, &entry->size);\n+\tentry->type = sha1_object_info(entry->idx.oid.hash, &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@@ -1514,7 +1520,7 @@ static int pack_offset_sort(const void *_a, const void *_b)\n \n \t/* avoid filesystem trashing with loose objects */\n \tif (!a->in_pack && !b->in_pack)\n-\t\treturn hashcmp(a->idx.sha1, b->idx.sha1);\n+\t\treturn oidcmp(&a->idx.oid, &b->idx.oid);\n \n \tif (a->in_pack < b->in_pack)\n \t\treturn -1;\n@@ -1560,7 +1566,8 @@ 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.sha1, &entry->size);\n+\t\tentry->type = sha1_object_info(entry->idx.oid.hash,\n+\t\t\t\t\t       &entry->size);\n \t}\n }\n \n@@ -1852,26 +1859,29 @@ 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.sha1, &type, &sz);\n+\t\ttrg->data = read_sha1_file(trg_entry->idx.oid.hash, &type,\n+\t\t\t\t\t   &sz);\n \t\tread_unlock();\n \t\tif (!trg->data)\n \t\t\tdie(\"object %s cannot be read\",\n-\t\t\t    sha1_to_hex(trg_entry->idx.sha1));\n+\t\t\t    oid_to_hex(&trg_entry->idx.oid));\n \t\tif (sz != trg_size)\n \t\t\tdie(\"object %s inconsistent object length (%lu vs %lu)\",\n-\t\t\t    sha1_to_hex(trg_entry->idx.sha1), sz, trg_size);\n+\t\t\t    oid_to_hex(&trg_entry->idx.oid), sz,\n+\t\t\t    trg_size);\n \t\t*mem_usage += sz;\n \t}\n \tif (!src->data) {\n \t\tread_lock();\n-\t\tsrc->data = read_sha1_file(src_entry->idx.sha1, &type, &sz);\n+\t\tsrc->data = read_sha1_file(src_entry->idx.oid.hash, &type,\n+\t\t\t\t\t   &sz);\n \t\tread_unlock();\n \t\tif (!src->data) {\n \t\t\tif (src_entry->preferred_base) {\n \t\t\t\tstatic int warned = 0;\n \t\t\t\tif (!warned++)\n \t\t\t\t\twarning(\"object %s cannot be read\",\n-\t\t\t\t\t\tsha1_to_hex(src_entry->idx.sha1));\n+\t\t\t\t\t\toid_to_hex(&src_entry->idx.oid));\n \t\t\t\t/*\n \t\t\t\t * Those objects are not included in the\n \t\t\t\t * resulting pack.  Be resilient and ignore\n@@ -1881,11 +1891,12 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t\t\t\treturn 0;\n \t\t\t}\n \t\t\tdie(\"object %s cannot be read\",\n-\t\t\t    sha1_to_hex(src_entry->idx.sha1));\n+\t\t\t    oid_to_hex(&src_entry->idx.oid));\n \t\t}\n \t\tif (sz != src_size)\n \t\t\tdie(\"object %s inconsistent object length (%lu vs %lu)\",\n-\t\t\t    sha1_to_hex(src_entry->idx.sha1), sz, src_size);\n+\t\t\t    oid_to_hex(&src_entry->idx.oid), sz,\n+\t\t\t    src_size);\n \t\t*mem_usage += sz;\n \t}\n \tif (!src->index) {\n@@ -2406,7 +2417,7 @@ static void prepare_pack(int window, int depth)\n \t\t\tnr_deltas++;\n \t\t\tif (entry->type < 0)\n \t\t\t\tdie(\"unable to get type of object %s\",\n-\t\t\t\t    sha1_to_hex(entry->idx.sha1));\n+\t\t\t\t    oid_to_hex(&entry->idx.oid));\n \t\t} else {\n \t\t\tif (entry->type < 0) {\n \t\t\t\t/*\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex ddb6070c4..5be7ce5c7 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -69,7 +69,7 @@ static int already_written(struct bulk_checkin_state *state, unsigned char sha1[\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]->sha1, sha1))\n+\t\tif (!hashcmp(state->written[i]->oid.hash, sha1))\n \t\t\treturn 1;\n \n \t/* This is a new object we need to keep */\n@@ -242,7 +242,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,\n \t\tstate->offset = checkpoint.offset;\n \t\tfree(idx);\n \t} else {\n-\t\thashcpy(idx->sha1, result_sha1);\n+\t\thashcpy(idx->oid.hash, result_sha1);\n \t\tALLOC_GROW(state->written,\n \t\t\t   state->nr_written + 1,\n \t\t\t   state->alloc_written);\ndiff --git a/fast-import.c b/fast-import.c\nindex 0aa81d522..d517b7536 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -563,7 +563,7 @@ static struct object_entry *new_object(struct object_id *oid)\n \t\talloc_objects(object_entry_alloc);\n \n \te = blocks->next_free++;\n-\thashcpy(e->idx.sha1, oid->hash);\n+\toidcpy(&e->idx.oid, oid);\n \treturn e;\n }\n \n@@ -572,7 +572,7 @@ static struct object_entry *find_object(struct object_id *oid)\n \tunsigned int h = oid->hash[0] << 8 | oid->hash[1];\n \tstruct object_entry *e;\n \tfor (e = object_table[h]; e; e = e->next)\n-\t\tif (!hashcmp(oid->hash, e->idx.sha1))\n+\t\tif (!oidcmp(oid, &e->idx.oid))\n \t\t\treturn e;\n \treturn NULL;\n }\n@@ -583,7 +583,7 @@ static struct object_entry *insert_object(struct object_id *oid)\n \tstruct object_entry *e = object_table[h];\n \n \twhile (e) {\n-\t\tif (!hashcmp(oid->hash, e->idx.sha1))\n+\t\tif (!oidcmp(oid, &e->idx.oid))\n \t\t\treturn e;\n \t\te = e->next;\n \t}\n@@ -1847,7 +1847,7 @@ static void dump_marks_helper(FILE *f,\n \t\tfor (k = 0; k < 1024; k++) {\n \t\t\tif (m->data.marked[k])\n \t\t\t\tfprintf(f, \":%\" PRIuMAX \" %s\\n\", base + k,\n-\t\t\t\t\tsha1_to_hex(m->data.marked[k]->idx.sha1));\n+\t\t\t\t\toid_to_hex(&m->data.marked[k]->idx.oid));\n \t\t}\n \t}\n }\n@@ -2385,7 +2385,7 @@ static void file_change_m(const char *p, struct branch *b)\n \n \tif (*p == ':') {\n \t\toe = find_mark(parse_mark_ref_space(&p));\n-\t\thashcpy(oid.hash, oe->idx.sha1);\n+\t\toidcpy(&oid, &oe->idx.oid);\n \t} else if (skip_prefix(p, \"inline \", &p)) {\n \t\tinline_data = 1;\n \t\toe = NULL; /* not used with inline_data, but makes gcc happy */\n@@ -2551,7 +2551,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t/* <dataref> or 'inline' */\n \tif (*p == ':') {\n \t\toe = find_mark(parse_mark_ref_space(&p));\n-\t\thashcpy(oid.hash, oe->idx.sha1);\n+\t\toidcpy(&oid, &oe->idx.oid);\n \t} else if (skip_prefix(p, \"inline \", &p)) {\n \t\tinline_data = 1;\n \t\toe = NULL; /* not used with inline_data, but makes gcc happy */\n@@ -2574,7 +2574,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\tstruct object_entry *commit_oe = find_mark(commit_mark);\n \t\tif (commit_oe->type != OBJ_COMMIT)\n \t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", commit_mark);\n-\t\thashcpy(commit_oid.hash, commit_oe->idx.sha1);\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@@ -2679,8 +2679,8 @@ static int parse_from(struct branch *b)\n \t\tstruct object_entry *oe = find_mark(idnum);\n \t\tif (oe->type != OBJ_COMMIT)\n \t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", idnum);\n-\t\tif (hashcmp(b->oid.hash, oe->idx.sha1)) {\n-\t\t\thashcpy(b->oid.hash, oe->idx.sha1);\n+\t\tif (oidcmp(&b->oid, &oe->idx.oid)) {\n+\t\t\toidcpy(&b->oid, &oe->idx.oid);\n \t\t\tif (oe->pack_id != MAX_PACK_ID) {\n \t\t\t\tunsigned long size;\n \t\t\t\tchar *buf = gfi_unpack_entry(oe, &size);\n@@ -2723,7 +2723,7 @@ static struct hash_list *parse_merge(unsigned int *count)\n \t\t\tstruct object_entry *oe = find_mark(idnum);\n \t\t\tif (oe->type != OBJ_COMMIT)\n \t\t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", idnum);\n-\t\t\thashcpy(n->oid.hash, oe->idx.sha1);\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@@ -2878,7 +2878,7 @@ static void parse_new_tag(const char *arg)\n \t\tfrom_mark = parse_mark_ref_eol(from);\n \t\toe = find_mark(from_mark);\n \t\ttype = oe->type;\n-\t\thashcpy(oid.hash, oe->idx.sha1);\n+\t\toidcpy(&oid, &oe->idx.oid);\n \t} else if (!get_oid(from, &oid)) {\n \t\tstruct object_entry *oe = find_object(&oid);\n \t\tif (!oe) {\n@@ -3008,7 +3008,7 @@ static void parse_get_mark(const char *p)\n \tif (!oe)\n \t\tdie(\"Unknown mark: %s\", command_buf.buf);\n \n-\txsnprintf(output, sizeof(output), \"%s\\n\", sha1_to_hex(oe->idx.sha1));\n+\txsnprintf(output, sizeof(output), \"%s\\n\", oid_to_hex(&oe->idx.oid));\n \tcat_blob_write(output, GIT_SHA1_HEXSZ + 1);\n }\n \n@@ -3022,7 +3022,7 @@ static void parse_cat_blob(const char *p)\n \t\toe = find_mark(parse_mark_ref_eol(p));\n \t\tif (!oe)\n \t\t\tdie(\"Unknown mark: %s\", command_buf.buf);\n-\t\thashcpy(oid.hash, oe->idx.sha1);\n+\t\toidcpy(&oid, &oe->idx.oid);\n \t} else {\n \t\tif (parse_oid_hex(p, &oid, &p))\n \t\t\tdie(\"Invalid dataref: %s\", command_buf.buf);\n@@ -3094,7 +3094,7 @@ static struct object_entry *parse_treeish_dataref(const char **p)\n \t\te = find_mark(parse_mark_ref_space(p));\n \t\tif (!e)\n \t\t\tdie(\"Unknown mark: %s\", command_buf.buf);\n-\t\thashcpy(oid.hash, e->idx.sha1);\n+\t\toidcpy(&oid, &e->idx.oid);\n \t} else {\t/* <sha1> */\n \t\tif (parse_oid_hex(*p, &oid, p))\n \t\t\tdie(\"Invalid dataref: %s\", command_buf.buf);\n@@ -3148,7 +3148,7 @@ static void parse_ls(const char *p, struct branch *b)\n \t} else {\n \t\tstruct object_entry *e = parse_treeish_dataref(&p);\n \t\troot = new_tree_entry();\n-\t\thashcpy(root->versions[1].oid.hash, e->idx.sha1);\n+\t\toidcpy(&root->versions[1].oid, &e->idx.oid);\n \t\tif (!is_null_oid(&root->versions[1].oid))\n \t\t\troot->versions[1].mode = S_IFDIR;\n \t\tload_tree(root);\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex e313f4f2b..8e47a96b3 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -73,7 +73,8 @@ 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.sha1, NULL);\n+\t\t\treal_type = sha1_object_info(entry->idx.oid.hash,\n+\t\t\t\t\t\t     NULL);\n \t\t\tbreak;\n \t\t}\n \n@@ -96,7 +97,8 @@ void bitmap_writer_build_type_index(struct pack_idx_entry **index,\n \n \t\tdefault:\n \t\t\tdie(\"Missing type information for %s (%d/%d)\",\n-\t\t\t    sha1_to_hex(entry->idx.sha1), real_type, entry->type);\n+\t\t\t    oid_to_hex(&entry->idx.oid), real_type,\n+\t\t\t    entry->type);\n \t\t}\n \t}\n }\n@@ -459,7 +461,7 @@ static inline void dump_bitmap(struct sha1file *f, struct ewah_bitmap *bitmap)\n static const unsigned char *sha1_access(size_t pos, void *table)\n {\n \tstruct pack_idx_entry **index = table;\n-\treturn index[pos]->sha1;\n+\treturn index[pos]->oid.hash;\n }\n \n static void write_selected_commits_v1(struct sha1file *f,\ndiff --git a/pack-objects.c b/pack-objects.c\nindex 6398a8aa9..9558d1383 100644\n--- a/pack-objects.c\n+++ b/pack-objects.c\n@@ -14,7 +14,7 @@ static uint32_t locate_object_entry_hash(struct packing_data *pdata,\n \twhile (pdata->index[i] > 0) {\n \t\tuint32_t pos = pdata->index[i] - 1;\n \n-\t\tif (!hashcmp(sha1, pdata->objects[pos].idx.sha1)) {\n+\t\tif (!hashcmp(sha1, pdata->objects[pos].idx.oid.hash)) {\n \t\t\t*found = 1;\n \t\t\treturn i;\n \t\t}\n@@ -53,7 +53,9 @@ static void rehash_objects(struct packing_data *pdata)\n \n \tfor (i = 0; i < pdata->nr_objects; i++) {\n \t\tint found;\n-\t\tuint32_t ix = locate_object_entry_hash(pdata, entry->idx.sha1, &found);\n+\t\tuint32_t ix = locate_object_entry_hash(pdata,\n+\t\t\t\t\t\t       entry->idx.oid.hash,\n+\t\t\t\t\t\t       &found);\n \n \t\tif (found)\n \t\t\tdie(\"BUG: Duplicate object in hash\");\n@@ -98,7 +100,7 @@ struct object_entry *packlist_alloc(struct packing_data *pdata,\n \tnew_entry = pdata->objects + pdata->nr_objects++;\n \n \tmemset(new_entry, 0, sizeof(*new_entry));\n-\thashcpy(new_entry->idx.sha1, sha1);\n+\thashcpy(new_entry->idx.oid.hash, sha1);\n \n \tif (pdata->index_size * 3 <= pdata->nr_objects * 4)\n \t\trehash_objects(pdata);\ndiff --git a/pack-write.c b/pack-write.c\nindex fa97b7255..a333ec675 100644\n--- a/pack-write.c\n+++ b/pack-write.c\n@@ -13,7 +13,7 @@ static int sha1_compare(const void *_a, const void *_b)\n {\n \tstruct pack_idx_entry *a = *(struct pack_idx_entry **)_a;\n \tstruct pack_idx_entry *b = *(struct pack_idx_entry **)_b;\n-\treturn hashcmp(a->sha1, b->sha1);\n+\treturn oidcmp(&a->oid, &b->oid);\n }\n \n static int cmp_uint32(const void *a_, const void *b_)\n@@ -103,7 +103,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec\n \t\tstruct pack_idx_entry **next = list;\n \t\twhile (next < last) {\n \t\t\tstruct pack_idx_entry *obj = *next;\n-\t\t\tif (obj->sha1[0] != i)\n+\t\t\tif (obj->oid.hash[0] != i)\n \t\t\t\tbreak;\n \t\t\tnext++;\n \t\t}\n@@ -122,11 +122,11 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec\n \t\t\tuint32_t offset = htonl(obj->offset);\n \t\t\tsha1write(f, &offset, 4);\n \t\t}\n-\t\tsha1write(f, obj->sha1, 20);\n+\t\tsha1write(f, obj->oid.hash, 20);\n \t\tif ((opts->flags & WRITE_IDX_STRICT) &&\n-\t\t    (i && !hashcmp(list[-2]->sha1, obj->sha1)))\n+\t\t    (i && !oidcmp(&list[-2]->oid, &obj->oid)))\n \t\t\tdie(\"The same object %s appears twice in the pack\",\n-\t\t\t    sha1_to_hex(obj->sha1));\n+\t\t\t    oid_to_hex(&obj->oid));\n \t}\n \n \tif (index_version >= 2) {\ndiff --git a/pack.h b/pack.h\nindex 5c2158746..c7de42ef3 100644\n--- a/pack.h\n+++ b/pack.h\n@@ -67,7 +67,7 @@ struct pack_idx_header {\n  * Common part of object structure used for write_idx_file\n  */\n struct pack_idx_entry {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tuint32_t crc32;\n \toff_t offset;\n };\n"},{"id":"317593","messageId":"20170423213453.253425-26-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 25/53] Convert lookup_commit* to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:25Z","receivedAt":"2017-04-23T21:37:00Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert lookup_commit, lookup_commit_or_die,\nlookup_commit_reference, and lookup_commit_reference_gently to take\nstruct object_id arguments.\n\nIntroduce a temporary in parse_object buffer in order to convert this\nfunction.  This is required since in order to convert parse_object and\nparse_object_buffer, lookup_commit_reference_gently and\nlookup_commit_or_die would need to be converted.  Not introducing a\ntemporary would therefore require that lookup_commit_or_die take a\nstruct object_id *, but lookup_commit would take unsigned char *,\nleaving a confusing and hard-to-use interface.\n\nparse_object_buffer will lose this temporary in a later patch.\n\nThis commit was created with manual changes to commit.c, commit.h, and\nobject.c, plus the following semantic patch:\n\n@@\nexpression E1, E2;\n@@\n- lookup_commit_reference_gently(E1.hash, E2)\n+ lookup_commit_reference_gently(&E1, E2)\n\n@@\nexpression E1, E2;\n@@\n- lookup_commit_reference_gently(E1->hash, E2)\n+ lookup_commit_reference_gently(E1, E2)\n\n@@\nexpression E1;\n@@\n- lookup_commit_reference(E1.hash)\n+ lookup_commit_reference(&E1)\n\n@@\nexpression E1;\n@@\n- lookup_commit_reference(E1->hash)\n+ lookup_commit_reference(E1)\n\n@@\nexpression E1;\n@@\n- lookup_commit(E1.hash)\n+ lookup_commit(&E1)\n\n@@\nexpression E1;\n@@\n- lookup_commit(E1->hash)\n+ lookup_commit(E1)\n\n@@\nexpression E1, E2;\n@@\n- lookup_commit_or_die(E1.hash, E2)\n+ lookup_commit_or_die(&E1, E2)\n\n@@\nexpression E1, E2;\n@@\n- lookup_commit_or_die(E1->hash, E2)\n+ lookup_commit_or_die(E1, E2)\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n archive.c               |  2 +-\n bisect.c                |  2 +-\n branch.c                |  2 +-\n builtin/am.c            |  4 ++--\n builtin/blame.c         |  4 ++--\n builtin/branch.c        |  6 +++---\n builtin/checkout.c      |  6 +++---\n builtin/clone.c         |  2 +-\n builtin/commit-tree.c   |  2 +-\n builtin/commit.c        |  4 ++--\n builtin/describe.c      |  4 ++--\n builtin/diff-tree.c     |  4 ++--\n builtin/fast-export.c   |  2 +-\n builtin/fetch.c         |  7 ++++---\n builtin/fmt-merge-msg.c |  4 ++--\n builtin/log.c           |  8 ++++----\n builtin/merge-base.c    |  6 +++---\n builtin/merge.c         |  2 +-\n builtin/notes.c         |  2 +-\n builtin/pull.c          | 10 +++++-----\n builtin/reflog.c        |  8 ++++----\n builtin/replace.c       |  4 ++--\n builtin/reset.c         |  4 ++--\n builtin/rev-parse.c     |  6 +++---\n builtin/show-branch.c   |  4 ++--\n builtin/tag.c           |  2 +-\n builtin/verify-commit.c |  2 +-\n bundle.c                |  2 +-\n commit.c                | 30 +++++++++++++++---------------\n commit.h                | 12 ++++++------\n fast-import.c           |  4 ++--\n fetch-pack.c            |  2 +-\n http-push.c             |  5 +++--\n log-tree.c              |  2 +-\n notes-cache.c           |  2 +-\n notes-merge.c           |  4 ++--\n notes-utils.c           |  2 +-\n object.c                |  5 ++++-\n parse-options-cb.c      |  2 +-\n ref-filter.c            |  4 ++--\n remote.c                | 13 +++++++------\n revision.c              |  8 ++++----\n sequencer.c             |  8 ++++----\n sha1_name.c             | 10 +++++-----\n shallow.c               | 20 ++++++++++----------\n submodule.c             | 14 +++++++-------\n tag.c                   |  2 +-\n tree.c                  |  2 +-\n walker.c                |  2 +-\n wt-status.c             |  2 +-\n 50 files changed, 138 insertions(+), 132 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 60b889198..54701e8bb 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -360,7 +360,7 @@ static void parse_treeish_arg(const char **argv,\n \tif (get_sha1(name, oid.hash))\n \t\tdie(\"Not a valid object name\");\n \n-\tcommit = lookup_commit_reference_gently(oid.hash, 1);\n+\tcommit = lookup_commit_reference_gently(&oid, 1);\n \tif (commit) {\n \t\tcommit_sha1 = commit->object.oid.hash;\n \t\tarchive_time = commit->date;\ndiff --git a/bisect.c b/bisect.c\nindex 03af06c66..1f273a85a 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -704,7 +704,7 @@ static int bisect_checkout(const unsigned char *bisect_rev, int no_checkout)\n \n static struct commit *get_commit_reference(const struct object_id *oid)\n {\n-\tstruct commit *r = lookup_commit_reference(oid->hash);\n+\tstruct commit *r = lookup_commit_reference(oid);\n \tif (!r)\n \t\tdie(_(\"Not a valid commit name %s\"), oid_to_hex(oid));\n \treturn r;\ndiff --git a/branch.c b/branch.c\nindex 1758c9708..4899144f5 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -286,7 +286,7 @@ void create_branch(const char *name, const char *start_name,\n \t\tbreak;\n \t}\n \n-\tif ((commit = lookup_commit_reference(oid.hash)) == NULL)\n+\tif ((commit = lookup_commit_reference(&oid)) == NULL)\n \t\tdie(_(\"Not a valid branch point: '%s'.\"), start_name);\n \toidcpy(&oid, &commit->object.oid);\n \ndiff --git a/builtin/am.c b/builtin/am.c\nindex f7a7a971f..a0979fab2 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1492,7 +1492,7 @@ static int parse_mail_rebase(struct am_state *state, const char *mail)\n \tif (get_mail_commit_oid(&commit_oid, mail) < 0)\n \t\tdie(_(\"could not parse %s\"), mail);\n \n-\tcommit = lookup_commit_or_die(commit_oid.hash, mail);\n+\tcommit = lookup_commit_or_die(&commit_oid, mail);\n \n \tget_commit_info(state, commit);\n \n@@ -1687,7 +1687,7 @@ static void do_commit(const struct am_state *state)\n \n \tif (!get_sha1_commit(\"HEAD\", parent.hash)) {\n \t\told_oid = &parent;\n-\t\tcommit_list_insert(lookup_commit(parent.hash), &parents);\n+\t\tcommit_list_insert(lookup_commit(&parent), &parents);\n \t} else {\n \t\told_oid = NULL;\n \t\tsay(state, stderr, _(\"applying to an empty history\"));\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 7d644d092..58bb274d0 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -2253,7 +2253,7 @@ static struct commit_list **append_parent(struct commit_list **tail, const struc\n {\n \tstruct commit *parent;\n \n-\tparent = lookup_commit_reference(oid->hash);\n+\tparent = lookup_commit_reference(oid);\n \tif (!parent)\n \t\tdie(\"no such commit %s\", oid_to_hex(oid));\n \treturn &commit_list_insert(parent, tail)->next;\n@@ -2475,7 +2475,7 @@ static const char *dwim_reverse_initial(struct scoreboard *sb)\n \t/* Do we have HEAD? */\n \tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, head_oid.hash, NULL))\n \t\treturn NULL;\n-\thead_commit = lookup_commit_reference_gently(head_oid.hash, 1);\n+\thead_commit = lookup_commit_reference_gently(&head_oid, 1);\n \tif (!head_commit)\n \t\treturn NULL;\n \ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 0552c42ad..720576160 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -124,7 +124,7 @@ static int branch_merged(int kind, const char *name,\n \t\t    (reference_name = reference_name_to_free =\n \t\t     resolve_refdup(upstream, RESOLVE_REF_READING,\n \t\t\t\t    oid.hash, NULL)) != NULL)\n-\t\t\treference_rev = lookup_commit_reference(oid.hash);\n+\t\t\treference_rev = lookup_commit_reference(&oid);\n \t}\n \tif (!reference_rev)\n \t\treference_rev = head_rev;\n@@ -157,7 +157,7 @@ static int check_branch_commit(const char *branchname, const char *refname,\n \t\t\t       const struct object_id *oid, struct commit *head_rev,\n \t\t\t       int kinds, int force)\n {\n-\tstruct commit *rev = lookup_commit_reference(oid->hash);\n+\tstruct commit *rev = lookup_commit_reference(oid);\n \tif (!rev) {\n \t\terror(_(\"Couldn't look up commit object for '%s'\"), refname);\n \t\treturn -1;\n@@ -211,7 +211,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,\n \t}\n \n \tif (!force) {\n-\t\thead_rev = lookup_commit_reference(head_oid.hash);\n+\t\thead_rev = lookup_commit_reference(&head_oid);\n \t\tif (!head_rev)\n \t\t\tdie(_(\"Couldn't look up commit object for HEAD\"));\n \t}\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex bfa5419f3..afa99fb8a 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -393,7 +393,7 @@ static int checkout_paths(const struct checkout_opts *opts,\n \t\tdie(_(\"unable to write new index file\"));\n \n \tread_ref_full(\"HEAD\", 0, rev.hash, NULL);\n-\thead = lookup_commit_reference_gently(rev.hash, 1);\n+\thead = lookup_commit_reference_gently(&rev, 1);\n \n \terrs |= post_checkout_hook(head, head, 0);\n \treturn errs;\n@@ -833,7 +833,7 @@ static int switch_branches(const struct checkout_opts *opts,\n \tint flag, writeout_error = 0;\n \tmemset(&old, 0, sizeof(old));\n \told.path = path_to_free = resolve_refdup(\"HEAD\", 0, rev.hash, &flag);\n-\told.commit = lookup_commit_reference_gently(rev.hash, 1);\n+\told.commit = lookup_commit_reference_gently(&rev, 1);\n \tif (!(flag & REF_ISSYMREF))\n \t\told.path = NULL;\n \n@@ -1047,7 +1047,7 @@ static int parse_branchname_arg(int argc, const char **argv,\n \telse\n \t\tnew->path = NULL; /* not an existing branch */\n \n-\tnew->commit = lookup_commit_reference_gently(rev->hash, 1);\n+\tnew->commit = lookup_commit_reference_gently(rev, 1);\n \tif (!new->commit) {\n \t\t/* not a commit */\n \t\t*source_tree = parse_tree_indirect(rev->hash);\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex de85b8525..646f28792 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -682,7 +682,7 @@ static void update_head(const struct ref *our, const struct ref *remote,\n \t\t\tinstall_branch_config(0, head, option_origin, our->name);\n \t\t}\n \t} else if (our) {\n-\t\tstruct commit *c = lookup_commit_reference(our->old_oid.hash);\n+\t\tstruct commit *c = lookup_commit_reference(&our->old_oid);\n \t\t/* --branch specifies a non-branch (i.e. tags), detach HEAD */\n \t\tupdate_ref(msg, \"HEAD\", c->object.oid.hash,\n \t\t\t   NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex 605017261..f39c2b273 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\tif (get_sha1_commit(argv[i], oid.hash))\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\tnew_parent(lookup_commit(oid.hash), &parents);\n+\t\t\tnew_parent(lookup_commit(&oid), &parents);\n \t\t\tcontinue;\n \t\t}\n \ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 05a0b609e..d349d48ef 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1430,7 +1430,7 @@ static void print_summary(const char *prefix, const struct object_id *oid,\n \tstruct strbuf author_ident = STRBUF_INIT;\n \tstruct strbuf committer_ident = STRBUF_INIT;\n \n-\tcommit = lookup_commit(oid->hash);\n+\tcommit = lookup_commit(oid);\n \tif (!commit)\n \t\tdie(_(\"couldn't look up newly created commit\"));\n \tif (parse_commit(commit))\n@@ -1654,7 +1654,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \tif (get_sha1(\"HEAD\", oid.hash))\n \t\tcurrent_head = NULL;\n \telse {\n-\t\tcurrent_head = lookup_commit_or_die(oid.hash, \"HEAD\");\n+\t\tcurrent_head = lookup_commit_or_die(&oid, \"HEAD\");\n \t\tif (parse_commit(current_head))\n \t\t\tdie(_(\"could not parse HEAD commit\"));\n \t}\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex a5cd8c513..f6032f593 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -281,7 +281,7 @@ static void describe(const char *arg, int last_one)\n \n \tif (get_oid(arg, &oid))\n \t\tdie(_(\"Not a valid object name %s\"), arg);\n-\tcmit = lookup_commit_reference(oid.hash);\n+\tcmit = lookup_commit_reference(&oid);\n \tif (!cmit)\n \t\tdie(_(\"%s is not a valid '%s' object\"), arg, commit_type);\n \n@@ -309,7 +309,7 @@ static void describe(const char *arg, int last_one)\n \t\tstruct commit *c;\n \t\tstruct commit_name *n = hashmap_iter_first(&names, &iter);\n \t\tfor (; n; n = hashmap_iter_next(&iter)) {\n-\t\t\tc = lookup_commit_reference_gently(n->peeled.hash, 1);\n+\t\t\tc = lookup_commit_reference_gently(&n->peeled, 1);\n \t\t\tif (c)\n \t\t\t\tc->util = n;\n \t\t}\ndiff --git a/builtin/diff-tree.c b/builtin/diff-tree.c\nindex 326f88b65..e85a449df 100644\n--- a/builtin/diff-tree.c\n+++ b/builtin/diff-tree.c\n@@ -9,7 +9,7 @@ static struct rev_info log_tree_opt;\n \n static int diff_tree_commit_sha1(const struct object_id *oid)\n {\n-\tstruct commit *commit = lookup_commit_reference(oid->hash);\n+\tstruct commit *commit = lookup_commit_reference(oid);\n \tif (!commit)\n \t\treturn -1;\n \treturn log_tree_commit(&log_tree_opt, commit);\n@@ -23,7 +23,7 @@ static int stdin_diff_commit(struct commit *commit, const char *p)\n \n \t/* Graft the fake parents locally to the commit */\n \twhile (isspace(*p++) && !parse_oid_hex(p, &oid, &p)) {\n-\t\tstruct commit *parent = lookup_commit(oid.hash);\n+\t\tstruct commit *parent = lookup_commit(&oid);\n \t\tif (!pptr) {\n \t\t\t/* Free the real parent list */\n \t\t\tfree_commit_list(commit->parents);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex e0220630d..b4521cb62 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -938,7 +938,7 @@ static void import_marks(char *input_file)\n \t\t\t/* only commits */\n \t\t\tcontinue;\n \n-\t\tcommit = lookup_commit(oid.hash);\n+\t\tcommit = lookup_commit(&oid);\n \t\tif (!commit)\n \t\t\tdie(\"not a commit? can't happen: %s\", oid_to_hex(&oid));\n \ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 5f2c2ab23..d4d573b98 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -636,8 +636,8 @@ static int update_local_ref(struct ref *ref,\n \t\treturn r;\n \t}\n \n-\tcurrent = lookup_commit_reference_gently(ref->old_oid.hash, 1);\n-\tupdated = lookup_commit_reference_gently(ref->new_oid.hash, 1);\n+\tcurrent = lookup_commit_reference_gently(&ref->old_oid, 1);\n+\tupdated = lookup_commit_reference_gently(&ref->new_oid, 1);\n \tif (!current || !updated) {\n \t\tconst char *msg;\n \t\tconst char *what;\n@@ -770,7 +770,8 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \t\t\t\tcontinue;\n \t\t\t}\n \n-\t\t\tcommit = lookup_commit_reference_gently(rm->old_oid.hash, 1);\n+\t\t\tcommit = lookup_commit_reference_gently(&rm->old_oid,\n+\t\t\t\t\t\t\t\t1);\n \t\t\tif (!commit)\n \t\t\t\trm->fetch_head_status = FETCH_HEAD_NOT_FOR_MERGE;\n \ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 6faa3c0d2..91dd753dd 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -566,7 +566,7 @@ static void find_merge_parents(struct merge_parents *result,\n \t\tcommit_list_insert(parent, &parents);\n \t\tadd_merge_parent(result, &obj->oid, &parent->object.oid);\n \t}\n-\thead_commit = lookup_commit(head->hash);\n+\thead_commit = lookup_commit(head);\n \tif (head_commit)\n \t\tcommit_list_insert(head_commit, &parents);\n \tparents = reduce_heads(parents);\n@@ -633,7 +633,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,\n \t\tstruct commit *head;\n \t\tstruct rev_info rev;\n \n-\t\thead = lookup_commit_or_die(head_oid.hash, \"HEAD\");\n+\t\thead = lookup_commit_or_die(&head_oid, \"HEAD\");\n \t\tinit_revisions(&rev, NULL);\n \t\trev.commit_format = CMIT_FMT_ONELINE;\n \t\trev.ignore_merges = 1;\ndiff --git a/builtin/log.c b/builtin/log.c\nindex b3b10cc1e..d8b56ea41 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -878,8 +878,8 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)\n \to2 = rev->pending.objects[1].item;\n \tflags1 = o1->flags;\n \tflags2 = o2->flags;\n-\tc1 = lookup_commit_reference(o1->oid.hash);\n-\tc2 = lookup_commit_reference(o2->oid.hash);\n+\tc1 = lookup_commit_reference(&o1->oid);\n+\tc2 = lookup_commit_reference(&o2->oid);\n \n \tif ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))\n \t\tdie(_(\"Not a range.\"));\n@@ -1263,7 +1263,7 @@ static struct commit *get_base_commit(const char *base_commit,\n \n \t\t\tif (get_oid(upstream, &oid))\n \t\t\t\tdie(_(\"Failed to resolve '%s' as a valid ref.\"), upstream);\n-\t\t\tcommit = lookup_commit_or_die(oid.hash, \"upstream base\");\n+\t\t\tcommit = lookup_commit_or_die(&oid, \"upstream base\");\n \t\t\tbase_list = get_merge_bases_many(commit, total, list);\n \t\t\t/* There should be one and only one merge base. */\n \t\t\tif (!base_list || base_list->next)\n@@ -1819,7 +1819,7 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)\n {\n \tstruct object_id oid;\n \tif (get_oid(arg, &oid) == 0) {\n-\t\tstruct commit *commit = lookup_commit_reference(oid.hash);\n+\t\tstruct commit *commit = lookup_commit_reference(&oid);\n \t\tif (commit) {\n \t\t\tcommit->object.flags |= flags;\n \t\t\tadd_pending_object(revs, &commit->object, arg);\ndiff --git a/builtin/merge-base.c b/builtin/merge-base.c\nindex cfe2a796f..5c74ce249 100644\n--- a/builtin/merge-base.c\n+++ b/builtin/merge-base.c\n@@ -41,7 +41,7 @@ static struct commit *get_commit_reference(const char *arg)\n \n \tif (get_oid(arg, &revkey))\n \t\tdie(\"Not a valid object name %s\", arg);\n-\tr = lookup_commit_reference(revkey.hash);\n+\tr = lookup_commit_reference(&revkey);\n \tif (!r)\n \t\tdie(\"Not a valid commit name %s\", arg);\n \n@@ -120,7 +120,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)\n \tif (is_null_oid(oid))\n \t\treturn;\n \n-\tcommit = lookup_commit(oid->hash);\n+\tcommit = lookup_commit(oid);\n \tif (!commit ||\n \t    (commit->object.flags & TMP_MARK) ||\n \t    parse_commit(commit))\n@@ -168,7 +168,7 @@ static int handle_fork_point(int argc, const char **argv)\n \tif (get_oid(commitname, &oid))\n \t\tdie(\"Not a valid object name: '%s'\", commitname);\n \n-\tderived = lookup_commit_reference(oid.hash);\n+\tderived = lookup_commit_reference(&oid);\n \tmemset(&revs, 0, sizeof(revs));\n \trevs.initial = 1;\n \tfor_each_reflog_ent(refname, collect_one_reflog_ent, &revs);\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 703827f00..f11b5f3de 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -1123,7 +1123,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \tif (!branch || is_null_oid(&head_oid))\n \t\thead_commit = NULL;\n \telse\n-\t\thead_commit = lookup_commit_or_die(head_oid.hash, \"HEAD\");\n+\t\thead_commit = lookup_commit_or_die(&head_oid, \"HEAD\");\n \n \tinit_diff_ui_defaults();\n \tgit_config(git_merge_config, NULL);\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 7b891471c..f2847c41e 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -706,7 +706,7 @@ static int merge_commit(struct notes_merge_options *o)\n \n \tif (get_oid(\"NOTES_MERGE_PARTIAL\", &oid))\n \t\tdie(_(\"failed to read ref NOTES_MERGE_PARTIAL\"));\n-\telse if (!(partial = lookup_commit_reference(oid.hash)))\n+\telse if (!(partial = lookup_commit_reference(&oid)))\n \t\tdie(_(\"could not find commit from NOTES_MERGE_PARTIAL.\"));\n \telse if (parse_commit(partial))\n \t\tdie(_(\"could not parse commit from NOTES_MERGE_PARTIAL.\"));\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex d8aa26d8a..21e114ec0 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -698,10 +698,10 @@ static int get_octopus_merge_base(struct object_id *merge_base,\n {\n \tstruct commit_list *revs = NULL, *result;\n \n-\tcommit_list_insert(lookup_commit_reference(curr_head->hash), &revs);\n-\tcommit_list_insert(lookup_commit_reference(merge_head->hash), &revs);\n+\tcommit_list_insert(lookup_commit_reference(curr_head), &revs);\n+\tcommit_list_insert(lookup_commit_reference(merge_head), &revs);\n \tif (!is_null_oid(fork_point))\n-\t\tcommit_list_insert(lookup_commit_reference(fork_point->hash), &revs);\n+\t\tcommit_list_insert(lookup_commit_reference(fork_point), &revs);\n \n \tresult = reduce_heads(get_octopus_merge_bases(revs));\n \tfree_commit_list(revs);\n@@ -865,9 +865,9 @@ int cmd_pull(int argc, const char **argv, const char *prefix)\n \t\tstruct commit_list *list = NULL;\n \t\tstruct commit *merge_head, *head;\n \n-\t\thead = lookup_commit_reference(orig_head.hash);\n+\t\thead = lookup_commit_reference(&orig_head);\n \t\tcommit_list_insert(head, &list);\n-\t\tmerge_head = lookup_commit_reference(merge_heads.oid[0].hash);\n+\t\tmerge_head = lookup_commit_reference(&merge_heads.oid[0]);\n \t\tif (is_descendant_of(merge_head, list)) {\n \t\t\t/* we can fast-forward this without invoking rebase */\n \t\t\topt_ff = \"--ff-only\";\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex d6718d326..4831116ea 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -192,7 +192,7 @@ static int keep_entry(struct commit **it, struct object_id *oid)\n \n \tif (is_null_oid(oid))\n \t\treturn 1;\n-\tcommit = lookup_commit_reference_gently(oid->hash, 1);\n+\tcommit = lookup_commit_reference_gently(oid, 1);\n \tif (!commit)\n \t\treturn 0;\n \n@@ -261,7 +261,7 @@ static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit\n \t\tif (is_null_oid(oid))\n \t\t\treturn 0;\n \n-\t\tcommit = lookup_commit_reference_gently(oid->hash, 1);\n+\t\tcommit = lookup_commit_reference_gently(oid, 1);\n \n \t\t/* Not a commit -- keep it */\n \t\tif (!commit)\n@@ -318,7 +318,7 @@ static int push_tip_to_list(const char *refname, const struct object_id *oid,\n \tstruct commit *tip_commit;\n \tif (flags & REF_ISSYMREF)\n \t\treturn 0;\n-\ttip_commit = lookup_commit_reference_gently(oid->hash, 1);\n+\ttip_commit = lookup_commit_reference_gently(oid, 1);\n \tif (!tip_commit)\n \t\treturn 0;\n \tcommit_list_insert(tip_commit, list);\n@@ -335,7 +335,7 @@ static void reflog_expiry_prepare(const char *refname,\n \t\tcb->tip_commit = NULL;\n \t\tcb->unreachable_expire_kind = UE_HEAD;\n \t} else {\n-\t\tcb->tip_commit = lookup_commit_reference_gently(oid->hash, 1);\n+\t\tcb->tip_commit = lookup_commit_reference_gently(oid, 1);\n \t\tif (!cb->tip_commit)\n \t\t\tcb->unreachable_expire_kind = UE_ALWAYS;\n \t\telse\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 065515bab..e2ea3d47b 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -327,7 +327,7 @@ static void replace_parents(struct strbuf *buf, int argc, const char **argv)\n \t\tstruct object_id oid;\n \t\tif (get_oid(argv[i], &oid) < 0)\n \t\t\tdie(_(\"Not a valid object name: '%s'\"), argv[i]);\n-\t\tlookup_commit_or_die(oid.hash, argv[i]);\n+\t\tlookup_commit_or_die(&oid, argv[i]);\n \t\tstrbuf_addf(&new_parents, \"parent %s\\n\", oid_to_hex(&oid));\n \t}\n \n@@ -393,7 +393,7 @@ static int create_graft(int argc, const char **argv, int force)\n \n \tif (get_oid(old_ref, &old) < 0)\n \t\tdie(_(\"Not a valid object name: '%s'\"), old_ref);\n-\tcommit = lookup_commit_or_die(old.hash, old_ref);\n+\tcommit = lookup_commit_or_die(&old, old_ref);\n \n \tbuffer = get_commit_buffer(commit, &size);\n \tstrbuf_add(&buf, buffer, size);\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex fc3b906c4..0be52fa36 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -303,7 +303,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \t\tstruct commit *commit;\n \t\tif (get_sha1_committish(rev, oid.hash))\n \t\t\tdie(_(\"Failed to resolve '%s' as a valid revision.\"), rev);\n-\t\tcommit = lookup_commit_reference(oid.hash);\n+\t\tcommit = lookup_commit_reference(&oid);\n \t\tif (!commit)\n \t\t\tdie(_(\"Could not parse object '%s'.\"), rev);\n \t\toidcpy(&oid, &commit->object.oid);\n@@ -380,7 +380,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \t\tupdate_ref_status = reset_refs(rev, &oid);\n \n \t\tif (reset_type == HARD && !update_ref_status && !quiet)\n-\t\t\tprint_new_head_line(lookup_commit_reference(oid.hash));\n+\t\t\tprint_new_head_line(lookup_commit_reference(&oid));\n \t}\n \tif (!pathspec.nr)\n \t\tremove_branch_state();\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex 272bb13a0..01c67a1f1 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -279,8 +279,8 @@ static int try_difference(const char *arg)\n \t\tif (symmetric) {\n \t\t\tstruct commit_list *exclude;\n \t\t\tstruct commit *a, *b;\n-\t\t\ta = lookup_commit_reference(oid.hash);\n-\t\t\tb = lookup_commit_reference(end.hash);\n+\t\t\ta = lookup_commit_reference(&oid);\n+\t\t\tb = lookup_commit_reference(&end);\n \t\t\texclude = get_merge_bases(a, b);\n \t\t\twhile (exclude) {\n \t\t\t\tstruct commit *commit = pop_commit(&exclude);\n@@ -332,7 +332,7 @@ static int try_parent_shorthands(const char *arg)\n \t\treturn 0;\n \t}\n \n-\tcommit = lookup_commit_reference(oid.hash);\n+\tcommit = lookup_commit_reference(&oid);\n \tif (exclude_parent &&\n \t    exclude_parent > commit_list_count(commit->parents)) {\n \t\t*dotdot = '^';\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 19756595d..71b6f3c17 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -358,7 +358,7 @@ static void sort_ref_range(int bottom, int top)\n static int append_ref(const char *refname, const struct object_id *oid,\n \t\t      int allow_dups)\n {\n-\tstruct commit *commit = lookup_commit_reference_gently(oid->hash, 1);\n+\tstruct commit *commit = lookup_commit_reference_gently(oid, 1);\n \tint i;\n \n \tif (!commit)\n@@ -816,7 +816,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\t\t       MAX_REVS), MAX_REVS);\n \t\tif (get_sha1(ref_name[num_rev], revkey.hash))\n \t\t\tdie(_(\"'%s' is not a valid ref.\"), ref_name[num_rev]);\n-\t\tcommit = lookup_commit_reference(revkey.hash);\n+\t\tcommit = lookup_commit_reference(&revkey);\n \t\tif (!commit)\n \t\t\tdie(_(\"cannot find commit %s (%s)\"),\n \t\t\t    ref_name[num_rev], oid_to_hex(&revkey));\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 597c925e3..d0070b37c 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -328,7 +328,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t\t}\n \t\tfree(buf);\n \n-\t\tif ((c = lookup_commit_reference(oid->hash)) != NULL)\n+\t\tif ((c = lookup_commit_reference(oid)) != NULL)\n \t\t\tstrbuf_addf(sb, \", %s\", show_date(c->date, 0, DATE_MODE(SHORT)));\n \t\tbreak;\n \tcase OBJ_TREE:\ndiff --git a/builtin/verify-commit.c b/builtin/verify-commit.c\nindex a5db1c427..05b734e6d 100644\n--- a/builtin/verify-commit.c\n+++ b/builtin/verify-commit.c\n@@ -25,7 +25,7 @@ static int run_gpg_verify(const struct object_id *oid, const char *buf, unsigned\n \n \tmemset(&signature_check, 0, sizeof(signature_check));\n \n-\tret = check_commit_signature(lookup_commit(oid->hash), &signature_check);\n+\tret = check_commit_signature(lookup_commit(oid), &signature_check);\n \tprint_signature_buffer(&signature_check, flags);\n \n \tsignature_check_clear(&signature_check);\ndiff --git a/bundle.c b/bundle.c\nindex 6e181bb3d..3386dba3b 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -367,7 +367,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)\n \t\t\t * in terms of a tag (e.g. v2.0 from the range\n \t\t\t * \"v1.0..v2.0\")?\n \t\t\t */\n-\t\t\tstruct commit *one = lookup_commit_reference(oid.hash);\n+\t\t\tstruct commit *one = lookup_commit_reference(&oid);\n \t\t\tstruct object *obj;\n \n \t\t\tif (e->item == &(one->object)) {\ndiff --git a/commit.c b/commit.c\nindex ec41ba5e0..0f6c9b6bf 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -18,38 +18,38 @@ int save_commit_buffer = 1;\n \n const char *commit_type = \"commit\";\n \n-struct commit *lookup_commit_reference_gently(const unsigned char *sha1,\n+struct commit *lookup_commit_reference_gently(const struct object_id *oid,\n \t\t\t\t\t      int quiet)\n {\n-\tstruct object *obj = deref_tag(parse_object(sha1), NULL, 0);\n+\tstruct object *obj = deref_tag(parse_object(oid->hash), NULL, 0);\n \n \tif (!obj)\n \t\treturn NULL;\n \treturn object_as_type(obj, OBJ_COMMIT, quiet);\n }\n \n-struct commit *lookup_commit_reference(const unsigned char *sha1)\n+struct commit *lookup_commit_reference(const struct object_id *oid)\n {\n-\treturn lookup_commit_reference_gently(sha1, 0);\n+\treturn lookup_commit_reference_gently(oid, 0);\n }\n \n-struct commit *lookup_commit_or_die(const unsigned char *sha1, const char *ref_name)\n+struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name)\n {\n-\tstruct commit *c = lookup_commit_reference(sha1);\n+\tstruct commit *c = lookup_commit_reference(oid);\n \tif (!c)\n \t\tdie(_(\"could not parse %s\"), ref_name);\n-\tif (hashcmp(sha1, c->object.oid.hash)) {\n+\tif (oidcmp(oid, &c->object.oid)) {\n \t\twarning(_(\"%s %s is not a commit!\"),\n-\t\t\tref_name, sha1_to_hex(sha1));\n+\t\t\tref_name, oid_to_hex(oid));\n \t}\n \treturn c;\n }\n \n-struct commit *lookup_commit(const unsigned char *sha1)\n+struct commit *lookup_commit(const struct object_id *oid)\n {\n-\tstruct object *obj = lookup_object(sha1);\n+\tstruct object *obj = lookup_object(oid->hash);\n \tif (!obj)\n-\t\treturn create_object(sha1, alloc_commit_node());\n+\t\treturn create_object(oid->hash, alloc_commit_node());\n \treturn object_as_type(obj, OBJ_COMMIT, 0);\n }\n \n@@ -60,7 +60,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)\n \n \tif (get_sha1_committish(name, oid.hash))\n \t\treturn NULL;\n-\tcommit = lookup_commit_reference(oid.hash);\n+\tcommit = lookup_commit_reference(&oid);\n \tif (parse_commit(commit))\n \t\treturn NULL;\n \treturn commit;\n@@ -350,7 +350,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s\n \t\t */\n \t\tif (graft && (graft->nr_parent < 0 || grafts_replace_parents))\n \t\t\tcontinue;\n-\t\tnew_parent = lookup_commit(parent.hash);\n+\t\tnew_parent = lookup_commit(&parent);\n \t\tif (new_parent)\n \t\t\tpptr = &commit_list_insert(new_parent, pptr)->next;\n \t}\n@@ -358,7 +358,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s\n \t\tint i;\n \t\tstruct commit *new_parent;\n \t\tfor (i = 0; i < graft->nr_parent; i++) {\n-\t\t\tnew_parent = lookup_commit(graft->parent[i].hash);\n+\t\t\tnew_parent = lookup_commit(&graft->parent[i]);\n \t\t\tif (!new_parent)\n \t\t\t\tcontinue;\n \t\t\tpptr = &commit_list_insert(new_parent, pptr)->next;\n@@ -562,7 +562,7 @@ void clear_commit_marks_for_object_array(struct object_array *a, unsigned mark)\n \n \tfor (i = 0; i < a->nr; i++) {\n \t\tobject = a->objects[i].item;\n-\t\tcommit = lookup_commit_reference_gently(object->oid.hash, 1);\n+\t\tcommit = lookup_commit_reference_gently(&object->oid, 1);\n \t\tif (commit)\n \t\t\tclear_commit_marks(commit, mark);\n \t}\ndiff --git a/commit.h b/commit.h\nindex 884177b8f..3488a285b 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -45,18 +45,18 @@ enum decoration_type {\n void add_name_decoration(enum decoration_type type, const char *name, struct object *obj);\n const struct name_decoration *get_name_decoration(const struct object *obj);\n \n-struct commit *lookup_commit(const unsigned char *sha1);\n-struct commit *lookup_commit_reference(const unsigned char *sha1);\n-struct commit *lookup_commit_reference_gently(const unsigned char *sha1,\n+struct commit *lookup_commit(const struct object_id *oid);\n+struct commit *lookup_commit_reference(const struct object_id *oid);\n+struct commit *lookup_commit_reference_gently(const struct object_id *oid,\n \t\t\t\t\t      int quiet);\n struct commit *lookup_commit_reference_by_name(const char *name);\n \n /*\n- * Look up object named by \"sha1\", dereference tag as necessary,\n- * get a commit and return it. If \"sha1\" does not dereference to\n+ * Look up object named by \"oid\", dereference tag as necessary,\n+ * get a commit and return it. If \"oid\" does not dereference to\n  * a commit, use ref_name to report an error and die.\n  */\n-struct commit *lookup_commit_or_die(const unsigned char *sha1, const char *ref_name);\n+struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);\n \n int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size);\n int parse_commit_gently(struct commit *item, int quiet_on_missing);\ndiff --git a/fast-import.c b/fast-import.c\nindex 6b0117e51..0aa81d522 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1761,8 +1761,8 @@ static int update_branch(struct branch *b)\n \tif (!force_update && !is_null_oid(&old_oid)) {\n \t\tstruct commit *old_cmit, *new_cmit;\n \n-\t\told_cmit = lookup_commit_reference_gently(old_oid.hash, 0);\n-\t\tnew_cmit = lookup_commit_reference_gently(b->oid.hash, 0);\n+\t\told_cmit = lookup_commit_reference_gently(&old_oid, 0);\n+\t\tnew_cmit = lookup_commit_reference_gently(&b->oid, 0);\n \t\tif (!old_cmit || !new_cmit)\n \t\t\treturn error(\"Branch %s is missing commits.\", b->name);\n \ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex f3aae85d5..ab767503b 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -481,7 +481,7 @@ static int find_common(struct fetch_pack_args *args,\n \t\t\t\tcase ACK_ready:\n \t\t\t\tcase ACK_continue: {\n \t\t\t\t\tstruct commit *commit =\n-\t\t\t\t\t\tlookup_commit(result_oid->hash);\n+\t\t\t\t\t\tlookup_commit(result_oid);\n \t\t\t\t\tif (!commit)\n \t\t\t\t\t\tdie(_(\"invalid commit %s\"), oid_to_hex(result_oid));\n \t\t\t\t\tif (args->stateless_rpc\ndiff --git a/http-push.c b/http-push.c\nindex f3dd0a560..04568e4fb 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1569,8 +1569,9 @@ static void fetch_symref(const char *path, char **symref, struct object_id *oid)\n \n static int verify_merge_base(struct object_id *head_oid, struct ref *remote)\n {\n-\tstruct commit *head = lookup_commit_or_die(head_oid->hash, \"HEAD\");\n-\tstruct commit *branch = lookup_commit_or_die(remote->old_oid.hash, remote->name);\n+\tstruct commit *head = lookup_commit_or_die(head_oid, \"HEAD\");\n+\tstruct commit *branch = lookup_commit_or_die(&remote->old_oid,\n+\t\t\t\t\t\t     remote->name);\n \n \treturn in_merge_bases(branch, head);\n }\ndiff --git a/log-tree.c b/log-tree.c\nindex 4618dd04c..7fb1a85d2 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -140,7 +140,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,\n \n static int add_graft_decoration(const struct commit_graft *graft, void *cb_data)\n {\n-\tstruct commit *commit = lookup_commit(graft->oid.hash);\n+\tstruct commit *commit = lookup_commit(&graft->oid);\n \tif (!commit)\n \t\treturn 0;\n \tadd_name_decoration(DECORATION_GRAFTED, \"grafted\", &commit->object);\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 1cdd4984a..2843e9857 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -14,7 +14,7 @@ static int notes_cache_match_validity(const char *ref, const char *validity)\n \tif (read_ref(ref, oid.hash) < 0)\n \t\treturn 0;\n \n-\tcommit = lookup_commit_reference_gently(oid.hash, 1);\n+\tcommit = lookup_commit_reference_gently(&oid, 1);\n \tif (!commit)\n \t\treturn 0;\n \ndiff --git a/notes-merge.c b/notes-merge.c\nindex 7ac9bb9a4..b6c704045 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -554,7 +554,7 @@ int notes_merge(struct notes_merge_options *o,\n \telse if (!check_refname_format(o->local_ref, 0) &&\n \t\tis_null_oid(&local_oid))\n \t\tlocal = NULL; /* local_sha1 == null_sha1 indicates unborn ref */\n-\telse if (!(local = lookup_commit_reference(local_oid.hash)))\n+\telse if (!(local = lookup_commit_reference(&local_oid)))\n \t\tdie(\"Could not parse local commit %s (%s)\",\n \t\t    oid_to_hex(&local_oid), o->local_ref);\n \ttrace_printf(\"\\tlocal commit: %.7s\\n\", oid_to_hex(&local_oid));\n@@ -572,7 +572,7 @@ int notes_merge(struct notes_merge_options *o,\n \t\t\tdie(\"Failed to resolve remote notes ref '%s'\",\n \t\t\t    o->remote_ref);\n \t\t}\n-\t} else if (!(remote = lookup_commit_reference(remote_oid.hash))) {\n+\t} else if (!(remote = lookup_commit_reference(&remote_oid))) {\n \t\tdie(\"Could not parse remote commit %s (%s)\",\n \t\t    oid_to_hex(&remote_oid), o->remote_ref);\n \t}\ndiff --git a/notes-utils.c b/notes-utils.c\nindex 36c1490aa..325ff3daa 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -18,7 +18,7 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,\n \t\t/* Deduce parent commit from t->ref */\n \t\tstruct object_id parent_oid;\n \t\tif (!read_ref(t->ref, parent_oid.hash)) {\n-\t\t\tstruct commit *parent = lookup_commit(parent_oid.hash);\n+\t\t\tstruct commit *parent = lookup_commit(&parent_oid);\n \t\t\tif (parse_commit(parent))\n \t\t\t\tdie(\"Failed to find/parse commit %s\", t->ref);\n \t\t\tcommit_list_insert(parent, &parents);\ndiff --git a/object.c b/object.c\nindex e680d881a..fe2222356 100644\n--- a/object.c\n+++ b/object.c\n@@ -182,9 +182,12 @@ struct object *lookup_unknown_object(const unsigned char *sha1)\n \n struct object *parse_object_buffer(const unsigned char *sha1, enum object_type type, unsigned long size, void *buffer, int *eaten_p)\n {\n+\tstruct object_id oid;\n \tstruct object *obj;\n \t*eaten_p = 0;\n \n+\thashcpy(oid.hash, sha1);\n+\n \tobj = NULL;\n \tif (type == OBJ_BLOB) {\n \t\tstruct blob *blob = lookup_blob(sha1);\n@@ -206,7 +209,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t\n \t\t\t}\n \t\t}\n \t} else if (type == OBJ_COMMIT) {\n-\t\tstruct commit *commit = lookup_commit(sha1);\n+\t\tstruct commit *commit = lookup_commit(&oid);\n \t\tif (commit) {\n \t\t\tif (parse_commit_buffer(commit, buffer, size))\n \t\t\t\treturn NULL;\ndiff --git a/parse-options-cb.c b/parse-options-cb.c\nindex 35a941fdd..8dd57cf6e 100644\n--- a/parse-options-cb.c\n+++ b/parse-options-cb.c\n@@ -87,7 +87,7 @@ int parse_opt_commits(const struct option *opt, const char *arg, int unset)\n \t\treturn -1;\n \tif (get_oid(arg, &oid))\n \t\treturn error(\"malformed object name %s\", arg);\n-\tcommit = lookup_commit_reference(oid.hash);\n+\tcommit = lookup_commit_reference(&oid);\n \tif (!commit)\n \t\treturn error(\"no such commit %s\", arg);\n \tcommit_list_insert(commit, opt->value);\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 47cce0a18..e1d18ac0d 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -1782,7 +1782,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,\n \t * non-commits early. The actual filtering is done later.\n \t */\n \tif (filter->merge_commit || filter->with_commit || filter->no_commit || filter->verbose) {\n-\t\tcommit = lookup_commit_reference_gently(oid->hash, 1);\n+\t\tcommit = lookup_commit_reference_gently(oid, 1);\n \t\tif (!commit)\n \t\t\treturn 0;\n \t\t/* We perform the filtering for the '--contains' option... */\n@@ -2108,7 +2108,7 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)\n \tif (get_oid(arg, &oid))\n \t\tdie(_(\"malformed object name %s\"), arg);\n \n-\trf->merge_commit = lookup_commit_reference_gently(oid.hash, 0);\n+\trf->merge_commit = lookup_commit_reference_gently(&oid, 0);\n \tif (!rf->merge_commit)\n \t\treturn opterror(opt, \"must point to a commit\", 0);\n \ndiff --git a/remote.c b/remote.c\nindex 801137c72..bf9a47d95 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1296,7 +1296,7 @@ static void add_to_tips(struct tips *tips, const struct object_id *oid)\n \n \tif (is_null_oid(oid))\n \t\treturn;\n-\tcommit = lookup_commit_reference_gently(oid->hash, 1);\n+\tcommit = lookup_commit_reference_gently(oid, 1);\n \tif (!commit || (commit->object.flags & TMP_MARK))\n \t\treturn;\n \tcommit->object.flags |= TMP_MARK;\n@@ -1358,7 +1358,8 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \n \t\t\tif (is_null_oid(&ref->new_oid))\n \t\t\t\tcontinue;\n-\t\t\tcommit = lookup_commit_reference_gently(ref->new_oid.hash, 1);\n+\t\t\tcommit = lookup_commit_reference_gently(&ref->new_oid,\n+\t\t\t\t\t\t\t\t1);\n \t\t\tif (!commit)\n \t\t\t\t/* not pushing a commit, which is not an error */\n \t\t\t\tcontinue;\n@@ -1585,8 +1586,8 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n \t\t\t\treject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;\n \t\t\telse if (!has_object_file(&ref->old_oid))\n \t\t\t\treject_reason = REF_STATUS_REJECT_FETCH_FIRST;\n-\t\t\telse if (!lookup_commit_reference_gently(ref->old_oid.hash, 1) ||\n-\t\t\t\t !lookup_commit_reference_gently(ref->new_oid.hash, 1))\n+\t\t\telse if (!lookup_commit_reference_gently(&ref->old_oid, 1) ||\n+\t\t\t\t !lookup_commit_reference_gently(&ref->new_oid, 1))\n \t\t\t\treject_reason = REF_STATUS_REJECT_NEEDS_FORCE;\n \t\t\telse if (!ref_newer(&ref->new_oid, &ref->old_oid))\n \t\t\t\treject_reason = REF_STATUS_REJECT_NONFASTFORWARD;\n@@ -2009,13 +2010,13 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,\n \t/* Cannot stat if what we used to build on no longer exists */\n \tif (read_ref(base, oid.hash))\n \t\treturn -1;\n-\ttheirs = lookup_commit_reference(oid.hash);\n+\ttheirs = lookup_commit_reference(&oid);\n \tif (!theirs)\n \t\treturn -1;\n \n \tif (read_ref(branch->refname, oid.hash))\n \t\treturn -1;\n-\tours = lookup_commit_reference(oid.hash);\n+\tours = lookup_commit_reference(&oid);\n \tif (!ours)\n \t\treturn -1;\n \ndiff --git a/revision.c b/revision.c\nindex 945367034..f8e0dee6d 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1395,10 +1395,10 @@ static void prepare_show_merge(struct rev_info *revs)\n \n \tif (get_oid(\"HEAD\", &oid))\n \t\tdie(\"--merge without HEAD?\");\n-\thead = lookup_commit_or_die(oid.hash, \"HEAD\");\n+\thead = lookup_commit_or_die(&oid, \"HEAD\");\n \tif (get_oid(\"MERGE_HEAD\", &oid))\n \t\tdie(\"--merge without MERGE_HEAD?\");\n-\tother = lookup_commit_or_die(oid.hash, \"MERGE_HEAD\");\n+\tother = lookup_commit_or_die(&oid, \"MERGE_HEAD\");\n \tadd_pending_object(revs, &head->object, \"HEAD\");\n \tadd_pending_object(revs, &other->object, \"MERGE_HEAD\");\n \tbases = get_merge_bases(head, other);\n@@ -1500,10 +1500,10 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi\n \n \t\t\t\ta = (a_obj->type == OBJ_COMMIT\n \t\t\t\t     ? (struct commit *)a_obj\n-\t\t\t\t     : lookup_commit_reference(a_obj->oid.hash));\n+\t\t\t\t     : lookup_commit_reference(&a_obj->oid));\n \t\t\t\tb = (b_obj->type == OBJ_COMMIT\n \t\t\t\t     ? (struct commit *)b_obj\n-\t\t\t\t     : lookup_commit_reference(b_obj->oid.hash));\n+\t\t\t\t     : lookup_commit_reference(&b_obj->oid));\n \t\t\t\tif (!a || !b)\n \t\t\t\t\tgoto missing;\n \t\t\t\texclude = get_merge_bases(a, b);\ndiff --git a/sequencer.c b/sequencer.c\nindex cfa544ab9..46e05e385 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -488,7 +488,7 @@ static int is_index_unchanged(void)\n \tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, head_oid.hash, NULL))\n \t\treturn error(_(\"could not resolve HEAD commit\\n\"));\n \n-\thead_commit = lookup_commit(head_oid.hash);\n+\thead_commit = lookup_commit(&head_oid);\n \n \t/*\n \t * If head_commit is NULL, check_commit, called from\n@@ -841,7 +841,7 @@ static int update_squash_messages(enum todo_command command,\n \n \t\tif (get_oid(\"HEAD\", &head))\n \t\t\treturn error(_(\"need a HEAD to fixup\"));\n-\t\tif (!(head_commit = lookup_commit_reference(head.hash)))\n+\t\tif (!(head_commit = lookup_commit_reference(&head)))\n \t\t\treturn error(_(\"could not read HEAD\"));\n \t\tif (!(head_message = get_commit_buffer(head_commit, NULL)))\n \t\t\treturn error(_(\"could not read HEAD's commit message\"));\n@@ -1279,7 +1279,7 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)\n \tif (status < 0)\n \t\treturn -1;\n \n-\titem->commit = lookup_commit_reference(commit_oid.hash);\n+\titem->commit = lookup_commit_reference(&commit_oid);\n \treturn !item->commit;\n }\n \n@@ -2275,7 +2275,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)\n \t\t\tcontinue;\n \n \t\tif (!get_oid(name, &oid)) {\n-\t\t\tif (!lookup_commit_reference_gently(oid.hash, 1)) {\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\treturn error(_(\"%s: can't cherry-pick a %s\"),\n \t\t\t\t\tname, typename(type));\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 8889190a9..390a09c41 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -354,7 +354,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \n \ttype = sha1_object_info(oid->hash, NULL);\n \tif (type == OBJ_COMMIT) {\n-\t\tstruct commit *commit = lookup_commit(oid->hash);\n+\t\tstruct commit *commit = lookup_commit(oid);\n \t\tif (commit) {\n \t\t\tstruct pretty_print_context pp = {0};\n \t\t\tpp.date_mode.type = DATE_SHORT;\n@@ -729,7 +729,7 @@ static int get_parent(const char *name, int len,\n \n \tif (ret)\n \t\treturn ret;\n-\tcommit = lookup_commit_reference(oid.hash);\n+\tcommit = lookup_commit_reference(&oid);\n \tif (parse_commit(commit))\n \t\treturn -1;\n \tif (!idx) {\n@@ -757,7 +757,7 @@ static int get_nth_ancestor(const char *name, int len,\n \tret = get_sha1_1(name, len, oid.hash, GET_SHA1_COMMITTISH);\n \tif (ret)\n \t\treturn ret;\n-\tcommit = lookup_commit_reference(oid.hash);\n+\tcommit = lookup_commit_reference(&oid);\n \tif (!commit)\n \t\treturn -1;\n \n@@ -1136,13 +1136,13 @@ int get_oid_mb(const char *name, struct object_id *oid)\n \t}\n \tif (st)\n \t\treturn st;\n-\tone = lookup_commit_reference_gently(oid_tmp.hash, 0);\n+\tone = lookup_commit_reference_gently(&oid_tmp, 0);\n \tif (!one)\n \t\treturn -1;\n \n \tif (get_sha1_committish(dots[3] ? (dots + 3) : \"HEAD\", oid_tmp.hash))\n \t\treturn -1;\n-\ttwo = lookup_commit_reference_gently(oid_tmp.hash, 0);\n+\ttwo = lookup_commit_reference_gently(&oid_tmp, 0);\n \tif (!two)\n \t\treturn -1;\n \tmbs = get_merge_bases(one, two);\ndiff --git a/shallow.c b/shallow.c\nindex 1327ee16f..6950cc24f 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -31,7 +31,7 @@ int register_shallow(const struct object_id *oid)\n {\n \tstruct commit_graft *graft =\n \t\txmalloc(sizeof(struct commit_graft));\n-\tstruct commit *commit = lookup_commit(oid->hash);\n+\tstruct commit *commit = lookup_commit(oid);\n \n \toidcpy(&graft->oid, oid);\n \tgraft->nr_parent = -1;\n@@ -241,7 +241,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)\n \tif (graft->nr_parent != -1)\n \t\treturn 0;\n \tif (data->flags & SEEN_ONLY) {\n-\t\tstruct commit *c = lookup_commit(graft->oid.hash);\n+\t\tstruct commit *c = lookup_commit(&graft->oid);\n \t\tif (!c || !(c->object.flags & SEEN)) {\n \t\t\tif (data->flags & VERBOSE)\n \t\t\t\tprintf(\"Removing %s from .git/shallow\\n\",\n@@ -475,7 +475,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,\n \tsize_t bitmap_size = st_mult(sizeof(uint32_t), bitmap_nr);\n \tuint32_t *tmp = xmalloc(bitmap_size); /* to be freed before return */\n \tuint32_t *bitmap = paint_alloc(info);\n-\tstruct commit *c = lookup_commit_reference_gently(oid->hash, 1);\n+\tstruct commit *c = lookup_commit_reference_gently(oid, 1);\n \tif (!c)\n \t\treturn;\n \tmemset(bitmap, 0, bitmap_size);\n@@ -531,7 +531,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,\n static int mark_uninteresting(const char *refname, const struct object_id *oid,\n \t\t\t      int flags, void *cb_data)\n {\n-\tstruct commit *commit = lookup_commit_reference_gently(oid->hash, 1);\n+\tstruct commit *commit = lookup_commit_reference_gently(oid, 1);\n \tif (!commit)\n \t\treturn 0;\n \tcommit->object.flags |= UNINTERESTING;\n@@ -599,7 +599,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,\n \n \t/* Mark potential bottoms so we won't go out of bound */\n \tfor (i = 0; i < nr_shallow; i++) {\n-\t\tstruct commit *c = lookup_commit(oid[shallow[i]].hash);\n+\t\tstruct commit *c = lookup_commit(&oid[shallow[i]]);\n \t\tc->object.flags |= BOTTOM;\n \t}\n \n@@ -610,7 +610,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,\n \t\tint bitmap_size = ((pi.nr_bits + 31) / 32) * sizeof(uint32_t);\n \t\tmemset(used, 0, sizeof(*used) * info->shallow->nr);\n \t\tfor (i = 0; i < nr_shallow; i++) {\n-\t\t\tconst struct commit *c = lookup_commit(oid[shallow[i]].hash);\n+\t\t\tconst struct commit *c = lookup_commit(&oid[shallow[i]]);\n \t\t\tuint32_t **map = ref_bitmap_at(&pi.ref_bitmap, c);\n \t\t\tif (*map)\n \t\t\t\tused[shallow[i]] = xmemdupz(*map, bitmap_size);\n@@ -641,7 +641,7 @@ static int add_ref(const char *refname, const struct object_id *oid,\n {\n \tstruct commit_array *ca = cb_data;\n \tALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);\n-\tca->commits[ca->nr] = lookup_commit_reference_gently(oid->hash, 1);\n+\tca->commits[ca->nr] = lookup_commit_reference_gently(oid, 1);\n \tif (ca->commits[ca->nr])\n \t\tca->nr++;\n \treturn 0;\n@@ -679,7 +679,7 @@ static void post_assign_shallow(struct shallow_info *info,\n \tfor (i = dst = 0; i < info->nr_theirs; i++) {\n \t\tif (i != dst)\n \t\t\tinfo->theirs[dst] = info->theirs[i];\n-\t\tc = lookup_commit(oid[info->theirs[i]].hash);\n+\t\tc = lookup_commit(&oid[info->theirs[i]]);\n \t\tbitmap = ref_bitmap_at(ref_bitmap, c);\n \t\tif (!*bitmap)\n \t\t\tcontinue;\n@@ -700,7 +700,7 @@ static void post_assign_shallow(struct shallow_info *info,\n \tfor (i = dst = 0; i < info->nr_ours; i++) {\n \t\tif (i != dst)\n \t\t\tinfo->ours[dst] = info->ours[i];\n-\t\tc = lookup_commit(oid[info->ours[i]].hash);\n+\t\tc = lookup_commit(&oid[info->ours[i]]);\n \t\tbitmap = ref_bitmap_at(ref_bitmap, c);\n \t\tif (!*bitmap)\n \t\t\tcontinue;\n@@ -722,7 +722,7 @@ static void post_assign_shallow(struct shallow_info *info,\n int delayed_reachability_test(struct shallow_info *si, int c)\n {\n \tif (si->need_reachability_test[c]) {\n-\t\tstruct commit *commit = lookup_commit(si->shallow->oid[c].hash);\n+\t\tstruct commit *commit = lookup_commit(&si->shallow->oid[c]);\n \n \t\tif (!si->commits) {\n \t\t\tstruct commit_array ca;\ndiff --git a/submodule.c b/submodule.c\nindex ebbf66d31..e0e69e02c 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -447,8 +447,8 @@ static void show_submodule_header(FILE *f, const char *path,\n \t * Attempt to lookup the commit references, and determine if this is\n \t * a fast forward or fast backwards update.\n \t */\n-\t*left = lookup_commit_reference(one->hash);\n-\t*right = lookup_commit_reference(two->hash);\n+\t*left = lookup_commit_reference(one);\n+\t*right = lookup_commit_reference(two);\n \n \t/*\n \t * Warn about missing commits in the submodule project, but only if\n@@ -634,7 +634,7 @@ static int check_has_commit(const struct object_id *oid, void *data)\n {\n \tint *has_commit = data;\n \n-\tif (!lookup_commit_reference(oid->hash))\n+\tif (!lookup_commit_reference(oid))\n \t\t*has_commit = 0;\n \n \treturn 0;\n@@ -899,7 +899,7 @@ int push_unpushed_submodules(struct oid_array *commits,\n static int is_submodule_commit_present(const char *path, struct object_id *oid)\n {\n \tint is_present = 0;\n-\tif (!add_submodule_odb(path) && lookup_commit_reference(oid->hash)) {\n+\tif (!add_submodule_odb(path) && lookup_commit_reference(oid)) {\n \t\t/* Even if the submodule is checked out and the commit is\n \t\t * present, make sure it is reachable from a ref. */\n \t\tstruct child_process cp = CHILD_PROCESS_INIT;\n@@ -1593,9 +1593,9 @@ int merge_submodule(struct object_id *result, const char *path,\n \t\treturn 0;\n \t}\n \n-\tif (!(commit_base = lookup_commit_reference(base->hash)) ||\n-\t    !(commit_a = lookup_commit_reference(a->hash)) ||\n-\t    !(commit_b = lookup_commit_reference(b->hash))) {\n+\tif (!(commit_base = lookup_commit_reference(base)) ||\n+\t    !(commit_a = lookup_commit_reference(a)) ||\n+\t    !(commit_b = lookup_commit_reference(b))) {\n \t\tMERGE_WARNING(path, \"commits not present\");\n \t\treturn 0;\n \t}\ndiff --git a/tag.c b/tag.c\nindex 625f5cd71..79b78d358 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -146,7 +146,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n \t} else if (!strcmp(type, tree_type)) {\n \t\titem->tagged = &lookup_tree(oid.hash)->object;\n \t} else if (!strcmp(type, commit_type)) {\n-\t\titem->tagged = &lookup_commit(oid.hash)->object;\n+\t\titem->tagged = &lookup_commit(&oid)->object;\n \t} else if (!strcmp(type, tag_type)) {\n \t\titem->tagged = &lookup_tag(oid.hash)->object;\n \t} else {\ndiff --git a/tree.c b/tree.c\nindex ce345c551..33fa7ee71 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -91,7 +91,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,\n \t\telse if (S_ISGITLINK(entry.mode)) {\n \t\t\tstruct commit *commit;\n \n-\t\t\tcommit = lookup_commit(entry.oid->hash);\n+\t\t\tcommit = lookup_commit(entry.oid);\n \t\t\tif (!commit)\n \t\t\t\tdie(\"Commit %s in submodule path %s%s not found\",\n \t\t\t\t    oid_to_hex(entry.oid),\ndiff --git a/walker.c b/walker.c\nindex 2c86e406f..b499fcb72 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -206,7 +206,7 @@ static int interpret_target(struct walker *walker, char *target, unsigned char *\n static int mark_complete(const char *path, const struct object_id *oid,\n \t\t\t int flag, void *cb_data)\n {\n-\tstruct commit *commit = lookup_commit_reference_gently(oid->hash, 1);\n+\tstruct commit *commit = lookup_commit_reference_gently(oid, 1);\n \n \tif (commit) {\n \t\tcommit->object.flags |= COMPLETE;\ndiff --git a/wt-status.c b/wt-status.c\nindex 037548496..e5854ba6f 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1428,7 +1428,7 @@ static void wt_status_get_detached_from(struct wt_status_state *state)\n \t    /* sha1 is a commit? match without further lookup */\n \t    (!oidcmp(&cb.noid, &oid) ||\n \t     /* perhaps sha1 is a tag, try to dereference to a commit */\n-\t     ((commit = lookup_commit_reference_gently(oid.hash, 1)) != NULL &&\n+\t     ((commit = lookup_commit_reference_gently(&oid, 1)) != NULL &&\n \t      !oidcmp(&cb.noid, &commit->object.oid)))) {\n \t\tconst char *from = ref;\n \t\tif (!skip_prefix(from, \"refs/tags/\", &from))\n"},{"id":"317594","messageId":"20170423213453.253425-28-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 27/53] builtin/unpack-objects: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:27Z","receivedAt":"2017-04-23T21:37:02Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert struct delta_info and struct object_info, as well as the various\nfunctions, to use struct object_id.  Convert several hard-coded 20\nvalues to GIT_SHA1_RAWSZ.  Among the functions converted is a caller of\nlookup_blob, which we will convert shortly.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/unpack-objects.c | 64 ++++++++++++++++++++++++------------------------\n 1 file changed, 32 insertions(+), 32 deletions(-)\n\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 4532aa083..3dc5e5691 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -127,7 +127,7 @@ static void *get_data(unsigned long size)\n }\n \n struct delta_info {\n-\tunsigned char base_sha1[20];\n+\tstruct object_id base_oid;\n \tunsigned nr;\n \toff_t base_offset;\n \tunsigned long size;\n@@ -137,13 +137,13 @@ struct delta_info {\n \n static struct delta_info *delta_list;\n \n-static void add_delta_to_list(unsigned nr, unsigned const char *base_sha1,\n+static void add_delta_to_list(unsigned nr, const struct object_id *base_oid,\n \t\t\t      off_t base_offset,\n \t\t\t      void *delta, unsigned long size)\n {\n \tstruct delta_info *info = xmalloc(sizeof(*info));\n \n-\thashcpy(info->base_sha1, base_sha1);\n+\toidcpy(&info->base_oid, base_oid);\n \tinfo->base_offset = base_offset;\n \tinfo->size = size;\n \tinfo->delta = delta;\n@@ -154,7 +154,7 @@ static void add_delta_to_list(unsigned nr, unsigned const char *base_sha1,\n \n struct obj_info {\n \toff_t offset;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct object *obj;\n };\n \n@@ -170,9 +170,9 @@ static unsigned nr_objects;\n  */\n static void write_cached_object(struct object *obj, struct obj_buffer *obj_buf)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \n-\tif (write_sha1_file(obj_buf->buffer, obj_buf->size, typename(obj->type), sha1) < 0)\n+\tif (write_sha1_file(obj_buf->buffer, obj_buf->size, typename(obj->type), oid.hash) < 0)\n \t\tdie(\"failed to write object %s\", oid_to_hex(&obj->oid));\n \tobj->flags |= FLAG_WRITTEN;\n }\n@@ -237,19 +237,19 @@ static void write_object(unsigned nr, enum object_type type,\n \t\t\t void *buf, unsigned long size)\n {\n \tif (!strict) {\n-\t\tif (write_sha1_file(buf, size, typename(type), obj_list[nr].sha1) < 0)\n+\t\tif (write_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash) < 0)\n \t\t\tdie(\"failed to write object\");\n \t\tadded_object(nr, type, buf, size);\n \t\tfree(buf);\n \t\tobj_list[nr].obj = NULL;\n \t} else if (type == OBJ_BLOB) {\n \t\tstruct blob *blob;\n-\t\tif (write_sha1_file(buf, size, typename(type), obj_list[nr].sha1) < 0)\n+\t\tif (write_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash) < 0)\n \t\t\tdie(\"failed to write object\");\n \t\tadded_object(nr, type, buf, size);\n \t\tfree(buf);\n \n-\t\tblob = lookup_blob(obj_list[nr].sha1);\n+\t\tblob = lookup_blob(obj_list[nr].oid.hash);\n \t\tif (blob)\n \t\t\tblob->object.flags |= FLAG_WRITTEN;\n \t\telse\n@@ -258,9 +258,9 @@ static void write_object(unsigned nr, enum object_type type,\n \t} else {\n \t\tstruct object *obj;\n \t\tint eaten;\n-\t\thash_sha1_file(buf, size, typename(type), obj_list[nr].sha1);\n+\t\thash_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash);\n \t\tadded_object(nr, type, buf, size);\n-\t\tobj = parse_object_buffer(obj_list[nr].sha1, type, size, buf, &eaten);\n+\t\tobj = parse_object_buffer(obj_list[nr].oid.hash, type, size, buf, &eaten);\n \t\tif (!obj)\n \t\t\tdie(\"invalid %s\", typename(type));\n \t\tadd_object_buffer(obj, buf, size);\n@@ -296,7 +296,7 @@ static void added_object(unsigned nr, enum object_type type,\n \tstruct delta_info *info;\n \n \twhile ((info = *p) != NULL) {\n-\t\tif (!hashcmp(info->base_sha1, obj_list[nr].sha1) ||\n+\t\tif (!oidcmp(&info->base_oid, &obj_list[nr].oid) ||\n \t\t    info->base_offset == obj_list[nr].offset) {\n \t\t\t*p = info->next;\n \t\t\tp = &delta_list;\n@@ -320,12 +320,12 @@ static void unpack_non_delta_entry(enum object_type type, unsigned long size,\n \t\tfree(buf);\n }\n \n-static int resolve_against_held(unsigned nr, const unsigned char *base,\n+static int resolve_against_held(unsigned nr, const struct object_id *base,\n \t\t\t\tvoid *delta_data, unsigned long delta_size)\n {\n \tstruct object *obj;\n \tstruct obj_buffer *obj_buffer;\n-\tobj = lookup_object(base);\n+\tobj = lookup_object(base->hash);\n \tif (!obj)\n \t\treturn 0;\n \tobj_buffer = lookup_object_buffer(obj);\n@@ -341,25 +341,25 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n {\n \tvoid *delta_data, *base;\n \tunsigned long base_size;\n-\tunsigned char base_sha1[20];\n+\tstruct object_id base_oid;\n \n \tif (type == OBJ_REF_DELTA) {\n-\t\thashcpy(base_sha1, fill(20));\n-\t\tuse(20);\n+\t\thashcpy(base_oid.hash, fill(GIT_SHA1_RAWSZ));\n+\t\tuse(GIT_SHA1_RAWSZ);\n \t\tdelta_data = get_data(delta_size);\n \t\tif (dry_run || !delta_data) {\n \t\t\tfree(delta_data);\n \t\t\treturn;\n \t\t}\n-\t\tif (has_sha1_file(base_sha1))\n+\t\tif (has_object_file(&base_oid))\n \t\t\t; /* Ok we have this one */\n-\t\telse if (resolve_against_held(nr, base_sha1,\n+\t\telse if (resolve_against_held(nr, &base_oid,\n \t\t\t\t\t      delta_data, delta_size))\n \t\t\treturn; /* we are done */\n \t\telse {\n \t\t\t/* cannot resolve yet --- queue it */\n-\t\t\thashclr(obj_list[nr].sha1);\n-\t\t\tadd_delta_to_list(nr, base_sha1, 0, delta_data, delta_size);\n+\t\t\toidclr(&obj_list[nr].oid);\n+\t\t\tadd_delta_to_list(nr, &base_oid, 0, delta_data, delta_size);\n \t\t\treturn;\n \t\t}\n \t} else {\n@@ -399,8 +399,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \t\t\t} else if (base_offset > obj_list[mid].offset) {\n \t\t\t\tlo = mid + 1;\n \t\t\t} else {\n-\t\t\t\thashcpy(base_sha1, obj_list[mid].sha1);\n-\t\t\t\tbase_found = !is_null_sha1(base_sha1);\n+\t\t\t\toidcpy(&base_oid, &obj_list[mid].oid);\n+\t\t\t\tbase_found = !is_null_oid(&base_oid);\n \t\t\t\tbreak;\n \t\t\t}\n \t\t}\n@@ -409,19 +409,19 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \t\t\t * The delta base object is itself a delta that\n \t\t\t * has not been resolved yet.\n \t\t\t */\n-\t\t\thashclr(obj_list[nr].sha1);\n-\t\t\tadd_delta_to_list(nr, null_sha1, base_offset, delta_data, delta_size);\n+\t\t\toidclr(&obj_list[nr].oid);\n+\t\t\tadd_delta_to_list(nr, &null_oid, base_offset, delta_data, delta_size);\n \t\t\treturn;\n \t\t}\n \t}\n \n-\tif (resolve_against_held(nr, base_sha1, delta_data, delta_size))\n+\tif (resolve_against_held(nr, &base_oid, delta_data, delta_size))\n \t\treturn;\n \n-\tbase = read_sha1_file(base_sha1, &type, &base_size);\n+\tbase = read_sha1_file(base_oid.hash, &type, &base_size);\n \tif (!base) {\n \t\terror(\"failed to read delta-pack base object %s\",\n-\t\t      sha1_to_hex(base_sha1));\n+\t\t      oid_to_hex(&base_oid));\n \t\tif (!recover)\n \t\t\texit(1);\n \t\thas_errors = 1;\n@@ -505,7 +505,7 @@ static void unpack_all(void)\n int cmd_unpack_objects(int argc, const char **argv, const char *prefix)\n {\n \tint i;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \n \tcheck_replace_refs = 0;\n \n@@ -566,12 +566,12 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)\n \tgit_SHA1_Init(&ctx);\n \tunpack_all();\n \tgit_SHA1_Update(&ctx, buffer, offset);\n-\tgit_SHA1_Final(sha1, &ctx);\n+\tgit_SHA1_Final(oid.hash, &ctx);\n \tif (strict)\n \t\twrite_rest();\n-\tif (hashcmp(fill(20), sha1))\n+\tif (hashcmp(fill(GIT_SHA1_RAWSZ), oid.hash))\n \t\tdie(\"final sha1 did not match\");\n-\tuse(20);\n+\tuse(GIT_SHA1_RAWSZ);\n \n \t/* Write the last part of the buffer to stdout */\n \twhile (len) {\n"},{"id":"317595","messageId":"20170423213453.253425-29-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 28/53] Convert remaining callers of lookup_blob to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:28Z","receivedAt":"2017-04-23T21:37:07Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"All but a few callers of lookup_blob have been converted to struct\nobject_id.  Introduce a temporary, which will be removed later, into\nparse_object to ease the transition, and convert the remaining callers\nso that we can update lookup_blob to take struct object_id *.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/index-pack.c | 28 ++++++++++++++--------------\n builtin/merge-tree.c | 10 +++++-----\n object.c             |  9 ++++++---\n 3 files changed, 25 insertions(+), 22 deletions(-)\n\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex fef0025e4..2241ee68e 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -785,7 +785,7 @@ static int check_collison(struct object_entry *entry)\n \n static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\t\tunsigned long size, enum object_type type,\n-\t\t\tconst unsigned char *sha1)\n+\t\t\tconst struct object_id *oid)\n {\n \tvoid *new_data = NULL;\n \tint collision_test_needed = 0;\n@@ -794,7 +794,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \n \tif (startup_info->have_repository) {\n \t\tread_lock();\n-\t\tcollision_test_needed = has_sha1_file_with_flags(sha1, HAS_SHA1_QUICK);\n+\t\tcollision_test_needed = has_sha1_file_with_flags(oid->hash, HAS_SHA1_QUICK);\n \t\tread_unlock();\n \t}\n \n@@ -809,31 +809,31 @@ 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(sha1, &has_size);\n+\t\thas_type = sha1_object_info(oid->hash, &has_size);\n \t\tif (has_type < 0)\n-\t\t\tdie(_(\"cannot read existing object info %s\"), sha1_to_hex(sha1));\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 !\"), sha1_to_hex(sha1));\n-\t\thas_data = read_sha1_file(sha1, &has_type, &has_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\tread_unlock();\n \t\tif (!data)\n \t\t\tdata = new_data = get_data_from_pack(obj_entry);\n \t\tif (!has_data)\n-\t\t\tdie(_(\"cannot read existing object %s\"), sha1_to_hex(sha1));\n+\t\t\tdie(_(\"cannot read existing object %s\"), oid_to_hex(oid));\n \t\tif (size != has_size || type != has_type ||\n \t\t    memcmp(data, has_data, size) != 0)\n-\t\t\tdie(_(\"SHA1 COLLISION FOUND WITH %s !\"), sha1_to_hex(sha1));\n+\t\t\tdie(_(\"SHA1 COLLISION FOUND WITH %s !\"), oid_to_hex(oid));\n \t\tfree(has_data);\n \t}\n \n \tif (strict) {\n \t\tread_lock();\n \t\tif (type == OBJ_BLOB) {\n-\t\t\tstruct blob *blob = lookup_blob(sha1);\n+\t\t\tstruct blob *blob = lookup_blob(oid->hash);\n \t\t\tif (blob)\n \t\t\t\tblob->object.flags |= FLAG_CHECKED;\n \t\t\telse\n-\t\t\t\tdie(_(\"invalid blob object %s\"), sha1_to_hex(sha1));\n+\t\t\t\tdie(_(\"invalid blob object %s\"), oid_to_hex(oid));\n \t\t} else {\n \t\t\tstruct object *obj;\n \t\t\tint eaten;\n@@ -845,7 +845,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\t\t * we do not need to free the memory here, as the\n \t\t\t * buf is deleted by the caller.\n \t\t\t */\n-\t\t\tobj = parse_object_buffer(sha1, type, size, buf, &eaten);\n+\t\t\tobj = parse_object_buffer(oid->hash, type, size, buf, &eaten);\n \t\t\tif (!obj)\n \t\t\t\tdie(_(\"invalid %s\"), typename(type));\n \t\t\tif (do_fsck_object &&\n@@ -960,7 +960,7 @@ static void resolve_delta(struct object_entry *delta_obj,\n \t\t       typename(delta_obj->real_type),\n \t\t       delta_obj->idx.oid.hash);\n \tsha1_object(result->data, NULL, result->size, delta_obj->real_type,\n-\t\t    delta_obj->idx.oid.hash);\n+\t\t    &delta_obj->idx.oid);\n \tcounter_lock();\n \tnr_resolved_deltas++;\n \tcounter_unlock();\n@@ -1149,7 +1149,7 @@ static void parse_pack_objects(unsigned char *sha1)\n \t\t\tnr_delays++;\n \t\t} else\n \t\t\tsha1_object(data, NULL, obj->size, obj->type,\n-\t\t\t\t    obj->idx.oid.hash);\n+\t\t\t\t    &obj->idx.oid);\n \t\tfree(data);\n \t\tdisplay_progress(progress, i+1);\n \t}\n@@ -1176,7 +1176,7 @@ static void parse_pack_objects(unsigned char *sha1)\n \t\t\tcontinue;\n \t\tobj->real_type = obj->type;\n \t\tsha1_object(NULL, obj, obj->size, obj->type,\n-\t\t\t    obj->idx.oid.hash);\n+\t\t\t    &obj->idx.oid);\n \t\tnr_delays--;\n \t}\n \tif (nr_delays)\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 5b7ab9b96..cdeb6562d 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -161,14 +161,14 @@ static int both_empty(struct name_entry *a, struct name_entry *b)\n \treturn !(a->oid || b->oid);\n }\n \n-static struct merge_list *create_entry(unsigned stage, unsigned mode, const unsigned char *sha1, const char *path)\n+static struct merge_list *create_entry(unsigned stage, unsigned mode, const struct object_id *oid, const char *path)\n {\n \tstruct merge_list *res = xcalloc(1, sizeof(*res));\n \n \tres->stage = stage;\n \tres->path = path;\n \tres->mode = mode;\n-\tres->blob = lookup_blob(sha1);\n+\tres->blob = lookup_blob(oid->hash);\n \treturn res;\n }\n \n@@ -188,8 +188,8 @@ static void resolve(const struct traverse_info *info, struct name_entry *ours, s\n \t\treturn;\n \n \tpath = traverse_path(info, result);\n-\torig = create_entry(2, ours->mode, ours->oid->hash, path);\n-\tfinal = create_entry(0, result->mode, result->oid->hash, path);\n+\torig = create_entry(2, ours->mode, ours->oid, path);\n+\tfinal = create_entry(0, result->mode, result->oid, path);\n \n \tfinal->link = orig;\n \n@@ -239,7 +239,7 @@ static struct merge_list *link_entry(unsigned stage, const struct traverse_info\n \t\tpath = entry->path;\n \telse\n \t\tpath = traverse_path(info, n);\n-\tlink = create_entry(stage, n->mode, n->oid->hash, path);\n+\tlink = create_entry(stage, n->mode, n->oid, path);\n \tlink->link = entry;\n \treturn link;\n }\ndiff --git a/object.c b/object.c\nindex fe2222356..0208c407a 100644\n--- a/object.c\n+++ b/object.c\n@@ -190,7 +190,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t\n \n \tobj = NULL;\n \tif (type == OBJ_BLOB) {\n-\t\tstruct blob *blob = lookup_blob(sha1);\n+\t\tstruct blob *blob = lookup_blob(oid.hash);\n \t\tif (blob) {\n \t\t\tif (parse_blob_buffer(blob, buffer, size))\n \t\t\t\treturn NULL;\n@@ -251,8 +251,11 @@ struct object *parse_object(const unsigned char *sha1)\n \tconst unsigned char *repl = lookup_replace_object(sha1);\n \tvoid *buffer;\n \tstruct object *obj;\n+\tstruct object_id oid;\n \n-\tobj = lookup_object(sha1);\n+\thashcpy(oid.hash, sha1);\n+\n+\tobj = lookup_object(oid.hash);\n \tif (obj && obj->parsed)\n \t\treturn obj;\n \n@@ -263,7 +266,7 @@ struct object *parse_object(const unsigned char *sha1)\n \t\t\terror(\"sha1 mismatch %s\", sha1_to_hex(repl));\n \t\t\treturn NULL;\n \t\t}\n-\t\tparse_blob_buffer(lookup_blob(sha1), NULL, 0);\n+\t\tparse_blob_buffer(lookup_blob(oid.hash), NULL, 0);\n \t\treturn lookup_object(sha1);\n \t}\n \n"},{"id":"317596","messageId":"20170423213453.253425-30-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 29/53] Convert lookup_blob to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:29Z","receivedAt":"2017-04-23T21:37:12Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert lookup_blob to take a pointer to struct object_id.\n\nThe commit was created with manual changes to blob.c and blob.h, plus\nthe following semantic patch:\n\n@@\nexpression E1;\n@@\n- lookup_blob(E1.hash)\n+ lookup_blob(&E1)\n\n@@\nexpression E1;\n@@\n- lookup_blob(E1->hash)\n+ lookup_blob(E1)\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n blob.c                   | 6 +++---\n blob.h                   | 2 +-\n builtin/fast-export.c    | 2 +-\n builtin/fsck.c           | 2 +-\n builtin/index-pack.c     | 2 +-\n builtin/merge-tree.c     | 2 +-\n builtin/unpack-objects.c | 2 +-\n fsck.c                   | 2 +-\n http-push.c              | 2 +-\n list-objects.c           | 2 +-\n object.c                 | 4 ++--\n reachable.c              | 2 +-\n revision.c               | 4 ++--\n tag.c                    | 2 +-\n walker.c                 | 2 +-\n 15 files changed, 19 insertions(+), 19 deletions(-)\n\ndiff --git a/blob.c b/blob.c\nindex 1fcb8e44b..fa2ab4f7a 100644\n--- a/blob.c\n+++ b/blob.c\n@@ -3,11 +3,11 @@\n \n const char *blob_type = \"blob\";\n \n-struct blob *lookup_blob(const unsigned char *sha1)\n+struct blob *lookup_blob(const struct object_id *oid)\n {\n-\tstruct object *obj = lookup_object(sha1);\n+\tstruct object *obj = lookup_object(oid->hash);\n \tif (!obj)\n-\t\treturn create_object(sha1, alloc_blob_node());\n+\t\treturn create_object(oid->hash, alloc_blob_node());\n \treturn object_as_type(obj, OBJ_BLOB, 0);\n }\n \ndiff --git a/blob.h b/blob.h\nindex 59b394eea..446061683 100644\n--- a/blob.h\n+++ b/blob.h\n@@ -9,7 +9,7 @@ struct blob {\n \tstruct object object;\n };\n \n-struct blob *lookup_blob(const unsigned char *sha1);\n+struct blob *lookup_blob(const struct object_id *oid);\n \n int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);\n \ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex b4521cb62..ae36b14db 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -232,7 +232,7 @@ static void export_blob(const struct object_id *oid)\n \n \tif (anonymize) {\n \t\tbuf = anonymize_blob(&size);\n-\t\tobject = (struct object *)lookup_blob(oid->hash);\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);\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 543122f04..14a216ee6 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -780,7 +780,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)\n \t\t\tmode = active_cache[i]->ce_mode;\n \t\t\tif (S_ISGITLINK(mode))\n \t\t\t\tcontinue;\n-\t\t\tblob = lookup_blob(active_cache[i]->oid.hash);\n+\t\t\tblob = lookup_blob(&active_cache[i]->oid);\n \t\t\tif (!blob)\n \t\t\t\tcontinue;\n \t\t\tobj = &blob->object;\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 2241ee68e..b75133f62 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -829,7 +829,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \tif (strict) {\n \t\tread_lock();\n \t\tif (type == OBJ_BLOB) {\n-\t\t\tstruct blob *blob = lookup_blob(oid->hash);\n+\t\t\tstruct blob *blob = lookup_blob(oid);\n \t\t\tif (blob)\n \t\t\t\tblob->object.flags |= FLAG_CHECKED;\n \t\t\telse\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex cdeb6562d..bad6735c7 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -168,7 +168,7 @@ static struct merge_list *create_entry(unsigned stage, unsigned mode, const stru\n \tres->stage = stage;\n \tres->path = path;\n \tres->mode = mode;\n-\tres->blob = lookup_blob(oid->hash);\n+\tres->blob = lookup_blob(oid);\n \treturn res;\n }\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 3dc5e5691..7d5efa2b3 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -249,7 +249,7 @@ static void write_object(unsigned nr, enum object_type type,\n \t\tadded_object(nr, type, buf, size);\n \t\tfree(buf);\n \n-\t\tblob = lookup_blob(obj_list[nr].oid.hash);\n+\t\tblob = lookup_blob(&obj_list[nr].oid);\n \t\tif (blob)\n \t\t\tblob->object.flags |= FLAG_WRITTEN;\n \t\telse\ndiff --git a/fsck.c b/fsck.c\nindex e6152e4e6..ab3016c0e 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -365,7 +365,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op\n \t\t\tresult = options->walk(obj, OBJ_TREE, data, options);\n \t\t}\n \t\telse if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) {\n-\t\t\tobj = &lookup_blob(entry.oid->hash)->object;\n+\t\t\tobj = &lookup_blob(entry.oid)->object;\n \t\t\tif (name)\n \t\t\t\tput_object_name(options, obj, \"%s%s\", name,\n \t\t\t\t\tentry.path);\ndiff --git a/http-push.c b/http-push.c\nindex 04568e4fb..9bb5e0648 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1315,7 +1315,7 @@ static struct object_list **process_tree(struct tree *tree,\n \t\t\tp = process_tree(lookup_tree(entry.oid->hash), p);\n \t\t\tbreak;\n \t\tcase OBJ_BLOB:\n-\t\t\tp = process_blob(lookup_blob(entry.oid->hash), p);\n+\t\t\tp = process_blob(lookup_blob(entry.oid), p);\n \t\t\tbreak;\n \t\tdefault:\n \t\t\t/* Subproject commit - not in this repository */\ndiff --git a/list-objects.c b/list-objects.c\nindex f3ca6aafb..721e5fb08 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -119,7 +119,7 @@ static void process_tree(struct rev_info *revs,\n \t\t\t\t\tcb_data);\n \t\telse\n \t\t\tprocess_blob(revs,\n-\t\t\t\t     lookup_blob(entry.oid->hash),\n+\t\t\t\t     lookup_blob(entry.oid),\n \t\t\t\t     show, base, entry.path,\n \t\t\t\t     cb_data);\n \t}\ndiff --git a/object.c b/object.c\nindex 0208c407a..2c8d1e5d3 100644\n--- a/object.c\n+++ b/object.c\n@@ -190,7 +190,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t\n \n \tobj = NULL;\n \tif (type == OBJ_BLOB) {\n-\t\tstruct blob *blob = lookup_blob(oid.hash);\n+\t\tstruct blob *blob = lookup_blob(&oid);\n \t\tif (blob) {\n \t\t\tif (parse_blob_buffer(blob, buffer, size))\n \t\t\t\treturn NULL;\n@@ -266,7 +266,7 @@ struct object *parse_object(const unsigned char *sha1)\n \t\t\terror(\"sha1 mismatch %s\", sha1_to_hex(repl));\n \t\t\treturn NULL;\n \t\t}\n-\t\tparse_blob_buffer(lookup_blob(oid.hash), NULL, 0);\n+\t\tparse_blob_buffer(lookup_blob(&oid), NULL, 0);\n \t\treturn lookup_object(sha1);\n \t}\n \ndiff --git a/reachable.c b/reachable.c\nindex a8a979bd4..8ea0bdd7c 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -88,7 +88,7 @@ static void add_recent_object(const struct object_id *oid,\n \t\tobj = (struct object *)lookup_tree(oid->hash);\n \t\tbreak;\n \tcase OBJ_BLOB:\n-\t\tobj = (struct object *)lookup_blob(oid->hash);\n+\t\tobj = (struct object *)lookup_blob(oid);\n \t\tbreak;\n \tdefault:\n \t\tdie(\"unknown object type for %s: %s\",\ndiff --git a/revision.c b/revision.c\nindex f8e0dee6d..db2de7a7a 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -62,7 +62,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree)\n \t\t\tmark_tree_uninteresting(lookup_tree(entry.oid->hash));\n \t\t\tbreak;\n \t\tcase OBJ_BLOB:\n-\t\t\tmark_blob_uninteresting(lookup_blob(entry.oid->hash));\n+\t\t\tmark_blob_uninteresting(lookup_blob(entry.oid));\n \t\t\tbreak;\n \t\tdefault:\n \t\t\t/* Subproject commit - not in this repository */\n@@ -1275,7 +1275,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)\n \t\tif (S_ISGITLINK(ce->ce_mode))\n \t\t\tcontinue;\n \n-\t\tblob = lookup_blob(ce->oid.hash);\n+\t\tblob = lookup_blob(&ce->oid);\n \t\tif (!blob)\n \t\t\tdie(\"unable to add index blob to traversal\");\n \t\tadd_pending_object_with_path(revs, &blob->object, \"\",\ndiff --git a/tag.c b/tag.c\nindex 79b78d358..dff251673 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -142,7 +142,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n \tbufptr = nl + 1;\n \n \tif (!strcmp(type, blob_type)) {\n-\t\titem->tagged = &lookup_blob(oid.hash)->object;\n+\t\titem->tagged = &lookup_blob(&oid)->object;\n \t} else if (!strcmp(type, tree_type)) {\n \t\titem->tagged = &lookup_tree(oid.hash)->object;\n \t} else if (!strcmp(type, commit_type)) {\ndiff --git a/walker.c b/walker.c\nindex b499fcb72..3d6029c8e 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -52,7 +52,7 @@ static int process_tree(struct walker *walker, struct tree *tree)\n \t\t\t\tobj = &tree->object;\n \t\t}\n \t\telse {\n-\t\t\tstruct blob *blob = lookup_blob(entry.oid->hash);\n+\t\t\tstruct blob *blob = lookup_blob(entry.oid);\n \t\t\tif (blob)\n \t\t\t\tobj = &blob->object;\n \t\t}\n"},{"id":"317597","messageId":"20170423213453.253425-31-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 30/53] tree: convert read_tree_1 to use struct object_id internally","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:30Z","receivedAt":"2017-04-23T21:37:16Z","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 tree.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/tree.c b/tree.c\nindex 33fa7ee71..21fd80b80 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -58,7 +58,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,\n {\n \tstruct tree_desc desc;\n \tstruct name_entry entry;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tint len, oldlen = base->len;\n \tenum interesting retval = entry_not_interesting;\n \n@@ -87,7 +87,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,\n \t\t}\n \n \t\tif (S_ISDIR(entry.mode))\n-\t\t\thashcpy(sha1, entry.oid->hash);\n+\t\t\toidcpy(&oid, entry.oid);\n \t\telse if (S_ISGITLINK(entry.mode)) {\n \t\t\tstruct commit *commit;\n \n@@ -102,7 +102,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,\n \t\t\t\t    oid_to_hex(entry.oid),\n \t\t\t\t    base->buf, entry.path);\n \n-\t\t\thashcpy(sha1, commit->tree->object.oid.hash);\n+\t\t\toidcpy(&oid, &commit->tree->object.oid);\n \t\t}\n \t\telse\n \t\t\tcontinue;\n@@ -110,7 +110,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,\n \t\tlen = tree_entry_len(&entry);\n \t\tstrbuf_add(base, entry.path, len);\n \t\tstrbuf_addch(base, '/');\n-\t\tretval = read_tree_1(lookup_tree(sha1),\n+\t\tretval = read_tree_1(lookup_tree(oid.hash),\n \t\t\t\t     base, stage, pathspec,\n \t\t\t\t     fn, context);\n \t\tstrbuf_setlen(base, oldlen);\n"},{"id":"317598","messageId":"20170423213453.253425-32-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 31/53] builtin/reflog: convert tree_is_complete to take struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:31Z","receivedAt":"2017-04-23T21:37:19Z","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/reflog.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 4831116ea..7866a0341 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -55,14 +55,14 @@ struct collect_reflog_cb {\n #define STUDYING\t(1u<<11)\n #define REACHABLE\t(1u<<12)\n \n-static int tree_is_complete(const unsigned char *sha1)\n+static int tree_is_complete(const struct object_id *oid)\n {\n \tstruct tree_desc desc;\n \tstruct name_entry entry;\n \tint complete;\n \tstruct tree *tree;\n \n-\ttree = lookup_tree(sha1);\n+\ttree = lookup_tree(oid->hash);\n \tif (!tree)\n \t\treturn 0;\n \tif (tree->object.flags & SEEN)\n@@ -73,7 +73,7 @@ static int tree_is_complete(const unsigned char *sha1)\n \tif (!tree->buffer) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tvoid *data = read_sha1_file(sha1, &type, &size);\n+\t\tvoid *data = read_sha1_file(oid->hash, &type, &size);\n \t\tif (!data) {\n \t\t\ttree->object.flags |= INCOMPLETE;\n \t\t\treturn 0;\n@@ -85,7 +85,7 @@ static int tree_is_complete(const unsigned char *sha1)\n \tcomplete = 1;\n \twhile (tree_entry(&desc, &entry)) {\n \t\tif (!has_sha1_file(entry.oid->hash) ||\n-\t\t    (S_ISDIR(entry.mode) && !tree_is_complete(entry.oid->hash))) {\n+\t\t    (S_ISDIR(entry.mode) && !tree_is_complete(entry.oid))) {\n \t\t\ttree->object.flags |= INCOMPLETE;\n \t\t\tcomplete = 0;\n \t\t}\n@@ -152,7 +152,7 @@ static int commit_is_complete(struct commit *commit)\n \t\tfor (i = 0; i < found.nr; i++) {\n \t\t\tstruct commit *c =\n \t\t\t\t(struct commit *)found.objects[i].item;\n-\t\t\tif (!tree_is_complete(c->tree->object.oid.hash)) {\n+\t\t\tif (!tree_is_complete(&c->tree->object.oid)) {\n \t\t\t\tis_incomplete = 1;\n \t\t\t\tc->object.flags |= INCOMPLETE;\n \t\t\t}\n"},{"id":"317599","messageId":"20170423213453.253425-35-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 34/53] Convert lookup_tag to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:34Z","receivedAt":"2017-04-23T21:37:23Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert lookup_tag to take a pointer to struct object_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/describe.c     | 6 +++---\n builtin/pack-objects.c | 2 +-\n builtin/replace.c      | 2 +-\n log-tree.c             | 2 +-\n object.c               | 2 +-\n sha1_name.c            | 2 +-\n tag.c                  | 8 ++++----\n tag.h                  | 2 +-\n 8 files changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex f6032f593..893c8789f 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -79,13 +79,13 @@ static int replace_name(struct commit_name *e,\n \t\tstruct tag *t;\n \n \t\tif (!e->tag) {\n-\t\t\tt = lookup_tag(e->oid.hash);\n+\t\t\tt = lookup_tag(&e->oid);\n \t\t\tif (!t || parse_tag(t))\n \t\t\t\treturn 1;\n \t\t\te->tag = t;\n \t\t}\n \n-\t\tt = lookup_tag(oid->hash);\n+\t\tt = lookup_tag(oid);\n \t\tif (!t || parse_tag(t))\n \t\t\treturn 0;\n \t\t*tag = t;\n@@ -245,7 +245,7 @@ static unsigned long finish_depth_computation(\n static void display_name(struct commit_name *n)\n {\n \tif (n->prio == 2 && !n->tag) {\n-\t\tn->tag = lookup_tag(n->oid.hash);\n+\t\tn->tag = lookup_tag(&n->oid);\n \t\tif (!n->tag || parse_tag(n->tag))\n \t\t\tdie(_(\"annotated tag %s not available\"), n->path);\n \t}\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex d76ff0542..7cebb5a7f 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2348,7 +2348,7 @@ static void add_tag_chain(const struct object_id *oid)\n \tif (packlist_find(&to_pack, oid->hash, NULL))\n \t\treturn;\n \n-\ttag = lookup_tag(oid->hash);\n+\ttag = lookup_tag(oid);\n \twhile (1) {\n \t\tif (!tag || parse_tag(tag) || !tag->tagged)\n \t\t\tdie(\"unable to pack objects reachable from tag %s\",\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex e2ea3d47b..205510b5b 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -354,7 +354,7 @@ static void check_one_mergetag(struct commit *commit,\n \tint i;\n \n \thash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), tag_oid.hash);\n-\ttag = lookup_tag(tag_oid.hash);\n+\ttag = lookup_tag(&tag_oid);\n \tif (!tag)\n \t\tdie(_(\"bad mergetag in commit '%s'\"), ref);\n \tif (parse_tag_buffer(tag, extra->value, extra->len))\ndiff --git a/log-tree.c b/log-tree.c\nindex 169fd039f..6532c892c 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -488,7 +488,7 @@ static void show_one_mergetag(struct commit *commit,\n \tsize_t payload_size, gpg_message_offset;\n \n \thash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), oid.hash);\n-\ttag = lookup_tag(oid.hash);\n+\ttag = lookup_tag(&oid);\n \tif (!tag)\n \t\treturn; /* error message already given */\n \ndiff --git a/object.c b/object.c\nindex d23c5fad3..dd4d3a1ea 100644\n--- a/object.c\n+++ b/object.c\n@@ -220,7 +220,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t\n \t\t\tobj = &commit->object;\n \t\t}\n \t} else if (type == OBJ_TAG) {\n-\t\tstruct tag *tag = lookup_tag(sha1);\n+\t\tstruct tag *tag = lookup_tag(&oid);\n \t\tif (tag) {\n \t\t\tif (parse_tag_buffer(tag, buffer, size))\n \t\t\t       return NULL;\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 390a09c41..b7e09ac13 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -361,7 +361,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \t\t\tformat_commit_message(commit, \" %ad - %s\", &desc, &pp);\n \t\t}\n \t} else if (type == OBJ_TAG) {\n-\t\tstruct tag *tag = lookup_tag(oid->hash);\n+\t\tstruct tag *tag = lookup_tag(oid);\n \t\tif (!parse_tag(tag) && tag->tag)\n \t\t\tstrbuf_addf(&desc, \" %s\", tag->tag);\n \t}\ndiff --git a/tag.c b/tag.c\nindex 062516b40..571798519 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -89,11 +89,11 @@ struct object *deref_tag_noverify(struct object *o)\n \treturn o;\n }\n \n-struct tag *lookup_tag(const unsigned char *sha1)\n+struct tag *lookup_tag(const struct object_id *oid)\n {\n-\tstruct object *obj = lookup_object(sha1);\n+\tstruct object *obj = lookup_object(oid->hash);\n \tif (!obj)\n-\t\treturn create_object(sha1, alloc_tag_node());\n+\t\treturn create_object(oid->hash, alloc_tag_node());\n \treturn object_as_type(obj, OBJ_TAG, 0);\n }\n \n@@ -148,7 +148,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n \t} else if (!strcmp(type, commit_type)) {\n \t\titem->tagged = &lookup_commit(&oid)->object;\n \t} else if (!strcmp(type, tag_type)) {\n-\t\titem->tagged = &lookup_tag(oid.hash)->object;\n+\t\titem->tagged = &lookup_tag(&oid)->object;\n \t} else {\n \t\terror(\"Unknown type %s\", type);\n \t\titem->tagged = NULL;\ndiff --git a/tag.h b/tag.h\nindex a5721b673..8d6fc2814 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -12,7 +12,7 @@ struct tag {\n \tunsigned long date;\n };\n \n-extern struct tag *lookup_tag(const unsigned char *sha1);\n+extern struct tag *lookup_tag(const struct object_id *oid);\n extern int parse_tag_buffer(struct tag *item, const void *data, unsigned long size);\n extern int parse_tag(struct tag *item);\n extern struct object *deref_tag(struct object *, const char *, int);\n"},{"id":"317600","messageId":"20170423213453.253425-33-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 32/53] Convert lookup_tree to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:32Z","receivedAt":"2017-04-23T21:37:26Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the lookup_tree function to take a pointer to struct object_id.\n\nThe commit was created with manual changes to tree.c, tree.h, and\nobject.c, plus the following semantic patch:\n\n@@\n@@\n- lookup_tree(EMPTY_TREE_SHA1_BIN)\n+ lookup_tree(&empty_tree_oid)\n\n@@\nexpression E1;\n@@\n- lookup_tree(E1.hash)\n+ lookup_tree(&E1)\n\n@@\nexpression E1;\n@@\n- lookup_tree(E1->hash)\n+ lookup_tree(E1)\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/am.c        | 4 ++--\n builtin/diff-tree.c | 2 +-\n builtin/diff.c      | 2 +-\n builtin/reflog.c    | 2 +-\n cache-tree.c        | 2 +-\n commit.c            | 2 +-\n fsck.c              | 2 +-\n http-push.c         | 2 +-\n list-objects.c      | 2 +-\n merge-recursive.c   | 6 +++---\n object.c            | 2 +-\n reachable.c         | 2 +-\n revision.c          | 4 ++--\n sequencer.c         | 2 +-\n tag.c               | 2 +-\n tree.c              | 8 ++++----\n tree.h              | 2 +-\n walker.c            | 2 +-\n 18 files changed, 25 insertions(+), 25 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex a0979fab2..e12da7b3f 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1457,9 +1457,9 @@ static void write_index_patch(const struct am_state *state)\n \tFILE *fp;\n \n \tif (!get_sha1_tree(\"HEAD\", head.hash))\n-\t\ttree = lookup_tree(head.hash);\n+\t\ttree = lookup_tree(&head);\n \telse\n-\t\ttree = lookup_tree(EMPTY_TREE_SHA1_BIN);\n+\t\ttree = lookup_tree(&empty_tree_oid);\n \n \tfp = xfopen(am_path(state, \"patch\"), \"w\");\n \tinit_revisions(&rev_info, NULL);\ndiff --git a/builtin/diff-tree.c b/builtin/diff-tree.c\nindex e85a449df..95b8d1ba7 100644\n--- a/builtin/diff-tree.c\n+++ b/builtin/diff-tree.c\n@@ -44,7 +44,7 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)\n \tstruct tree *tree2;\n \tif (!isspace(*p++) || parse_oid_hex(p, &oid, &p) || *p)\n \t\treturn error(\"Need exactly two trees, separated by a space\");\n-\ttree2 = lookup_tree(oid.hash);\n+\ttree2 = lookup_tree(&oid);\n \tif (!tree2 || parse_tree(tree2))\n \t\treturn -1;\n \tprintf(\"%s %s\\n\", oid_to_hex(&tree1->object.oid),\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex a25b4e4ae..895f92897 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -381,7 +381,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\t\t\tadd_head_to_pending(&rev);\n \t\t\t\tif (!rev.pending.nr) {\n \t\t\t\t\tstruct tree *tree;\n-\t\t\t\t\ttree = lookup_tree(EMPTY_TREE_SHA1_BIN);\n+\t\t\t\t\ttree = lookup_tree(&empty_tree_oid);\n \t\t\t\t\tadd_pending_object(&rev, &tree->object, \"HEAD\");\n \t\t\t\t}\n \t\t\t\tbreak;\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 7866a0341..7e89e84dc 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -62,7 +62,7 @@ static int tree_is_complete(const struct object_id *oid)\n \tint complete;\n \tstruct tree *tree;\n \n-\ttree = lookup_tree(oid->hash);\n+\ttree = lookup_tree(oid);\n \tif (!tree)\n \t\treturn 0;\n \tif (tree->object.flags & SEEN)\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 35d507ed7..489241021 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -672,7 +672,7 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)\n \t\t\tcnt++;\n \t\telse {\n \t\t\tstruct cache_tree_sub *sub;\n-\t\t\tstruct tree *subtree = lookup_tree(entry.oid->hash);\n+\t\t\tstruct tree *subtree = lookup_tree(entry.oid);\n \t\t\tif (!subtree->object.parsed)\n \t\t\t\tparse_tree(subtree);\n \t\t\tsub = cache_tree_sub(it, entry.path);\ndiff --git a/commit.c b/commit.c\nindex 0f6c9b6bf..8004008bc 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -331,7 +331,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s\n \tif (get_sha1_hex(bufptr + 5, parent.hash) < 0)\n \t\treturn error(\"bad tree pointer in commit %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\n-\titem->tree = lookup_tree(parent.hash);\n+\titem->tree = lookup_tree(&parent);\n \tbufptr += tree_entry_len + 1; /* \"tree \" + \"hex sha1\" + \"\\n\" */\n \tpptr = &item->parents;\n \ndiff --git a/fsck.c b/fsck.c\nindex ab3016c0e..ee5224aea 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -358,7 +358,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op\n \t\t\tcontinue;\n \n \t\tif (S_ISDIR(entry.mode)) {\n-\t\t\tobj = &lookup_tree(entry.oid->hash)->object;\n+\t\t\tobj = &lookup_tree(entry.oid)->object;\n \t\t\tif (name)\n \t\t\t\tput_object_name(options, obj, \"%s%s/\", name,\n \t\t\t\t\tentry.path);\ndiff --git a/http-push.c b/http-push.c\nindex 9bb5e0648..7781f4078 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1312,7 +1312,7 @@ static struct object_list **process_tree(struct tree *tree,\n \twhile (tree_entry(&desc, &entry))\n \t\tswitch (object_type(entry.mode)) {\n \t\tcase OBJ_TREE:\n-\t\t\tp = process_tree(lookup_tree(entry.oid->hash), p);\n+\t\t\tp = process_tree(lookup_tree(entry.oid), p);\n \t\t\tbreak;\n \t\tcase OBJ_BLOB:\n \t\t\tp = process_blob(lookup_blob(entry.oid), p);\ndiff --git a/list-objects.c b/list-objects.c\nindex 721e5fb08..b3931fa43 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -110,7 +110,7 @@ static void process_tree(struct rev_info *revs,\n \n \t\tif (S_ISDIR(entry.mode))\n \t\t\tprocess_tree(revs,\n-\t\t\t\t     lookup_tree(entry.oid->hash),\n+\t\t\t\t     lookup_tree(entry.oid),\n \t\t\t\t     show, base, entry.path,\n \t\t\t\t     cb_data);\n \t\telse if (S_ISGITLINK(entry.mode))\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 1315a45b9..92e0a63dc 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -67,7 +67,7 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two,\n \t}\n \tif (!oidcmp(&two->object.oid, &shifted))\n \t\treturn two;\n-\treturn lookup_tree(shifted.hash);\n+\treturn lookup_tree(&shifted);\n }\n \n static struct commit *make_virtual_commit(struct tree *tree, const char *comment)\n@@ -304,7 +304,7 @@ struct tree *write_tree_from_memory(struct merge_options *o)\n \t\treturn NULL;\n \t}\n \n-\tresult = lookup_tree(active_cache_tree->oid.hash);\n+\tresult = lookup_tree(&active_cache_tree->oid);\n \n \treturn result;\n }\n@@ -2042,7 +2042,7 @@ int merge_recursive(struct merge_options *o,\n \t\t/* if there is no common ancestor, use an empty tree */\n \t\tstruct tree *tree;\n \n-\t\ttree = lookup_tree(EMPTY_TREE_SHA1_BIN);\n+\t\ttree = lookup_tree(&empty_tree_oid);\n \t\tmerged_common_ancestors = make_virtual_commit(tree, \"ancestor\");\n \t}\n \ndiff --git a/object.c b/object.c\nindex 2c8d1e5d3..d23c5fad3 100644\n--- a/object.c\n+++ b/object.c\n@@ -197,7 +197,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t\n \t\t\tobj = &blob->object;\n \t\t}\n \t} else if (type == OBJ_TREE) {\n-\t\tstruct tree *tree = lookup_tree(sha1);\n+\t\tstruct tree *tree = lookup_tree(&oid);\n \t\tif (tree) {\n \t\t\tobj = &tree->object;\n \t\t\tif (!tree->buffer)\ndiff --git a/reachable.c b/reachable.c\nindex 8ea0bdd7c..3bbc84417 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -85,7 +85,7 @@ static void add_recent_object(const struct object_id *oid,\n \t\tobj = parse_object_or_die(oid->hash, NULL);\n \t\tbreak;\n \tcase OBJ_TREE:\n-\t\tobj = (struct object *)lookup_tree(oid->hash);\n+\t\tobj = (struct object *)lookup_tree(oid);\n \t\tbreak;\n \tcase OBJ_BLOB:\n \t\tobj = (struct object *)lookup_blob(oid);\ndiff --git a/revision.c b/revision.c\nindex db2de7a7a..c2091b6de 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -59,7 +59,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree)\n \twhile (tree_entry(&desc, &entry)) {\n \t\tswitch (object_type(entry.mode)) {\n \t\tcase OBJ_TREE:\n-\t\t\tmark_tree_uninteresting(lookup_tree(entry.oid->hash));\n+\t\t\tmark_tree_uninteresting(lookup_tree(entry.oid));\n \t\t\tbreak;\n \t\tcase OBJ_BLOB:\n \t\t\tmark_blob_uninteresting(lookup_blob(entry.oid));\n@@ -1249,7 +1249,7 @@ static void add_cache_tree(struct cache_tree *it, struct rev_info *revs,\n \tint i;\n \n \tif (it->entry_count >= 0) {\n-\t\tstruct tree *tree = lookup_tree(it->oid.hash);\n+\t\tstruct tree *tree = lookup_tree(&it->oid);\n \t\tadd_pending_object_with_path(revs, &tree->object, \"\",\n \t\t\t\t\t     040000, path->buf);\n \t}\ndiff --git a/sequencer.c b/sequencer.c\nindex 46e05e385..6957f3b4e 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -344,7 +344,7 @@ static int read_oneliner(struct strbuf *buf,\n \n static struct tree *empty_tree(void)\n {\n-\treturn lookup_tree(EMPTY_TREE_SHA1_BIN);\n+\treturn lookup_tree(&empty_tree_oid);\n }\n \n static int error_dirty_index(struct replay_opts *opts)\ndiff --git a/tag.c b/tag.c\nindex dff251673..062516b40 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -144,7 +144,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n \tif (!strcmp(type, blob_type)) {\n \t\titem->tagged = &lookup_blob(&oid)->object;\n \t} else if (!strcmp(type, tree_type)) {\n-\t\titem->tagged = &lookup_tree(oid.hash)->object;\n+\t\titem->tagged = &lookup_tree(&oid)->object;\n \t} else if (!strcmp(type, commit_type)) {\n \t\titem->tagged = &lookup_commit(&oid)->object;\n \t} else if (!strcmp(type, tag_type)) {\ndiff --git a/tree.c b/tree.c\nindex 21fd80b80..28ce930b9 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -110,7 +110,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,\n \t\tlen = tree_entry_len(&entry);\n \t\tstrbuf_add(base, entry.path, len);\n \t\tstrbuf_addch(base, '/');\n-\t\tretval = read_tree_1(lookup_tree(oid.hash),\n+\t\tretval = read_tree_1(lookup_tree(&oid),\n \t\t\t\t     base, stage, pathspec,\n \t\t\t\t     fn, context);\n \t\tstrbuf_setlen(base, oldlen);\n@@ -184,11 +184,11 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match)\n \treturn 0;\n }\n \n-struct tree *lookup_tree(const unsigned char *sha1)\n+struct tree *lookup_tree(const struct object_id *oid)\n {\n-\tstruct object *obj = lookup_object(sha1);\n+\tstruct object *obj = lookup_object(oid->hash);\n \tif (!obj)\n-\t\treturn create_object(sha1, alloc_tree_node());\n+\t\treturn create_object(oid->hash, alloc_tree_node());\n \treturn object_as_type(obj, OBJ_TREE, 0);\n }\n \ndiff --git a/tree.h b/tree.h\nindex d24786cba..2b2c8dbbe 100644\n--- a/tree.h\n+++ b/tree.h\n@@ -12,7 +12,7 @@ struct tree {\n \tunsigned long size;\n };\n \n-struct tree *lookup_tree(const unsigned char *sha1);\n+struct tree *lookup_tree(const struct object_id *oid);\n \n int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);\n \ndiff --git a/walker.c b/walker.c\nindex 3d6029c8e..eae9fb974 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -47,7 +47,7 @@ static int process_tree(struct walker *walker, struct tree *tree)\n \t\tif (S_ISGITLINK(entry.mode))\n \t\t\tcontinue;\n \t\tif (S_ISDIR(entry.mode)) {\n-\t\t\tstruct tree *tree = lookup_tree(entry.oid->hash);\n+\t\t\tstruct tree *tree = lookup_tree(entry.oid);\n \t\t\tif (tree)\n \t\t\t\tobj = &tree->object;\n \t\t}\n"},{"id":"317601","messageId":"20170423213453.253425-34-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 33/53] log-tree: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:33Z","receivedAt":"2017-04-23T21:37:29Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the remaining functions to take pointers to struct object_id\ninstead of pointers to unsigned char, and update the internals of these\nfunctions as well.  Among these functions is a caller of lookup_tag,\nwhich we will convert shortly.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n log-tree.c | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/log-tree.c b/log-tree.c\nindex 7fb1a85d2..169fd039f 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -184,7 +184,7 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d\n {\n \tconst struct name_decoration *list, *head = NULL;\n \tconst char *branch_name = NULL;\n-\tunsigned char unused[20];\n+\tstruct object_id unused;\n \tint rru_flags;\n \n \t/* First find HEAD */\n@@ -197,7 +197,7 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d\n \t\treturn NULL;\n \n \t/* Now resolve and find the matching current branch */\n-\tbranch_name = resolve_ref_unsafe(\"HEAD\", 0, unused, &rru_flags);\n+\tbranch_name = resolve_ref_unsafe(\"HEAD\", 0, unused.hash, &rru_flags);\n \tif (!(rru_flags & REF_ISSYMREF))\n \t\treturn NULL;\n \n@@ -456,13 +456,13 @@ static void show_signature(struct rev_info *opt, struct commit *commit)\n \tstrbuf_release(&signature);\n }\n \n-static int which_parent(const unsigned char *sha1, const struct commit *commit)\n+static int which_parent(const struct object_id *oid, const struct commit *commit)\n {\n \tint nth;\n \tconst struct commit_list *parent;\n \n \tfor (nth = 0, parent = commit->parents; parent; parent = parent->next) {\n-\t\tif (!hashcmp(parent->item->object.oid.hash, sha1))\n+\t\tif (!oidcmp(&parent->item->object.oid, oid))\n \t\t\treturn nth;\n \t\tnth++;\n \t}\n@@ -481,14 +481,14 @@ static void show_one_mergetag(struct commit *commit,\n \t\t\t      void *data)\n {\n \tstruct rev_info *opt = (struct rev_info *)data;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct tag *tag;\n \tstruct strbuf verify_message;\n \tint status, nth;\n \tsize_t payload_size, gpg_message_offset;\n \n-\thash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), sha1);\n-\ttag = lookup_tag(sha1);\n+\thash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), oid.hash);\n+\ttag = lookup_tag(oid.hash);\n \tif (!tag)\n \t\treturn; /* error message already given */\n \n@@ -500,7 +500,7 @@ static void show_one_mergetag(struct commit *commit,\n \t\t\t  &commit->parents->next->item->object.oid))\n \t\tstrbuf_addf(&verify_message,\n \t\t\t    \"merged tag '%s'\\n\", tag->tag);\n-\telse if ((nth = which_parent(tag->tagged->oid.hash, commit)) < 0)\n+\telse if ((nth = which_parent(&tag->tagged->oid, commit)) < 0)\n \t\tstrbuf_addf(&verify_message, \"tag %s names a non-parent %s\\n\",\n \t\t\t\t    tag->tag, tag->tagged->oid.hash);\n \telse\n@@ -536,7 +536,7 @@ void show_log(struct rev_info *opt)\n \tstruct strbuf msgbuf = STRBUF_INIT;\n \tstruct log_info *log = opt->loginfo;\n \tstruct commit *commit = log->commit, *parent = log->parent;\n-\tint abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;\n+\tint abbrev_commit = opt->abbrev_commit ? opt->abbrev : GIT_SHA1_HEXSZ;\n \tconst char *extra_headers = opt->extra_headers;\n \tstruct pretty_print_context ctx = {0};\n \n"},{"id":"317602","messageId":"20170423213453.253425-36-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 35/53] Convert the verify_pack callback to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:35Z","receivedAt":"2017-04-23T21:37:31Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Make the verify_pack_callback take a pointer to struct object_id.  Use a\nstruct object_id to hold the pack checksum, even though it is not\nstrictly an object ID.  Doing so ensures resilience against future hash\nsize changes, and allows us to remove hard-coded assumptions about how\nbig the buffer needs to be.\n\nAlso, use a union to convert the pointer from nth_packed_object_sha1 to\nto a pointer to struct object_id.  This behavior is compatible with GCC\nand clang and explicitly sanctioned by C11.  The alternatives are to\njust perform a cast, which would run afoul of strict aliasing rules, but\nshould just work, and changing the pointer into an instance of struct\nobject_id and copying the value.  The latter operation could seriously\nbloat memory usage on fsck, which already uses a lot of memory on some\nrepositories.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/fsck.c |  6 +++---\n pack-check.c   | 26 +++++++++++++++-----------\n pack.h         |  2 +-\n 3 files changed, 19 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 14a216ee6..359d61de0 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -377,7 +377,7 @@ static int fsck_obj(struct object *obj)\n \treturn 0;\n }\n \n-static int fsck_obj_buffer(const unsigned char *sha1, enum object_type type,\n+static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,\n \t\t\t   unsigned long size, void *buffer, int *eaten)\n {\n \t/*\n@@ -385,10 +385,10 @@ static int fsck_obj_buffer(const unsigned char *sha1, enum object_type type,\n \t * verify_packfile(), data_valid variable for details.\n \t */\n \tstruct object *obj;\n-\tobj = parse_object_buffer(sha1, type, size, buffer, eaten);\n+\tobj = parse_object_buffer(oid->hash, type, size, buffer, eaten);\n \tif (!obj) {\n \t\terrors_found |= ERROR_OBJECT;\n-\t\treturn error(\"%s: object corrupt or missing\", sha1_to_hex(sha1));\n+\t\treturn error(\"%s: object corrupt or missing\", oid_to_hex(oid));\n \t}\n \tobj->flags = HAS_OBJ;\n \treturn fsck_obj(obj);\ndiff --git a/pack-check.c b/pack-check.c\nindex 27f70d345..0b504d9c5 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -5,7 +5,10 @@\n \n struct idx_entry {\n \toff_t                offset;\n-\tconst unsigned char *sha1;\n+\tunion idx_entry_object {\n+\t\tconst unsigned char *hash;\n+\t\tstruct object_id *oid;\n+\t} oid;\n \tunsigned int nr;\n };\n \n@@ -51,7 +54,8 @@ static int verify_packfile(struct packed_git *p,\n \toff_t index_size = p->index_size;\n \tconst unsigned char *index_base = p->index_data;\n \tgit_SHA_CTX ctx;\n-\tunsigned char sha1[20], *pack_sig;\n+\tstruct object_id oid;\n+\tunsigned char *pack_sig;\n \toff_t offset = 0, pack_sig_ofs = 0;\n \tuint32_t nr_objects, i;\n \tint err = 0;\n@@ -71,9 +75,9 @@ static int verify_packfile(struct packed_git *p,\n \t\t\tremaining -= (unsigned int)(offset - pack_sig_ofs);\n \t\tgit_SHA1_Update(&ctx, in, remaining);\n \t} while (offset < pack_sig_ofs);\n-\tgit_SHA1_Final(sha1, &ctx);\n+\tgit_SHA1_Final(oid.hash, &ctx);\n \tpack_sig = use_pack(p, w_curs, pack_sig_ofs, NULL);\n-\tif (hashcmp(sha1, pack_sig))\n+\tif (hashcmp(oid.hash, pack_sig))\n \t\terr = error(\"%s SHA1 checksum mismatch\",\n \t\t\t    p->pack_name);\n \tif (hashcmp(index_base + index_size - 40, pack_sig))\n@@ -90,8 +94,8 @@ static int verify_packfile(struct packed_git *p,\n \tentries[nr_objects].offset = pack_sig_ofs;\n \t/* first sort entries by pack offset, since unpacking them is more efficient that way */\n \tfor (i = 0; i < nr_objects; i++) {\n-\t\tentries[i].sha1 = nth_packed_object_sha1(p, i);\n-\t\tif (!entries[i].sha1)\n+\t\tentries[i].oid.hash = nth_packed_object_sha1(p, i);\n+\t\tif (!entries[i].oid.hash)\n \t\t\tdie(\"internal error pack-check nth-packed-object\");\n \t\tentries[i].offset = nth_packed_object_offset(p, i);\n \t\tentries[i].nr = i;\n@@ -112,7 +116,7 @@ static int verify_packfile(struct packed_git *p,\n \t\t\tif (check_pack_crc(p, w_curs, offset, len, nr))\n \t\t\t\terr = error(\"index CRC mismatch for object %s \"\n \t\t\t\t\t    \"from %s at offset %\"PRIuMAX\"\",\n-\t\t\t\t\t    sha1_to_hex(entries[i].sha1),\n+\t\t\t\t\t    oid_to_hex(entries[i].oid.oid),\n \t\t\t\t\t    p->pack_name, (uintmax_t)offset);\n \t\t}\n \n@@ -135,14 +139,14 @@ static int verify_packfile(struct packed_git *p,\n \n \t\tif (data_valid && !data)\n \t\t\terr = error(\"cannot unpack %s from %s at offset %\"PRIuMAX\"\",\n-\t\t\t\t    sha1_to_hex(entries[i].sha1), p->pack_name,\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].sha1, data, size, typename(type)))\n+\t\telse if (check_sha1_signature(entries[i].oid.hash, data, size, typename(type)))\n \t\t\terr = error(\"packed %s from %s is corrupt\",\n-\t\t\t\t    sha1_to_hex(entries[i].sha1), p->pack_name);\n+\t\t\t\t    oid_to_hex(entries[i].oid.oid), p->pack_name);\n \t\telse if (fn) {\n \t\t\tint eaten = 0;\n-\t\t\terr |= fn(entries[i].sha1, type, size, data, &eaten);\n+\t\t\terr |= fn(entries[i].oid.oid, type, size, data, &eaten);\n \t\t\tif (eaten)\n \t\t\t\tdata = NULL;\n \t\t}\ndiff --git a/pack.h b/pack.h\nindex c7de42ef3..8294341af 100644\n--- a/pack.h\n+++ b/pack.h\n@@ -75,7 +75,7 @@ struct pack_idx_entry {\n \n struct progress;\n /* Note, the data argument could be NULL if object type is blob */\n-typedef int (*verify_fn)(const unsigned char*, enum object_type, unsigned long, void*, int*);\n+typedef int (*verify_fn)(const struct object_id *, enum object_type, unsigned long, void*, int*);\n \n extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, const struct pack_idx_option *, const unsigned char *sha1);\n extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off_t offset, off_t len, unsigned int nr);\n"},{"id":"317603","messageId":"20170423213453.253425-37-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 36/53] Convert struct ref_array_item to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:36Z","receivedAt":"2017-04-23T21:37:35Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert struct ref_array_item to use struct object_id by changing the\ndefinition and applying the following semantic patch, plus the standard\nobject_id transforms:\n\n@@\nstruct ref_array_item E1;\n@@\n- E1.objectname\n+ E1.objectname.hash\n\n@@\nstruct ref_array_item *E1;\n@@\n- E1->objectname\n+ E1->objectname.hash\n\nThis transformation allows us to convert get_obj, which is needed to\nconvert parse_object_buffer.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n ref-filter.c | 10 +++++-----\n ref-filter.h |  2 +-\n 2 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex e1d18ac0d..77aee273f 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -1366,7 +1366,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, v, atom)) {\n+\t\t} else if (!deref && grab_objectname(name, ref->objectname.hash, v, atom)) {\n \t\t\tcontinue;\n \t\t} else if (!strcmp(name, \"HEAD\")) {\n \t\t\tconst char *head;\n@@ -1415,13 +1415,13 @@ static void populate_value(struct ref_array_item *ref)\n \treturn;\n \n  need_obj:\n-\tbuf = get_obj(ref->objectname, &obj, &size, &eaten);\n+\tbuf = get_obj(ref->objectname.hash, &obj, &size, &eaten);\n \tif (!buf)\n \t\tdie(_(\"missing object %s for %s\"),\n-\t\t    sha1_to_hex(ref->objectname), ref->refname);\n+\t\t    oid_to_hex(&ref->objectname), ref->refname);\n \tif (!obj)\n \t\tdie(_(\"parse_object_buffer failed on %s for %s\"),\n-\t\t    sha1_to_hex(ref->objectname), ref->refname);\n+\t\t    oid_to_hex(&ref->objectname), ref->refname);\n \n \tgrab_values(ref->value, 0, obj, buf, size);\n \tif (!eaten)\n@@ -1704,7 +1704,7 @@ static struct ref_array_item *new_ref_array_item(const char *refname,\n {\n \tstruct ref_array_item *ref;\n \tFLEX_ALLOC_STR(ref, refname, refname);\n-\thashcpy(ref->objectname, objectname);\n+\thashcpy(ref->objectname.hash, objectname);\n \tref->flag = flag;\n \n \treturn ref;\ndiff --git a/ref-filter.h b/ref-filter.h\nindex c20167aa3..6552024f0 100644\n--- a/ref-filter.h\n+++ b/ref-filter.h\n@@ -34,7 +34,7 @@ struct ref_sorting {\n };\n \n struct ref_array_item {\n-\tunsigned char objectname[20];\n+\tstruct object_id objectname;\n \tint flag;\n \tunsigned int kind;\n \tconst char *symref;\n"},{"id":"317604","messageId":"20170423213453.253425-38-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 37/53] ref-filter: convert some static functions to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:37Z","receivedAt":"2017-04-23T21:37:36Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Among the converted functions is a caller of parse_object_buffer, which\nwe will convert later.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n ref-filter.c | 20 ++++++++++----------\n 1 file changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 77aee273f..56fc990a5 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -677,13 +677,13 @@ int verify_ref_format(const char *format)\n  * by the \"struct object\" representation, set *eaten as well---it is a\n  * signal from parse_object_buffer to us not to free the buffer.\n  */\n-static void *get_obj(const unsigned char *sha1, struct object **obj, unsigned long *sz, int *eaten)\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(sha1, &type, sz);\n+\tvoid *buf = read_sha1_file(oid->hash, &type, sz);\n \n \tif (buf)\n-\t\t*obj = parse_object_buffer(sha1, type, *sz, buf, eaten);\n+\t\t*obj = parse_object_buffer(oid->hash, type, *sz, buf, eaten);\n \telse\n \t\t*obj = NULL;\n \treturn buf;\n@@ -1293,7 +1293,7 @@ static void populate_value(struct ref_array_item *ref)\n \tstruct object *obj;\n \tint eaten, i;\n \tunsigned long size;\n-\tconst unsigned char *tagged;\n+\tconst struct object_id *tagged;\n \n \tref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));\n \n@@ -1370,10 +1370,10 @@ static void populate_value(struct ref_array_item *ref)\n \t\t\tcontinue;\n \t\t} else if (!strcmp(name, \"HEAD\")) {\n \t\t\tconst char *head;\n-\t\t\tunsigned char sha1[20];\n+\t\t\tstruct object_id oid;\n \n \t\t\thead = resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING,\n-\t\t\t\t\t\t  sha1, NULL);\n+\t\t\t\t\t\t  oid.hash, NULL);\n \t\t\tif (head && !strcmp(ref->refname, head))\n \t\t\t\tv->s = \"*\";\n \t\t\telse\n@@ -1415,7 +1415,7 @@ static void populate_value(struct ref_array_item *ref)\n \treturn;\n \n  need_obj:\n-\tbuf = get_obj(ref->objectname.hash, &obj, &size, &eaten);\n+\tbuf = get_obj(&ref->objectname, &obj, &size, &eaten);\n \tif (!buf)\n \t\tdie(_(\"missing object %s for %s\"),\n \t\t    oid_to_hex(&ref->objectname), ref->refname);\n@@ -1438,7 +1438,7 @@ static void populate_value(struct ref_array_item *ref)\n \t * If it is a tag object, see if we use a value that derefs\n \t * the object, and if we do grab the object it refers to.\n \t */\n-\ttagged = ((struct tag *)obj)->tagged->oid.hash;\n+\ttagged = &((struct tag *)obj)->tagged->oid;\n \n \t/*\n \t * NEEDSWORK: This derefs tag only once, which\n@@ -1449,10 +1449,10 @@ static void populate_value(struct ref_array_item *ref)\n \tbuf = get_obj(tagged, &obj, &size, &eaten);\n \tif (!buf)\n \t\tdie(_(\"missing object %s for %s\"),\n-\t\t    sha1_to_hex(tagged), ref->refname);\n+\t\t    oid_to_hex(tagged), ref->refname);\n \tif (!obj)\n \t\tdie(_(\"parse_object_buffer failed on %s for %s\"),\n-\t\t    sha1_to_hex(tagged), ref->refname);\n+\t\t    oid_to_hex(tagged), ref->refname);\n \tgrab_values(ref->value, 1, obj, buf, size);\n \tif (!eaten)\n \t\tfree(buf);\n"},{"id":"317605","messageId":"20170423213453.253425-39-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 38/53] refs: convert struct ref_update to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:38Z","receivedAt":"2017-04-23T21:37:45Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert struct ref_array_item to use struct object_id by changing the\ndefinition and applying the following semantic patch, plus the standard\nobject_id transforms:\n\n@@\nstruct ref_update E1;\n@@\n- E1.new_sha1\n+ E1.new_oid.hash\n\n@@\nstruct ref_update *E1;\n@@\n- E1->new_sha1\n+ E1->new_oid.hash\n\n@@\nstruct ref_update E1;\n@@\n- E1.old_sha1\n+ E1.old_oid.hash\n\n@@\nstruct ref_update *E1;\n@@\n- E1->old_sha1\n+ E1->old_oid.hash\n\nThis transformation allows us to convert write_ref_to_lockfile, which is\nrequired to convert parse_object.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n refs.c               |  4 ++--\n refs/files-backend.c | 29 +++++++++++++++--------------\n refs/refs-internal.h |  4 ++--\n 3 files changed, 19 insertions(+), 18 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex d1e1b4399..f76c42081 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -881,9 +881,9 @@ struct ref_update *ref_transaction_add_update(\n \tupdate->flags = flags;\n \n \tif (flags & REF_HAVE_NEW)\n-\t\thashcpy(update->new_sha1, new_sha1);\n+\t\thashcpy(update->new_oid.hash, new_sha1);\n \tif (flags & REF_HAVE_OLD)\n-\t\thashcpy(update->old_sha1, old_sha1);\n+\t\thashcpy(update->old_oid.hash, old_sha1);\n \tupdate->msg = xstrdup_or_null(msg);\n \treturn update;\n }\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 238a046e6..ccabf761e 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -3549,7 +3549,7 @@ static int split_head_update(struct ref_update *update,\n \tnew_update = ref_transaction_add_update(\n \t\t\ttransaction, \"HEAD\",\n \t\t\tupdate->flags | REF_LOG_ONLY | REF_NODEREF,\n-\t\t\tupdate->new_sha1, update->old_sha1,\n+\t\t\tupdate->new_oid.hash, update->old_oid.hash,\n \t\t\tupdate->msg);\n \n \titem->util = new_update;\n@@ -3606,7 +3606,7 @@ static int split_symref_update(struct files_ref_store *refs,\n \n \tnew_update = ref_transaction_add_update(\n \t\t\ttransaction, referent, new_flags,\n-\t\t\tupdate->new_sha1, update->old_sha1,\n+\t\t\tupdate->new_oid.hash, update->old_oid.hash,\n \t\t\tupdate->msg);\n \n \tnew_update->parent_update = update;\n@@ -3645,10 +3645,10 @@ static int check_old_oid(struct ref_update *update, struct object_id *oid,\n \t\t\t struct strbuf *err)\n {\n \tif (!(update->flags & REF_HAVE_OLD) ||\n-\t\t   !hashcmp(oid->hash, update->old_sha1))\n+\t\t   !oidcmp(oid, &update->old_oid))\n \t\treturn 0;\n \n-\tif (is_null_sha1(update->old_sha1))\n+\tif (is_null_oid(&update->old_oid))\n \t\tstrbuf_addf(err, \"cannot lock ref '%s': \"\n \t\t\t    \"reference already exists\",\n \t\t\t    original_update_refname(update));\n@@ -3656,13 +3656,13 @@ static int check_old_oid(struct ref_update *update, struct object_id *oid,\n \t\tstrbuf_addf(err, \"cannot lock ref '%s': \"\n \t\t\t    \"reference is missing but expected %s\",\n \t\t\t    original_update_refname(update),\n-\t\t\t    sha1_to_hex(update->old_sha1));\n+\t\t\t    oid_to_hex(&update->old_oid));\n \telse\n \t\tstrbuf_addf(err, \"cannot lock ref '%s': \"\n \t\t\t    \"is at %s but expected %s\",\n \t\t\t    original_update_refname(update),\n \t\t\t    oid_to_hex(oid),\n-\t\t\t    sha1_to_hex(update->old_sha1));\n+\t\t\t    oid_to_hex(&update->old_oid));\n \n \treturn -1;\n }\n@@ -3689,13 +3689,13 @@ static int lock_ref_for_update(struct files_ref_store *refs,\n {\n \tstruct strbuf referent = STRBUF_INIT;\n \tint mustexist = (update->flags & REF_HAVE_OLD) &&\n-\t\t!is_null_sha1(update->old_sha1);\n+\t\t!is_null_oid(&update->old_oid);\n \tint ret;\n \tstruct ref_lock *lock;\n \n \tfiles_assert_main_repository(refs, \"lock_ref_for_update\");\n \n-\tif ((update->flags & REF_HAVE_NEW) && is_null_sha1(update->new_sha1))\n+\tif ((update->flags & REF_HAVE_NEW) && is_null_oid(&update->new_oid))\n \t\tupdate->flags |= REF_DELETING;\n \n \tif (head_ref) {\n@@ -3777,12 +3777,12 @@ static int lock_ref_for_update(struct files_ref_store *refs,\n \t    !(update->flags & REF_DELETING) &&\n \t    !(update->flags & REF_LOG_ONLY)) {\n \t\tif (!(update->type & REF_ISSYMREF) &&\n-\t\t    !hashcmp(lock->old_oid.hash, update->new_sha1)) {\n+\t\t    !oidcmp(&lock->old_oid, &update->new_oid)) {\n \t\t\t/*\n \t\t\t * The reference already has the desired\n \t\t\t * value, so we don't need to write it.\n \t\t\t */\n-\t\t} else if (write_ref_to_lockfile(lock, update->new_sha1,\n+\t\t} else if (write_ref_to_lockfile(lock, update->new_oid.hash,\n \t\t\t\t\t\t err)) {\n \t\t\tchar *write_err = strbuf_detach(err, NULL);\n \n@@ -3918,7 +3918,7 @@ static int files_transaction_commit(struct ref_store *ref_store,\n \t\t\tif (files_log_ref_write(refs,\n \t\t\t\t\t\tlock->ref_name,\n \t\t\t\t\t\tlock->old_oid.hash,\n-\t\t\t\t\t\tupdate->new_sha1,\n+\t\t\t\t\t\tupdate->new_oid.hash,\n \t\t\t\t\t\tupdate->msg, update->flags,\n \t\t\t\t\t\terr)) {\n \t\t\t\tchar *old_msg = strbuf_detach(err, NULL);\n@@ -4067,7 +4067,7 @@ static int files_initial_transaction_commit(struct ref_store *ref_store,\n \t\tstruct ref_update *update = transaction->updates[i];\n \n \t\tif ((update->flags & REF_HAVE_OLD) &&\n-\t\t    !is_null_sha1(update->old_sha1))\n+\t\t    !is_null_oid(&update->old_oid))\n \t\t\tdie(\"BUG: initial ref transaction with old_sha1 set\");\n \t\tif (refs_verify_refname_available(&refs->base, update->refname,\n \t\t\t\t\t\t  &affected_refnames, NULL,\n@@ -4088,8 +4088,9 @@ static int files_initial_transaction_commit(struct ref_store *ref_store,\n \t\tstruct ref_update *update = transaction->updates[i];\n \n \t\tif ((update->flags & REF_HAVE_NEW) &&\n-\t\t    !is_null_sha1(update->new_sha1))\n-\t\t\tadd_packed_ref(refs, update->refname, update->new_sha1);\n+\t\t    !is_null_oid(&update->new_oid))\n+\t\t\tadd_packed_ref(refs, update->refname,\n+\t\t\t\t       update->new_oid.hash);\n \t}\n \n \tif (commit_packed_refs(refs)) {\ndiff --git a/refs/refs-internal.h b/refs/refs-internal.h\nindex 690498698..72a4a49fb 100644\n--- a/refs/refs-internal.h\n+++ b/refs/refs-internal.h\n@@ -130,13 +130,13 @@ struct ref_update {\n \t/*\n \t * If (flags & REF_HAVE_NEW), set the reference to this value:\n \t */\n-\tunsigned char new_sha1[20];\n+\tstruct object_id new_oid;\n \n \t/*\n \t * If (flags & REF_HAVE_OLD), check that the reference\n \t * previously had this value:\n \t */\n-\tunsigned char old_sha1[20];\n+\tstruct object_id old_oid;\n \n \t/*\n \t * One or more of REF_HAVE_NEW, REF_HAVE_OLD, REF_NODEREF,\n"},{"id":"317606","messageId":"20170423213453.253425-40-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 39/53] refs/files-backend: convert many internals to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:39Z","receivedAt":"2017-04-23T21:37:47Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert many of the internals of the files backend to use struct\nobject_id.  Avoid converting public APIs to limit the scope of the\nchanges.\n\nConvert one use of get_sha1_hex to parse_oid_hex, and rely on the fact\nthat a strbuf will be NUL-terminated and that parse_oid_hex will fail on\ntruncated input to avoid the need to check for an explicit length.\n\nThis is a requirement to convert parse_object later on.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n refs/files-backend.c | 133 ++++++++++++++++++++++++---------------------------\n 1 file changed, 62 insertions(+), 71 deletions(-)\n\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex ccabf761e..171a157f7 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -166,8 +166,8 @@ static struct ref_entry *create_dir_entry(struct files_ref_store *ref_store,\n \t\t\t\t\t  int incomplete);\n static void add_entry_to_dir(struct ref_dir *dir, struct ref_entry *entry);\n static int files_log_ref_write(struct files_ref_store *refs,\n-\t\t\t       const char *refname, const unsigned char *old_sha1,\n-\t\t\t       const unsigned char *new_sha1, const char *msg,\n+\t\t\t       const char *refname, const struct object_id *old_oid,\n+\t\t\t       const struct object_id *new_oid, const char *msg,\n \t\t\t       int flags, struct strbuf *err);\n \n static struct ref_dir *get_ref_dir(struct ref_entry *entry)\n@@ -201,7 +201,7 @@ static struct ref_dir *get_ref_dir(struct ref_entry *entry)\n }\n \n static struct ref_entry *create_ref_entry(const char *refname,\n-\t\t\t\t\t  const unsigned char *sha1, int flag,\n+\t\t\t\t\t  const struct object_id *oid, int flag,\n \t\t\t\t\t  int check_name)\n {\n \tstruct ref_entry *ref;\n@@ -210,7 +210,7 @@ static struct ref_entry *create_ref_entry(const char *refname,\n \t    check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))\n \t\tdie(\"Reference has invalid format: '%s'\", refname);\n \tFLEX_ALLOC_STR(ref, name, refname);\n-\thashcpy(ref->u.value.oid.hash, sha1);\n+\toidcpy(&ref->u.value.oid, oid);\n \toidclr(&ref->u.value.peeled);\n \tref->flag = flag;\n \treturn ref;\n@@ -1049,27 +1049,18 @@ static const char PACKED_REFS_HEADER[] =\n  * Return a pointer to the refname within the line (null-terminated),\n  * or NULL if there was a problem.\n  */\n-static const char *parse_ref_line(struct strbuf *line, unsigned char *sha1)\n+static const char *parse_ref_line(struct strbuf *line, struct object_id *oid)\n {\n \tconst char *ref;\n \n-\t/*\n-\t * 42: the answer to everything.\n-\t *\n-\t * In this case, it happens to be the answer to\n-\t *  40 (length of sha1 hex representation)\n-\t *  +1 (space in between hex and name)\n-\t *  +1 (newline at the end of the line)\n-\t */\n-\tif (line->len <= 42)\n+\tif (!line->len)\n \t\treturn NULL;\n \n-\tif (get_sha1_hex(line->buf, sha1) < 0)\n+\tif (parse_oid_hex(line->buf, oid, &ref) < 0)\n \t\treturn NULL;\n-\tif (!isspace(line->buf[40]))\n+\tif (!isspace(*ref++))\n \t\treturn NULL;\n \n-\tref = line->buf + 41;\n \tif (isspace(*ref))\n \t\treturn NULL;\n \n@@ -1114,7 +1105,7 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)\n \tenum { PEELED_NONE, PEELED_TAGS, PEELED_FULLY } peeled = PEELED_NONE;\n \n \twhile (strbuf_getwholeline(&line, f, '\\n') != EOF) {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tconst char *refname;\n \t\tconst char *traits;\n \n@@ -1127,17 +1118,17 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)\n \t\t\tcontinue;\n \t\t}\n \n-\t\trefname = parse_ref_line(&line, sha1);\n+\t\trefname = parse_ref_line(&line, &oid);\n \t\tif (refname) {\n \t\t\tint flag = REF_ISPACKED;\n \n \t\t\tif (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {\n \t\t\t\tif (!refname_is_safe(refname))\n \t\t\t\t\tdie(\"packed refname is dangerous: %s\", refname);\n-\t\t\t\thashclr(sha1);\n+\t\t\t\toidclr(&oid);\n \t\t\t\tflag |= REF_BAD_NAME | REF_ISBROKEN;\n \t\t\t}\n-\t\t\tlast = create_ref_entry(refname, sha1, flag, 0);\n+\t\t\tlast = create_ref_entry(refname, &oid, flag, 0);\n \t\t\tif (peeled == PEELED_FULLY ||\n \t\t\t    (peeled == PEELED_TAGS && starts_with(refname, \"refs/tags/\")))\n \t\t\t\tlast->flag |= REF_KNOWS_PEELED;\n@@ -1148,8 +1139,8 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)\n \t\t    line.buf[0] == '^' &&\n \t\t    line.len == PEELED_LINE_LENGTH &&\n \t\t    line.buf[PEELED_LINE_LENGTH - 1] == '\\n' &&\n-\t\t    !get_sha1_hex(line.buf + 1, sha1)) {\n-\t\t\thashcpy(last->u.value.peeled.hash, sha1);\n+\t\t    !get_oid_hex(line.buf + 1, &oid)) {\n+\t\t\toidcpy(&last->u.value.peeled, &oid);\n \t\t\t/*\n \t\t\t * Regardless of what the file header said,\n \t\t\t * we definitely know the value of *this*\n@@ -1257,14 +1248,14 @@ static struct ref_dir *get_packed_refs(struct files_ref_store *refs)\n  * commit_packed_refs().\n  */\n static void add_packed_ref(struct files_ref_store *refs,\n-\t\t\t   const char *refname, const unsigned char *sha1)\n+\t\t\t   const char *refname, const struct object_id *oid)\n {\n \tstruct packed_ref_cache *packed_ref_cache = get_packed_ref_cache(refs);\n \n \tif (!packed_ref_cache->lock)\n \t\tdie(\"internal error: packed refs not locked\");\n \tadd_ref(get_packed_ref_dir(packed_ref_cache),\n-\t\tcreate_ref_entry(refname, sha1, REF_ISPACKED, 1));\n+\t\tcreate_ref_entry(refname, oid, REF_ISPACKED, 1));\n }\n \n /*\n@@ -1295,7 +1286,7 @@ static void read_loose_refs(const char *dirname, struct ref_dir *dir)\n \tstrbuf_add(&refname, dirname, dirnamelen);\n \n \twhile ((de = readdir(d)) != NULL) {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tstruct stat st;\n \t\tint flag;\n \n@@ -1316,10 +1307,10 @@ static void read_loose_refs(const char *dirname, struct ref_dir *dir)\n \t\t\tif (!refs_resolve_ref_unsafe(&refs->base,\n \t\t\t\t\t\t     refname.buf,\n \t\t\t\t\t\t     RESOLVE_REF_READING,\n-\t\t\t\t\t\t     sha1, &flag)) {\n-\t\t\t\thashclr(sha1);\n+\t\t\t\t\t\t     oid.hash, &flag)) {\n+\t\t\t\toidclr(&oid);\n \t\t\t\tflag |= REF_ISBROKEN;\n-\t\t\t} else if (is_null_sha1(sha1)) {\n+\t\t\t} else if (is_null_oid(&oid)) {\n \t\t\t\t/*\n \t\t\t\t * It is so astronomically unlikely\n \t\t\t\t * that NULL_SHA1 is the SHA-1 of an\n@@ -1335,11 +1326,11 @@ static void read_loose_refs(const char *dirname, struct ref_dir *dir)\n \t\t\t\t\t\t REFNAME_ALLOW_ONELEVEL)) {\n \t\t\t\tif (!refname_is_safe(refname.buf))\n \t\t\t\t\tdie(\"loose refname is dangerous: %s\", refname.buf);\n-\t\t\t\thashclr(sha1);\n+\t\t\t\toidclr(&oid);\n \t\t\t\tflag |= REF_BAD_NAME | REF_ISBROKEN;\n \t\t\t}\n \t\t\tadd_entry_to_dir(dir,\n-\t\t\t\t\t create_ref_entry(refname.buf, sha1, flag, 0));\n+\t\t\t\t\t create_ref_entry(refname.buf, &oid, flag, 0));\n \t\t}\n \t\tstrbuf_setlen(&refname, dirnamelen);\n \t\tstrbuf_setlen(&path, path_baselen);\n@@ -2327,7 +2318,7 @@ static int pack_if_possible_fn(struct ref_entry *entry, void *cb_data)\n \t\tpacked_entry->flag = REF_ISPACKED | REF_KNOWS_PEELED;\n \t\toidcpy(&packed_entry->u.value.oid, &entry->u.value.oid);\n \t} else {\n-\t\tpacked_entry = create_ref_entry(entry->name, entry->u.value.oid.hash,\n+\t\tpacked_entry = create_ref_entry(entry->name, &entry->u.value.oid,\n \t\t\t\t\t\tREF_ISPACKED | REF_KNOWS_PEELED, 0);\n \t\tadd_ref(cb->packed_refs, packed_entry);\n \t}\n@@ -2629,10 +2620,10 @@ static int files_verify_refname_available(struct ref_store *ref_store,\n }\n \n static int write_ref_to_lockfile(struct ref_lock *lock,\n-\t\t\t\t const unsigned char *sha1, struct strbuf *err);\n+\t\t\t\t const struct object_id *oid, struct strbuf *err);\n static int commit_ref_update(struct files_ref_store *refs,\n \t\t\t     struct ref_lock *lock,\n-\t\t\t     const unsigned char *sha1, const char *logmsg,\n+\t\t\t     const struct object_id *oid, const char *logmsg,\n \t\t\t     struct strbuf *err);\n \n static int files_rename_ref(struct ref_store *ref_store,\n@@ -2641,7 +2632,7 @@ static int files_rename_ref(struct ref_store *ref_store,\n {\n \tstruct files_ref_store *refs =\n \t\tfiles_downcast(ref_store, REF_STORE_WRITE, \"rename_ref\");\n-\tunsigned char sha1[20], orig_sha1[20];\n+\tstruct object_id oid, orig_oid;\n \tint flag = 0, logmoved = 0;\n \tstruct ref_lock *lock;\n \tstruct stat loginfo;\n@@ -2663,7 +2654,7 @@ static int files_rename_ref(struct ref_store *ref_store,\n \n \tif (!refs_resolve_ref_unsafe(&refs->base, oldrefname,\n \t\t\t\t     RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,\n-\t\t\t\torig_sha1, &flag)) {\n+\t\t\t\torig_oid.hash, &flag)) {\n \t\tret = error(\"refname %s not found\", oldrefname);\n \t\tgoto out;\n \t}\n@@ -2685,21 +2676,21 @@ static int files_rename_ref(struct ref_store *ref_store,\n \t}\n \n \tif (refs_delete_ref(&refs->base, logmsg, oldrefname,\n-\t\t\t    orig_sha1, REF_NODEREF)) {\n+\t\t\t    orig_oid.hash, REF_NODEREF)) {\n \t\terror(\"unable to delete old %s\", oldrefname);\n \t\tgoto rollback;\n \t}\n \n \t/*\n-\t * Since we are doing a shallow lookup, sha1 is not the\n-\t * correct value to pass to delete_ref as old_sha1. But that\n-\t * doesn't matter, because an old_sha1 check wouldn't add to\n+\t * Since we are doing a shallow lookup, oid is not the\n+\t * correct value to pass to delete_ref as old_oid. But that\n+\t * doesn't matter, because an old_oid check wouldn't add to\n \t * the safety anyway; we want to delete the reference whatever\n \t * its current value.\n \t */\n \tif (!refs_read_ref_full(&refs->base, newrefname,\n \t\t\t\tRESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,\n-\t\t\t\tsha1, NULL) &&\n+\t\t\t\toid.hash, NULL) &&\n \t    refs_delete_ref(&refs->base, NULL, newrefname,\n \t\t\t    NULL, REF_NODEREF)) {\n \t\tif (errno == EISDIR) {\n@@ -2732,10 +2723,10 @@ static int files_rename_ref(struct ref_store *ref_store,\n \t\tstrbuf_release(&err);\n \t\tgoto rollback;\n \t}\n-\thashcpy(lock->old_oid.hash, orig_sha1);\n+\toidcpy(&lock->old_oid, &orig_oid);\n \n-\tif (write_ref_to_lockfile(lock, orig_sha1, &err) ||\n-\t    commit_ref_update(refs, lock, orig_sha1, logmsg, &err)) {\n+\tif (write_ref_to_lockfile(lock, &orig_oid, &err) ||\n+\t    commit_ref_update(refs, lock, &orig_oid, logmsg, &err)) {\n \t\terror(\"unable to write current sha1 into %s: %s\", newrefname, err.buf);\n \t\tstrbuf_release(&err);\n \t\tgoto rollback;\n@@ -2755,8 +2746,8 @@ static int files_rename_ref(struct ref_store *ref_store,\n \n \tflag = log_all_ref_updates;\n \tlog_all_ref_updates = LOG_REFS_NONE;\n-\tif (write_ref_to_lockfile(lock, orig_sha1, &err) ||\n-\t    commit_ref_update(refs, lock, orig_sha1, NULL, &err)) {\n+\tif (write_ref_to_lockfile(lock, &orig_oid, &err) ||\n+\t    commit_ref_update(refs, lock, &orig_oid, NULL, &err)) {\n \t\terror(\"unable to write current sha1 into %s: %s\", oldrefname, err.buf);\n \t\tstrbuf_release(&err);\n \t}\n@@ -2906,8 +2897,8 @@ static int files_create_reflog(struct ref_store *ref_store,\n \treturn 0;\n }\n \n-static int log_ref_write_fd(int fd, const unsigned char *old_sha1,\n-\t\t\t    const unsigned char *new_sha1,\n+static int log_ref_write_fd(int fd, const struct object_id *old_oid,\n+\t\t\t    const struct object_id *new_oid,\n \t\t\t    const char *committer, const char *msg)\n {\n \tint msglen, written;\n@@ -2918,8 +2909,8 @@ static int log_ref_write_fd(int fd, const unsigned char *old_sha1,\n \tmaxlen = strlen(committer) + msglen + 100;\n \tlogrec = xmalloc(maxlen);\n \tlen = xsnprintf(logrec, maxlen, \"%s %s %s\\n\",\n-\t\t\tsha1_to_hex(old_sha1),\n-\t\t\tsha1_to_hex(new_sha1),\n+\t\t\toid_to_hex(old_oid),\n+\t\t\toid_to_hex(new_oid),\n \t\t\tcommitter);\n \tif (msglen)\n \t\tlen += copy_reflog_msg(logrec + len - 1, msg) - 1;\n@@ -2933,8 +2924,8 @@ static int log_ref_write_fd(int fd, const unsigned char *old_sha1,\n }\n \n static int files_log_ref_write(struct files_ref_store *refs,\n-\t\t\t       const char *refname, const unsigned char *old_sha1,\n-\t\t\t       const unsigned char *new_sha1, const char *msg,\n+\t\t\t       const char *refname, const struct object_id *old_oid,\n+\t\t\t       const struct object_id *new_oid, const char *msg,\n \t\t\t       int flags, struct strbuf *err)\n {\n \tint logfd, result;\n@@ -2951,7 +2942,7 @@ static int files_log_ref_write(struct files_ref_store *refs,\n \n \tif (logfd < 0)\n \t\treturn 0;\n-\tresult = log_ref_write_fd(logfd, old_sha1, new_sha1,\n+\tresult = log_ref_write_fd(logfd, old_oid, new_oid,\n \t\t\t\t  git_committer_info(0), msg);\n \tif (result) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n@@ -2983,29 +2974,29 @@ static int files_log_ref_write(struct files_ref_store *refs,\n  * return -1.\n  */\n static int write_ref_to_lockfile(struct ref_lock *lock,\n-\t\t\t\t const unsigned char *sha1, struct strbuf *err)\n+\t\t\t\t const struct object_id *oid, struct strbuf *err)\n {\n \tstatic char term = '\\n';\n \tstruct object *o;\n \tint fd;\n \n-\to = parse_object(sha1);\n+\to = parse_object(oid->hash);\n \tif (!o) {\n \t\tstrbuf_addf(err,\n \t\t\t    \"trying to write ref '%s' with nonexistent object %s\",\n-\t\t\t    lock->ref_name, sha1_to_hex(sha1));\n+\t\t\t    lock->ref_name, oid_to_hex(oid));\n \t\tunlock_ref(lock);\n \t\treturn -1;\n \t}\n \tif (o->type != OBJ_COMMIT && is_branch(lock->ref_name)) {\n \t\tstrbuf_addf(err,\n \t\t\t    \"trying to write non-commit object %s to branch '%s'\",\n-\t\t\t    sha1_to_hex(sha1), lock->ref_name);\n+\t\t\t    oid_to_hex(oid), lock->ref_name);\n \t\tunlock_ref(lock);\n \t\treturn -1;\n \t}\n \tfd = get_lock_file_fd(lock->lk);\n-\tif (write_in_full(fd, sha1_to_hex(sha1), 40) != 40 ||\n+\tif (write_in_full(fd, oid_to_hex(oid), GIT_SHA1_HEXSZ) != GIT_SHA1_HEXSZ ||\n \t    write_in_full(fd, &term, 1) != 1 ||\n \t    close_ref(lock) < 0) {\n \t\tstrbuf_addf(err,\n@@ -3023,14 +3014,14 @@ static int write_ref_to_lockfile(struct ref_lock *lock,\n  */\n static int commit_ref_update(struct files_ref_store *refs,\n \t\t\t     struct ref_lock *lock,\n-\t\t\t     const unsigned char *sha1, const char *logmsg,\n+\t\t\t     const struct object_id *oid, const char *logmsg,\n \t\t\t     struct strbuf *err)\n {\n \tfiles_assert_main_repository(refs, \"commit_ref_update\");\n \n \tclear_loose_ref_cache(refs);\n \tif (files_log_ref_write(refs, lock->ref_name,\n-\t\t\t\tlock->old_oid.hash, sha1,\n+\t\t\t\t&lock->old_oid, oid,\n \t\t\t\tlogmsg, 0, err)) {\n \t\tchar *old_msg = strbuf_detach(err, NULL);\n \t\tstrbuf_addf(err, \"cannot update the ref '%s': %s\",\n@@ -3053,18 +3044,18 @@ static int commit_ref_update(struct files_ref_store *refs,\n \t\t * check with HEAD only which should cover 99% of all usage\n \t\t * scenarios (even 100% of the default ones).\n \t\t */\n-\t\tunsigned char head_sha1[20];\n+\t\tstruct object_id head_oid;\n \t\tint head_flag;\n \t\tconst char *head_ref;\n \n \t\thead_ref = refs_resolve_ref_unsafe(&refs->base, \"HEAD\",\n \t\t\t\t\t\t   RESOLVE_REF_READING,\n-\t\t\t\t\t\t   head_sha1, &head_flag);\n+\t\t\t\t\t\t   head_oid.hash, &head_flag);\n \t\tif (head_ref && (head_flag & REF_ISSYMREF) &&\n \t\t    !strcmp(head_ref, lock->ref_name)) {\n \t\t\tstruct strbuf log_err = STRBUF_INIT;\n \t\t\tif (files_log_ref_write(refs, \"HEAD\",\n-\t\t\t\t\t\tlock->old_oid.hash, sha1,\n+\t\t\t\t\t\t&lock->old_oid, oid,\n \t\t\t\t\t\tlogmsg, 0, &log_err)) {\n \t\t\t\terror(\"%s\", log_err.buf);\n \t\t\t\tstrbuf_release(&log_err);\n@@ -3102,12 +3093,12 @@ static void update_symref_reflog(struct files_ref_store *refs,\n \t\t\t\t const char *target, const char *logmsg)\n {\n \tstruct strbuf err = STRBUF_INIT;\n-\tunsigned char new_sha1[20];\n+\tstruct object_id new_oid;\n \tif (logmsg &&\n \t    !refs_read_ref_full(&refs->base, target,\n-\t\t\t\tRESOLVE_REF_READING, new_sha1, NULL) &&\n-\t    files_log_ref_write(refs, refname, lock->old_oid.hash,\n-\t\t\t\tnew_sha1, logmsg, 0, &err)) {\n+\t\t\t\tRESOLVE_REF_READING, new_oid.hash, NULL) &&\n+\t    files_log_ref_write(refs, refname, &lock->old_oid,\n+\t\t\t\t&new_oid, logmsg, 0, &err)) {\n \t\terror(\"%s\", err.buf);\n \t\tstrbuf_release(&err);\n \t}\n@@ -3782,7 +3773,7 @@ static int lock_ref_for_update(struct files_ref_store *refs,\n \t\t\t * The reference already has the desired\n \t\t\t * value, so we don't need to write it.\n \t\t\t */\n-\t\t} else if (write_ref_to_lockfile(lock, update->new_oid.hash,\n+\t\t} else if (write_ref_to_lockfile(lock, &update->new_oid,\n \t\t\t\t\t\t err)) {\n \t\t\tchar *write_err = strbuf_detach(err, NULL);\n \n@@ -3917,8 +3908,8 @@ static int files_transaction_commit(struct ref_store *ref_store,\n \t\t    update->flags & REF_LOG_ONLY) {\n \t\t\tif (files_log_ref_write(refs,\n \t\t\t\t\t\tlock->ref_name,\n-\t\t\t\t\t\tlock->old_oid.hash,\n-\t\t\t\t\t\tupdate->new_oid.hash,\n+\t\t\t\t\t\t&lock->old_oid,\n+\t\t\t\t\t\t&update->new_oid,\n \t\t\t\t\t\tupdate->msg, update->flags,\n \t\t\t\t\t\terr)) {\n \t\t\t\tchar *old_msg = strbuf_detach(err, NULL);\n@@ -4090,7 +4081,7 @@ static int files_initial_transaction_commit(struct ref_store *ref_store,\n \t\tif ((update->flags & REF_HAVE_NEW) &&\n \t\t    !is_null_oid(&update->new_oid))\n \t\t\tadd_packed_ref(refs, update->refname,\n-\t\t\t\t       update->new_oid.hash);\n+\t\t\t\t       &update->new_oid);\n \t}\n \n \tif (commit_packed_refs(refs)) {\n"},{"id":"317607","messageId":"20170423213453.253425-41-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 40/53] http-push: convert process_ls_object and descendants to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:40Z","receivedAt":"2017-04-23T21:37:48Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Rename one function to reflect that it now uses struct object_id.  This\nconversion is a prerequisite for converting parse_object.\n\nNote that while the use of a buffer that is exactly forty bytes long\nlooks questionable, get_oid_hex reads exactly the right number of bytes\nand does not require the data to be NUL-terminated.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n http-push.c | 22 +++++++++++-----------\n 1 file changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex 7781f4078..4e7bd9e42 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -718,13 +718,13 @@ static int fetch_indices(void)\n \treturn ret;\n }\n \n-static void one_remote_object(const unsigned char *sha1)\n+static void one_remote_object(const struct object_id *oid)\n {\n \tstruct object *obj;\n \n-\tobj = lookup_object(sha1);\n+\tobj = lookup_object(oid->hash);\n \tif (!obj)\n-\t\tobj = parse_object(sha1);\n+\t\tobj = parse_object(oid->hash);\n \n \t/* Ignore remote objects that don't exist locally */\n \tif (!obj)\n@@ -1013,26 +1013,26 @@ static void remote_ls(const char *path, int flags,\n \t\t      void *userData);\n \n /* extract hex from sharded \"xx/x{40}\" filename */\n-static int get_sha1_hex_from_objpath(const char *path, unsigned char *sha1)\n+static int get_oid_hex_from_objpath(const char *path, struct object_id *oid)\n {\n-\tchar hex[40];\n+\tchar hex[GIT_MAX_HEXSZ];\n \n-\tif (strlen(path) != 41)\n+\tif (strlen(path) != GIT_SHA1_HEXSZ + 1)\n \t\treturn -1;\n \n \tmemcpy(hex, path, 2);\n \tpath += 2;\n \tpath++; /* skip '/' */\n-\tmemcpy(hex, path, 38);\n+\tmemcpy(hex, path, GIT_SHA1_HEXSZ - 2);\n \n-\treturn get_sha1_hex(hex, sha1);\n+\treturn get_oid_hex(hex, oid);\n }\n \n static void process_ls_object(struct remote_ls_ctx *ls)\n {\n \tunsigned int *parent = (unsigned int *)ls->userData;\n \tconst char *path = ls->dentry_name;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \n \tif (!strcmp(ls->path, ls->dentry_name) && (ls->flags & IS_DIR)) {\n \t\tremote_dir_exists[*parent] = 1;\n@@ -1040,10 +1040,10 @@ static void process_ls_object(struct remote_ls_ctx *ls)\n \t}\n \n \tif (!skip_prefix(path, \"objects/\", &path) ||\n-\t    get_sha1_hex_from_objpath(path, sha1))\n+\t    get_oid_hex_from_objpath(path, &oid))\n \t\treturn;\n \n-\tone_remote_object(sha1);\n+\tone_remote_object(&oid);\n }\n \n static void process_ls_ref(struct remote_ls_ctx *ls)\n"},{"id":"317608","messageId":"20170423213453.253425-42-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 41/53] revision: rename add_pending_sha1 to add_pending_oid","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:41Z","receivedAt":"2017-04-23T21:37:50Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Rename this function and convert it to take a pointer to struct\nobject_id.\n\nThis is a prerequisite for converting get_reference, which is needed to\nconvert parse_object.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/am.c       | 2 +-\n builtin/checkout.c | 4 ++--\n revision.c         | 8 ++++----\n revision.h         | 6 +++---\n 4 files changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex e12da7b3f..46828646c 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1622,7 +1622,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa\n \t\tinit_revisions(&rev_info, NULL);\n \t\trev_info.diffopt.output_format = DIFF_FORMAT_NAME_STATUS;\n \t\tdiff_opt_parse(&rev_info.diffopt, &diff_filter_str, 1, rev_info.prefix);\n-\t\tadd_pending_sha1(&rev_info, \"HEAD\", our_tree.hash, 0);\n+\t\tadd_pending_oid(&rev_info, \"HEAD\", &our_tree, 0);\n \t\tdiff_setup_done(&rev_info.diffopt);\n \t\trun_diff_index(&rev_info, 1);\n \t}\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex afa99fb8a..7f1eeea94 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -721,7 +721,7 @@ static int add_pending_uninteresting_ref(const char *refname,\n \t\t\t\t\t const struct object_id *oid,\n \t\t\t\t\t int flags, void *cb_data)\n {\n-\tadd_pending_sha1(cb_data, refname, oid->hash, UNINTERESTING);\n+\tadd_pending_oid(cb_data, refname, oid, UNINTERESTING);\n \treturn 0;\n }\n \n@@ -807,7 +807,7 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new)\n \tadd_pending_object(&revs, object, oid_to_hex(&object->oid));\n \n \tfor_each_ref(add_pending_uninteresting_ref, &revs);\n-\tadd_pending_sha1(&revs, \"HEAD\", new->object.oid.hash, UNINTERESTING);\n+\tadd_pending_oid(&revs, \"HEAD\", &new->object.oid, UNINTERESTING);\n \n \trefs = revs.pending;\n \trevs.leak_pending = 1;\ndiff --git a/revision.c b/revision.c\nindex c2091b6de..f82c56e1f 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -203,10 +203,10 @@ static struct object *get_reference(struct rev_info *revs, const char *name,\n \treturn object;\n }\n \n-void add_pending_sha1(struct rev_info *revs, const char *name,\n-\t\t      const unsigned char *sha1, unsigned int flags)\n+void add_pending_oid(struct rev_info *revs, const char *name,\n+\t\t      const struct object_id *oid, unsigned int flags)\n {\n-\tstruct object *object = get_reference(revs, name, sha1, flags);\n+\tstruct object *object = get_reference(revs, name, oid->hash, flags);\n \tadd_pending_object(revs, object, name);\n }\n \n@@ -1159,7 +1159,7 @@ static int handle_one_ref(const char *path, const struct object_id *oid,\n \n \tobject = get_reference(cb->all_revs, path, oid->hash, cb->all_flags);\n \tadd_rev_cmdline(cb->all_revs, object, path, REV_CMD_REF, cb->all_flags);\n-\tadd_pending_sha1(cb->all_revs, path, oid->hash, cb->all_flags);\n+\tadd_pending_oid(cb->all_revs, path, oid, cb->all_flags);\n \treturn 0;\n }\n \ndiff --git a/revision.h b/revision.h\nindex 14886ec92..728425a02 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -263,9 +263,9 @@ extern void show_object_with_name(FILE *, struct object *, const char *);\n \n extern void add_pending_object(struct rev_info *revs,\n \t\t\t       struct object *obj, const char *name);\n-extern void add_pending_sha1(struct rev_info *revs,\n-\t\t\t     const char *name, const unsigned char *sha1,\n-\t\t\t     unsigned int flags);\n+extern void add_pending_oid(struct rev_info *revs,\n+\t\t\t    const char *name, const struct object_id *oid,\n+\t\t\t    unsigned int flags);\n \n extern void add_head_to_pending(struct rev_info *);\n extern void add_reflogs_to_pending(struct rev_info *, unsigned int flags);\n"},{"id":"317609","messageId":"20170423213453.253425-44-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 43/53] upload-pack: convert remaining parse_object callers to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:43Z","receivedAt":"2017-04-23T21:37:53Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the remaining parse_object callers to struct object_id.  Use\nnamed constants for several hard-coded values.  In addition, rename\ngot_sha1 to got_oid to reflect the new argument.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n upload-pack.c | 50 +++++++++++++++++++++++++-------------------------\n 1 file changed, 25 insertions(+), 25 deletions(-)\n\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 20f87cd38..5b9d21089 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -286,19 +286,19 @@ static void create_pack_file(void)\n \tdie(\"git upload-pack: %s\", abort_msg);\n }\n \n-static int got_sha1(const char *hex, unsigned char *sha1)\n+static int got_oid(const char *hex, struct object_id *oid)\n {\n \tstruct object *o;\n \tint we_knew_they_have = 0;\n \n-\tif (get_sha1_hex(hex, sha1))\n+\tif (get_oid_hex(hex, oid))\n \t\tdie(\"git upload-pack: expected SHA1 object, got '%s'\", hex);\n-\tif (!has_sha1_file(sha1))\n+\tif (!has_object_file(oid))\n \t\treturn -1;\n \n-\to = parse_object(sha1);\n+\to = parse_object(oid->hash);\n \tif (!o)\n-\t\tdie(\"oops (%s)\", sha1_to_hex(sha1));\n+\t\tdie(\"oops (%s)\", oid_to_hex(oid));\n \tif (o->type == OBJ_COMMIT) {\n \t\tstruct commit_list *parents;\n \t\tstruct commit *commit = (struct commit *)o;\n@@ -382,8 +382,8 @@ static int ok_to_give_up(void)\n \n static int get_common_commits(void)\n {\n-\tunsigned char sha1[20];\n-\tchar last_hex[41];\n+\tstruct object_id oid;\n+\tchar last_hex[GIT_MAX_HEXSZ + 1];\n \tint got_common = 0;\n \tint got_other = 0;\n \tint sent_ready = 0;\n@@ -416,11 +416,11 @@ static int get_common_commits(void)\n \t\t\tcontinue;\n \t\t}\n \t\tif (skip_prefix(line, \"have \", &arg)) {\n-\t\t\tswitch (got_sha1(arg, sha1)) {\n+\t\t\tswitch (got_oid(arg, &oid)) {\n \t\t\tcase -1: /* they have what we do not */\n \t\t\t\tgot_other = 1;\n \t\t\t\tif (multi_ack && ok_to_give_up()) {\n-\t\t\t\t\tconst char *hex = sha1_to_hex(sha1);\n+\t\t\t\t\tconst char *hex = oid_to_hex(&oid);\n \t\t\t\t\tif (multi_ack == 2) {\n \t\t\t\t\t\tsent_ready = 1;\n \t\t\t\t\t\tpacket_write_fmt(1, \"ACK %s ready\\n\", hex);\n@@ -430,7 +430,7 @@ static int get_common_commits(void)\n \t\t\t\tbreak;\n \t\t\tdefault:\n \t\t\t\tgot_common = 1;\n-\t\t\t\tmemcpy(last_hex, sha1_to_hex(sha1), 41);\n+\t\t\t\tmemcpy(last_hex, oid_to_hex(&oid), 41);\n \t\t\t\tif (multi_ack == 2)\n \t\t\t\t\tpacket_write_fmt(1, \"ACK %s common\\n\", last_hex);\n \t\t\t\telse if (multi_ack)\n@@ -492,7 +492,7 @@ static int do_reachable_revlist(struct child_process *cmd,\n \t\tgoto error;\n \n \tnamebuf[0] = '^';\n-\tnamebuf[41] = '\\n';\n+\tnamebuf[GIT_SHA1_HEXSZ + 1] = '\\n';\n \tfor (i = get_max_object_index(); 0 < i; ) {\n \t\to = get_indexed_object(--i);\n \t\tif (!o)\n@@ -502,10 +502,10 @@ static int do_reachable_revlist(struct child_process *cmd,\n \t\tif (!is_our_ref(o))\n \t\t\tcontinue;\n \t\tmemcpy(namebuf + 1, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ);\n-\t\tif (write_in_full(cmd->in, namebuf, 42) < 0)\n+\t\tif (write_in_full(cmd->in, namebuf, GIT_SHA1_HEXSZ + 2) < 0)\n \t\t\tgoto error;\n \t}\n-\tnamebuf[40] = '\\n';\n+\tnamebuf[GIT_SHA1_HEXSZ] = '\\n';\n \tfor (i = 0; i < src->nr; i++) {\n \t\to = src->objects[i].item;\n \t\tif (is_our_ref(o)) {\n@@ -516,7 +516,7 @@ static int do_reachable_revlist(struct child_process *cmd,\n \t\tif (reachable && o->type == OBJ_COMMIT)\n \t\t\to->flags |= TMP_MARK;\n \t\tmemcpy(namebuf, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ);\n-\t\tif (write_in_full(cmd->in, namebuf, 41) < 0)\n+\t\tif (write_in_full(cmd->in, namebuf, GIT_SHA1_HEXSZ + 1) < 0)\n \t\t\tgoto error;\n \t}\n \tclose(cmd->in);\n@@ -742,7 +742,7 @@ static void receive_needs(void)\n \tfor (;;) {\n \t\tstruct object *o;\n \t\tconst char *features;\n-\t\tunsigned char sha1_buf[20];\n+\t\tstruct object_id oid_buf;\n \t\tchar *line = packet_read_line(0, NULL);\n \t\tconst char *arg;\n \n@@ -751,15 +751,15 @@ static void receive_needs(void)\n \t\t\tbreak;\n \n \t\tif (skip_prefix(line, \"shallow \", &arg)) {\n-\t\t\tunsigned char sha1[20];\n+\t\t\tstruct object_id oid;\n \t\t\tstruct object *object;\n-\t\t\tif (get_sha1_hex(arg, sha1))\n+\t\t\tif (get_oid_hex(arg, &oid))\n \t\t\t\tdie(\"invalid shallow line: %s\", line);\n-\t\t\tobject = parse_object(sha1);\n+\t\t\tobject = parse_object(oid.hash);\n \t\t\tif (!object)\n \t\t\t\tcontinue;\n \t\t\tif (object->type != OBJ_COMMIT)\n-\t\t\t\tdie(\"invalid shallow object %s\", sha1_to_hex(sha1));\n+\t\t\t\tdie(\"invalid shallow object %s\", oid_to_hex(&oid));\n \t\t\tif (!(object->flags & CLIENT_SHALLOW)) {\n \t\t\t\tobject->flags |= CLIENT_SHALLOW;\n \t\t\t\tadd_object_array(object, NULL, &shallows);\n@@ -785,8 +785,8 @@ static void receive_needs(void)\n \t\t}\n \t\tif (skip_prefix(line, \"deepen-not \", &arg)) {\n \t\t\tchar *ref = NULL;\n-\t\t\tunsigned char sha1[20];\n-\t\t\tif (expand_ref(arg, strlen(arg), sha1, &ref) != 1)\n+\t\t\tstruct object_id oid;\n+\t\t\tif (expand_ref(arg, strlen(arg), oid.hash, &ref) != 1)\n \t\t\t\tdie(\"git upload-pack: ambiguous deepen-not: %s\", line);\n \t\t\tstring_list_append(&deepen_not, ref);\n \t\t\tfree(ref);\n@@ -794,7 +794,7 @@ static void receive_needs(void)\n \t\t\tcontinue;\n \t\t}\n \t\tif (!skip_prefix(line, \"want \", &arg) ||\n-\t\t    get_sha1_hex(arg, sha1_buf))\n+\t\t    get_oid_hex(arg, &oid_buf))\n \t\t\tdie(\"git upload-pack: protocol error, \"\n \t\t\t    \"expected to get sha, not '%s'\", line);\n \n@@ -821,13 +821,13 @@ static void receive_needs(void)\n \t\tif (parse_feature_request(features, \"include-tag\"))\n \t\t\tuse_include_tag = 1;\n \n-\t\to = parse_object(sha1_buf);\n+\t\to = parse_object(oid_buf.hash);\n \t\tif (!o) {\n \t\t\tpacket_write_fmt(1,\n \t\t\t\t\t \"ERR upload-pack: not our ref %s\",\n-\t\t\t\t\t sha1_to_hex(sha1_buf));\n+\t\t\t\t\t oid_to_hex(&oid_buf));\n \t\t\tdie(\"git upload-pack: not our ref %s\",\n-\t\t\t    sha1_to_hex(sha1_buf));\n+\t\t\t    oid_to_hex(&oid_buf));\n \t\t}\n \t\tif (!(o->flags & WANTED)) {\n \t\t\to->flags |= WANTED;\n"},{"id":"317610","messageId":"20170423213453.253425-47-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 46/53] builtin/ls-files: convert overlay_tree_on_cache to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:46Z","receivedAt":"2017-04-23T21:37:55Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is another caller of parse_tree_indirect.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/ls-files.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex d449e46db..948c7066c 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -407,14 +407,14 @@ static void prune_cache(const char *prefix, size_t prefixlen)\n void overlay_tree_on_cache(const char *tree_name, const char *prefix)\n {\n \tstruct tree *tree;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct pathspec pathspec;\n \tstruct cache_entry *last_stage0 = NULL;\n \tint i;\n \n-\tif (get_sha1(tree_name, sha1))\n+\tif (get_oid(tree_name, &oid))\n \t\tdie(\"tree-ish %s not found.\", tree_name);\n-\ttree = parse_tree_indirect(sha1);\n+\ttree = parse_tree_indirect(oid.hash);\n \tif (!tree)\n \t\tdie(\"bad tree-ish %s\", tree_name);\n \n"},{"id":"317611","messageId":"20170423213453.253425-46-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 45/53] builtin/read-tree: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:45Z","receivedAt":"2017-04-23T21:38:00Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is a caller of parse_tree_indirect, which must be converted in\norder to convert parse_object.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/read-tree.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/read-tree.c b/builtin/read-tree.c\nindex 23e212ee8..92eff23e4 100644\n--- a/builtin/read-tree.c\n+++ b/builtin/read-tree.c\n@@ -23,13 +23,13 @@ static int read_empty;\n static struct tree *trees[MAX_UNPACK_TREES];\n static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;\n \n-static int list_tree(unsigned char *sha1)\n+static int list_tree(struct object_id *oid)\n {\n \tstruct tree *tree;\n \n \tif (nr_trees >= MAX_UNPACK_TREES)\n \t\tdie(\"I cannot read more than %d trees\", MAX_UNPACK_TREES);\n-\ttree = parse_tree_indirect(sha1);\n+\ttree = parse_tree_indirect(oid->hash);\n \tif (!tree)\n \t\treturn -1;\n \ttrees[nr_trees++] = tree;\n@@ -121,7 +121,7 @@ static struct lock_file lock_file;\n int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)\n {\n \tint i, stage = 0;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct tree_desc t[MAX_UNPACK_TREES];\n \tstruct unpack_trees_options opts;\n \tint prefix_set = 0;\n@@ -204,9 +204,9 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)\n \tfor (i = 0; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \n-\t\tif (get_sha1(arg, sha1))\n+\t\tif (get_oid(arg, &oid))\n \t\t\tdie(\"Not a valid object name %s\", arg);\n-\t\tif (list_tree(sha1) < 0)\n+\t\tif (list_tree(&oid) < 0)\n \t\t\tdie(\"failed to unpack tree object %s\", arg);\n \t\tstage++;\n \t}\n"},{"id":"317612","messageId":"20170423213453.253425-48-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 47/53] sequencer: convert fast_forward_to to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:47Z","receivedAt":"2017-04-23T21:38:03Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"fast_forward_to is required for checkout_fast_fowrard, which is required\nfor parse_tree_indirect.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n sequencer.c | 22 +++++++++++-----------\n 1 file changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 6957f3b4e..c673bb930 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -374,7 +374,7 @@ static void update_abort_safety_file(void)\n \t\twrite_file(git_path_abort_safety_file(), \"%s\", \"\");\n }\n \n-static int fast_forward_to(const unsigned char *to, const unsigned char *from,\n+static int fast_forward_to(const struct object_id *to, const struct object_id *from,\n \t\t\tint unborn, struct replay_opts *opts)\n {\n \tstruct ref_transaction *transaction;\n@@ -382,7 +382,7 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,\n \tstruct strbuf err = STRBUF_INIT;\n \n \tread_cache();\n-\tif (checkout_fast_forward(from, to, 1))\n+\tif (checkout_fast_forward(from->hash, to->hash, 1))\n \t\treturn -1; /* the callee should have complained already */\n \n \tstrbuf_addf(&sb, _(\"%s: fast-forward\"), _(action_name(opts)));\n@@ -390,7 +390,7 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,\n \ttransaction = ref_transaction_begin(&err);\n \tif (!transaction ||\n \t    ref_transaction_update(transaction, \"HEAD\",\n-\t\t\t\t   to, unborn ? null_sha1 : from,\n+\t\t\t\t   to->hash, unborn ? null_sha1 : from->hash,\n \t\t\t\t   0, sb.buf, &err) ||\n \t    ref_transaction_commit(transaction, &err)) {\n \t\tref_transaction_free(transaction);\n@@ -935,7 +935,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n {\n \tunsigned int flags = opts->edit ? EDIT_MSG : 0;\n \tconst char *msg_file = opts->edit ? NULL : git_path_merge_msg();\n-\tunsigned char head[20];\n+\tstruct object_id head;\n \tstruct commit *base, *next, *parent;\n \tconst char *base_label, *next_label;\n \tstruct commit_message msg = { NULL, NULL, NULL, NULL };\n@@ -949,12 +949,12 @@ 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, 0, NULL))\n+\t\tif (write_cache_as_tree(head.hash, 0, NULL))\n \t\t\treturn error(_(\"your index file is unmerged.\"));\n \t} else {\n-\t\tunborn = get_sha1(\"HEAD\", head);\n+\t\tunborn = get_oid(\"HEAD\", &head);\n \t\tif (unborn)\n-\t\t\thashcpy(head, EMPTY_TREE_SHA1_BIN);\n+\t\t\toidcpy(&head, &empty_tree_oid);\n \t\tif (index_differs_from(unborn ? EMPTY_TREE_SHA1_HEX : \"HEAD\", 0, 0))\n \t\t\treturn error_dirty_index(opts);\n \t}\n@@ -990,11 +990,11 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\t\toid_to_hex(&commit->object.oid));\n \n \tif (opts->allow_ff && !is_fixup(command) &&\n-\t    ((parent && !hashcmp(parent->object.oid.hash, head)) ||\n+\t    ((parent && !oidcmp(&parent->object.oid, &head)) ||\n \t     (!parent && unborn))) {\n \t\tif (is_rebase_i(opts))\n \t\t\twrite_author_script(msg.message);\n-\t\tres = fast_forward_to(commit->object.oid.hash, head, unborn,\n+\t\tres = fast_forward_to(&commit->object.oid, &head, unborn,\n \t\t\topts);\n \t\tif (res || command != TODO_REWORD)\n \t\t\tgoto leave;\n@@ -1081,7 +1081,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\tres = -1;\n \telse if (!opts->strategy || !strcmp(opts->strategy, \"recursive\") || command == TODO_REVERT) {\n \t\tres = do_recursive_merge(base, next, base_label, next_label,\n-\t\t\t\t\t head, &msgbuf, opts);\n+\t\t\t\t\t head.hash, &msgbuf, opts);\n \t\tif (res < 0)\n \t\t\treturn res;\n \t\tres |= write_message(msgbuf.buf, msgbuf.len,\n@@ -1097,7 +1097,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\tcommit_list_insert(next, &remotes);\n \t\tres |= try_merge_command(opts->strategy,\n \t\t\t\t\t opts->xopts_nr, (const char **)opts->xopts,\n-\t\t\t\t\tcommon, sha1_to_hex(head), remotes);\n+\t\t\t\t\tcommon, oid_to_hex(&head), remotes);\n \t\tfree_commit_list(common);\n \t\tfree_commit_list(remotes);\n \t}\n"},{"id":"317613","messageId":"20170423213453.253425-52-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 51/53] sequencer: convert do_recursive_merge to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:51Z","receivedAt":"2017-04-23T21:38:06Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This conversion is required to convert parse_tree_indirect.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n sequencer.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex dfa44afa7..ed48c4c29 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -426,7 +426,7 @@ void append_conflicts_hint(struct strbuf *msgbuf)\n \n static int do_recursive_merge(struct commit *base, struct commit *next,\n \t\t\t      const char *base_label, const char *next_label,\n-\t\t\t      unsigned char *head, struct strbuf *msgbuf,\n+\t\t\t      struct object_id *head, struct strbuf *msgbuf,\n \t\t\t      struct replay_opts *opts)\n {\n \tstruct merge_options o;\n@@ -446,7 +446,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n \tif (is_rebase_i(opts))\n \t\to.buffer_output = 2;\n \n-\thead_tree = parse_tree_indirect(head);\n+\thead_tree = parse_tree_indirect(head->hash);\n \tnext_tree = next ? next->tree : empty_tree();\n \tbase_tree = base ? base->tree : empty_tree();\n \n@@ -1081,7 +1081,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\tres = -1;\n \telse if (!opts->strategy || !strcmp(opts->strategy, \"recursive\") || command == TODO_REVERT) {\n \t\tres = do_recursive_merge(base, next, base_label, next_label,\n-\t\t\t\t\t head.hash, &msgbuf, opts);\n+\t\t\t\t\t &head, &msgbuf, opts);\n \t\tif (res < 0)\n \t\t\treturn res;\n \t\tres |= write_message(msgbuf.buf, msgbuf.len,\n"},{"id":"317614","messageId":"20170423213453.253425-51-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 50/53] diff-lib: convert do_diff_cache to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:50Z","receivedAt":"2017-04-23T21:38:09Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is needed to convert parse_tree_indirect.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/am.c    |  2 +-\n builtin/blame.c |  6 +++---\n builtin/reset.c |  2 +-\n diff-lib.c      | 12 ++++++------\n diff.h          |  2 +-\n 5 files changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 46828646c..210ecc554 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1143,7 +1143,7 @@ static int index_has_changes(struct strbuf *sb)\n \t\tDIFF_OPT_SET(&opt, EXIT_WITH_STATUS);\n \t\tif (!sb)\n \t\t\tDIFF_OPT_SET(&opt, QUICK);\n-\t\tdo_diff_cache(head.hash, &opt);\n+\t\tdo_diff_cache(&head, &opt);\n \t\tdiffcore_std(&opt);\n \t\tfor (i = 0; sb && i < diff_queued_diff.nr; i++) {\n \t\t\tif (i)\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 58bb274d0..e920314a7 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -563,7 +563,7 @@ static struct origin *find_origin(struct scoreboard *sb,\n \tdiff_setup_done(&diff_opts);\n \n \tif (is_null_oid(&origin->commit->object.oid))\n-\t\tdo_diff_cache(parent->tree->object.oid.hash, &diff_opts);\n+\t\tdo_diff_cache(&parent->tree->object.oid, &diff_opts);\n \telse\n \t\tdiff_tree_sha1(parent->tree->object.oid.hash,\n \t\t\t       origin->commit->tree->object.oid.hash,\n@@ -633,7 +633,7 @@ static struct origin *find_rename(struct scoreboard *sb,\n \tdiff_setup_done(&diff_opts);\n \n \tif (is_null_oid(&origin->commit->object.oid))\n-\t\tdo_diff_cache(parent->tree->object.oid.hash, &diff_opts);\n+\t\tdo_diff_cache(&parent->tree->object.oid, &diff_opts);\n \telse\n \t\tdiff_tree_sha1(parent->tree->object.oid.hash,\n \t\t\t       origin->commit->tree->object.oid.hash,\n@@ -1272,7 +1272,7 @@ static void find_copy_in_parent(struct scoreboard *sb,\n \t\tDIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);\n \n \tif (is_null_oid(&target->commit->object.oid))\n-\t\tdo_diff_cache(parent->tree->object.oid.hash, &diff_opts);\n+\t\tdo_diff_cache(&parent->tree->object.oid, &diff_opts);\n \telse\n \t\tdiff_tree_sha1(parent->tree->object.oid.hash,\n \t\t\t       target->commit->tree->object.oid.hash,\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 0be52fa36..3415dac5d 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -154,7 +154,7 @@ static int read_from_tree(const struct pathspec *pathspec,\n \topt.format_callback = update_index_from_diff;\n \topt.format_callback_data = &intent_to_add;\n \n-\tif (do_diff_cache(tree_oid->hash, &opt))\n+\tif (do_diff_cache(tree_oid, &opt))\n \t\treturn 1;\n \tdiffcore_std(&opt);\n \tdiff_flush(&opt);\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 52447466b..ee9df0f84 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -478,7 +478,7 @@ static int oneway_diff(const struct cache_entry * const *src,\n }\n \n static int diff_cache(struct rev_info *revs,\n-\t\t      const unsigned char *tree_sha1,\n+\t\t      const struct object_id *tree_oid,\n \t\t      const char *tree_name,\n \t\t      int cached)\n {\n@@ -486,10 +486,10 @@ static int diff_cache(struct rev_info *revs,\n \tstruct tree_desc t;\n \tstruct unpack_trees_options opts;\n \n-\ttree = parse_tree_indirect(tree_sha1);\n+\ttree = parse_tree_indirect(tree_oid->hash);\n \tif (!tree)\n \t\treturn error(\"bad tree object %s\",\n-\t\t\t     tree_name ? tree_name : sha1_to_hex(tree_sha1));\n+\t\t\t     tree_name ? tree_name : oid_to_hex(tree_oid));\n \tmemset(&opts, 0, sizeof(opts));\n \topts.head_idx = 1;\n \topts.index_only = cached;\n@@ -512,7 +512,7 @@ int run_diff_index(struct rev_info *revs, int cached)\n \tstruct object_array_entry *ent;\n \n \tent = revs->pending.objects;\n-\tif (diff_cache(revs, ent->item->oid.hash, ent->name, cached))\n+\tif (diff_cache(revs, &ent->item->oid, ent->name, cached))\n \t\texit(128);\n \n \tdiff_set_mnemonic_prefix(&revs->diffopt, \"c/\", cached ? \"i/\" : \"w/\");\n@@ -522,7 +522,7 @@ int run_diff_index(struct rev_info *revs, int cached)\n \treturn 0;\n }\n \n-int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)\n+int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)\n {\n \tstruct rev_info revs;\n \n@@ -530,7 +530,7 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)\n \tcopy_pathspec(&revs.prune_data, &opt->pathspec);\n \trevs.diffopt = *opt;\n \n-\tif (diff_cache(&revs, tree_sha1, NULL, 1))\n+\tif (diff_cache(&revs, tree_oid, NULL, 1))\n \t\texit(128);\n \treturn 0;\n }\ndiff --git a/diff.h b/diff.h\nindex 5be1ee77a..d75e6d15e 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -354,7 +354,7 @@ extern const char *diff_aligned_abbrev(const struct object_id *sha1, int);\n extern int run_diff_files(struct rev_info *revs, unsigned int option);\n extern int run_diff_index(struct rev_info *revs, int cached);\n \n-extern int do_diff_cache(const unsigned char *, struct diff_options *);\n+extern int do_diff_cache(const struct object_id *, struct diff_options *);\n extern int diff_flush_patch_id(struct diff_options *, unsigned char *, int);\n \n extern int diff_result_code(struct diff_options *, int);\n"},{"id":"317615","messageId":"20170423213453.253425-49-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 48/53] merge: convert checkout_fast_forward to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:48Z","receivedAt":"2017-04-23T21:38:12Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Converting checkout_fast_forward is required to convert\nparse_tree_indirect.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/merge.c | 4 ++--\n builtin/pull.c  | 4 ++--\n cache.h         | 4 ++--\n merge.c         | 8 ++++----\n sequencer.c     | 2 +-\n 5 files changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex f11b5f3de..5ea7f7da9 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -1372,8 +1372,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\t\tgoto done;\n \t\t}\n \n-\t\tif (checkout_fast_forward(head_commit->object.oid.hash,\n-\t\t\t\t\t  commit->object.oid.hash,\n+\t\tif (checkout_fast_forward(&head_commit->object.oid,\n+\t\t\t\t\t  &commit->object.oid,\n \t\t\t\t\t  overwrite_ignore)) {\n \t\t\tret = 1;\n \t\t\tgoto done;\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 21e114ec0..f539c7f78 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -523,7 +523,7 @@ static int pull_into_void(const struct object_id *merge_head,\n \t * index/worktree changes that the user already made on the unborn\n \t * branch.\n \t */\n-\tif (checkout_fast_forward(EMPTY_TREE_SHA1_BIN, merge_head->hash, 0))\n+\tif (checkout_fast_forward(&empty_tree_oid, merge_head, 0))\n \t\treturn 1;\n \n \tif (update_ref(\"initial pull\", \"HEAD\", merge_head->hash, curr_head->hash, 0, UPDATE_REFS_DIE_ON_ERR))\n@@ -839,7 +839,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)\n \t\t\t\"fast-forwarding your working tree from\\n\"\n \t\t\t\"commit %s.\"), oid_to_hex(&orig_head));\n \n-\t\tif (checkout_fast_forward(orig_head.hash, curr_head.hash, 0))\n+\t\tif (checkout_fast_forward(&orig_head, &curr_head, 0))\n \t\t\tdie(_(\"Cannot fast-forward your working tree.\\n\"\n \t\t\t\t\"After making sure that you saved anything precious from\\n\"\n \t\t\t\t\"$ git diff %s\\n\"\ndiff --git a/cache.h b/cache.h\nindex ba27595d5..552c44ef0 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -2188,8 +2188,8 @@ struct commit_list;\n int try_merge_command(const char *strategy, size_t xopts_nr,\n \t\tconst char **xopts, struct commit_list *common,\n \t\tconst char *head_arg, struct commit_list *remotes);\n-int checkout_fast_forward(const unsigned char *from,\n-\t\t\t  const unsigned char *to,\n+int checkout_fast_forward(const struct object_id *from,\n+\t\t\t  const struct object_id *to,\n \t\t\t  int overwrite_ignore);\n \n \ndiff --git a/merge.c b/merge.c\nindex 04ee5fc91..b0cffe16f 100644\n--- a/merge.c\n+++ b/merge.c\n@@ -44,8 +44,8 @@ int try_merge_command(const char *strategy, size_t xopts_nr,\n \treturn ret;\n }\n \n-int checkout_fast_forward(const unsigned char *head,\n-\t\t\t  const unsigned char *remote,\n+int checkout_fast_forward(const struct object_id *head,\n+\t\t\t  const struct object_id *remote,\n \t\t\t  int overwrite_ignore)\n {\n \tstruct tree *trees[MAX_UNPACK_TREES];\n@@ -79,10 +79,10 @@ int checkout_fast_forward(const unsigned char *head,\n \topts.fn = twoway_merge;\n \tsetup_unpack_trees_porcelain(&opts, \"merge\");\n \n-\ttrees[nr_trees] = parse_tree_indirect(head);\n+\ttrees[nr_trees] = parse_tree_indirect(head->hash);\n \tif (!trees[nr_trees++])\n \t\treturn -1;\n-\ttrees[nr_trees] = parse_tree_indirect(remote);\n+\ttrees[nr_trees] = parse_tree_indirect(remote->hash);\n \tif (!trees[nr_trees++])\n \t\treturn -1;\n \tfor (i = 0; i < nr_trees; i++) {\ndiff --git a/sequencer.c b/sequencer.c\nindex c673bb930..dfa44afa7 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -382,7 +382,7 @@ static int fast_forward_to(const struct object_id *to, const struct object_id *f\n \tstruct strbuf err = STRBUF_INIT;\n \n \tread_cache();\n-\tif (checkout_fast_forward(from->hash, to->hash, 1))\n+\tif (checkout_fast_forward(from, to, 1))\n \t\treturn -1; /* the callee should have complained already */\n \n \tstrbuf_addf(&sb, _(\"%s: fast-forward\"), _(action_name(opts)));\n"},{"id":"317616","messageId":"20170423213453.253425-50-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 49/53] builtin/ls-tree: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:49Z","receivedAt":"2017-04-23T21:38:16Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is a prerequisite to convert do_diff_cache, which is required to\nconvert parse_tree_indirect.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/ls-tree.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex d7ebeb4ce..5baac3ef2 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -119,7 +119,7 @@ static int show_tree(const unsigned char *sha1, struct strbuf *base,\n \n int cmd_ls_tree(int argc, const char **argv, const char *prefix)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct tree *tree;\n \tint i, full_tree = 0;\n \tconst struct option ls_tree_options[] = {\n@@ -164,7 +164,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)\n \n \tif (argc < 1)\n \t\tusage_with_options(ls_tree_usage, ls_tree_options);\n-\tif (get_sha1(argv[0], sha1))\n+\tif (get_oid(argv[0], &oid))\n \t\tdie(\"Not a valid object name %s\", argv[0]);\n \n \t/*\n@@ -180,7 +180,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)\n \tfor (i = 0; i < pathspec.nr; i++)\n \t\tpathspec.items[i].nowildcard_len = pathspec.items[i].len;\n \tpathspec.has_wildcard = 0;\n-\ttree = parse_tree_indirect(sha1);\n+\ttree = parse_tree_indirect(oid.hash);\n \tif (!tree)\n \t\tdie(\"not a tree object\");\n \treturn !!read_tree_recursive(tree, \"\", 0, 0, &pathspec, show_tree, NULL);\n"},{"id":"317617","messageId":"20170423213453.253425-45-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 44/53] sha1_name: convert internals of peel_onion to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:44Z","receivedAt":"2017-04-23T21:38:19Z","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 sha1_name.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex b7e09ac13..72e72ab9a 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -798,7 +798,7 @@ struct object *peel_to_type(const char *name, int namelen,\n static int peel_onion(const char *name, int len, unsigned char *sha1,\n \t\t      unsigned lookup_flags)\n {\n-\tunsigned char outer[20];\n+\tstruct object_id outer;\n \tconst char *sp;\n \tunsigned int expected_type = 0;\n \tstruct object *o;\n@@ -846,10 +846,10 @@ static int peel_onion(const char *name, int len, unsigned char *sha1,\n \telse if (expected_type == OBJ_TREE)\n \t\tlookup_flags |= GET_SHA1_TREEISH;\n \n-\tif (get_sha1_1(name, sp - name - 2, outer, lookup_flags))\n+\tif (get_sha1_1(name, sp - name - 2, outer.hash, lookup_flags))\n \t\treturn -1;\n \n-\to = parse_object(outer);\n+\to = parse_object(outer.hash);\n \tif (!o)\n \t\treturn -1;\n \tif (!expected_type) {\n"},{"id":"317618","messageId":"20170423213453.253425-43-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 42/53] revision: convert remaining parse_object callers to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:42Z","receivedAt":"2017-04-23T21:38:21Z","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 revision.c | 44 ++++++++++++++++++++++----------------------\n 1 file changed, 22 insertions(+), 22 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex f82c56e1f..80f74bb7b 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -177,23 +177,23 @@ void add_pending_object(struct rev_info *revs,\n \n void add_head_to_pending(struct rev_info *revs)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct object *obj;\n-\tif (get_sha1(\"HEAD\", sha1))\n+\tif (get_oid(\"HEAD\", &oid))\n \t\treturn;\n-\tobj = parse_object(sha1);\n+\tobj = parse_object(oid.hash);\n \tif (!obj)\n \t\treturn;\n \tadd_pending_object(revs, obj, \"HEAD\");\n }\n \n static struct object *get_reference(struct rev_info *revs, const char *name,\n-\t\t\t\t    const unsigned char *sha1,\n+\t\t\t\t    const struct object_id *oid,\n \t\t\t\t    unsigned int flags)\n {\n \tstruct object *object;\n \n-\tobject = parse_object(sha1);\n+\tobject = parse_object(oid->hash);\n \tif (!object) {\n \t\tif (revs->ignore_missing)\n \t\t\treturn object;\n@@ -206,7 +206,7 @@ static struct object *get_reference(struct rev_info *revs, const char *name,\n void add_pending_oid(struct rev_info *revs, const char *name,\n \t\t      const struct object_id *oid, unsigned int flags)\n {\n-\tstruct object *object = get_reference(revs, name, oid->hash, flags);\n+\tstruct object *object = get_reference(revs, name, oid, flags);\n \tadd_pending_object(revs, object, name);\n }\n \n@@ -1157,7 +1157,7 @@ static int handle_one_ref(const char *path, const struct object_id *oid,\n \tif (ref_excluded(cb->all_revs->ref_excludes, path))\n \t    return 0;\n \n-\tobject = get_reference(cb->all_revs, path, oid->hash, cb->all_flags);\n+\tobject = get_reference(cb->all_revs, path, oid, cb->all_flags);\n \tadd_rev_cmdline(cb->all_revs, object, path, REV_CMD_REF, cb->all_flags);\n \tadd_pending_oid(cb->all_revs, path, oid, cb->all_flags);\n \treturn 0;\n@@ -1292,7 +1292,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)\n static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,\n \t\t\t    int exclude_parent)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct object *it;\n \tstruct commit *commit;\n \tstruct commit_list *parents;\n@@ -1303,17 +1303,17 @@ static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,\n \t\tflags ^= UNINTERESTING | BOTTOM;\n \t\targ++;\n \t}\n-\tif (get_sha1_committish(arg, sha1))\n+\tif (get_sha1_committish(arg, oid.hash))\n \t\treturn 0;\n \twhile (1) {\n-\t\tit = get_reference(revs, arg, sha1, 0);\n+\t\tit = get_reference(revs, arg, &oid, 0);\n \t\tif (!it && revs->ignore_missing)\n \t\t\treturn 0;\n \t\tif (it->type != OBJ_TAG)\n \t\t\tbreak;\n \t\tif (!((struct tag*)it)->tagged)\n \t\t\treturn 0;\n-\t\thashcpy(sha1, ((struct tag*)it)->tagged->oid.hash);\n+\t\toidcpy(&oid, &((struct tag*)it)->tagged->oid);\n \t}\n \tif (it->type != OBJ_COMMIT)\n \t\treturn 0;\n@@ -1434,7 +1434,7 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi\n \tstruct object_context oc;\n \tchar *dotdot;\n \tstruct object *object;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tint local_flags;\n \tconst char *arg = arg_;\n \tint cant_be_filename = revarg_opt & REVARG_CANNOT_BE_FILENAME;\n@@ -1444,7 +1444,7 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi\n \n \tdotdot = strstr(arg, \"..\");\n \tif (dotdot) {\n-\t\tunsigned char from_sha1[20];\n+\t\tstruct object_id from_oid;\n \t\tconst char *next = dotdot + 2;\n \t\tconst char *this = arg;\n \t\tint symmetric = *next == '.';\n@@ -1470,8 +1470,8 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi\n \t\t\t\treturn -1;\n \t\t\t}\n \t\t}\n-\t\tif (!get_sha1_committish(this, from_sha1) &&\n-\t\t    !get_sha1_committish(next, sha1)) {\n+\t\tif (!get_sha1_committish(this, from_oid.hash) &&\n+\t\t    !get_sha1_committish(next, oid.hash)) {\n \t\t\tstruct object *a_obj, *b_obj;\n \n \t\t\tif (!cant_be_filename) {\n@@ -1479,8 +1479,8 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi\n \t\t\t\tverify_non_filename(revs->prefix, arg);\n \t\t\t}\n \n-\t\t\ta_obj = parse_object(from_sha1);\n-\t\t\tb_obj = parse_object(sha1);\n+\t\t\ta_obj = parse_object(from_oid.hash);\n+\t\t\tb_obj = parse_object(oid.hash);\n \t\t\tif (!a_obj || !b_obj) {\n \t\t\tmissing:\n \t\t\t\tif (revs->ignore_missing)\n@@ -1568,11 +1568,11 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi\n \tif (revarg_opt & REVARG_COMMITTISH)\n \t\tget_sha1_flags = GET_SHA1_COMMITTISH;\n \n-\tif (get_sha1_with_context(arg, get_sha1_flags, sha1, &oc))\n+\tif (get_sha1_with_context(arg, get_sha1_flags, oid.hash, &oc))\n \t\treturn revs->ignore_missing ? 0 : -1;\n \tif (!cant_be_filename)\n \t\tverify_non_filename(revs->prefix, arg);\n-\tobject = get_reference(revs, arg, sha1, flags ^ local_flags);\n+\tobject = get_reference(revs, arg, &oid, flags ^ local_flags);\n \tadd_rev_cmdline(revs, object, arg_, REV_CMD_REV, flags ^ local_flags);\n \tadd_pending_object_with_mode(revs, object, arg, oc.mode);\n \treturn 0;\n@@ -2287,12 +2287,12 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s\n \tif (revs->show_merge)\n \t\tprepare_show_merge(revs);\n \tif (revs->def && !revs->pending.nr && !got_rev_arg) {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tstruct object *object;\n \t\tstruct object_context oc;\n-\t\tif (get_sha1_with_context(revs->def, 0, sha1, &oc))\n+\t\tif (get_sha1_with_context(revs->def, 0, oid.hash, &oc))\n \t\t\tdiagnose_missing_default(revs->def);\n-\t\tobject = get_reference(revs, revs->def, sha1, 0);\n+\t\tobject = get_reference(revs, revs->def, &oid, 0);\n \t\tadd_pending_object_with_mode(revs, object, revs->def, oc.mode);\n \t}\n \n"},{"id":"317619","messageId":"20170423213453.253425-53-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 52/53] tree: convert parse_tree_indirect to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:52Z","receivedAt":"2017-04-23T21:38:25Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert parse_tree_indirect to take a pointer to struct object_id.\nUpdate all the callers.  This transformation was achieved using the\nfollowing semantic patch and manual updates to the declaration and\ndefinition.  Update builtin/checkout.c manually as well, since it uses a\nternary expression not handled by the semantic patch.\n\n@@\nexpression E1;\n@@\n- parse_tree_indirect(E1.hash)\n+ parse_tree_indirect(&E1)\n\n@@\nexpression E1;\n@@\n- parse_tree_indirect(E1->hash)\n+ parse_tree_indirect(E1)\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n archive.c                   | 4 ++--\n builtin/am.c                | 6 +++---\n builtin/checkout.c          | 8 ++++----\n builtin/clone.c             | 2 +-\n builtin/commit.c            | 2 +-\n builtin/ls-files.c          | 2 +-\n builtin/ls-tree.c           | 2 +-\n builtin/merge.c             | 6 +++---\n builtin/read-tree.c         | 2 +-\n builtin/reset.c             | 4 ++--\n diff-lib.c                  | 2 +-\n merge.c                     | 4 ++--\n sequencer.c                 | 2 +-\n t/helper/test-match-trees.c | 4 ++--\n tree.c                      | 4 ++--\n tree.h                      | 2 +-\n 16 files changed, 28 insertions(+), 28 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 54701e8bb..b15a922da 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -369,7 +369,7 @@ static void parse_treeish_arg(const char **argv,\n \t\tarchive_time = time(NULL);\n \t}\n \n-\ttree = parse_tree_indirect(oid.hash);\n+\ttree = parse_tree_indirect(&oid);\n \tif (tree == NULL)\n \t\tdie(\"not a tree object\");\n \n@@ -383,7 +383,7 @@ static void parse_treeish_arg(const char **argv,\n \t\tif (err || !S_ISDIR(mode))\n \t\t\tdie(\"current working directory is untracked\");\n \n-\t\ttree = parse_tree_indirect(tree_oid.hash);\n+\t\ttree = parse_tree_indirect(&tree_oid);\n \t}\n \tar_args->tree = tree;\n \tar_args->commit_sha1 = commit_sha1;\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 210ecc554..c21059e6e 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -2046,11 +2046,11 @@ static int clean_index(const struct object_id *head, const struct object_id *rem\n \tstruct tree *head_tree, *remote_tree, *index_tree;\n \tstruct object_id index;\n \n-\thead_tree = parse_tree_indirect(head->hash);\n+\thead_tree = parse_tree_indirect(head);\n \tif (!head_tree)\n \t\treturn error(_(\"Could not parse object '%s'.\"), oid_to_hex(head));\n \n-\tremote_tree = parse_tree_indirect(remote->hash);\n+\tremote_tree = parse_tree_indirect(remote);\n \tif (!remote_tree)\n \t\treturn error(_(\"Could not parse object '%s'.\"), oid_to_hex(remote));\n \n@@ -2062,7 +2062,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem\n \tif (write_cache_as_tree(index.hash, 0, NULL))\n \t\treturn -1;\n \n-\tindex_tree = parse_tree_indirect(index.hash);\n+\tindex_tree = parse_tree_indirect(&index);\n \tif (!index_tree)\n \t\treturn error(_(\"Could not parse object '%s'.\"), oid_to_hex(&index));\n \ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 7f1eeea94..13365fb62 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -527,10 +527,10 @@ static int merge_working_tree(const struct checkout_opts *opts,\n \t\t\tsetup_standard_excludes(topts.dir);\n \t\t}\n \t\ttree = parse_tree_indirect(old->commit ?\n-\t\t\t\t\t   old->commit->object.oid.hash :\n-\t\t\t\t\t   EMPTY_TREE_SHA1_BIN);\n+\t\t\t\t\t   &old->commit->object.oid :\n+\t\t\t\t\t   &empty_tree_oid);\n \t\tinit_tree_desc(&trees[0], tree->buffer, tree->size);\n-\t\ttree = parse_tree_indirect(new->commit->object.oid.hash);\n+\t\ttree = parse_tree_indirect(&new->commit->object.oid);\n \t\tinit_tree_desc(&trees[1], tree->buffer, tree->size);\n \n \t\tret = unpack_trees(2, trees, &topts);\n@@ -1050,7 +1050,7 @@ static int parse_branchname_arg(int argc, const char **argv,\n \tnew->commit = lookup_commit_reference_gently(rev, 1);\n \tif (!new->commit) {\n \t\t/* not a commit */\n-\t\t*source_tree = parse_tree_indirect(rev->hash);\n+\t\t*source_tree = parse_tree_indirect(rev);\n \t} else {\n \t\tparse_commit_or_die(new->commit);\n \t\t*source_tree = new->commit->tree;\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 646f28792..da2d3c1ae 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -739,7 +739,7 @@ static int checkout(int submodule_progress)\n \topts.src_index = &the_index;\n \topts.dst_index = &the_index;\n \n-\ttree = parse_tree_indirect(oid.hash);\n+\ttree = parse_tree_indirect(&oid);\n \tparse_tree(tree);\n \tinit_tree_desc(&t, tree->buffer, tree->size);\n \tif (unpack_trees(1, &t, &opts) < 0)\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex d349d48ef..1d625e49e 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -313,7 +313,7 @@ static void create_base_index(const struct commit *current_head)\n \topts.dst_index = &the_index;\n \n \topts.fn = oneway_merge;\n-\ttree = parse_tree_indirect(current_head->object.oid.hash);\n+\ttree = parse_tree_indirect(&current_head->object.oid);\n \tif (!tree)\n \t\tdie(_(\"failed to unpack HEAD tree object\"));\n \tparse_tree(tree);\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex 948c7066c..cac802ff9 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -414,7 +414,7 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)\n \n \tif (get_oid(tree_name, &oid))\n \t\tdie(\"tree-ish %s not found.\", tree_name);\n-\ttree = parse_tree_indirect(oid.hash);\n+\ttree = parse_tree_indirect(&oid);\n \tif (!tree)\n \t\tdie(\"bad tree-ish %s\", tree_name);\n \ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 5baac3ef2..ee7b293b1 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -180,7 +180,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)\n \tfor (i = 0; i < pathspec.nr; i++)\n \t\tpathspec.items[i].nowildcard_len = pathspec.items[i].len;\n \tpathspec.has_wildcard = 0;\n-\ttree = parse_tree_indirect(oid.hash);\n+\ttree = parse_tree_indirect(&oid);\n \tif (!tree)\n \t\tdie(\"not a tree object\");\n \treturn !!read_tree_recursive(tree, \"\", 0, 0, &pathspec, show_tree, NULL);\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 5ea7f7da9..a4a098f40 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -605,13 +605,13 @@ static int read_tree_trivial(struct object_id *common, struct object_id *head,\n \topts.verbose_update = 1;\n \topts.trivial_merges_only = 1;\n \topts.merge = 1;\n-\ttrees[nr_trees] = parse_tree_indirect(common->hash);\n+\ttrees[nr_trees] = parse_tree_indirect(common);\n \tif (!trees[nr_trees++])\n \t\treturn -1;\n-\ttrees[nr_trees] = parse_tree_indirect(head->hash);\n+\ttrees[nr_trees] = parse_tree_indirect(head);\n \tif (!trees[nr_trees++])\n \t\treturn -1;\n-\ttrees[nr_trees] = parse_tree_indirect(one->hash);\n+\ttrees[nr_trees] = parse_tree_indirect(one);\n \tif (!trees[nr_trees++])\n \t\treturn -1;\n \topts.fn = threeway_merge;\ndiff --git a/builtin/read-tree.c b/builtin/read-tree.c\nindex 92eff23e4..6d45175f6 100644\n--- a/builtin/read-tree.c\n+++ b/builtin/read-tree.c\n@@ -29,7 +29,7 @@ static int list_tree(struct object_id *oid)\n \n \tif (nr_trees >= MAX_UNPACK_TREES)\n \t\tdie(\"I cannot read more than %d trees\", MAX_UNPACK_TREES);\n-\ttree = parse_tree_indirect(oid->hash);\n+\ttree = parse_tree_indirect(oid);\n \tif (!tree)\n \t\treturn -1;\n \ttrees[nr_trees++] = tree;\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 3415dac5d..c782739c2 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -84,7 +84,7 @@ static int reset_index(const struct object_id *oid, int reset_type, int quiet)\n \t\treturn -1;\n \n \tif (reset_type == MIXED || reset_type == HARD) {\n-\t\ttree = parse_tree_indirect(oid->hash);\n+\t\ttree = parse_tree_indirect(oid);\n \t\tprime_cache_tree(&the_index, tree);\n \t}\n \n@@ -311,7 +311,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \t\tstruct tree *tree;\n \t\tif (get_sha1_treeish(rev, oid.hash))\n \t\t\tdie(_(\"Failed to resolve '%s' as a valid tree.\"), rev);\n-\t\ttree = parse_tree_indirect(oid.hash);\n+\t\ttree = parse_tree_indirect(&oid);\n \t\tif (!tree)\n \t\t\tdie(_(\"Could not parse object '%s'.\"), rev);\n \t\toidcpy(&oid, &tree->object.oid);\ndiff --git a/diff-lib.c b/diff-lib.c\nindex ee9df0f84..2982bf055 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -486,7 +486,7 @@ static int diff_cache(struct rev_info *revs,\n \tstruct tree_desc t;\n \tstruct unpack_trees_options opts;\n \n-\ttree = parse_tree_indirect(tree_oid->hash);\n+\ttree = parse_tree_indirect(tree_oid);\n \tif (!tree)\n \t\treturn error(\"bad tree object %s\",\n \t\t\t     tree_name ? tree_name : oid_to_hex(tree_oid));\ndiff --git a/merge.c b/merge.c\nindex b0cffe16f..1d441ad94 100644\n--- a/merge.c\n+++ b/merge.c\n@@ -79,10 +79,10 @@ int checkout_fast_forward(const struct object_id *head,\n \topts.fn = twoway_merge;\n \tsetup_unpack_trees_porcelain(&opts, \"merge\");\n \n-\ttrees[nr_trees] = parse_tree_indirect(head->hash);\n+\ttrees[nr_trees] = parse_tree_indirect(head);\n \tif (!trees[nr_trees++])\n \t\treturn -1;\n-\ttrees[nr_trees] = parse_tree_indirect(remote->hash);\n+\ttrees[nr_trees] = parse_tree_indirect(remote);\n \tif (!trees[nr_trees++])\n \t\treturn -1;\n \tfor (i = 0; i < nr_trees; i++) {\ndiff --git a/sequencer.c b/sequencer.c\nindex ed48c4c29..a2aa77f46 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -446,7 +446,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n \tif (is_rebase_i(opts))\n \t\to.buffer_output = 2;\n \n-\thead_tree = parse_tree_indirect(head->hash);\n+\thead_tree = parse_tree_indirect(head);\n \tnext_tree = next ? next->tree : empty_tree();\n \tbase_tree = base ? base->tree : empty_tree();\n \ndiff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c\nindex e93950286..356d8edef 100644\n--- a/t/helper/test-match-trees.c\n+++ b/t/helper/test-match-trees.c\n@@ -12,10 +12,10 @@ int cmd_main(int ac, const char **av)\n \t\tdie(\"cannot parse %s as an object name\", av[1]);\n \tif (get_oid(av[2], &hash2))\n \t\tdie(\"cannot parse %s as an object name\", av[2]);\n-\tone = parse_tree_indirect(hash1.hash);\n+\tone = parse_tree_indirect(&hash1);\n \tif (!one)\n \t\tdie(\"not a tree-ish %s\", av[1]);\n-\ttwo = parse_tree_indirect(hash2.hash);\n+\ttwo = parse_tree_indirect(&hash2);\n \tif (!two)\n \t\tdie(\"not a tree-ish %s\", av[2]);\n \ndiff --git a/tree.c b/tree.c\nindex 28ce930b9..9adcd8bd4 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -232,9 +232,9 @@ void free_tree_buffer(struct tree *tree)\n \ttree->object.parsed = 0;\n }\n \n-struct tree *parse_tree_indirect(const unsigned char *sha1)\n+struct tree *parse_tree_indirect(const struct object_id *oid)\n {\n-\tstruct object *obj = parse_object(sha1);\n+\tstruct object *obj = parse_object(oid->hash);\n \tdo {\n \t\tif (!obj)\n \t\t\treturn NULL;\ndiff --git a/tree.h b/tree.h\nindex 2b2c8dbbe..0d4734b94 100644\n--- a/tree.h\n+++ b/tree.h\n@@ -24,7 +24,7 @@ static inline int parse_tree(struct tree *tree)\n void free_tree_buffer(struct tree *tree);\n \n /* Parses and returns the tree in the given ent, chasing tags and commits. */\n-struct tree *parse_tree_indirect(const unsigned char *sha1);\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"},{"id":"317620","messageId":"20170423213453.253425-54-sandals@crustytoothpaste.net","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"[PATCH 53/53] object: convert parse_object* to take struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-23T21:34:53Z","receivedAt":"2017-04-23T21:38:27Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Make parse_object, parse_object_or_die, and parse_object_buffer take a\npointer to struct object_id.  Remove the temporary variables inserted\nearlier, since they are no longer necessary.  Transform all of the\ncallers using the following semantic patch:\n\n@@\nexpression E1;\n@@\n- parse_object(E1.hash)\n+ parse_object(&E1)\n\n@@\nexpression E1;\n@@\n- parse_object(E1->hash)\n+ parse_object(E1)\n\n@@\nexpression E1, E2;\n@@\n- parse_object_or_die(E1.hash, E2)\n+ parse_object_or_die(&E1, E2)\n\n@@\nexpression E1, E2;\n@@\n- parse_object_or_die(E1->hash, E2)\n+ parse_object_or_die(E1, E2)\n\n@@\nexpression E1, E2, E3, E4, E5;\n@@\n- parse_object_buffer(E1.hash, E2, E3, E4, E5)\n+ parse_object_buffer(&E1, E2, E3, E4, E5)\n\n@@\nexpression E1, E2, E3, E4, E5;\n@@\n- parse_object_buffer(E1->hash, E2, E3, E4, E5)\n+ parse_object_buffer(E1, E2, E3, E4, E5)\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/diff-tree.c      |  2 +-\n builtin/diff.c           |  2 +-\n builtin/fast-export.c    |  4 ++--\n builtin/fmt-merge-msg.c  |  4 ++--\n builtin/fsck.c           |  8 ++++----\n builtin/grep.c           |  2 +-\n builtin/index-pack.c     |  3 ++-\n builtin/log.c            |  2 +-\n builtin/name-rev.c       |  6 +++---\n builtin/prune.c          |  3 ++-\n builtin/receive-pack.c   |  6 +++---\n builtin/reflog.c         |  2 +-\n builtin/rev-list.c       |  2 +-\n builtin/unpack-objects.c |  3 ++-\n bundle.c                 | 10 ++++++----\n commit.c                 |  4 ++--\n fetch-pack.c             | 14 +++++++-------\n fsck.c                   |  2 +-\n http-backend.c           |  2 +-\n http-push.c              |  4 ++--\n log-tree.c               |  6 +++---\n merge-recursive.c        |  2 +-\n object.c                 | 44 +++++++++++++++++++-------------------------\n object.h                 |  8 ++++----\n pack-bitmap.c            |  4 ++--\n pretty.c                 |  2 +-\n reachable.c              |  4 ++--\n ref-filter.c             |  4 ++--\n reflog-walk.c            |  4 ++--\n refs/files-backend.c     |  2 +-\n remote.c                 |  4 ++--\n revision.c               | 12 ++++++------\n server-info.c            |  2 +-\n sha1_name.c              | 14 +++++++-------\n tag.c                    |  4 ++--\n tree.c                   |  4 ++--\n upload-pack.c            |  8 ++++----\n walker.c                 |  2 +-\n 38 files changed, 107 insertions(+), 108 deletions(-)\n\ndiff --git a/builtin/diff-tree.c b/builtin/diff-tree.c\nindex 95b8d1ba7..5ea1c1431 100644\n--- a/builtin/diff-tree.c\n+++ b/builtin/diff-tree.c\n@@ -67,7 +67,7 @@ static int diff_tree_stdin(char *line)\n \tline[len-1] = 0;\n \tif (parse_oid_hex(line, &oid, &p))\n \t\treturn -1;\n-\tobj = parse_object(oid.hash);\n+\tobj = parse_object(&oid);\n \tif (!obj)\n \t\treturn -1;\n \tif (obj->type == OBJ_COMMIT)\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex 895f92897..8c03ddaf5 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -395,7 +395,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\tconst char *name = entry->name;\n \t\tint flags = (obj->flags & UNINTERESTING);\n \t\tif (!obj->parsed)\n-\t\t\tobj = parse_object(obj->oid.hash);\n+\t\t\tobj = parse_object(&obj->oid);\n \t\tobj = deref_tag(obj, NULL, 0);\n \t\tif (!obj)\n \t\t\tdie(_(\"invalid object '%s' given.\"), name);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex ae36b14db..969550531 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\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\t\tdie(\"sha1 mismatch in blob %s\", oid_to_hex(oid));\n-\t\tobject = parse_object_buffer(oid->hash, type, size, buf, &eaten);\n+\t\tobject = parse_object_buffer(oid, type, size, buf, &eaten);\n \t}\n \n \tif (!object)\n@@ -777,7 +777,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)\n \n \t\t/* handle nested tags */\n \t\twhile (tag && tag->object.type == OBJ_TAG) {\n-\t\t\tparse_object(tag->object.oid.hash);\n+\t\t\tparse_object(&tag->object.oid);\n \t\t\tstring_list_append(&extra_refs, full_name)->util = tag;\n \t\t\ttag = (struct tag *)tag->tagged;\n \t\t}\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 91dd753dd..70137b0b7 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -341,7 +341,7 @@ static void shortlog(const char *name,\n \tconst struct object_id *oid = &origin_data->oid;\n \tint limit = opts->shortlog_len;\n \n-\tbranch = deref_tag(parse_object(oid->hash), oid_to_hex(oid), GIT_SHA1_HEXSZ);\n+\tbranch = deref_tag(parse_object(oid), oid_to_hex(oid), GIT_SHA1_HEXSZ);\n \tif (!branch || branch->type != OBJ_COMMIT)\n \t\treturn;\n \n@@ -559,7 +559,7 @@ static void find_merge_parents(struct merge_parents *result,\n \t\t * \"name\" here and we do not want to contaminate its\n \t\t * util field yet.\n \t\t */\n-\t\tobj = parse_object(oid.hash);\n+\t\tobj = parse_object(&oid);\n \t\tparent = (struct commit *)peel_to_type(NULL, 0, obj, OBJ_COMMIT);\n \t\tif (!parent)\n \t\t\tcontinue;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 359d61de0..40bf88943 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -385,7 +385,7 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,\n \t * verify_packfile(), data_valid variable for details.\n \t */\n \tstruct object *obj;\n-\tobj = parse_object_buffer(oid->hash, type, size, buffer, eaten);\n+\tobj = parse_object_buffer(oid, type, size, buffer, eaten);\n \tif (!obj) {\n \t\terrors_found |= ERROR_OBJECT;\n \t\treturn error(\"%s: object corrupt or missing\", oid_to_hex(oid));\n@@ -444,7 +444,7 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid,\n {\n \tstruct object *obj;\n \n-\tobj = parse_object(oid->hash);\n+\tobj = parse_object(oid);\n \tif (!obj) {\n \t\terror(\"%s: invalid sha1 pointer %s\", refname, oid_to_hex(oid));\n \t\terrors_found |= ERROR_REACHABLE;\n@@ -506,7 +506,7 @@ static struct object *parse_loose_object(const struct object_id *oid,\n \tif (!contents && type != OBJ_BLOB)\n \t\tdie(\"BUG: read_loose_object streamed a non-blob\");\n \n-\tobj = parse_object_buffer(oid->hash, type, size, contents, &eaten);\n+\tobj = parse_object_buffer(oid, type, size, contents, &eaten);\n \n \tif (!eaten)\n \t\tfree(contents);\n@@ -599,7 +599,7 @@ static int fsck_cache_tree(struct cache_tree *it)\n \t\tfprintf(stderr, \"Checking cache tree\\n\");\n \n \tif (0 <= it->entry_count) {\n-\t\tstruct object *obj = parse_object(it->oid.hash);\n+\t\tstruct object *obj = parse_object(&it->oid);\n \t\tif (!obj) {\n \t\t\terror(\"%s: invalid sha1 pointer in cache-tree\",\n \t\t\t      oid_to_hex(&it->oid));\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3ffb5b4e8..e64e14e94 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -1196,7 +1196,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\t\tbreak;\n \t\t}\n \n-\t\tobject = parse_object_or_die(oid.hash, arg);\n+\t\tobject = parse_object_or_die(&oid, arg);\n \t\tif (!seen_dashdash)\n \t\t\tverify_non_filename(prefix, arg);\n \t\tadd_object_array_with_path(object, arg, &list, oc.mode, oc.path);\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex b75133f62..04b9dcaf0 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -845,7 +845,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\t\t * we do not need to free the memory here, as the\n \t\t\t * buf is deleted by the caller.\n \t\t\t */\n-\t\t\tobj = parse_object_buffer(oid->hash, type, size, buf, &eaten);\n+\t\t\tobj = parse_object_buffer(oid, type, size, buf,\n+\t\t\t\t\t\t  &eaten);\n \t\t\tif (!obj)\n \t\t\t\tdie(_(\"invalid %s\"), typename(type));\n \t\t\tif (do_fsck_object &&\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d8b56ea41..8dd4e3dae 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -596,7 +596,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \t\t\trev.shown_one = 1;\n \t\t\tif (ret)\n \t\t\t\tbreak;\n-\t\t\to = parse_object(t->tagged->oid.hash);\n+\t\t\to = parse_object(&t->tagged->oid);\n \t\t\tif (!o)\n \t\t\t\tret = error(_(\"Could not read object %s\"),\n \t\t\t\t\t    oid_to_hex(&t->tagged->oid));\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 00760ecc6..f06261cad 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -142,7 +142,7 @@ static int tipcmp(const void *a_, const void *b_)\n \n static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)\n {\n-\tstruct object *o = parse_object(oid->hash);\n+\tstruct object *o = parse_object(oid);\n \tstruct name_ref_data *data = cb_data;\n \tint can_abbreviate_output = data->tags_only && data->name_only;\n \tint deref = 0;\n@@ -200,7 +200,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo\n \t\tstruct tag *t = (struct tag *) o;\n \t\tif (!t->tagged)\n \t\t\tbreak; /* broken repository */\n-\t\to = parse_object(t->tagged->oid.hash);\n+\t\to = parse_object(&t->tagged->oid);\n \t\tderef = 1;\n \t\ttaggerdate = t->date;\n \t}\n@@ -385,7 +385,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t}\n \n \t\tcommit = NULL;\n-\t\tobject = parse_object(oid.hash);\n+\t\tobject = parse_object(&oid);\n \t\tif (object) {\n \t\t\tstruct object *peeled = deref_tag(object, *argv, 0);\n \t\t\tif (peeled && peeled->type == OBJ_COMMIT)\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 96dca7d58..536366056 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -127,7 +127,8 @@ int cmd_prune(int argc, const char **argv, const char *prefix)\n \t\tconst char *name = *argv++;\n \n \t\tif (!get_oid(name, &oid)) {\n-\t\t\tstruct object *object = parse_object_or_die(oid.hash, name);\n+\t\t\tstruct object *object = parse_object_or_die(&oid,\n+\t\t\t\t\t\t\t\t    name);\n \t\t\tadd_pending_object(&revs, object, \"\");\n \t\t}\n \t\telse\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 38e5164f6..471b83fcb 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1059,8 +1059,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)\n \t\tstruct object *old_object, *new_object;\n \t\tstruct commit *old_commit, *new_commit;\n \n-\t\told_object = parse_object(old_oid->hash);\n-\t\tnew_object = parse_object(new_oid->hash);\n+\t\told_object = parse_object(old_oid);\n+\t\tnew_object = parse_object(new_oid);\n \n \t\tif (!old_object || !new_object ||\n \t\t    old_object->type != OBJ_COMMIT ||\n@@ -1083,7 +1083,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)\n \n \tif (is_null_oid(new_oid)) {\n \t\tstruct strbuf err = STRBUF_INIT;\n-\t\tif (!parse_object(old_oid->hash)) {\n+\t\tif (!parse_object(old_oid)) {\n \t\t\told_oid = NULL;\n \t\t\tif (ref_exists(name)) {\n \t\t\t\trp_warning(\"Allowing deletion of corrupt ref.\");\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 7e89e84dc..8f3f1bd99 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -126,7 +126,7 @@ static int commit_is_complete(struct commit *commit)\n \t\tstruct commit_list *parent;\n \n \t\tc = (struct commit *)study.objects[--study.nr].item;\n-\t\tif (!c->object.parsed && !parse_object(c->object.oid.hash))\n+\t\tif (!c->object.parsed && !parse_object(&c->object.oid))\n \t\t\tc->object.flags |= INCOMPLETE;\n \n \t\tif (c->object.flags & INCOMPLETE) {\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex bcf77f0b8..1ddfca32b 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -181,7 +181,7 @@ static void finish_object(struct object *obj, const char *name, void *cb_data)\n \tif (obj->type == OBJ_BLOB && !has_object_file(&obj->oid))\n \t\tdie(\"missing blob object '%s'\", oid_to_hex(&obj->oid));\n \tif (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)\n-\t\tparse_object(obj->oid.hash);\n+\t\tparse_object(&obj->oid);\n }\n \n static void show_object(struct object *obj, const char *name, void *cb_data)\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 7d5efa2b3..8bc999776 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -260,7 +260,8 @@ static void write_object(unsigned nr, enum object_type type,\n \t\tint eaten;\n \t\thash_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash);\n \t\tadded_object(nr, type, buf, size);\n-\t\tobj = parse_object_buffer(obj_list[nr].oid.hash, type, size, buf, &eaten);\n+\t\tobj = parse_object_buffer(&obj_list[nr].oid, type, size, buf,\n+\t\t\t\t\t  &eaten);\n \t\tif (!obj)\n \t\t\tdie(\"invalid %s\", typename(type));\n \t\tadd_object_buffer(obj, buf, size);\ndiff --git a/bundle.c b/bundle.c\nindex 3386dba3b..f4abac467 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -142,7 +142,7 @@ int verify_bundle(struct bundle_header *header, int verbose)\n \tinit_revisions(&revs, NULL);\n \tfor (i = 0; i < p->nr; i++) {\n \t\tstruct ref_list_entry *e = p->list + i;\n-\t\tstruct object *o = parse_object(e->oid.hash);\n+\t\tstruct object *o = parse_object(&e->oid);\n \t\tif (o) {\n \t\t\to->flags |= PREREQ_MARK;\n \t\t\tadd_pending_object(&revs, o, e->name);\n@@ -290,12 +290,14 @@ static int compute_and_write_prerequisites(int bundle_fd,\n \t\tif (buf.len > 0 && buf.buf[0] == '-') {\n \t\t\twrite_or_die(bundle_fd, buf.buf, buf.len);\n \t\t\tif (!get_oid_hex(buf.buf + 1, &oid)) {\n-\t\t\t\tstruct object *object = parse_object_or_die(oid.hash, buf.buf);\n+\t\t\t\tstruct object *object = parse_object_or_die(&oid,\n+\t\t\t\t\t\t\t\t\t    buf.buf);\n \t\t\t\tobject->flags |= UNINTERESTING;\n \t\t\t\tadd_pending_object(revs, object, buf.buf);\n \t\t\t}\n \t\t} else if (!get_oid_hex(buf.buf, &oid)) {\n-\t\t\tstruct object *object = parse_object_or_die(oid.hash, buf.buf);\n+\t\t\tstruct object *object = parse_object_or_die(&oid,\n+\t\t\t\t\t\t\t\t    buf.buf);\n \t\t\tobject->flags |= SHOWN;\n \t\t}\n \t}\n@@ -379,7 +381,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)\n \t\t\t\t * end up triggering \"empty bundle\"\n \t\t\t\t * error.\n \t\t\t\t */\n-\t\t\t\tobj = parse_object_or_die(oid.hash, e->name);\n+\t\t\t\tobj = parse_object_or_die(&oid, e->name);\n \t\t\t\tobj->flags |= SHOWN;\n \t\t\t\tadd_pending_object(revs, obj, e->name);\n \t\t\t}\ndiff --git a/commit.c b/commit.c\nindex 8004008bc..424237a8e 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -21,7 +21,7 @@ const char *commit_type = \"commit\";\n struct commit *lookup_commit_reference_gently(const struct object_id *oid,\n \t\t\t\t\t      int quiet)\n {\n-\tstruct object *obj = deref_tag(parse_object(oid->hash), NULL, 0);\n+\tstruct object *obj = deref_tag(parse_object(oid), NULL, 0);\n \n \tif (!obj)\n \t\treturn NULL;\n@@ -1589,7 +1589,7 @@ struct commit *get_merge_parent(const char *name)\n \tstruct object_id oid;\n \tif (get_sha1(name, oid.hash))\n \t\treturn NULL;\n-\tobj = parse_object(oid.hash);\n+\tobj = parse_object(&oid);\n \tcommit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);\n \tif (commit && !commit->util)\n \t\tset_merge_remote_desc(commit, name, obj);\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex ab767503b..9026ad95a 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -78,7 +78,7 @@ static void cache_one_alternate(const char *refname,\n \t\t\t\tvoid *vcache)\n {\n \tstruct alternate_object_cache *cache = vcache;\n-\tstruct object *obj = parse_object(oid->hash);\n+\tstruct object *obj = parse_object(oid);\n \n \tif (!obj || (obj->flags & ALTERNATE))\n \t\treturn;\n@@ -120,7 +120,7 @@ static void rev_list_push(struct commit *commit, int mark)\n \n static int rev_list_insert_ref(const char *refname, const struct object_id *oid)\n {\n-\tstruct object *o = deref_tag(parse_object(oid->hash), refname, 0);\n+\tstruct object *o = deref_tag(parse_object(oid), refname, 0);\n \n \tif (o && o->type == OBJ_COMMIT)\n \t\trev_list_push((struct commit *)o, SEEN);\n@@ -137,7 +137,7 @@ static int rev_list_insert_ref_oid(const char *refname, const struct object_id *\n static int clear_marks(const char *refname, const struct object_id *oid,\n \t\t       int flag, void *cb_data)\n {\n-\tstruct object *o = deref_tag(parse_object(oid->hash), refname, 0);\n+\tstruct object *o = deref_tag(parse_object(oid), refname, 0);\n \n \tif (o && o->type == OBJ_COMMIT)\n \t\tclear_commit_marks((struct commit *)o,\n@@ -424,7 +424,7 @@ static int find_common(struct fetch_pack_args *args,\n \t\t\t\tif (!lookup_object(oid.hash))\n \t\t\t\t\tdie(_(\"object not found: %s\"), line);\n \t\t\t\t/* make sure that it is parsed as shallow */\n-\t\t\t\tif (!parse_object(oid.hash))\n+\t\t\t\tif (!parse_object(&oid))\n \t\t\t\t\tdie(_(\"error in object: %s\"), line);\n \t\t\t\tif (unregister_shallow(&oid))\n \t\t\t\t\tdie(_(\"no shallow found: %s\"), line);\n@@ -555,14 +555,14 @@ static struct commit_list *complete;\n \n static int mark_complete(const struct object_id *oid)\n {\n-\tstruct object *o = parse_object(oid->hash);\n+\tstruct object *o = parse_object(oid);\n \n \twhile (o && o->type == OBJ_TAG) {\n \t\tstruct tag *t = (struct tag *) o;\n \t\tif (!t->tagged)\n \t\t\tbreak; /* broken repository */\n \t\to->flags |= COMPLETE;\n-\t\to = parse_object(t->tagged->oid.hash);\n+\t\to = parse_object(&t->tagged->oid);\n \t}\n \tif (o && o->type == OBJ_COMMIT) {\n \t\tstruct commit *commit = (struct commit *)o;\n@@ -679,7 +679,7 @@ static int everything_local(struct fetch_pack_args *args,\n \t\tif (!has_object_file(&ref->old_oid))\n \t\t\tcontinue;\n \n-\t\to = parse_object(ref->old_oid.hash);\n+\t\to = parse_object(&ref->old_oid);\n \t\tif (!o)\n \t\t\tcontinue;\n \ndiff --git a/fsck.c b/fsck.c\nindex ee5224aea..90857e122 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -461,7 +461,7 @@ int fsck_walk(struct object *obj, void *data, struct fsck_options *options)\n \t\treturn -1;\n \n \tif (obj->type == OBJ_NONE)\n-\t\tparse_object(obj->oid.hash);\n+\t\tparse_object(&obj->oid);\n \n \tswitch (obj->type) {\n \tcase OBJ_BLOB:\ndiff --git a/http-backend.c b/http-backend.c\nindex eef0a361f..766381332 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -431,7 +431,7 @@ static int show_text_ref(const char *name, const struct object_id *oid,\n {\n \tconst char *name_nons = strip_namespace(name);\n \tstruct strbuf *buf = cb_data;\n-\tstruct object *o = parse_object(oid->hash);\n+\tstruct object *o = parse_object(oid);\n \tif (!o)\n \t\treturn 0;\n \ndiff --git a/http-push.c b/http-push.c\nindex 4e7bd9e42..67c4d4b47 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -724,7 +724,7 @@ static void one_remote_object(const struct object_id *oid)\n \n \tobj = lookup_object(oid->hash);\n \tif (!obj)\n-\t\tobj = parse_object(oid->hash);\n+\t\tobj = parse_object(oid);\n \n \t/* Ignore remote objects that don't exist locally */\n \tif (!obj)\n@@ -1462,7 +1462,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)\n \t\treturn;\n \t}\n \n-\to = parse_object(ref->old_oid.hash);\n+\to = parse_object(&ref->old_oid);\n \tif (!o) {\n \t\tfprintf(stderr,\n \t\t\t\"Unable to parse object %s for remote ref %s\\n\",\ndiff --git a/log-tree.c b/log-tree.c\nindex 6532c892c..a4ec11c2b 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -105,13 +105,13 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,\n \t\t\twarning(\"invalid replace ref %s\", refname);\n \t\t\treturn 0;\n \t\t}\n-\t\tobj = parse_object(original_oid.hash);\n+\t\tobj = parse_object(&original_oid);\n \t\tif (obj)\n \t\t\tadd_name_decoration(DECORATION_GRAFTED, \"replaced\", obj);\n \t\treturn 0;\n \t}\n \n-\tobj = parse_object(oid->hash);\n+\tobj = parse_object(oid);\n \tif (!obj)\n \t\treturn 0;\n \n@@ -132,7 +132,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,\n \t\tif (!obj)\n \t\t\tbreak;\n \t\tif (!obj->parsed)\n-\t\t\tparse_object(obj->oid.hash);\n+\t\t\tparse_object(&obj->oid);\n \t\tadd_name_decoration(DECORATION_REF_TAG, refname, obj);\n \t}\n \treturn 0;\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 92e0a63dc..ae5238d82 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -2103,7 +2103,7 @@ static struct commit *get_ref(const struct object_id *oid, const char *name)\n {\n \tstruct object *object;\n \n-\tobject = deref_tag(parse_object(oid->hash), name, strlen(name));\n+\tobject = deref_tag(parse_object(oid), name, strlen(name));\n \tif (!object)\n \t\treturn NULL;\n \tif (object->type == OBJ_TREE)\ndiff --git a/object.c b/object.c\nindex dd4d3a1ea..06ba3a11d 100644\n--- a/object.c\n+++ b/object.c\n@@ -180,24 +180,21 @@ struct object *lookup_unknown_object(const unsigned char *sha1)\n \treturn obj;\n }\n \n-struct object *parse_object_buffer(const unsigned char *sha1, enum object_type type, unsigned long size, void *buffer, int *eaten_p)\n+struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)\n {\n-\tstruct object_id oid;\n \tstruct object *obj;\n \t*eaten_p = 0;\n \n-\thashcpy(oid.hash, sha1);\n-\n \tobj = NULL;\n \tif (type == OBJ_BLOB) {\n-\t\tstruct blob *blob = lookup_blob(&oid);\n+\t\tstruct blob *blob = lookup_blob(oid);\n \t\tif (blob) {\n \t\t\tif (parse_blob_buffer(blob, buffer, size))\n \t\t\t\treturn NULL;\n \t\t\tobj = &blob->object;\n \t\t}\n \t} else if (type == OBJ_TREE) {\n-\t\tstruct tree *tree = lookup_tree(&oid);\n+\t\tstruct tree *tree = lookup_tree(oid);\n \t\tif (tree) {\n \t\t\tobj = &tree->object;\n \t\t\tif (!tree->buffer)\n@@ -209,7 +206,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t\n \t\t\t}\n \t\t}\n \t} else if (type == OBJ_COMMIT) {\n-\t\tstruct commit *commit = lookup_commit(&oid);\n+\t\tstruct commit *commit = lookup_commit(oid);\n \t\tif (commit) {\n \t\t\tif (parse_commit_buffer(commit, buffer, size))\n \t\t\t\treturn NULL;\n@@ -220,57 +217,54 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t\n \t\t\tobj = &commit->object;\n \t\t}\n \t} else if (type == OBJ_TAG) {\n-\t\tstruct tag *tag = lookup_tag(&oid);\n+\t\tstruct tag *tag = lookup_tag(oid);\n \t\tif (tag) {\n \t\t\tif (parse_tag_buffer(tag, buffer, size))\n \t\t\t       return NULL;\n \t\t\tobj = &tag->object;\n \t\t}\n \t} else {\n-\t\twarning(\"object %s has unknown type id %d\", sha1_to_hex(sha1), type);\n+\t\twarning(\"object %s has unknown type id %d\", oid_to_hex(oid), type);\n \t\tobj = NULL;\n \t}\n \treturn obj;\n }\n \n-struct object *parse_object_or_die(const unsigned char *sha1,\n+struct object *parse_object_or_die(const struct object_id *oid,\n \t\t\t\t   const char *name)\n {\n-\tstruct object *o = parse_object(sha1);\n+\tstruct object *o = parse_object(oid);\n \tif (o)\n \t\treturn o;\n \n-\tdie(_(\"unable to parse object: %s\"), name ? name : sha1_to_hex(sha1));\n+\tdie(_(\"unable to parse object: %s\"), name ? name : oid_to_hex(oid));\n }\n \n-struct object *parse_object(const unsigned char *sha1)\n+struct object *parse_object(const struct object_id *oid)\n {\n \tunsigned long size;\n \tenum object_type type;\n \tint eaten;\n-\tconst unsigned char *repl = lookup_replace_object(sha1);\n+\tconst unsigned char *repl = lookup_replace_object(oid->hash);\n \tvoid *buffer;\n \tstruct object *obj;\n-\tstruct object_id oid;\n \n-\thashcpy(oid.hash, sha1);\n-\n-\tobj = lookup_object(oid.hash);\n+\tobj = lookup_object(oid->hash);\n \tif (obj && obj->parsed)\n \t\treturn obj;\n \n \tif ((obj && obj->type == OBJ_BLOB) ||\n-\t    (!obj && has_sha1_file(sha1) &&\n-\t     sha1_object_info(sha1, NULL) == OBJ_BLOB)) {\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\t\terror(\"sha1 mismatch %s\", sha1_to_hex(repl));\n+\t\t\terror(\"sha1 mismatch %s\", oid_to_hex(oid));\n \t\t\treturn NULL;\n \t\t}\n-\t\tparse_blob_buffer(lookup_blob(&oid), NULL, 0);\n-\t\treturn lookup_object(sha1);\n+\t\tparse_blob_buffer(lookup_blob(oid), NULL, 0);\n+\t\treturn lookup_object(oid->hash);\n \t}\n \n-\tbuffer = read_sha1_file(sha1, &type, &size);\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\t\tfree(buffer);\n@@ -278,7 +272,7 @@ struct object *parse_object(const unsigned char *sha1)\n \t\t\treturn NULL;\n \t\t}\n \n-\t\tobj = parse_object_buffer(sha1, type, size, buffer, &eaten);\n+\t\tobj = parse_object_buffer(oid, type, size, buffer, &eaten);\n \t\tif (!eaten)\n \t\t\tfree(buffer);\n \t\treturn obj;\ndiff --git a/object.h b/object.h\nindex f52957dcb..33e5cc994 100644\n--- a/object.h\n+++ b/object.h\n@@ -89,20 +89,20 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet);\n  *\n  * Returns NULL if the object is missing or corrupt.\n  */\n-struct object *parse_object(const unsigned char *sha1);\n+struct object *parse_object(const struct object_id *oid);\n \n /*\n  * Like parse_object, but will die() instead of returning NULL. If the\n  * \"name\" parameter is not NULL, it is included in the error message\n- * (otherwise, the sha1 hex is given).\n+ * (otherwise, the hex object ID is given).\n  */\n-struct object *parse_object_or_die(const unsigned char *sha1, const char *name);\n+struct object *parse_object_or_die(const struct object_id *oid, const char *name);\n \n /* Given the result of read_sha1_file(), returns the object after\n  * parsing it.  eaten_p indicates if the object has a borrowed copy\n  * of buffer and the caller should not free() it.\n  */\n-struct object *parse_object_buffer(const unsigned char *sha1, enum object_type type, unsigned long size, void *buffer, int *eaten_p);\n+struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);\n \n /** Returns the object, with potentially excess memory allocated. **/\n struct object *lookup_unknown_object(const unsigned  char *sha1);\ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex 39bcc1684..a3ac3dccd 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -673,7 +673,7 @@ int prepare_bitmap_walk(struct rev_info *revs)\n \t\tstruct object *object = pending_e[i].item;\n \n \t\tif (object->type == OBJ_NONE)\n-\t\t\tparse_object_or_die(object->oid.hash, NULL);\n+\t\t\tparse_object_or_die(&object->oid, NULL);\n \n \t\twhile (object->type == OBJ_TAG) {\n \t\t\tstruct tag *tag = (struct tag *) object;\n@@ -685,7 +685,7 @@ int prepare_bitmap_walk(struct rev_info *revs)\n \n \t\t\tif (!tag->tagged)\n \t\t\t\tdie(\"bad tag\");\n-\t\t\tobject = parse_object_or_die(tag->tagged->oid.hash, NULL);\n+\t\t\tobject = parse_object_or_die(&tag->tagged->oid, NULL);\n \t\t}\n \n \t\tif (object->flags & UNINTERESTING)\ndiff --git a/pretty.c b/pretty.c\nindex d0f86f5d8..c4a0ace34 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1137,7 +1137,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */\n \n \t/* these depend on the commit */\n \tif (!commit->object.parsed)\n-\t\tparse_object(commit->object.oid.hash);\n+\t\tparse_object(&commit->object.oid);\n \n \tswitch (placeholder[0]) {\n \tcase 'H':\t\t/* commit hash */\ndiff --git a/reachable.c b/reachable.c\nindex 3bbc84417..69ca176f6 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -33,7 +33,7 @@ static int add_one_ref(const char *path, const struct object_id *oid,\n \t\treturn 0;\n \t}\n \n-\tobject = parse_object_or_die(oid->hash, path);\n+\tobject = parse_object_or_die(oid, path);\n \tadd_pending_object(revs, object, \"\");\n \n \treturn 0;\n@@ -82,7 +82,7 @@ static void add_recent_object(const struct object_id *oid,\n \tswitch (type) {\n \tcase OBJ_TAG:\n \tcase OBJ_COMMIT:\n-\t\tobj = parse_object_or_die(oid->hash, NULL);\n+\t\tobj = parse_object_or_die(oid, NULL);\n \t\tbreak;\n \tcase OBJ_TREE:\n \t\tobj = (struct object *)lookup_tree(oid);\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 56fc990a5..3f7cf71b5 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -683,7 +683,7 @@ static void *get_obj(const struct object_id *oid, struct object **obj, unsigned\n \tvoid *buf = read_sha1_file(oid->hash, &type, sz);\n \n \tif (buf)\n-\t\t*obj = parse_object_buffer(oid->hash, type, *sz, buf, eaten);\n+\t\t*obj = parse_object_buffer(oid, type, *sz, buf, eaten);\n \telse\n \t\t*obj = NULL;\n \treturn buf;\n@@ -1687,7 +1687,7 @@ static const struct object_id *match_points_at(struct oid_array *points_at,\n \n \tif (oid_array_lookup(points_at, oid) >= 0)\n \t\treturn oid;\n-\tobj = parse_object(oid->hash);\n+\tobj = parse_object(oid);\n \tif (!obj)\n \t\tdie(_(\"malformed object at '%s'\"), refname);\n \tif (obj->type == OBJ_TAG)\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex c8fdf051d..110e18f1f 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -238,13 +238,13 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)\n \tdo {\n \t\treflog = &commit_reflog->reflogs->items[commit_reflog->recno];\n \t\tcommit_reflog->recno--;\n-\t\tlogobj = parse_object(reflog->ooid.hash);\n+\t\tlogobj = parse_object(&reflog->ooid);\n \t} while (commit_reflog->recno && (logobj && logobj->type != OBJ_COMMIT));\n \n \tif (!logobj && commit_reflog->recno >= 0 && is_null_oid(&reflog->ooid)) {\n \t\t/* a root commit, but there are still more entries to show */\n \t\treflog = &commit_reflog->reflogs->items[commit_reflog->recno];\n-\t\tlogobj = parse_object(reflog->noid.hash);\n+\t\tlogobj = parse_object(&reflog->noid);\n \t}\n \n \tif (!logobj || logobj->type != OBJ_COMMIT) {\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 171a157f7..96e791676 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -2980,7 +2980,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock,\n \tstruct object *o;\n \tint fd;\n \n-\to = parse_object(oid->hash);\n+\to = parse_object(oid);\n \tif (!o) {\n \t\tstrbuf_addf(err,\n \t\t\t    \"trying to write ref '%s' with nonexistent object %s\",\ndiff --git a/remote.c b/remote.c\nindex bf9a47d95..38ca1353b 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1954,12 +1954,12 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)\n \t * Both new and old must be commit-ish and new is descendant of\n \t * old.  Otherwise we require --force.\n \t */\n-\to = deref_tag(parse_object(old_oid->hash), NULL, 0);\n+\to = deref_tag(parse_object(old_oid), NULL, 0);\n \tif (!o || o->type != OBJ_COMMIT)\n \t\treturn 0;\n \told = (struct commit *) o;\n \n-\to = deref_tag(parse_object(new_oid->hash), NULL, 0);\n+\to = deref_tag(parse_object(new_oid), NULL, 0);\n \tif (!o || o->type != OBJ_COMMIT)\n \t\treturn 0;\n \tnew = (struct commit *) o;\ndiff --git a/revision.c b/revision.c\nindex 80f74bb7b..64e67e017 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -181,7 +181,7 @@ void add_head_to_pending(struct rev_info *revs)\n \tstruct object *obj;\n \tif (get_oid(\"HEAD\", &oid))\n \t\treturn;\n-\tobj = parse_object(oid.hash);\n+\tobj = parse_object(&oid);\n \tif (!obj)\n \t\treturn;\n \tadd_pending_object(revs, obj, \"HEAD\");\n@@ -193,7 +193,7 @@ static struct object *get_reference(struct rev_info *revs, const char *name,\n {\n \tstruct object *object;\n \n-\tobject = parse_object(oid->hash);\n+\tobject = parse_object(oid);\n \tif (!object) {\n \t\tif (revs->ignore_missing)\n \t\t\treturn object;\n@@ -228,7 +228,7 @@ static struct commit *handle_commit(struct rev_info *revs,\n \t\t\tadd_pending_object(revs, object, tag->tag);\n \t\tif (!tag->tagged)\n \t\t\tdie(\"bad tag\");\n-\t\tobject = parse_object(tag->tagged->oid.hash);\n+\t\tobject = parse_object(&tag->tagged->oid);\n \t\tif (!object) {\n \t\t\tif (flags & UNINTERESTING)\n \t\t\t\treturn NULL;\n@@ -1200,7 +1200,7 @@ static void handle_one_reflog_commit(struct object_id *oid, void *cb_data)\n {\n \tstruct all_refs_cb *cb = cb_data;\n \tif (!is_null_oid(oid)) {\n-\t\tstruct object *o = parse_object(oid->hash);\n+\t\tstruct object *o = parse_object(oid);\n \t\tif (o) {\n \t\t\to->flags |= cb->all_flags;\n \t\t\t/* ??? CMDLINEFLAGS ??? */\n@@ -1479,8 +1479,8 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi\n \t\t\t\tverify_non_filename(revs->prefix, arg);\n \t\t\t}\n \n-\t\t\ta_obj = parse_object(from_oid.hash);\n-\t\t\tb_obj = parse_object(oid.hash);\n+\t\t\ta_obj = parse_object(&from_oid);\n+\t\t\tb_obj = parse_object(&oid);\n \t\t\tif (!a_obj || !b_obj) {\n \t\t\tmissing:\n \t\t\t\tif (revs->ignore_missing)\ndiff --git a/server-info.c b/server-info.c\nindex 7bc4e75d2..7f75229bd 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -51,7 +51,7 @@ static int add_info_ref(const char *path, const struct object_id *oid,\n \t\t\tint flag, void *cb_data)\n {\n \tFILE *fp = cb_data;\n-\tstruct object *o = parse_object(oid->hash);\n+\tstruct object *o = parse_object(oid);\n \tif (!o)\n \t\treturn -1;\n \ndiff --git a/sha1_name.c b/sha1_name.c\nindex 72e72ab9a..de8278530 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -241,7 +241,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da\n \t\treturn 0;\n \n \t/* We need to do this the hard way... */\n-\tobj = deref_tag(parse_object(oid->hash), NULL, 0);\n+\tobj = deref_tag(parse_object(oid), NULL, 0);\n \tif (obj && obj->type == OBJ_COMMIT)\n \t\treturn 1;\n \treturn 0;\n@@ -265,7 +265,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_\n \t\treturn 0;\n \n \t/* We need to do this the hard way... */\n-\tobj = deref_tag(parse_object(oid->hash), NULL, 0);\n+\tobj = deref_tag(parse_object(oid), NULL, 0);\n \tif (obj && (obj->type == OBJ_TREE || obj->type == OBJ_COMMIT))\n \t\treturn 1;\n \treturn 0;\n@@ -776,7 +776,7 @@ struct object *peel_to_type(const char *name, int namelen,\n \tif (name && !namelen)\n \t\tnamelen = strlen(name);\n \twhile (1) {\n-\t\tif (!o || (!o->parsed && !parse_object(o->oid.hash)))\n+\t\tif (!o || (!o->parsed && !parse_object(&o->oid)))\n \t\t\treturn NULL;\n \t\tif (expected_type == OBJ_ANY || o->type == expected_type)\n \t\t\treturn o;\n@@ -849,12 +849,12 @@ static int peel_onion(const char *name, int len, unsigned char *sha1,\n \tif (get_sha1_1(name, sp - name - 2, outer.hash, lookup_flags))\n \t\treturn -1;\n \n-\to = parse_object(outer.hash);\n+\to = parse_object(&outer);\n \tif (!o)\n \t\treturn -1;\n \tif (!expected_type) {\n \t\to = deref_tag(o, name, sp - name - 2);\n-\t\tif (!o || (!o->parsed && !parse_object(o->oid.hash)))\n+\t\tif (!o || (!o->parsed && !parse_object(&o->oid)))\n \t\t\treturn -1;\n \t\thashcpy(sha1, o->oid.hash);\n \t\treturn 0;\n@@ -981,7 +981,7 @@ static int handle_one_ref(const char *path, const struct object_id *oid,\n \t\t\t  int flag, void *cb_data)\n {\n \tstruct commit_list **list = cb_data;\n-\tstruct object *object = parse_object(oid->hash);\n+\tstruct object *object = parse_object(oid);\n \tif (!object)\n \t\treturn 0;\n \tif (object->type == OBJ_TAG) {\n@@ -1027,7 +1027,7 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1,\n \t\tint matches;\n \n \t\tcommit = pop_most_recent_commit(&list, ONELINE_SEEN);\n-\t\tif (!parse_object(commit->object.oid.hash))\n+\t\tif (!parse_object(&commit->object.oid))\n \t\t\tcontinue;\n \t\tbuf = get_commit_buffer(commit, NULL);\n \t\tp = strstr(buf, \"\\n\\n\");\ndiff --git a/tag.c b/tag.c\nindex 571798519..eb7b146f4 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -66,7 +66,7 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen)\n {\n \twhile (o && o->type == OBJ_TAG)\n \t\tif (((struct tag *)o)->tagged)\n-\t\t\to = parse_object(((struct tag *)o)->tagged->oid.hash);\n+\t\t\to = parse_object(&((struct tag *)o)->tagged->oid);\n \t\telse\n \t\t\to = NULL;\n \tif (!o && warn) {\n@@ -80,7 +80,7 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen)\n struct object *deref_tag_noverify(struct object *o)\n {\n \twhile (o && o->type == OBJ_TAG) {\n-\t\to = parse_object(o->oid.hash);\n+\t\to = parse_object(&o->oid);\n \t\tif (o && o->type == OBJ_TAG && ((struct tag *)o)->tagged)\n \t\t\to = ((struct tag *)o)->tagged;\n \t\telse\ndiff --git a/tree.c b/tree.c\nindex 9adcd8bd4..603b29ee8 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -234,7 +234,7 @@ void free_tree_buffer(struct tree *tree)\n \n struct tree *parse_tree_indirect(const struct object_id *oid)\n {\n-\tstruct object *obj = parse_object(oid->hash);\n+\tstruct object *obj = parse_object(oid);\n \tdo {\n \t\tif (!obj)\n \t\t\treturn NULL;\n@@ -247,6 +247,6 @@ struct tree *parse_tree_indirect(const struct object_id *oid)\n \t\telse\n \t\t\treturn NULL;\n \t\tif (!obj->parsed)\n-\t\t\tparse_object(obj->oid.hash);\n+\t\t\tparse_object(&obj->oid);\n \t} while (1);\n }\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 5b9d21089..8619ec435 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -296,7 +296,7 @@ static int got_oid(const char *hex, struct object_id *oid)\n \tif (!has_object_file(oid))\n \t\treturn -1;\n \n-\to = parse_object(oid->hash);\n+\to = parse_object(oid);\n \tif (!o)\n \t\tdie(\"oops (%s)\", oid_to_hex(oid));\n \tif (o->type == OBJ_COMMIT) {\n@@ -334,7 +334,7 @@ static int reachable(struct commit *want)\n \t\t\tbreak;\n \t\t}\n \t\tif (!commit->object.parsed)\n-\t\t\tparse_object(commit->object.oid.hash);\n+\t\t\tparse_object(&commit->object.oid);\n \t\tif (commit->object.flags & REACHABLE)\n \t\t\tcontinue;\n \t\tcommit->object.flags |= REACHABLE;\n@@ -755,7 +755,7 @@ static void receive_needs(void)\n \t\t\tstruct object *object;\n \t\t\tif (get_oid_hex(arg, &oid))\n \t\t\t\tdie(\"invalid shallow line: %s\", line);\n-\t\t\tobject = parse_object(oid.hash);\n+\t\t\tobject = parse_object(&oid);\n \t\t\tif (!object)\n \t\t\t\tcontinue;\n \t\t\tif (object->type != OBJ_COMMIT)\n@@ -821,7 +821,7 @@ static void receive_needs(void)\n \t\tif (parse_feature_request(features, \"include-tag\"))\n \t\t\tuse_include_tag = 1;\n \n-\t\to = parse_object(oid_buf.hash);\n+\t\to = parse_object(&oid_buf);\n \t\tif (!o) {\n \t\t\tpacket_write_fmt(1,\n \t\t\t\t\t \"ERR upload-pack: not our ref %s\",\ndiff --git a/walker.c b/walker.c\nindex eae9fb974..274f1a493 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -180,7 +180,7 @@ static int loop(struct walker *walker)\n \t\t\t}\n \t\t}\n \t\tif (!obj->type)\n-\t\t\tparse_object(obj->oid.hash);\n+\t\t\tparse_object(&obj->oid);\n \t\tif (process_object(walker, obj))\n \t\t\treturn -1;\n \t}\n"},{"id":"317647","messageId":"xmqqk26az5kx.fsf@gitster.mtv.corp.google.com","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH 00/53] object_id part 8","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-04-24T06:23:58Z","receivedAt":"2017-04-24T06:24:09Z","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 eighth series of patches to convert unsigned char [20] to\n> struct object_id.  This series converts lookup_commit, lookup_blob,\n> lookup_tree, lookup_tag, and finally parse_object to struct object_id.\n>\n> A small number of functions have temporaries inserted during the\n> conversion in order to allow conversion of functions that still need to\n> take unsigned char *; they are removed either later in the series or\n> will be in a future series.\n>\n> This series can be fetched from the object-id-part8 branch from either\n> of the follwing:\n>\n> https://github.com/bk2204/git\n> https://git.crustytoothpaste.net/git/bmc/git.git\n\nThis is a huge series with a lot of effort and some of the patches\n(non-mechanical ones) may need careful double-checking, which I'll\ntry later.  I think I managed to deconflict other topics in flight\n(including some stalled ones that I should have discarded earlier).\n\nThanks.\n"},{"id":"317697","messageId":"20170424160830.GA195761@google.com","threadId":"45782","inReplyTo":"20170423213453.253425-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH 00/53] object_id part 8","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-04-24T16:08:30Z","receivedAt":"2017-04-24T16:08:45Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 04/23, brian m. carlson wrote:\n> This is the eighth series of patches to convert unsigned char [20] to\n> struct object_id.  This series converts lookup_commit, lookup_blob,\n> lookup_tree, lookup_tag, and finally parse_object to struct object_id.\n> \n> A small number of functions have temporaries inserted during the\n> conversion in order to allow conversion of functions that still need to\n> take unsigned char *; they are removed either later in the series or\n> will be in a future series.\n> \n> This series can be fetched from the object-id-part8 branch from either\n> of the follwing:\n> \n> https://github.com/bk2204/git\n> https://git.crustytoothpaste.net/git/bmc/git.git\n\nI still have a series to convert the diff logic to using object_id.\nI'll rebase it against this change and wait to send it out once this\ntopic has been reviewed and is stable (hopefully it won't require many\niterations).\n\n-- \nBrandon Williams\n"},{"id":"317701","messageId":"CAGZ79kbdVEhcxP4dhSR6GaOKjgTD+bPn_+5edV4TjV3A84HQ-A@mail.gmail.com","threadId":"45782","inReplyTo":"20170423213453.253425-12-sandals@crustytoothpaste.net","subject":"Re: [PATCH 11/53] fast-import: convert to struct object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-04-24T17:20:27Z","receivedAt":"2017-04-24T17:20:33Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Sun, Apr 23, 2017 at 2:34 PM, brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n> Convert the remaining parts of fast-import.c to use struct object_id.\n> Convert several instances of get_sha1_hex to parse_oid_hex to avoid\n> needing to specify constants.  Convert other hardcoded values to named\n> constants.  Finally, use the is_empty_tree_oid function instead of a\n> direct comparison against a fixed string.\n>\n> Note that the odd computation with GIT_MAX_HEXSZ is due to the insertion\n> of a slash between every two hex digits in the path, plus one for the\n> terminating NUL.\n\nUp to and including this patch are\nReviewed-by: Stefan Beller <sbeller@google.com>\n\nI may continue reviewing this series once my eyes are refreshed.\n\n>\n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> ---\n\n> @@ -2823,12 +2821,10 @@ static void parse_new_commit(const char *arg)\n>         strbuf_addf(&new_data, \"tree %s\\n\",\n>                 oid_to_hex(&b->branch_tree.versions[1].oid));\n>         if (!is_null_oid(&b->oid))\n> -               strbuf_addf(&new_data, \"parent %s\\n\",\n> -                           oid_to_hex(&b->oid));\n> +               strbuf_addf(&new_data, \"parent %s\\n\", oid_to_hex(&b->oid));\n>         while (merge_list) {\n>                 struct hash_list *next = merge_list->next;\n> -               strbuf_addf(&new_data, \"parent %s\\n\",\n> -                           oid_to_hex(&merge_list->oid));\n> +               strbuf_addf(&new_data, \"parent %s\\n\", oid_to_hex(&merge_list->oid));\n>                 free(merge_list);\n>                 merge_list = next;\n>         }\n\nThis is a funny one. The only change is line rewrapping, as it fits\ninto 80 cols easily.\nI was reviewing this series using colored --word-diff output, and this hunk does\nnot produce any red or green. I wonder if this is the intended\nbehavior of the word diffing\nor if we rather want to insert a <RED> - \\n - </RED>.\n\nThanks,\nStefan\n"},{"id":"317727","messageId":"CAGZ79kYKLin0=Yz33NO8tQrWUBbjBGU==2RCEeNZFLhV5j7oQw@mail.gmail.com","threadId":"45782","inReplyTo":"20170423213453.253425-14-sandals@crustytoothpaste.net","subject":"Re: [PATCH 13/53] notes-cache: convert to struct object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-04-24T22:10:24Z","receivedAt":"2017-04-24T22:10:30Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Sun, Apr 23, 2017 at 2:34 PM, brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n> Convert as many instances of unsigned char [20] as possible,  Update the\n\ns/Update/update/ or s/,/./\n\nSide remark: In all patches up to now you put a space between the char and\nthe [20] (or [40]), which is irritating to read (for me). I presume\nputting it adjacent\nto the char would offend others as that would violate our coding\nstyle. So having\nthe whitespace in between \"char\" and the array makes sense.\n\nUp and including this patch looks good.\n\nThanks,\nStefan\n"},{"id":"317736","messageId":"CAGZ79kZGVKT5Xg2AnS=DPa+xXRJq6w4HL9R+j+nu8QrW3eGPAA@mail.gmail.com","threadId":"45782","inReplyTo":"20170423213453.253425-29-sandals@crustytoothpaste.net","subject":"Re: [PATCH 28/53] Convert remaining callers of lookup_blob to object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-04-24T23:05:54Z","receivedAt":"2017-04-24T23:06:00Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Sun, Apr 23, 2017 at 2:34 PM, brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n> All but a few callers of lookup_blob have been converted to struct\n> object_id.  Introduce a temporary, which will be removed later, into\n> parse_object to ease the transition, and convert the remaining callers\n> so that we can update lookup_blob to take struct object_id *.\n>\n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n\nReviewed up to here, looking good,\n\nThanks,\nStefan\n"},{"id":"317737","messageId":"20170424232337.hg2dbpdt6rrfscko@genre.crustytoothpaste.net","threadId":"45782","inReplyTo":"CAGZ79kbdVEhcxP4dhSR6GaOKjgTD+bPn_+5edV4TjV3A84HQ-A@mail.gmail.com","subject":"Re: [PATCH 11/53] fast-import: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-24T23:23:37Z","receivedAt":"2017-04-24T23:23:50Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Mon, Apr 24, 2017 at 10:20:27AM -0700, Stefan Beller wrote:\n> On Sun, Apr 23, 2017 at 2:34 PM, brian m. carlson\n> <sandals@crustytoothpaste.net> wrote:\n> > Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> > ---\n> \n> > @@ -2823,12 +2821,10 @@ static void parse_new_commit(const char *arg)\n> >         strbuf_addf(&new_data, \"tree %s\\n\",\n> >                 oid_to_hex(&b->branch_tree.versions[1].oid));\n> >         if (!is_null_oid(&b->oid))\n> > -               strbuf_addf(&new_data, \"parent %s\\n\",\n> > -                           oid_to_hex(&b->oid));\n> > +               strbuf_addf(&new_data, \"parent %s\\n\", oid_to_hex(&b->oid));\n> >         while (merge_list) {\n> >                 struct hash_list *next = merge_list->next;\n> > -               strbuf_addf(&new_data, \"parent %s\\n\",\n> > -                           oid_to_hex(&merge_list->oid));\n> > +               strbuf_addf(&new_data, \"parent %s\\n\", oid_to_hex(&merge_list->oid));\n> >                 free(merge_list);\n> >                 merge_list = next;\n> >         }\n> \n> This is a funny one. The only change is line rewrapping, as it fits\n> into 80 cols easily.\n> I was reviewing this series using colored --word-diff output, and this hunk does\n> not produce any red or green. I wonder if this is the intended\n> behavior of the word diffing\n> or if we rather want to insert a <RED> - \\n - </RED>.\n\nI used Coccinelle for part of this, I think, so that would be why.\nSometimes it doesn't do everything I want, but it lets me do less manual\nwork.  I'll revert that change in the reroll.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\n+1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"318007","messageId":"CAGZ79kYhaX=tXM2aymFDkfU23E8=GzjgGbwQsynt1LWdLzxQQw@mail.gmail.com","threadId":"45782","inReplyTo":"20170423213453.253425-36-sandals@crustytoothpaste.net","subject":"Re: [PATCH 35/53] Convert the verify_pack callback to struct object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-04-26T23:01:27Z","receivedAt":"2017-04-26T23:01:33Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Sun, Apr 23, 2017 at 2:34 PM, brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n> Make the verify_pack_callback take a pointer to struct object_id.  Use a\n> struct object_id to hold the pack checksum, even though it is not\n> strictly an object ID.  Doing so ensures resilience against future hash\n> size changes, and allows us to remove hard-coded assumptions about how\n> big the buffer needs to be.\n>\n> Also, use a union to convert the pointer from nth_packed_object_sha1 to\n> to a pointer to struct object_id.  This behavior is compatible with GCC\n> and clang and explicitly sanctioned by C11.  The alternatives are to\n> just perform a cast, which would run afoul of strict aliasing rules, but\n> should just work, and changing the pointer into an instance of struct\n> object_id and copying the value.  The latter operation could seriously\n> bloat memory usage on fsck, which already uses a lot of memory on some\n> repositories.\n>\n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> ---\n\nUp to here *excluding* this one, looking good.\nThis one may need review by an expert specialized in weird corner cases,\nwhich I am not, yet. ;)\n\nThanks,\nStefan\n"},{"id":"318037","messageId":"c68038fc-5014-8b48-0ea3-a26a54e7d353@alum.mit.edu","threadId":"45782","inReplyTo":"20170423213453.253425-39-sandals@crustytoothpaste.net","subject":"Re: [PATCH 38/53] refs: convert struct ref_update to use struct object_id","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2017-04-27T04:55:49Z","receivedAt":"2017-04-27T04:56:03Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 04/23/2017 11:34 PM, brian m. carlson wrote:\n> Convert struct ref_array_item to use struct object_id by changing the\n> definition and applying the following semantic patch, plus the standard\n> object_id transforms:\n> [...]\n\nThis commit LGTM.\n\nMichael\n\n\n"},{"id":"318040","messageId":"1e4a72a0-9b6c-e9b4-7639-d241558e2120@alum.mit.edu","threadId":"45782","inReplyTo":"20170423213453.253425-40-sandals@crustytoothpaste.net","subject":"Re: [PATCH 39/53] refs/files-backend: convert many internals to struct object_id","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2017-04-27T05:04:48Z","receivedAt":"2017-04-27T05:05:03Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 04/23/2017 11:34 PM, brian m. carlson wrote:\n> Convert many of the internals of the files backend to use struct\n> object_id.  Avoid converting public APIs to limit the scope of the\n> changes.\n> \n> Convert one use of get_sha1_hex to parse_oid_hex, and rely on the fact\n> that a strbuf will be NUL-terminated and that parse_oid_hex will fail on\n> truncated input to avoid the need to check for an explicit length.\n> \n> This is a requirement to convert parse_object later on.\n> [...]\n\nThis patch also looks fine to me.\n\nMichael\n\n"},{"id":"318046","messageId":"20170427055209.ock533opgzans6ew@sigill.intra.peff.net","threadId":"45782","inReplyTo":"20170423213453.253425-36-sandals@crustytoothpaste.net","subject":"Re: [PATCH 35/53] Convert the verify_pack callback to struct object_id","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-04-27T05:52:09Z","receivedAt":"2017-04-27T05:52:27Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Apr 23, 2017 at 09:34:35PM +0000, brian m. carlson wrote:\n\n> Make the verify_pack_callback take a pointer to struct object_id.\n\nThat sounds good.\n\n> Use a\n> struct object_id to hold the pack checksum, even though it is not\n> strictly an object ID.  Doing so ensures resilience against future hash\n> size changes, and allows us to remove hard-coded assumptions about how\n> big the buffer needs to be.\n\nBut this part seems questionable to me. Sure, we may change the pack\nchecksum in the future. But there is a reasonable chance that it won't\nfollow the same rules for selecting a hash as object_id. And even if it\ndoes, calling it object_id just seems misleading.\n\nWhat's the gain in converting it here? I know we want to get rid of the\nbare \"20\", but we could switch it out for GIT_SHA1_RAWSZ. I suspect you\nprefer in the long run to get rid of even those GIT_SHA1_RAWSZ defines,\nthough.  Could we define a new struct csumfile_hash, csumfile_cmp, etc\n(and arguably change the name of \"struct sha1file\" and friends).  They'd\nbe boring wrappers around sha1 now, but I think the endgame will involve\nus being able to read multiple versions of packs, with distinct\nchecksum algorithms.\n\n> Also, use a union to convert the pointer from nth_packed_object_sha1 to\n> to a pointer to struct object_id.  This behavior is compatible with GCC\n> and clang and explicitly sanctioned by C11.  The alternatives are to\n> just perform a cast, which would run afoul of strict aliasing rules, but\n> should just work, and changing the pointer into an instance of struct\n> object_id and copying the value.  The latter operation could seriously\n> bloat memory usage on fsck, which already uses a lot of memory on some\n> repositories.\n\nNasty, but it's probably the least-bad option.\n\n-Peff\n"},{"id":"318096","messageId":"CAGZ79kant7b0-+DB3Q6a4Brta8LmdrZdgdkwQLvWc5YNxv5eCg@mail.gmail.com","threadId":"45782","inReplyTo":"20170423213453.253425-54-sandals@crustytoothpaste.net","subject":"Re: [PATCH 53/53] object: convert parse_object* to take struct object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-04-27T21:46:06Z","receivedAt":"2017-04-27T21:46:13Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Sun, Apr 23, 2017 at 2:34 PM, brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n> Make parse_object, parse_object_or_die, and parse_object_buffer take a\n> pointer to struct object_id.  Remove the temporary variables inserted\n> earlier, since they are no longer necessary.  Transform all of the\n> callers using the following semantic patch:\n\nI have finally reviewed the rest of the series and did not spot any other\nthings to raise.\n\nThanks,\nStefan\n"},{"id":"318110","messageId":"20170428001754.7h7gblafh2faz4vf@genre.crustytoothpaste.net","threadId":"45782","inReplyTo":"20170427055209.ock533opgzans6ew@sigill.intra.peff.net","subject":"Re: [PATCH 35/53] Convert the verify_pack callback to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-04-28T00:17:54Z","receivedAt":"2017-04-28T00:18:09Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Thu, Apr 27, 2017 at 01:52:09AM -0400, Jeff King wrote:\n> On Sun, Apr 23, 2017 at 09:34:35PM +0000, brian m. carlson wrote:\n> > Use a\n> > struct object_id to hold the pack checksum, even though it is not\n> > strictly an object ID.  Doing so ensures resilience against future hash\n> > size changes, and allows us to remove hard-coded assumptions about how\n> > big the buffer needs to be.\n> \n> But this part seems questionable to me. Sure, we may change the pack\n> checksum in the future. But there is a reasonable chance that it won't\n> follow the same rules for selecting a hash as object_id. And even if it\n> does, calling it object_id just seems misleading.\n> \n> What's the gain in converting it here? I know we want to get rid of the\n> bare \"20\", but we could switch it out for GIT_SHA1_RAWSZ. I suspect you\n> prefer in the long run to get rid of even those GIT_SHA1_RAWSZ defines,\n> though.  Could we define a new struct csumfile_hash, csumfile_cmp, etc\n> (and arguably change the name of \"struct sha1file\" and friends).  They'd\n> be boring wrappers around sha1 now, but I think the endgame will involve\n> us being able to read multiple versions of packs, with distinct\n> checksum algorithms.\n\nWhen I wrote this originally, the GIT_MAX_*SZ patch was in\nobject-id-part9 and hadn't been merged yet.  And I think your concerns\nabout this being kinda gross are legitimate.  I'll admit I had some\nhesitance about it at first.\n\nSo I'll reroll this leaving it as an unsigned char with GIT_MAX_RAWSZ.\nI feel confident that we're not going to pick a third, different\nalgorithm for the pack checksum, so that will get us to the point that\nwe have a big enough buffer, and we can incrementally improve on it\nlater by using a different struct if we like.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\n+1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"318111","messageId":"20170428011458.qcezjqonc2gqpthi@sigill.intra.peff.net","threadId":"45782","inReplyTo":"20170428001754.7h7gblafh2faz4vf@genre.crustytoothpaste.net","subject":"Re: [PATCH 35/53] Convert the verify_pack callback to struct object_id","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-04-28T01:14:59Z","receivedAt":"2017-04-28T01:15:07Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Apr 28, 2017 at 12:17:54AM +0000, brian m. carlson wrote:\n\n> > What's the gain in converting it here? I know we want to get rid of the\n> > bare \"20\", but we could switch it out for GIT_SHA1_RAWSZ. I suspect you\n> > prefer in the long run to get rid of even those GIT_SHA1_RAWSZ defines,\n> > though.  Could we define a new struct csumfile_hash, csumfile_cmp, etc\n> > (and arguably change the name of \"struct sha1file\" and friends).  They'd\n> > be boring wrappers around sha1 now, but I think the endgame will involve\n> > us being able to read multiple versions of packs, with distinct\n> > checksum algorithms.\n> \n> When I wrote this originally, the GIT_MAX_*SZ patch was in\n> object-id-part9 and hadn't been merged yet.  And I think your concerns\n> about this being kinda gross are legitimate.  I'll admit I had some\n> hesitance about it at first.\n> \n> So I'll reroll this leaving it as an unsigned char with GIT_MAX_RAWSZ.\n> I feel confident that we're not going to pick a third, different\n> algorithm for the pack checksum, so that will get us to the point that\n> we have a big enough buffer, and we can incrementally improve on it\n> later by using a different struct if we like.\n\nOK, that seems like a good middle ground. We won't know what the end\nresult looks like until we get closer to it.\n\n-Peff\n"}]}