{"thread":{"id":"46876","subject":"[PATCH 00/24] object_id part 10","startedAt":"2017-10-01T22:08:49Z","lastAt":"2017-10-03T01:44:03Z","messageCount":34,"participants":["brian m. carlson","Stefan Beller","Brandon Williams"],"isPatch":true,"patchVersion":1,"patchTotal":24},"messages":[{"id":"329322","messageId":"20171001220831.214705-1-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":null,"subject":"[PATCH 00/24] object_id part 10","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:07Z","receivedAt":"2017-10-01T22:08:49Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is the tenth in a series of patches to convert from unsigned char\n[20] to struct object_id.  This series mostly involves changes to the\nrefs code.  After these changes, there are almost no references to\nunsigned char in the main refs code.\n\nI've tried to update the code comments as I've touched them, but if I've\nmissed any, please point them out.  A big thank-you goes out to René\nScharfe, who did the work to make resolve_ref_unsafe optionally take a\nNULL pointer; this dramatically reduced the size of one of the patches,\nand allowed a few others to be dropped during the rebase.\n\nI apologize for the unintended bounced emails that occurred in late\nAugust; my mail server (previously hosted at home) got knocked offline\nbecause I was without Internet for over a week after Hurricane Harvey.\nI've since relocated mail to New York, so that shouldn't happen again.\n\nThis series is available from the following URL:\nhttps://github.com/bk2204/git.git object-id-part10\n\nbrian m. carlson (24):\n  walker: convert to struct object_id\n  refs/files-backend: convert struct ref_to_prune to object_id\n  refs: convert delete_ref and refs_delete_ref to struct object_id\n  refs: convert update_ref and refs_update_ref to use struct object_id\n  refs: update ref transactions to use struct object_id\n  Convert check_connected to use struct object_id\n  refs: convert resolve_refdup and refs_resolve_refdup to struct\n    object_id\n  refs: convert read_ref and read_ref_full to object_id\n  refs: convert dwim_ref and expand_ref to struct object_id\n  builtin/reflog: convert remaining unsigned char uses to object_id\n  refs: convert dwim_log to struct object_id\n  pack-bitmap: convert traverse_bitmap_commit_list to object_id\n  builtin/pack-objects: convert to struct object_id\n  refs: convert peel_ref to struct object_id\n  refs: convert read_ref_at to struct object_id\n  refs: convert reflog_expire parameter to struct object_id\n  sha1_file: convert index_path and index_fd to struct object_id\n  Convert remaining callers of resolve_gitlink_ref to object_id\n  refs: convert resolve_gitlink_ref to struct object_id\n  worktree: convert struct worktree to object_id\n  refs: convert resolve_ref_unsafe to struct object_id\n  refs: convert peel_object to struct object_id\n  refs: convert read_raw_ref backends to struct object_id\n  refs/files-backend: convert static functions to object_id\n\n archive.c                   |   2 +-\n bisect.c                    |   6 +-\n blame.c                     |   4 +-\n branch.c                    |   4 +-\n builtin/am.c                |  16 ++--\n builtin/branch.c            |   8 +-\n builtin/checkout.c          |  13 ++-\n builtin/clone.c             |  22 ++---\n builtin/commit.c            |   4 +-\n builtin/describe.c          |   2 +-\n builtin/fast-export.c       |   2 +-\n builtin/fetch.c             |   8 +-\n builtin/fmt-merge-msg.c     |   2 +-\n builtin/fsck.c              |   2 +-\n builtin/log.c               |   2 +-\n builtin/merge-base.c        |   2 +-\n builtin/merge.c             |  17 ++--\n builtin/notes.c             |  12 +--\n builtin/pack-objects.c      | 135 +++++++++++++-------------\n builtin/pull.c              |   2 +-\n builtin/receive-pack.c      |  16 ++--\n builtin/reflog.c            |  18 ++--\n builtin/remote.c            |   2 +-\n builtin/replace.c           |   8 +-\n builtin/reset.c             |   6 +-\n builtin/rev-list.c          |   4 +-\n builtin/rev-parse.c         |   2 +-\n builtin/show-branch.c       |  13 ++-\n builtin/show-ref.c          |   4 +-\n builtin/submodule--helper.c |   2 +-\n builtin/tag.c               |   8 +-\n builtin/update-index.c      |  10 +-\n builtin/update-ref.c        |  12 +--\n builtin/worktree.c          |   6 +-\n bundle.c                    |   4 +-\n combine-diff.c              |   2 +-\n connected.c                 |  18 ++--\n connected.h                 |   4 +-\n diff-lib.c                  |   4 +-\n dir.c                       |   8 +-\n fast-import.c               |   6 +-\n notes-cache.c               |   5 +-\n notes-merge.c               |   2 +-\n notes-utils.c               |   4 +-\n notes.c                     |   2 +-\n pack-bitmap.c               |   8 +-\n pack-bitmap.h               |   2 +-\n read-cache.c                |   6 +-\n ref-filter.c                |   4 +-\n reflog-walk.c               |   6 +-\n refs.c                      | 228 +++++++++++++++++++++-----------------------\n refs.h                      |  75 +++++++--------\n refs/files-backend.c        | 118 +++++++++++------------\n refs/packed-backend.c       |  14 +--\n refs/ref-cache.c            |   2 +-\n refs/refs-internal.h        |  22 ++---\n remote-testsvn.c            |   2 +-\n remote.c                    |   9 +-\n sequencer.c                 |  15 ++-\n sha1_file.c                 |  32 +++----\n sha1_name.c                 |  11 +--\n submodule.c                 |   2 +-\n t/helper/test-ref-store.c   |  28 +++---\n transport-helper.c          |  15 ++-\n transport.c                 |   6 +-\n unpack-trees.c              |   8 +-\n upload-pack.c               |   4 +-\n walker.c                    |  24 ++---\n worktree.c                  |   2 +-\n worktree.h                  |   2 +-\n wt-status.c                 |   4 +-\n 71 files changed, 532 insertions(+), 552 deletions(-)\n\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329323","messageId":"20171001220831.214705-2-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 01/24] walker: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:08Z","receivedAt":"2017-10-01T22:08:52Z","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 walker.c | 24 ++++++++++++------------\n 1 file changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/walker.c b/walker.c\nindex 274f1a4935..2d83254bc0 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -7,7 +7,7 @@\n #include \"blob.h\"\n #include \"refs.h\"\n \n-static unsigned char current_commit_sha1[20];\n+static struct object_id current_commit_oid;\n \n void walker_say(struct walker *walker, const char *fmt, ...)\n {\n@@ -24,9 +24,9 @@ static void report_missing(const struct object *obj)\n \tfprintf(stderr, \"Cannot obtain needed %s %s\\n\",\n \t\tobj->type ? typename(obj->type): \"object\",\n \t\toid_to_hex(&obj->oid));\n-\tif (!is_null_sha1(current_commit_sha1))\n+\tif (!is_null_oid(&current_commit_oid))\n \t\tfprintf(stderr, \"while processing commit %s.\\n\",\n-\t\t\tsha1_to_hex(current_commit_sha1));\n+\t\t\toid_to_hex(&current_commit_oid));\n }\n \n static int process(struct walker *walker, struct object *obj);\n@@ -82,7 +82,7 @@ static int process_commit(struct walker *walker, struct commit *commit)\n \tif (commit->object.flags & COMPLETE)\n \t\treturn 0;\n \n-\thashcpy(current_commit_sha1, commit->object.oid.hash);\n+\toidcpy(&current_commit_oid, &commit->object.oid);\n \n \twalker_say(walker, \"walk %s\\n\", oid_to_hex(&commit->object.oid));\n \n@@ -187,14 +187,14 @@ static int loop(struct walker *walker)\n \treturn 0;\n }\n \n-static int interpret_target(struct walker *walker, char *target, unsigned char *sha1)\n+static int interpret_target(struct walker *walker, char *target, struct object_id *oid)\n {\n-\tif (!get_sha1_hex(target, sha1))\n+\tif (!get_oid_hex(target, oid))\n \t\treturn 0;\n \tif (!check_refname_format(target, 0)) {\n \t\tstruct ref *ref = alloc_ref(target);\n \t\tif (!walker->fetch_ref(walker, ref)) {\n-\t\t\thashcpy(sha1, ref->old_oid.hash);\n+\t\t\toidcpy(oid, &ref->old_oid);\n \t\t\tfree(ref);\n \t\t\treturn 0;\n \t\t}\n@@ -259,7 +259,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,\n \tstruct strbuf refname = STRBUF_INIT;\n \tstruct strbuf err = STRBUF_INIT;\n \tstruct ref_transaction *transaction = NULL;\n-\tunsigned char *sha1 = xmalloc(targets * 20);\n+\tstruct object_id *oids = xmalloc(targets * sizeof(struct object_id));\n \tchar *msg = NULL;\n \tint i, ret = -1;\n \n@@ -279,11 +279,11 @@ int walker_fetch(struct walker *walker, int targets, char **target,\n \t}\n \n \tfor (i = 0; i < targets; i++) {\n-\t\tif (interpret_target(walker, target[i], &sha1[20 * i])) {\n+\t\tif (interpret_target(walker, target[i], oids + i)) {\n \t\t\terror(\"Could not interpret response from server '%s' as something to pull\", target[i]);\n \t\t\tgoto done;\n \t\t}\n-\t\tif (process(walker, lookup_unknown_object(&sha1[20 * i])))\n+\t\tif (process(walker, lookup_unknown_object(oids[i].hash)))\n \t\t\tgoto done;\n \t}\n \n@@ -304,7 +304,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,\n \t\tstrbuf_reset(&refname);\n \t\tstrbuf_addf(&refname, \"refs/%s\", write_ref[i]);\n \t\tif (ref_transaction_update(transaction, refname.buf,\n-\t\t\t\t\t   &sha1[20 * i], NULL, 0,\n+\t\t\t\t\t   oids[i].hash, NULL, 0,\n \t\t\t\t\t   msg ? msg : \"fetch (unknown)\",\n \t\t\t\t\t   &err)) {\n \t\t\terror(\"%s\", err.buf);\n@@ -321,7 +321,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,\n done:\n \tref_transaction_free(transaction);\n \tfree(msg);\n-\tfree(sha1);\n+\tfree(oids);\n \tstrbuf_release(&err);\n \tstrbuf_release(&refname);\n \treturn ret;\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329324","messageId":"20171001220831.214705-3-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 02/24] refs/files-backend: convert struct ref_to_prune to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:09Z","receivedAt":"2017-10-01T22:08:54Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Change the member of this struct to be a struct object_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n refs/files-backend.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex fec77744b4..e3968d4f7c 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -961,7 +961,7 @@ static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,\n \n struct ref_to_prune {\n \tstruct ref_to_prune *next;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tchar name[FLEX_ARRAY];\n };\n \n@@ -1029,7 +1029,7 @@ static void prune_ref(struct files_ref_store *refs, struct ref_to_prune *r)\n \n \ttransaction = ref_store_transaction_begin(&refs->base, &err);\n \tif (!transaction ||\n-\t    ref_transaction_delete(transaction, r->name, r->sha1,\n+\t    ref_transaction_delete(transaction, r->name, r->oid.hash,\n \t\t\t\t   REF_ISPRUNING | REF_NODEREF, NULL, &err) ||\n \t    ref_transaction_commit(transaction, &err)) {\n \t\tref_transaction_free(transaction);\n@@ -1123,7 +1123,7 @@ static int files_pack_refs(struct ref_store *ref_store, unsigned int flags)\n \t\tif ((flags & PACK_REFS_PRUNE)) {\n \t\t\tstruct ref_to_prune *n;\n \t\t\tFLEX_ALLOC_STR(n, name, iter->refname);\n-\t\t\thashcpy(n->sha1, iter->oid->hash);\n+\t\t\toidcpy(&n->oid, iter->oid);\n \t\t\tn->next = refs_to_prune;\n \t\t\trefs_to_prune = n;\n \t\t}\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329325","messageId":"20171001220831.214705-6-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 05/24] refs: update ref transactions to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:12Z","receivedAt":"2017-10-01T22:08:56Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Update the ref transaction code to use struct object_id.  Remove one\nNULL pointer check which was previously inserted around a dereference;\nsince we now pass a pointer to struct object_id directly through, the\ncode we're calling handles this for us.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n branch.c               |  2 +-\n builtin/clone.c        |  2 +-\n builtin/commit.c       |  4 ++--\n builtin/fetch.c        |  4 ++--\n builtin/receive-pack.c |  4 ++--\n builtin/replace.c      |  2 +-\n builtin/tag.c          |  2 +-\n builtin/update-ref.c   |  8 ++++----\n fast-import.c          |  4 ++--\n refs.c                 | 44 +++++++++++++++++++++-----------------------\n refs.h                 | 24 ++++++++++++------------\n refs/files-backend.c   | 12 ++++++------\n refs/refs-internal.h   |  4 ++--\n sequencer.c            |  2 +-\n walker.c               |  2 +-\n 15 files changed, 59 insertions(+), 61 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 4377ce2fb1..45029ea142 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -305,7 +305,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   oid.hash, forcing ? NULL : null_sha1,\n+\t\t\t\t\t   &oid, forcing ? NULL : &null_oid,\n \t\t\t\t\t   0, msg, &err) ||\n \t\t    ref_transaction_commit(transaction, &err))\n \t\t\tdie(\"%s\", err.buf);\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 4135621aa3..665a0e2673 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -588,7 +588,7 @@ static void write_remote_refs(const struct ref *local_refs)\n \tfor (r = local_refs; r; r = r->next) {\n \t\tif (!r->peer_ref)\n \t\t\tcontinue;\n-\t\tif (ref_transaction_create(t, r->peer_ref->name, r->old_oid.hash,\n+\t\tif (ref_transaction_create(t, r->peer_ref->name, &r->old_oid,\n \t\t\t\t\t   0, NULL, &err))\n \t\t\tdie(\"%s\", err.buf);\n \t}\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 0f8ddb6866..d5fbf404f4 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1785,9 +1785,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \n \ttransaction = ref_transaction_begin(&err);\n \tif (!transaction ||\n-\t    ref_transaction_update(transaction, \"HEAD\", oid.hash,\n+\t    ref_transaction_update(transaction, \"HEAD\", &oid,\n \t\t\t\t   current_head\n-\t\t\t\t   ? current_head->object.oid.hash : null_sha1,\n+\t\t\t\t   ? &current_head->object.oid : &null_oid,\n \t\t\t\t   0, sb.buf, &err) ||\n \t    ref_transaction_commit(transaction, &err)) {\n \t\trollback_index_files();\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 225c734924..859be91d6c 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -457,8 +457,8 @@ static int s_update_ref(const char *action,\n \ttransaction = ref_transaction_begin(&err);\n \tif (!transaction ||\n \t    ref_transaction_update(transaction, ref->name,\n-\t\t\t\t   ref->new_oid.hash,\n-\t\t\t\t   check_old ? ref->old_oid.hash : NULL,\n+\t\t\t\t   &ref->new_oid,\n+\t\t\t\t   check_old ? &ref->old_oid : NULL,\n \t\t\t\t   0, msg, &err))\n \t\tgoto fail;\n \ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 29a0f3b75f..39defd4e3c 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1139,7 +1139,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)\n \t\t}\n \t\tif (ref_transaction_delete(transaction,\n \t\t\t\t\t   namespaced_name,\n-\t\t\t\t\t   old_oid ? old_oid->hash : NULL,\n+\t\t\t\t\t   old_oid,\n \t\t\t\t\t   0, \"push\", &err)) {\n \t\t\trp_error(\"%s\", err.buf);\n \t\t\tstrbuf_release(&err);\n@@ -1156,7 +1156,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)\n \n \t\tif (ref_transaction_update(transaction,\n \t\t\t\t\t   namespaced_name,\n-\t\t\t\t\t   new_oid->hash, old_oid->hash,\n+\t\t\t\t\t   new_oid, old_oid,\n \t\t\t\t\t   0, \"push\",\n \t\t\t\t\t   &err)) {\n \t\t\trp_error(\"%s\", err.buf);\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 2854eaa0f3..3099e55307 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -175,7 +175,7 @@ static int replace_object_oid(const char *object_ref,\n \n \ttransaction = ref_transaction_begin(&err);\n \tif (!transaction ||\n-\t    ref_transaction_update(transaction, ref.buf, repl->hash, prev.hash,\n+\t    ref_transaction_update(transaction, ref.buf, repl, &prev,\n \t\t\t\t   0, NULL, &err) ||\n \t    ref_transaction_commit(transaction, &err))\n \t\tdie(\"%s\", err.buf);\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 46ff4ca736..2ededc3fb1 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -543,7 +543,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \n \ttransaction = ref_transaction_begin(&err);\n \tif (!transaction ||\n-\t    ref_transaction_update(transaction, ref.buf, object.hash, prev.hash,\n+\t    ref_transaction_update(transaction, ref.buf, &object, &prev,\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))\ndiff --git a/builtin/update-ref.c b/builtin/update-ref.c\nindex f491cf1a92..cf1552b478 100644\n--- a/builtin/update-ref.c\n+++ b/builtin/update-ref.c\n@@ -200,7 +200,7 @@ static const char *parse_cmd_update(struct ref_transaction *transaction,\n \t\tdie(\"update %s: extra input: %s\", refname, next);\n \n \tif (ref_transaction_update(transaction, refname,\n-\t\t\t\t   new_oid.hash, have_old ? old_oid.hash : NULL,\n+\t\t\t\t   &new_oid, have_old ? &old_oid : NULL,\n \t\t\t\t   update_flags | create_reflog_flag,\n \t\t\t\t   msg, &err))\n \t\tdie(\"%s\", err.buf);\n@@ -232,7 +232,7 @@ static const char *parse_cmd_create(struct ref_transaction *transaction,\n \tif (*next != line_termination)\n \t\tdie(\"create %s: extra input: %s\", refname, next);\n \n-\tif (ref_transaction_create(transaction, refname, new_oid.hash,\n+\tif (ref_transaction_create(transaction, refname, &new_oid,\n \t\t\t\t   update_flags | create_reflog_flag,\n \t\t\t\t   msg, &err))\n \t\tdie(\"%s\", err.buf);\n@@ -269,7 +269,7 @@ static const char *parse_cmd_delete(struct ref_transaction *transaction,\n \t\tdie(\"delete %s: extra input: %s\", refname, next);\n \n \tif (ref_transaction_delete(transaction, refname,\n-\t\t\t\t   have_old ? old_oid.hash : NULL,\n+\t\t\t\t   have_old ? &old_oid : NULL,\n \t\t\t\t   update_flags, msg, &err))\n \t\tdie(\"%s\", err.buf);\n \n@@ -298,7 +298,7 @@ static const char *parse_cmd_verify(struct ref_transaction *transaction,\n \tif (*next != line_termination)\n \t\tdie(\"verify %s: extra input: %s\", refname, next);\n \n-\tif (ref_transaction_verify(transaction, refname, old_oid.hash,\n+\tif (ref_transaction_verify(transaction, refname, &old_oid,\n \t\t\t\t   update_flags, &err))\n \t\tdie(\"%s\", err.buf);\n \ndiff --git a/fast-import.c b/fast-import.c\nindex 35bf671f12..2d2d0d98f0 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1778,7 +1778,7 @@ static int update_branch(struct branch *b)\n \t}\n \ttransaction = ref_transaction_begin(&err);\n \tif (!transaction ||\n-\t    ref_transaction_update(transaction, b->name, b->oid.hash, old_oid.hash,\n+\t    ref_transaction_update(transaction, b->name, &b->oid, &old_oid,\n \t\t\t\t   0, msg, &err) ||\n \t    ref_transaction_commit(transaction, &err)) {\n \t\tref_transaction_free(transaction);\n@@ -1820,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->oid.hash, NULL, 0, msg, &err)) {\n+\t\t\t\t\t   &t->oid, NULL, 0, msg, &err)) {\n \t\t\tfailure |= error(\"%s\", err.buf);\n \t\t\tgoto cleanup;\n \t\t}\ndiff --git a/refs.c b/refs.c\nindex 66d66af126..90c2f9ccca 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -668,8 +668,7 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,\n \n \ttransaction = ref_store_transaction_begin(refs, &err);\n \tif (!transaction ||\n-\t    ref_transaction_delete(transaction, refname,\n-\t\t\t\t   old_oid ? old_oid->hash : NULL,\n+\t    ref_transaction_delete(transaction, refname, old_oid,\n \t\t\t\t   flags, msg, &err) ||\n \t    ref_transaction_commit(transaction, &err)) {\n \t\terror(\"%s\", err.buf);\n@@ -895,8 +894,8 @@ void ref_transaction_free(struct ref_transaction *transaction)\n struct ref_update *ref_transaction_add_update(\n \t\tstruct ref_transaction *transaction,\n \t\tconst char *refname, unsigned int flags,\n-\t\tconst unsigned char *new_sha1,\n-\t\tconst unsigned char *old_sha1,\n+\t\tconst struct object_id *new_oid,\n+\t\tconst struct object_id *old_oid,\n \t\tconst char *msg)\n {\n \tstruct ref_update *update;\n@@ -914,23 +913,23 @@ struct ref_update *ref_transaction_add_update(\n \tupdate->flags = flags;\n \n \tif (flags & REF_HAVE_NEW)\n-\t\thashcpy(update->new_oid.hash, new_sha1);\n+\t\toidcpy(&update->new_oid, new_oid);\n \tif (flags & REF_HAVE_OLD)\n-\t\thashcpy(update->old_oid.hash, old_sha1);\n+\t\toidcpy(&update->old_oid, old_oid);\n \tupdate->msg = xstrdup_or_null(msg);\n \treturn update;\n }\n \n int ref_transaction_update(struct ref_transaction *transaction,\n \t\t\t   const char *refname,\n-\t\t\t   const unsigned char *new_sha1,\n-\t\t\t   const unsigned char *old_sha1,\n+\t\t\t   const struct object_id *new_oid,\n+\t\t\t   const struct object_id *old_oid,\n \t\t\t   unsigned int flags, const char *msg,\n \t\t\t   struct strbuf *err)\n {\n \tassert(err);\n \n-\tif ((new_sha1 && !is_null_sha1(new_sha1)) ?\n+\tif ((new_oid && !is_null_oid(new_oid)) ?\n \t    check_refname_format(refname, REFNAME_ALLOW_ONELEVEL) :\n \t    !refname_is_safe(refname)) {\n \t\tstrbuf_addf(err, \"refusing to update ref with bad name '%s'\",\n@@ -940,48 +939,48 @@ int ref_transaction_update(struct ref_transaction *transaction,\n \n \tflags &= REF_TRANSACTION_UPDATE_ALLOWED_FLAGS;\n \n-\tflags |= (new_sha1 ? REF_HAVE_NEW : 0) | (old_sha1 ? REF_HAVE_OLD : 0);\n+\tflags |= (new_oid ? REF_HAVE_NEW : 0) | (old_oid ? REF_HAVE_OLD : 0);\n \n \tref_transaction_add_update(transaction, refname, flags,\n-\t\t\t\t   new_sha1, old_sha1, msg);\n+\t\t\t\t   new_oid, old_oid, msg);\n \treturn 0;\n }\n \n int ref_transaction_create(struct ref_transaction *transaction,\n \t\t\t   const char *refname,\n-\t\t\t   const unsigned char *new_sha1,\n+\t\t\t   const struct object_id *new_oid,\n \t\t\t   unsigned int flags, const char *msg,\n \t\t\t   struct strbuf *err)\n {\n-\tif (!new_sha1 || is_null_sha1(new_sha1))\n+\tif (!new_oid || is_null_oid(new_oid))\n \t\tdie(\"BUG: create called without valid new_sha1\");\n-\treturn ref_transaction_update(transaction, refname, new_sha1,\n-\t\t\t\t      null_sha1, flags, msg, err);\n+\treturn ref_transaction_update(transaction, refname, new_oid,\n+\t\t\t\t      &null_oid, flags, msg, err);\n }\n \n int ref_transaction_delete(struct ref_transaction *transaction,\n \t\t\t   const char *refname,\n-\t\t\t   const unsigned char *old_sha1,\n+\t\t\t   const struct object_id *old_oid,\n \t\t\t   unsigned int flags, const char *msg,\n \t\t\t   struct strbuf *err)\n {\n-\tif (old_sha1 && is_null_sha1(old_sha1))\n+\tif (old_oid && is_null_oid(old_oid))\n \t\tdie(\"BUG: delete called with old_sha1 set to zeros\");\n \treturn ref_transaction_update(transaction, refname,\n-\t\t\t\t      null_sha1, old_sha1,\n+\t\t\t\t      &null_oid, old_oid,\n \t\t\t\t      flags, msg, err);\n }\n \n int ref_transaction_verify(struct ref_transaction *transaction,\n \t\t\t   const char *refname,\n-\t\t\t   const unsigned char *old_sha1,\n+\t\t\t   const struct object_id *old_oid,\n \t\t\t   unsigned int flags,\n \t\t\t   struct strbuf *err)\n {\n-\tif (!old_sha1)\n+\tif (!old_oid)\n \t\tdie(\"BUG: verify called with old_sha1 set to NULL\");\n \treturn ref_transaction_update(transaction, refname,\n-\t\t\t\t      NULL, old_sha1,\n+\t\t\t\t      NULL, old_oid,\n \t\t\t\t      flags, NULL, err);\n }\n \n@@ -1000,8 +999,7 @@ int refs_update_ref(struct ref_store *refs, const char *msg,\n \t} else {\n \t\tt = ref_store_transaction_begin(refs, &err);\n \t\tif (!t ||\n-\t\t    ref_transaction_update(t, refname, new_oid ? new_oid->hash : NULL,\n-\t\t\t\t\t   old_oid ? old_oid->hash : NULL,\n+\t\t    ref_transaction_update(t, refname, new_oid, old_oid,\n \t\t\t\t\t   flags, msg, &err) ||\n \t\t    ref_transaction_commit(t, &err)) {\n \t\t\tret = 1;\ndiff --git a/refs.h b/refs.h\nindex 369614d392..543dcc5956 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -519,15 +519,15 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err);\n  */\n int ref_transaction_update(struct ref_transaction *transaction,\n \t\t\t   const char *refname,\n-\t\t\t   const unsigned char *new_sha1,\n-\t\t\t   const unsigned char *old_sha1,\n+\t\t\t   const struct object_id *new_oid,\n+\t\t\t   const struct object_id *old_oid,\n \t\t\t   unsigned int flags, const char *msg,\n \t\t\t   struct strbuf *err);\n \n /*\n- * Add a reference creation to transaction. new_sha1 is the value that\n+ * Add a reference creation to transaction. new_oid is the value that\n  * the reference should have after the update; it must not be\n- * null_sha1. It is verified that the reference does not exist\n+ * null_oid. It is verified that the reference does not exist\n  * already.\n  *\n  * See the above comment \"Reference transaction updates\" for more\n@@ -535,35 +535,35 @@ int ref_transaction_update(struct ref_transaction *transaction,\n  */\n int ref_transaction_create(struct ref_transaction *transaction,\n \t\t\t   const char *refname,\n-\t\t\t   const unsigned char *new_sha1,\n+\t\t\t   const struct object_id *new_oid,\n \t\t\t   unsigned int flags, const char *msg,\n \t\t\t   struct strbuf *err);\n \n /*\n- * Add a reference deletion to transaction. If old_sha1 is non-NULL,\n+ * Add a reference deletion to transaction. If old_oid is non-NULL,\n  * then it holds the value that the reference should have had before\n- * the update (which must not be null_sha1).\n+ * the update (which must not be null_oid).\n  *\n  * See the above comment \"Reference transaction updates\" for more\n  * information.\n  */\n int ref_transaction_delete(struct ref_transaction *transaction,\n \t\t\t   const char *refname,\n-\t\t\t   const unsigned char *old_sha1,\n+\t\t\t   const struct object_id *old_oid,\n \t\t\t   unsigned int flags, const char *msg,\n \t\t\t   struct strbuf *err);\n \n /*\n- * Verify, within a transaction, that refname has the value old_sha1,\n- * or, if old_sha1 is null_sha1, then verify that the reference\n- * doesn't exist. old_sha1 must be non-NULL.\n+ * Verify, within a transaction, that refname has the value old_oid,\n+ * or, if old_oid is null_oid, then verify that the reference\n+ * doesn't exist. old_oid must be non-NULL.\n  *\n  * See the above comment \"Reference transaction updates\" for more\n  * information.\n  */\n int ref_transaction_verify(struct ref_transaction *transaction,\n \t\t\t   const char *refname,\n-\t\t\t   const unsigned char *old_sha1,\n+\t\t\t   const struct object_id *old_oid,\n \t\t\t   unsigned int flags,\n \t\t\t   struct strbuf *err);\n \ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 0c641f0ad0..46dbcda6a6 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -1029,7 +1029,7 @@ static void prune_ref(struct files_ref_store *refs, struct ref_to_prune *r)\n \n \ttransaction = ref_store_transaction_begin(&refs->base, &err);\n \tif (!transaction ||\n-\t    ref_transaction_delete(transaction, r->name, r->oid.hash,\n+\t    ref_transaction_delete(transaction, r->name, &r->oid,\n \t\t\t\t   REF_ISPRUNING | REF_NODEREF, NULL, &err) ||\n \t    ref_transaction_commit(transaction, &err)) {\n \t\tref_transaction_free(transaction);\n@@ -1114,7 +1114,7 @@ static int files_pack_refs(struct ref_store *ref_store, unsigned int flags)\n \t\t * packed-refs transaction:\n \t\t */\n \t\tif (ref_transaction_update(transaction, iter->refname,\n-\t\t\t\t\t   iter->oid->hash, NULL,\n+\t\t\t\t\t   iter->oid, NULL,\n \t\t\t\t\t   REF_NODEREF, NULL, &err))\n \t\t\tdie(\"failure preparing to create packed reference %s: %s\",\n \t\t\t    iter->refname, err.buf);\n@@ -2153,7 +2153,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_oid.hash, update->old_oid.hash,\n+\t\t\t&update->new_oid, &update->old_oid,\n \t\t\tupdate->msg);\n \n \t/*\n@@ -2217,7 +2217,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_oid.hash, update->old_oid.hash,\n+\t\t\t&update->new_oid, &update->old_oid,\n \t\t\tupdate->msg);\n \n \tnew_update->parent_update = update;\n@@ -2600,7 +2600,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,\n \t\t\tref_transaction_add_update(\n \t\t\t\t\tpacked_transaction, update->refname,\n \t\t\t\t\tupdate->flags & ~REF_HAVE_OLD,\n-\t\t\t\t\tupdate->new_oid.hash, update->old_oid.hash,\n+\t\t\t\t\t&update->new_oid, &update->old_oid,\n \t\t\t\t\tNULL);\n \t\t}\n \t}\n@@ -2853,7 +2853,7 @@ static int files_initial_transaction_commit(struct ref_store *ref_store,\n \t\t */\n \t\tref_transaction_add_update(packed_transaction, update->refname,\n \t\t\t\t\t   update->flags & ~REF_HAVE_OLD,\n-\t\t\t\t\t   update->new_oid.hash, update->old_oid.hash,\n+\t\t\t\t\t   &update->new_oid, &update->old_oid,\n \t\t\t\t\t   NULL);\n \t}\n \ndiff --git a/refs/refs-internal.h b/refs/refs-internal.h\nindex d7d344de73..6636a13a62 100644\n--- a/refs/refs-internal.h\n+++ b/refs/refs-internal.h\n@@ -202,8 +202,8 @@ int ref_update_reject_duplicates(struct string_list *refnames,\n struct ref_update *ref_transaction_add_update(\n \t\tstruct ref_transaction *transaction,\n \t\tconst char *refname, unsigned int flags,\n-\t\tconst unsigned char *new_sha1,\n-\t\tconst unsigned char *old_sha1,\n+\t\tconst struct object_id *new_oid,\n+\t\tconst struct object_id *old_oid,\n \t\tconst char *msg);\n \n /*\ndiff --git a/sequencer.c b/sequencer.c\nindex b349474bd3..43a6f14eb3 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -392,7 +392,7 @@ static int fast_forward_to(const struct object_id *to, const struct object_id *f\n \ttransaction = ref_transaction_begin(&err);\n \tif (!transaction ||\n \t    ref_transaction_update(transaction, \"HEAD\",\n-\t\t\t\t   to->hash, unborn ? null_sha1 : from->hash,\n+\t\t\t\t   to, unborn ? &null_oid : from,\n \t\t\t\t   0, sb.buf, &err) ||\n \t    ref_transaction_commit(transaction, &err)) {\n \t\tref_transaction_free(transaction);\ndiff --git a/walker.c b/walker.c\nindex 2d83254bc0..5d4d3733f7 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -304,7 +304,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,\n \t\tstrbuf_reset(&refname);\n \t\tstrbuf_addf(&refname, \"refs/%s\", write_ref[i]);\n \t\tif (ref_transaction_update(transaction, refname.buf,\n-\t\t\t\t\t   oids[i].hash, NULL, 0,\n+\t\t\t\t\t   oids + i, NULL, 0,\n \t\t\t\t\t   msg ? msg : \"fetch (unknown)\",\n \t\t\t\t\t   &err)) {\n \t\t\terror(\"%s\", err.buf);\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329326","messageId":"20171001220831.214705-8-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 07/24] refs: convert resolve_refdup and refs_resolve_refdup to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:14Z","receivedAt":"2017-10-01T22:09:00Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"All of the callers already pass the hash member of struct object_id, so\nupdate them to pass a pointer to the struct directly,\n\nThis transformation was done with an update to declaration and\ndefinition and the following semantic patch:\n\n@@\nexpression E1, E2, E3, E4;\n@@\n- resolve_refdup(E1, E2, E3.hash, E4)\n+ resolve_refdup(E1, E2, &E3, E4)\n\n@@\nexpression E1, E2, E3, E4;\n@@\n- resolve_refdup(E1, E2, E3->hash, E4)\n+ resolve_refdup(E1, E2, E3, E4)\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/am.c                | 2 +-\n builtin/branch.c            | 6 +++---\n builtin/checkout.c          | 4 ++--\n builtin/clone.c             | 2 +-\n builtin/fmt-merge-msg.c     | 2 +-\n builtin/merge.c             | 2 +-\n builtin/notes.c             | 2 +-\n builtin/receive-pack.c      | 2 +-\n builtin/show-branch.c       | 6 +++---\n builtin/submodule--helper.c | 2 +-\n ref-filter.c                | 4 ++--\n reflog-walk.c               | 4 ++--\n refs.c                      | 8 ++++----\n refs.h                      | 4 ++--\n refs/files-backend.c        | 2 +-\n submodule.c                 | 2 +-\n transport.c                 | 2 +-\n wt-status.c                 | 2 +-\n 18 files changed, 29 insertions(+), 29 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 32120f42df..c9bb14a6c2 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -2135,7 +2135,7 @@ static void am_abort(struct am_state *state)\n \n \tam_rerere_clear();\n \n-\tcurr_branch = resolve_refdup(\"HEAD\", 0, curr_head.hash, NULL);\n+\tcurr_branch = resolve_refdup(\"HEAD\", 0, &curr_head, NULL);\n \thas_curr_head = curr_branch && !is_null_oid(&curr_head);\n \tif (!has_curr_head)\n \t\thashcpy(curr_head.hash, EMPTY_TREE_SHA1_BIN);\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 6031b74d68..75dadd3d93 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\tif (upstream &&\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\t\t    &oid, NULL)) != NULL)\n \t\t\treference_rev = lookup_commit_reference(&oid);\n \t}\n \tif (!reference_rev)\n@@ -240,7 +240,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,\n \t\t\t\t\tRESOLVE_REF_READING\n \t\t\t\t\t| RESOLVE_REF_NO_RECURSE\n \t\t\t\t\t| RESOLVE_REF_ALLOW_BAD_NAME,\n-\t\t\t\t\toid.hash, &flags);\n+\t\t\t\t\t&oid, &flags);\n \t\tif (!target) {\n \t\t\terror(remote_branch\n \t\t\t      ? _(\"remote-tracking branch '%s' not found.\")\n@@ -613,7 +613,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \n \ttrack = git_branch_track;\n \n-\thead = resolve_refdup(\"HEAD\", 0, head_oid.hash, NULL);\n+\thead = resolve_refdup(\"HEAD\", 0, &head_oid, NULL);\n \tif (!head)\n \t\tdie(_(\"Failed to resolve HEAD as a valid ref.\"));\n \tif (!strcmp(head, \"HEAD\"))\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex fd0dec401e..b803425bc4 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -826,7 +826,7 @@ static int switch_branches(const struct checkout_opts *opts,\n \tstruct object_id rev;\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.path = path_to_free = resolve_refdup(\"HEAD\", 0, &rev, &flag);\n \tif (old.path)\n \t\told.commit = lookup_commit_reference_gently(&rev, 1);\n \tif (!(flag & REF_ISSYMREF))\n@@ -1125,7 +1125,7 @@ static int checkout_branch(struct checkout_opts *opts,\n \t    !opts->ignore_other_worktrees) {\n \t\tstruct object_id oid;\n \t\tint flag;\n-\t\tchar *head_ref = resolve_refdup(\"HEAD\", 0, oid.hash, &flag);\n+\t\tchar *head_ref = resolve_refdup(\"HEAD\", 0, &oid, &flag);\n \t\tif (head_ref &&\n \t\t    (!(flag & REF_ISSYMREF) || strcmp(head_ref, new->path)))\n \t\t\tdie_if_checked_out(new->path, 1);\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 5cd1b02d53..695bdd7046 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -715,7 +715,7 @@ static int checkout(int submodule_progress)\n \tif (option_no_checkout)\n \t\treturn 0;\n \n-\thead = resolve_refdup(\"HEAD\", RESOLVE_REF_READING, oid.hash, NULL);\n+\thead = resolve_refdup(\"HEAD\", RESOLVE_REF_READING, &oid, NULL);\n \tif (!head) {\n \t\twarning(_(\"remote HEAD refers to nonexistent ref, \"\n \t\t\t  \"unable to checkout.\\n\"));\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex e99b5ddbf9..b69f7d3be2 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -603,7 +603,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,\n \n \t/* get current branch */\n \tcurrent_branch = current_branch_to_free =\n-\t\tresolve_refdup(\"HEAD\", RESOLVE_REF_READING, head_oid.hash, NULL);\n+\t\tresolve_refdup(\"HEAD\", RESOLVE_REF_READING, &head_oid, NULL);\n \tif (!current_branch)\n \t\tdie(\"No current branch\");\n \tif (starts_with(current_branch, \"refs/heads/\"))\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 99d4b873f0..99d2df965f 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -1142,7 +1142,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t * Check if we are _not_ on a detached HEAD, i.e. if there is a\n \t * current branch.\n \t */\n-\tbranch = branch_to_free = resolve_refdup(\"HEAD\", 0, head_oid.hash, NULL);\n+\tbranch = branch_to_free = resolve_refdup(\"HEAD\", 0, &head_oid, NULL);\n \tif (branch)\n \t\tskip_prefix(branch, \"refs/heads/\", &branch);\n \tif (!branch || is_null_oid(&head_oid))\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 8276af419b..12afdf1907 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -724,7 +724,7 @@ static int merge_commit(struct notes_merge_options *o)\n \tinit_notes(t, \"NOTES_MERGE_PARTIAL\", combine_notes_overwrite, 0);\n \n \to->local_ref = local_ref_to_free =\n-\t\tresolve_refdup(\"NOTES_MERGE_REF\", 0, oid.hash, NULL);\n+\t\tresolve_refdup(\"NOTES_MERGE_REF\", 0, &oid, NULL);\n \tif (!o->local_ref)\n \t\tdie(_(\"failed to resolve NOTES_MERGE_REF\"));\n \ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 046b600b11..313b224fad 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1515,7 +1515,7 @@ static void execute_commands(struct command *commands,\n \tcheck_aliased_updates(commands);\n \n \tfree(head_name_to_free);\n-\thead_name = head_name_to_free = resolve_refdup(\"HEAD\", 0, oid.hash, NULL);\n+\thead_name = head_name_to_free = resolve_refdup(\"HEAD\", 0, &oid, NULL);\n \n \tif (use_atomic)\n \t\texecute_commands_atomic(commands, si);\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 84547d6fba..0237be4975 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -705,8 +705,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\t\tstatic const char *fake_av[2];\n \n \t\t\tfake_av[0] = resolve_refdup(\"HEAD\",\n-\t\t\t\t\t\t    RESOLVE_REF_READING,\n-\t\t\t\t\t\t    oid.hash, NULL);\n+\t\t\t\t\t\t    RESOLVE_REF_READING, &oid,\n+\t\t\t\t\t\t    NULL);\n \t\t\tfake_av[1] = NULL;\n \t\t\tav = fake_av;\n \t\t\tac = 1;\n@@ -775,7 +775,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t}\n \n \thead = resolve_refdup(\"HEAD\", RESOLVE_REF_READING,\n-\t\t\t      head_oid.hash, NULL);\n+\t\t\t      &head_oid, NULL);\n \n \tif (with_current_branch && head) {\n \t\tint has_head = 0;\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 06ed02f994..5946a7ca93 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1144,7 +1144,7 @@ static int push_check(int argc, const char **argv, const char *prefix)\n \targv++;\n \targc--;\n \t/* Get the submodule's head ref and determine if it is detached */\n-\thead = resolve_refdup(\"HEAD\", 0, head_oid.hash, NULL);\n+\thead = resolve_refdup(\"HEAD\", 0, &head_oid, NULL);\n \tif (!head)\n \t\tdie(_(\"Failed to resolve HEAD as a valid ref.\"));\n \tif (!strcmp(head, \"HEAD\"))\ndiff --git a/ref-filter.c b/ref-filter.c\nindex bc591f4f3d..24f3ca1ea3 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -297,7 +297,7 @@ static void head_atom_parser(const struct ref_format *format, struct used_atom *\n {\n \tstruct object_id unused;\n \n-\tatom->u.head = resolve_refdup(\"HEAD\", RESOLVE_REF_READING, unused.hash, NULL);\n+\tatom->u.head = resolve_refdup(\"HEAD\", RESOLVE_REF_READING, &unused, NULL);\n }\n \n static struct {\n@@ -1319,7 +1319,7 @@ static void populate_value(struct ref_array_item *ref)\n \tif (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {\n \t\tstruct object_id unused1;\n \t\tref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING,\n-\t\t\t\t\t     unused1.hash, NULL);\n+\t\t\t\t\t     &unused1, NULL);\n \t\tif (!ref->symref)\n \t\t\tref->symref = \"\";\n \t}\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex 74ebe5148f..1a602a214d 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -65,7 +65,7 @@ static struct complete_reflogs *read_complete_reflog(const char *ref)\n \t\tconst char *name;\n \t\tvoid *name_to_free;\n \t\tname = name_to_free = resolve_refdup(ref, RESOLVE_REF_READING,\n-\t\t\t\t\t\t     oid.hash, NULL);\n+\t\t\t\t\t\t     &oid, NULL);\n \t\tif (name) {\n \t\t\tfor_each_reflog_ent(name, read_one_reflog, reflogs);\n \t\t\tfree(name_to_free);\n@@ -153,7 +153,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,\n \t\tif (*branch == '\\0') {\n \t\t\tstruct object_id oid;\n \t\t\tfree(branch);\n-\t\t\tbranch = resolve_refdup(\"HEAD\", 0, oid.hash, NULL);\n+\t\t\tbranch = resolve_refdup(\"HEAD\", 0, &oid, NULL);\n \t\t\tif (!branch)\n \t\t\t\tdie (\"No current branch\");\n \ndiff --git a/refs.c b/refs.c\nindex 90c2f9ccca..a86dbf9ec1 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -194,21 +194,21 @@ int ref_resolves_to_object(const char *refname,\n \n char *refs_resolve_refdup(struct ref_store *refs,\n \t\t\t  const char *refname, int resolve_flags,\n-\t\t\t  unsigned char *sha1, int *flags)\n+\t\t\t  struct object_id *oid, int *flags)\n {\n \tconst char *result;\n \n \tresult = refs_resolve_ref_unsafe(refs, refname, resolve_flags,\n-\t\t\t\t\t sha1, flags);\n+\t\t\t\t\t oid->hash, flags);\n \treturn xstrdup_or_null(result);\n }\n \n char *resolve_refdup(const char *refname, int resolve_flags,\n-\t\t     unsigned char *sha1, int *flags)\n+\t\t     struct object_id *oid, int *flags)\n {\n \treturn refs_resolve_refdup(get_main_ref_store(),\n \t\t\t\t   refname, resolve_flags,\n-\t\t\t\t   sha1, flags);\n+\t\t\t\t   oid, flags);\n }\n \n /* The argument to filter_refs */\ndiff --git a/refs.h b/refs.h\nindex 543dcc5956..9a573a4092 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -69,9 +69,9 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags,\n \n char *refs_resolve_refdup(struct ref_store *refs,\n \t\t\t  const char *refname, int resolve_flags,\n-\t\t\t  unsigned char *sha1, int *flags);\n+\t\t\t  struct object_id *oid, int *flags);\n char *resolve_refdup(const char *refname, int resolve_flags,\n-\t\t     unsigned char *sha1, int *flags);\n+\t\t     struct object_id *oid, int *flags);\n \n int refs_read_ref_full(struct ref_store *refs, const char *refname,\n \t\t       int resolve_flags, unsigned char *sha1, int *flags);\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 46dbcda6a6..1ab91fd346 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -2556,7 +2556,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,\n \t */\n \thead_ref = refs_resolve_refdup(ref_store, \"HEAD\",\n \t\t\t\t       RESOLVE_REF_NO_RECURSE,\n-\t\t\t\t       head_oid.hash, &head_type);\n+\t\t\t\t       &head_oid, &head_type);\n \n \tif (head_ref && !(head_type & REF_ISSYMREF)) {\n \t\tFREE_AND_NULL(head_ref);\ndiff --git a/submodule.c b/submodule.c\nindex f2f30bb488..c4af15c148 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -1016,7 +1016,7 @@ int push_unpushed_submodules(struct oid_array *commits,\n \t\tchar *head;\n \t\tstruct object_id head_oid;\n \n-\t\thead = resolve_refdup(\"HEAD\", 0, head_oid.hash, NULL);\n+\t\thead = resolve_refdup(\"HEAD\", 0, &head_oid, NULL);\n \t\tif (!head)\n \t\t\tdie(_(\"Failed to resolve HEAD as a valid ref.\"));\n \ndiff --git a/transport.c b/transport.c\nindex 09bd06e6e5..093d334e96 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -475,7 +475,7 @@ void transport_print_push_status(const char *dest, struct ref *refs,\n \tchar *head;\n \tint summary_width = transport_summary_width(refs);\n \n-\thead = resolve_refdup(\"HEAD\", RESOLVE_REF_READING, head_oid.hash, NULL);\n+\thead = resolve_refdup(\"HEAD\", RESOLVE_REF_READING, &head_oid, NULL);\n \n \tif (verbose) {\n \t\tfor (ref = refs; ref; ref = ref->next)\ndiff --git a/wt-status.c b/wt-status.c\nindex 6f730ee8f2..6d7d675a5b 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -129,7 +129,7 @@ void wt_status_prepare(struct wt_status *s)\n \ts->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n \ts->use_color = -1;\n \ts->relative_paths = 1;\n-\ts->branch = resolve_refdup(\"HEAD\", 0, oid.hash, NULL);\n+\ts->branch = resolve_refdup(\"HEAD\", 0, &oid, NULL);\n \ts->reference = \"HEAD\";\n \ts->fp = stdout;\n \ts->index_file = get_index_file();\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329327","messageId":"20171001220831.214705-4-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 03/24] refs: convert delete_ref and refs_delete_ref to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:10Z","receivedAt":"2017-10-01T22:09:03Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert delete_ref and refs_delete_ref to take a pointer to struct\nobject_id.  Update the documentation accordingly, including referring to\nnull_oid in lowercase, as it is not a #define constant.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/branch.c          |  2 +-\n builtin/replace.c         |  2 +-\n builtin/reset.c           |  2 +-\n builtin/tag.c             |  2 +-\n builtin/update-ref.c      |  2 +-\n refs.c                    | 21 +++++++++++----------\n refs.h                    | 12 ++++++------\n refs/files-backend.c      |  2 +-\n t/helper/test-ref-store.c |  6 +++---\n 9 files changed, 26 insertions(+), 25 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 355f9ef5da..6031b74d68 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -256,7 +256,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,\n \t\t\tgoto next;\n \t\t}\n \n-\t\tif (delete_ref(NULL, name, is_null_oid(&oid) ? NULL : oid.hash,\n+\t\tif (delete_ref(NULL, name, is_null_oid(&oid) ? NULL : &oid,\n \t\t\t       REF_NODEREF)) {\n \t\t\terror(remote_branch\n \t\t\t      ? _(\"Error deleting remote-tracking branch '%s'\")\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 3e71a77152..2854eaa0f3 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -128,7 +128,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn)\n static int delete_replace_ref(const char *name, const char *ref,\n \t\t\t      const struct object_id *oid)\n {\n-\tif (delete_ref(NULL, ref, oid->hash, 0))\n+\tif (delete_ref(NULL, ref, oid, 0))\n \t\treturn 1;\n \tprintf(\"Deleted replace ref '%s'\\n\", name);\n \treturn 0;\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 9cd89b2305..5f3632e05b 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -269,7 +269,7 @@ static int reset_refs(const char *rev, const struct object_id *oid)\n \t\tupdate_ref_oid(msg.buf, \"ORIG_HEAD\", orig, old_orig, 0,\n \t\t\t   UPDATE_REFS_MSG_ON_ERR);\n \t} else if (old_orig)\n-\t\tdelete_ref(NULL, \"ORIG_HEAD\", old_orig->hash, 0);\n+\t\tdelete_ref(NULL, \"ORIG_HEAD\", old_orig, 0);\n \tset_reflog_message(&msg, \"updating HEAD\", rev);\n \tupdate_ref_status = update_ref_oid(msg.buf, \"HEAD\", oid, orig, 0,\n \t\t\t\t       UPDATE_REFS_MSG_ON_ERR);\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex c627794181..46ff4ca736 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -97,7 +97,7 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn,\n static int delete_tag(const char *name, const char *ref,\n \t\t      const struct object_id *oid, const void *cb_data)\n {\n-\tif (delete_ref(NULL, ref, oid->hash, 0))\n+\tif (delete_ref(NULL, ref, oid, 0))\n \t\treturn 1;\n \tprintf(_(\"Deleted tag '%s' (was %s)\\n\"), name, find_unique_abbrev(oid->hash, DEFAULT_ABBREV));\n \treturn 0;\ndiff --git a/builtin/update-ref.c b/builtin/update-ref.c\nindex 6b90c5dead..bf0f80ebae 100644\n--- a/builtin/update-ref.c\n+++ b/builtin/update-ref.c\n@@ -434,7 +434,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)\n \t\t * NULL_SHA1 as \"don't care\" here:\n \t\t */\n \t\treturn delete_ref(msg, refname,\n-\t\t\t\t  (oldval && !is_null_oid(&oldoid)) ? oldoid.hash : NULL,\n+\t\t\t\t  (oldval && !is_null_oid(&oldoid)) ? &oldoid : NULL,\n \t\t\t\t  flags);\n \telse\n \t\treturn update_ref(msg, refname, oid.hash, oldval ? oldoid.hash : NULL,\ndiff --git a/refs.c b/refs.c\nindex 6042645c40..0a5b68d6fb 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -620,25 +620,25 @@ static int write_pseudoref(const char *pseudoref, const unsigned char *sha1,\n \treturn ret;\n }\n \n-static int delete_pseudoref(const char *pseudoref, const unsigned char *old_sha1)\n+static int delete_pseudoref(const char *pseudoref, const struct object_id *old_oid)\n {\n \tstatic struct lock_file lock;\n \tconst char *filename;\n \n \tfilename = git_path(\"%s\", pseudoref);\n \n-\tif (old_sha1 && !is_null_sha1(old_sha1)) {\n+\tif (old_oid && !is_null_oid(old_oid)) {\n \t\tint fd;\n-\t\tunsigned char actual_old_sha1[20];\n+\t\tstruct object_id actual_old_oid;\n \n \t\tfd = hold_lock_file_for_update_timeout(\n \t\t\t\t&lock, filename, LOCK_DIE_ON_ERROR,\n \t\t\t\tget_files_ref_lock_timeout_ms());\n \t\tif (fd < 0)\n \t\t\tdie_errno(_(\"Could not open '%s' for writing\"), filename);\n-\t\tif (read_ref(pseudoref, actual_old_sha1))\n+\t\tif (read_ref(pseudoref, actual_old_oid.hash))\n \t\t\tdie(\"could not read ref '%s'\", pseudoref);\n-\t\tif (hashcmp(actual_old_sha1, old_sha1)) {\n+\t\tif (oidcmp(&actual_old_oid, old_oid)) {\n \t\t\twarning(\"Unexpected sha1 when deleting %s\", pseudoref);\n \t\t\trollback_lock_file(&lock);\n \t\t\treturn -1;\n@@ -655,7 +655,7 @@ static int delete_pseudoref(const char *pseudoref, const unsigned char *old_sha1\n \n int refs_delete_ref(struct ref_store *refs, const char *msg,\n \t\t    const char *refname,\n-\t\t    const unsigned char *old_sha1,\n+\t\t    const struct object_id *old_oid,\n \t\t    unsigned int flags)\n {\n \tstruct ref_transaction *transaction;\n@@ -663,12 +663,13 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,\n \n \tif (ref_type(refname) == REF_TYPE_PSEUDOREF) {\n \t\tassert(refs == get_main_ref_store());\n-\t\treturn delete_pseudoref(refname, old_sha1);\n+\t\treturn delete_pseudoref(refname, old_oid);\n \t}\n \n \ttransaction = ref_store_transaction_begin(refs, &err);\n \tif (!transaction ||\n-\t    ref_transaction_delete(transaction, refname, old_sha1,\n+\t    ref_transaction_delete(transaction, refname,\n+\t\t\t\t   old_oid ? old_oid->hash : NULL,\n \t\t\t\t   flags, msg, &err) ||\n \t    ref_transaction_commit(transaction, &err)) {\n \t\terror(\"%s\", err.buf);\n@@ -682,10 +683,10 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,\n }\n \n int delete_ref(const char *msg, const char *refname,\n-\t       const unsigned char *old_sha1, unsigned int flags)\n+\t       const struct object_id *old_oid, unsigned int flags)\n {\n \treturn refs_delete_ref(get_main_ref_store(), msg, refname,\n-\t\t\t       old_sha1, flags);\n+\t\t\t       old_oid, flags);\n }\n \n int copy_reflog_msg(char *buf, const char *msg)\ndiff --git a/refs.h b/refs.h\nindex e1c5803f9a..07e9907b31 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -371,19 +371,19 @@ int refs_reflog_exists(struct ref_store *refs, const char *refname);\n int reflog_exists(const char *refname);\n \n /*\n- * Delete the specified reference. If old_sha1 is non-NULL, then\n+ * Delete the specified reference. If old_oid is non-NULL, then\n  * verify that the current value of the reference is old_sha1 before\n- * deleting it. If old_sha1 is NULL, delete the reference if it\n- * exists, regardless of its old value. It is an error for old_sha1 to\n- * be NULL_SHA1. msg and flags are passed through to\n+ * deleting it. If old_oid is NULL, delete the reference if it\n+ * exists, regardless of its old value. It is an error for old_oid to\n+ * be null_oid. msg and flags are passed through to\n  * ref_transaction_delete().\n  */\n int refs_delete_ref(struct ref_store *refs, const char *msg,\n \t\t    const char *refname,\n-\t\t    const unsigned char *old_sha1,\n+\t\t    const struct object_id *old_oid,\n \t\t    unsigned int flags);\n int delete_ref(const char *msg, const char *refname,\n-\t       const unsigned char *old_sha1, unsigned int flags);\n+\t       const struct object_id *old_oid, unsigned int flags);\n \n /*\n  * Delete the specified references. If there are any problems, emit\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex e3968d4f7c..0c641f0ad0 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -1308,7 +1308,7 @@ 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_oid.hash, REF_NODEREF)) {\n+\t\t\t    &orig_oid, REF_NODEREF)) {\n \t\terror(\"unable to delete old %s\", oldrefname);\n \t\tgoto rollback;\n \t}\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 05d8c4d8af..4624238641 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -218,12 +218,12 @@ static int cmd_delete_ref(struct ref_store *refs, const char **argv)\n \tconst char *refname = notnull(*argv++, \"refname\");\n \tconst char *sha1_buf = notnull(*argv++, \"old-sha1\");\n \tunsigned int flags = arg_flags(*argv++, \"flags\");\n-\tunsigned char old_sha1[20];\n+\tstruct object_id old_oid;\n \n-\tif (get_sha1_hex(sha1_buf, old_sha1))\n+\tif (get_oid_hex(sha1_buf, &old_oid))\n \t\tdie(\"not sha-1\");\n \n-\treturn refs_delete_ref(refs, msg, refname, old_sha1, flags);\n+\treturn refs_delete_ref(refs, msg, refname, &old_oid, flags);\n }\n \n static int cmd_update_ref(struct ref_store *refs, const char **argv)\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329328","messageId":"20171001220831.214705-9-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 08/24] refs: convert read_ref and read_ref_full to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:15Z","receivedAt":"2017-10-01T22:09:06Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"All but two of the call sites already had parameters using the hash\nparameter of struct object_id, so convert them to take a pointer to the\nstruct directly.  Also convert refs_read_refs_full, the underlying\nimplementation.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/checkout.c     |  6 +++---\n builtin/remote.c       |  2 +-\n builtin/replace.c      |  4 ++--\n builtin/show-ref.c     |  2 +-\n builtin/tag.c          |  4 ++--\n builtin/update-index.c |  6 +++---\n bundle.c               |  2 +-\n fast-import.c          |  2 +-\n notes-cache.c          |  2 +-\n notes-merge.c          |  2 +-\n notes-utils.c          |  2 +-\n notes.c                |  2 +-\n refs.c                 | 20 ++++++++++----------\n refs.h                 |  6 +++---\n refs/files-backend.c   | 16 ++++++++--------\n remote-testsvn.c       |  2 +-\n remote.c               |  6 +++---\n sequencer.c            |  2 +-\n transport-helper.c     |  5 ++---\n 19 files changed, 46 insertions(+), 47 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex b803425bc4..20d2bca007 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -379,7 +379,7 @@ static int checkout_paths(const struct checkout_opts *opts,\n \tif (write_locked_index(&the_index, lock_file, COMMIT_LOCK))\n \t\tdie(_(\"unable to write new index file\"));\n \n-\tread_ref_full(\"HEAD\", 0, rev.hash, NULL);\n+\tread_ref_full(\"HEAD\", 0, &rev, NULL);\n \thead = lookup_commit_reference_gently(&rev, 1);\n \n \terrs |= post_checkout_hook(head, head, 0);\n@@ -1037,7 +1037,7 @@ static int parse_branchname_arg(int argc, const char **argv,\n \tsetup_branch_path(new);\n \n \tif (!check_refname_format(new->path, 0) &&\n-\t    !read_ref(new->path, branch_rev.hash))\n+\t    !read_ref(new->path, &branch_rev))\n \t\toidcpy(rev, &branch_rev);\n \telse\n \t\tnew->path = NULL; /* not an existing branch */\n@@ -1136,7 +1136,7 @@ static int checkout_branch(struct checkout_opts *opts,\n \t\tstruct object_id rev;\n \t\tint flag;\n \n-\t\tif (!read_ref_full(\"HEAD\", 0, rev.hash, &flag) &&\n+\t\tif (!read_ref_full(\"HEAD\", 0, &rev, &flag) &&\n \t\t    (flag & REF_ISSYMREF) && is_null_oid(&rev))\n \t\t\treturn switch_unborn_to_new_branch(opts);\n \t}\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 4f5cac96b0..0fddc64461 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -690,7 +690,7 @@ static int mv(int argc, const char **argv)\n \t\tint flag = 0;\n \t\tstruct object_id oid;\n \n-\t\tread_ref_full(item->string, RESOLVE_REF_READING, oid.hash, &flag);\n+\t\tread_ref_full(item->string, RESOLVE_REF_READING, &oid, &flag);\n \t\tif (!(flag & REF_ISSYMREF))\n \t\t\tcontinue;\n \t\tif (delete_ref(NULL, item->string, NULL, REF_NODEREF))\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 3099e55307..10078ae371 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -113,7 +113,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn)\n \t\tstrbuf_addstr(&ref, oid_to_hex(&oid));\n \t\tfull_hex = ref.buf + base_len;\n \n-\t\tif (read_ref(ref.buf, oid.hash)) {\n+\t\tif (read_ref(ref.buf, &oid)) {\n \t\t\terror(\"replace ref '%s' not found.\", full_hex);\n \t\t\thad_error = 1;\n \t\t\tcontinue;\n@@ -144,7 +144,7 @@ static void check_ref_valid(struct object_id *object,\n \tif (check_refname_format(ref->buf, 0))\n \t\tdie(\"'%s' is not a valid ref name.\", ref->buf);\n \n-\tif (read_ref(ref->buf, prev->hash))\n+\tif (read_ref(ref->buf, prev))\n \t\toidclr(prev);\n \telse if (!force)\n \t\tdie(\"replace ref '%s' already exists\", ref->buf);\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 013d241abc..cbb8cfc7d2 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -197,7 +197,7 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)\n \t\t\tstruct object_id oid;\n \n \t\t\tif ((starts_with(*pattern, \"refs/\") || !strcmp(*pattern, \"HEAD\")) &&\n-\t\t\t    !read_ref(*pattern, oid.hash)) {\n+\t\t\t    !read_ref(*pattern, &oid)) {\n \t\t\t\tshow_one(*pattern, &oid);\n \t\t\t}\n \t\t\telse if (!quiet)\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 2ededc3fb1..c36d2f115c 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -82,7 +82,7 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn,\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, oid.hash)) {\n+\t\tif (read_ref(ref.buf, &oid)) {\n \t\t\terror(_(\"tag '%s' not found.\"), *p);\n \t\t\thad_error = 1;\n \t\t\tcontinue;\n@@ -517,7 +517,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\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.hash))\n+\tif (read_ref(ref.buf, &prev))\n \t\toidclr(&prev);\n \telse if (!force)\n \t\tdie(_(\"tag '%s' already exists\"), tag);\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex bf7420b808..24f4b28951 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -679,9 +679,9 @@ static int unresolve_one(const char *path)\n \n static void read_head_pointers(void)\n {\n-\tif (read_ref(\"HEAD\", head_oid.hash))\n+\tif (read_ref(\"HEAD\", &head_oid))\n \t\tdie(\"No HEAD -- no initial commit yet?\");\n-\tif (read_ref(\"MERGE_HEAD\", merge_head_oid.hash)) {\n+\tif (read_ref(\"MERGE_HEAD\", &merge_head_oid)) {\n \t\tfprintf(stderr, \"Not in the middle of a merge.\\n\");\n \t\texit(0);\n \t}\n@@ -721,7 +721,7 @@ static int do_reupdate(int ac, const char **av,\n \t\t       PATHSPEC_PREFER_CWD,\n \t\t       prefix, av + 1);\n \n-\tif (read_ref(\"HEAD\", head_oid.hash))\n+\tif (read_ref(\"HEAD\", &head_oid))\n \t\t/* If there is no HEAD, that means it is an initial\n \t\t * commit.  Update everything in the index.\n \t\t */\ndiff --git a/bundle.c b/bundle.c\nindex c092d5d68f..12658c5c9f 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -340,7 +340,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)\n \t\t\tcontinue;\n \t\tif (dwim_ref(e->name, strlen(e->name), oid.hash, &ref) != 1)\n \t\t\tgoto skip_write_ref;\n-\t\tif (read_ref_full(e->name, RESOLVE_REF_READING, oid.hash, &flag))\n+\t\tif (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flag))\n \t\t\tflag = 0;\n \t\tdisplay_ref = (flag & REF_ISSYMREF) ? e->name : ref;\n \ndiff --git a/fast-import.c b/fast-import.c\nindex 2d2d0d98f0..479e300aa3 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1758,7 +1758,7 @@ 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_oid.hash))\n+\tif (read_ref(b->name, &old_oid))\n \t\toidclr(&old_oid);\n \tif (!force_update && !is_null_oid(&old_oid)) {\n \t\tstruct commit *old_cmit, *new_cmit;\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 927b6645db..4e3c94631b 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -11,7 +11,7 @@ static int notes_cache_match_validity(const char *ref, const char *validity)\n \tstruct strbuf msg = STRBUF_INIT;\n \tint ret;\n \n-\tif (read_ref(ref, oid.hash) < 0)\n+\tif (read_ref(ref, &oid) < 0)\n \t\treturn 0;\n \n \tcommit = lookup_commit_reference_gently(&oid, 1);\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 597d43f65c..edc6acdd92 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -549,7 +549,7 @@ 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_oid.hash, NULL))\n+\tif (read_ref_full(o->local_ref, 0, &local_oid, 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_oid(&local_oid))\ndiff --git a/notes-utils.c b/notes-utils.c\nindex 3a7008948c..5c8e70c98f 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 \tif (!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\tif (!read_ref(t->ref, &parent_oid)) {\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);\ndiff --git a/notes.c b/notes.c\nindex 5c62862574..d273822b28 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -1027,7 +1027,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,\n \tif (flags & NOTES_INIT_EMPTY || !notes_ref ||\n \t    get_oid_treeish(notes_ref, &object_oid))\n \t\treturn;\n-\tif (flags & NOTES_INIT_WRITABLE && read_ref(notes_ref, object_oid.hash))\n+\tif (flags & NOTES_INIT_WRITABLE && read_ref(notes_ref, &object_oid))\n \t\tdie(\"Cannot use notes ref %s\", notes_ref);\n \tif (get_tree_entry(object_oid.hash, \"\", oid.hash, &mode))\n \t\tdie(\"Failed to read notes tree referenced by %s (%s)\",\ndiff --git a/refs.c b/refs.c\nindex a86dbf9ec1..d6f8587b57 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -219,22 +219,22 @@ struct ref_filter {\n };\n \n int refs_read_ref_full(struct ref_store *refs, const char *refname,\n-\t\t       int resolve_flags, unsigned char *sha1, int *flags)\n+\t\t       int resolve_flags, struct object_id *oid, int *flags)\n {\n-\tif (refs_resolve_ref_unsafe(refs, refname, resolve_flags, sha1, flags))\n+\tif (refs_resolve_ref_unsafe(refs, refname, resolve_flags, oid->hash, flags))\n \t\treturn 0;\n \treturn -1;\n }\n \n-int read_ref_full(const char *refname, int resolve_flags, unsigned char *sha1, int *flags)\n+int read_ref_full(const char *refname, int resolve_flags, struct object_id *oid, int *flags)\n {\n \treturn refs_read_ref_full(get_main_ref_store(), refname,\n-\t\t\t\t  resolve_flags, sha1, flags);\n+\t\t\t\t  resolve_flags, oid, flags);\n }\n \n-int read_ref(const char *refname, unsigned char *sha1)\n+int read_ref(const char *refname, struct object_id *oid)\n {\n-\treturn read_ref_full(refname, RESOLVE_REF_READING, sha1, NULL);\n+\treturn read_ref_full(refname, RESOLVE_REF_READING, oid, NULL);\n }\n \n int ref_exists(const char *refname)\n@@ -362,7 +362,7 @@ int head_ref_namespaced(each_ref_fn fn, void *cb_data)\n \tint flag;\n \n \tstrbuf_addf(&buf, \"%sHEAD\", get_git_namespace());\n-\tif (!read_ref_full(buf.buf, RESOLVE_REF_READING, oid.hash, &flag))\n+\tif (!read_ref_full(buf.buf, RESOLVE_REF_READING, &oid, &flag))\n \t\tret = fn(buf.buf, &oid, flag, cb_data);\n \tstrbuf_release(&buf);\n \n@@ -598,7 +598,7 @@ static int write_pseudoref(const char *pseudoref, const struct object_id *oid,\n \tif (old_oid) {\n \t\tstruct object_id actual_old_oid;\n \n-\t\tif (read_ref(pseudoref, actual_old_oid.hash))\n+\t\tif (read_ref(pseudoref, &actual_old_oid))\n \t\t\tdie(\"could not read ref '%s'\", pseudoref);\n \t\tif (oidcmp(&actual_old_oid, old_oid)) {\n \t\t\tstrbuf_addf(err, \"unexpected sha1 when writing '%s'\", pseudoref);\n@@ -636,7 +636,7 @@ static int delete_pseudoref(const char *pseudoref, const struct object_id *old_o\n \t\t\t\tget_files_ref_lock_timeout_ms());\n \t\tif (fd < 0)\n \t\t\tdie_errno(_(\"Could not open '%s' for writing\"), filename);\n-\t\tif (read_ref(pseudoref, actual_old_oid.hash))\n+\t\tif (read_ref(pseudoref, &actual_old_oid))\n \t\t\tdie(\"could not read ref '%s'\", pseudoref);\n \t\tif (oidcmp(&actual_old_oid, old_oid)) {\n \t\t\twarning(\"Unexpected sha1 when deleting %s\", pseudoref);\n@@ -1246,7 +1246,7 @@ int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)\n \tint flag;\n \n \tif (!refs_read_ref_full(refs, \"HEAD\", RESOLVE_REF_READING,\n-\t\t\t\toid.hash, &flag))\n+\t\t\t\t&oid, &flag))\n \t\treturn fn(\"HEAD\", &oid, flag, cb_data);\n \n \treturn 0;\ndiff --git a/refs.h b/refs.h\nindex 9a573a4092..a2032b8397 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -74,10 +74,10 @@ char *resolve_refdup(const char *refname, int resolve_flags,\n \t\t     struct object_id *oid, int *flags);\n \n int refs_read_ref_full(struct ref_store *refs, const char *refname,\n-\t\t       int resolve_flags, unsigned char *sha1, int *flags);\n+\t\t       int resolve_flags, struct object_id *oid, int *flags);\n int read_ref_full(const char *refname, int resolve_flags,\n-\t\t  unsigned char *sha1, int *flags);\n-int read_ref(const char *refname, unsigned char *sha1);\n+\t\t  struct object_id *oid, int *flags);\n+int read_ref(const char *refname, struct object_id *oid);\n \n /*\n  * Return 0 if a reference named refname could be created without\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 1ab91fd346..148b98490f 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -648,7 +648,7 @@ static int files_peel_ref(struct ref_store *ref_store,\n \t\tfiles_downcast(ref_store, REF_STORE_READ | REF_STORE_ODB,\n \t\t\t       \"peel_ref\");\n \tint flag;\n-\tunsigned char base[20];\n+\tstruct object_id base;\n \n \tif (current_ref_iter && current_ref_iter->refname == refname) {\n \t\tstruct object_id peeled;\n@@ -660,7 +660,7 @@ static int files_peel_ref(struct ref_store *ref_store,\n \t}\n \n \tif (refs_read_ref_full(ref_store, refname,\n-\t\t\t       RESOLVE_REF_READING, base, &flag))\n+\t\t\t       RESOLVE_REF_READING, &base, &flag))\n \t\treturn -1;\n \n \t/*\n@@ -675,7 +675,7 @@ static int files_peel_ref(struct ref_store *ref_store,\n \t    !refs_peel_ref(refs->packed_ref_store, refname, sha1))\n \t\treturn 0;\n \n-\treturn peel_object(base, sha1);\n+\treturn peel_object(base.hash, sha1);\n }\n \n struct files_ref_iterator {\n@@ -817,7 +817,7 @@ static int verify_lock(struct ref_store *ref_store, struct ref_lock *lock,\n \n \tif (refs_read_ref_full(ref_store, lock->ref_name,\n \t\t\t       mustexist ? RESOLVE_REF_READING : 0,\n-\t\t\t       lock->old_oid.hash, NULL)) {\n+\t\t\t       &lock->old_oid, NULL)) {\n \t\tif (old_sha1) {\n \t\t\tint save_errno = errno;\n \t\t\tstrbuf_addf(err, \"can't verify ref '%s'\", lock->ref_name);\n@@ -1322,7 +1322,7 @@ static int files_rename_ref(struct ref_store *ref_store,\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\toid.hash, NULL) &&\n+\t\t\t\t&oid, NULL) &&\n \t    refs_delete_ref(&refs->base, NULL, newrefname,\n \t\t\t    NULL, REF_NODEREF)) {\n \t\tif (errno == EISDIR) {\n@@ -1727,7 +1727,7 @@ static void update_symref_reflog(struct files_ref_store *refs,\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_oid.hash, NULL) &&\n+\t\t\t\tRESOLVE_REF_READING, &new_oid, 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@@ -2016,7 +2016,7 @@ static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator)\n \n \t\tif (refs_read_ref_full(iter->ref_store,\n \t\t\t\t       diter->relative_path, 0,\n-\t\t\t\t       iter->oid.hash, &flags)) {\n+\t\t\t\t       &iter->oid, &flags)) {\n \t\t\terror(\"bad ref for %s\", diter->path.buf);\n \t\t\tcontinue;\n \t\t}\n@@ -2352,7 +2352,7 @@ static int lock_ref_for_update(struct files_ref_store *refs,\n \t\t\t */\n \t\t\tif (refs_read_ref_full(&refs->base,\n \t\t\t\t\t       referent.buf, 0,\n-\t\t\t\t\t       lock->old_oid.hash, NULL)) {\n+\t\t\t\t\t       &lock->old_oid, NULL)) {\n \t\t\t\tif (update->flags & REF_HAVE_OLD) {\n \t\t\t\t\tstrbuf_addf(err, \"cannot lock ref '%s': \"\n \t\t\t\t\t\t    \"error reading reference\",\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex 0ff4a31262..bcebb4c789 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -174,7 +174,7 @@ static int cmd_import(const char *line)\n \tstruct child_process svndump_proc = CHILD_PROCESS_INIT;\n \tconst char *command = \"svnrdump\";\n \n-\tif (read_ref(private_ref, head_oid.hash))\n+\tif (read_ref(private_ref, &head_oid))\n \t\tstartrev = 0;\n \telse {\n \t\tnote_msg = read_ref_note(&head_oid);\ndiff --git a/remote.c b/remote.c\nindex b220f0dfc6..698a890a83 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -2002,13 +2002,13 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,\n \t\treturn -1;\n \n \t/* Cannot stat if what we used to build on no longer exists */\n-\tif (read_ref(base, oid.hash))\n+\tif (read_ref(base, &oid))\n \t\treturn -1;\n \ttheirs = lookup_commit_reference(&oid);\n \tif (!theirs)\n \t\treturn -1;\n \n-\tif (read_ref(branch->refname, oid.hash))\n+\tif (read_ref(branch->refname, &oid))\n \t\treturn -1;\n \tours = lookup_commit_reference(&oid);\n \tif (!ours)\n@@ -2327,7 +2327,7 @@ static int remote_tracking(struct remote *remote, const char *refname,\n \tdst = apply_refspecs(remote->fetch, remote->fetch_refspec_nr, refname);\n \tif (!dst)\n \t\treturn -1; /* no tracking ref for refname at remote */\n-\tif (read_ref(dst, oid->hash))\n+\tif (read_ref(dst, oid))\n \t\treturn -1; /* we know what the tracking ref is but we cannot read it */\n \treturn 0;\n }\ndiff --git a/sequencer.c b/sequencer.c\nindex 43a6f14eb3..f1f895774a 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1627,7 +1627,7 @@ static int rollback_single_pick(void)\n \tif (!file_exists(git_path_cherry_pick_head()) &&\n \t    !file_exists(git_path_revert_head()))\n \t\treturn error(_(\"no cherry-pick or revert in progress\"));\n-\tif (read_ref_full(\"HEAD\", 0, head_oid.hash, NULL))\n+\tif (read_ref_full(\"HEAD\", 0, &head_oid, NULL))\n \t\treturn error(_(\"cannot resolve HEAD\"));\n \tif (is_null_oid(&head_oid))\n \t\treturn error(_(\"cannot abort from a branch yet to be born\"));\ndiff --git a/transport-helper.c b/transport-helper.c\nindex f183601261..640ce5a492 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -535,7 +535,7 @@ static int fetch_with_import(struct transport *transport,\n \t\telse\n \t\t\tprivate = xstrdup(name);\n \t\tif (private) {\n-\t\t\tif (read_ref(private, posn->old_oid.hash) < 0)\n+\t\t\tif (read_ref(private, &posn->old_oid) < 0)\n \t\t\t\tdie(\"Could not read ref %s\", private);\n \t\t\tfree(private);\n \t\t}\n@@ -1067,8 +1067,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)\n \t\tif (eon) {\n \t\t\tif (has_attribute(eon + 1, \"unchanged\")) {\n \t\t\t\t(*tail)->status |= REF_STATUS_UPTODATE;\n-\t\t\t\tif (read_ref((*tail)->name,\n-\t\t\t\t\t     (*tail)->old_oid.hash) < 0)\n+\t\t\t\tif (read_ref((*tail)->name, &(*tail)->old_oid) < 0)\n \t\t\t\t\tdie(_(\"Could not read ref %s\"),\n \t\t\t\t\t    (*tail)->name);\n \t\t\t}\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329329","messageId":"20171001220831.214705-7-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 06/24] Convert check_connected to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:13Z","receivedAt":"2017-10-01T22:09:10Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert check_connected and the callbacks it takes to use struct\nobject_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/clone.c        |  4 ++--\n builtin/fetch.c        |  4 ++--\n builtin/receive-pack.c | 10 +++++-----\n connected.c            | 18 +++++++++---------\n connected.h            |  4 ++--\n 5 files changed, 20 insertions(+), 20 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 665a0e2673..5cd1b02d53 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -615,7 +615,7 @@ static void write_followtags(const struct ref *refs, const char *msg)\n \t}\n }\n \n-static int iterate_ref_map(void *cb_data, unsigned char sha1[20])\n+static int iterate_ref_map(void *cb_data, struct object_id *oid)\n {\n \tstruct ref **rm = cb_data;\n \tstruct ref *ref = *rm;\n@@ -630,7 +630,7 @@ static int iterate_ref_map(void *cb_data, unsigned char sha1[20])\n \tif (!ref)\n \t\treturn -1;\n \n-\thashcpy(sha1, ref->old_oid.hash);\n+\toidcpy(oid, &ref->old_oid);\n \t*rm = ref->next;\n \treturn 0;\n }\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 859be91d6c..e705237fa9 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -727,7 +727,7 @@ static int update_local_ref(struct ref *ref,\n \t}\n }\n \n-static int iterate_ref_map(void *cb_data, unsigned char sha1[20])\n+static int iterate_ref_map(void *cb_data, struct object_id *oid)\n {\n \tstruct ref **rm = cb_data;\n \tstruct ref *ref = *rm;\n@@ -737,7 +737,7 @@ static int iterate_ref_map(void *cb_data, unsigned char sha1[20])\n \tif (!ref)\n \t\treturn -1; /* end of the list */\n \t*rm = ref->next;\n-\thashcpy(sha1, ref->old_oid.hash);\n+\toidcpy(oid, &ref->old_oid);\n \treturn 0;\n }\n \ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 39defd4e3c..046b600b11 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -870,7 +870,7 @@ static void refuse_unconfigured_deny_delete_current(void)\n \trp_error(\"%s\", _(refuse_unconfigured_deny_delete_current_msg));\n }\n \n-static int command_singleton_iterator(void *cb_data, unsigned char sha1[20]);\n+static int command_singleton_iterator(void *cb_data, struct object_id *oid);\n static int update_shallow_ref(struct command *cmd, struct shallow_info *si)\n {\n \tstatic struct lock_file shallow_lock;\n@@ -1270,7 +1270,7 @@ static void check_aliased_updates(struct command *commands)\n \tstring_list_clear(&ref_list, 0);\n }\n \n-static int command_singleton_iterator(void *cb_data, unsigned char sha1[20])\n+static int command_singleton_iterator(void *cb_data, struct object_id *oid)\n {\n \tstruct command **cmd_list = cb_data;\n \tstruct command *cmd = *cmd_list;\n@@ -1278,7 +1278,7 @@ static int command_singleton_iterator(void *cb_data, unsigned char sha1[20])\n \tif (!cmd || is_null_oid(&cmd->new_oid))\n \t\treturn -1; /* end of list */\n \t*cmd_list = NULL; /* this returns only one */\n-\thashcpy(sha1, cmd->new_oid.hash);\n+\toidcpy(oid, &cmd->new_oid);\n \treturn 0;\n }\n \n@@ -1309,7 +1309,7 @@ struct iterate_data {\n \tstruct shallow_info *si;\n };\n \n-static int iterate_receive_command_list(void *cb_data, unsigned char sha1[20])\n+static int iterate_receive_command_list(void *cb_data, struct object_id *oid)\n {\n \tstruct iterate_data *data = cb_data;\n \tstruct command **cmd_list = &data->cmds;\n@@ -1320,7 +1320,7 @@ static int iterate_receive_command_list(void *cb_data, unsigned char sha1[20])\n \t\t\t/* to be checked in update_shallow_ref() */\n \t\t\tcontinue;\n \t\tif (!is_null_oid(&cmd->new_oid) && !cmd->skip_update) {\n-\t\t\thashcpy(sha1, cmd->new_oid.hash);\n+\t\t\toidcpy(oid, &cmd->new_oid);\n \t\t\t*cmd_list = cmd->next;\n \t\t\treturn 0;\n \t\t}\ndiff --git a/connected.c b/connected.c\nindex f416b05051..4a47f33270 100644\n--- a/connected.c\n+++ b/connected.c\n@@ -16,13 +16,13 @@\n  *\n  * Returns 0 if everything is connected, non-zero otherwise.\n  */\n-int check_connected(sha1_iterate_fn fn, void *cb_data,\n+int check_connected(oid_iterate_fn fn, void *cb_data,\n \t\t    struct check_connected_options *opt)\n {\n \tstruct child_process rev_list = CHILD_PROCESS_INIT;\n \tstruct check_connected_options defaults = CHECK_CONNECTED_INIT;\n-\tchar commit[41];\n-\tunsigned char sha1[20];\n+\tchar commit[GIT_MAX_HEXSZ + 1];\n+\tstruct object_id oid;\n \tint err = 0;\n \tstruct packed_git *new_pack = NULL;\n \tstruct transport *transport;\n@@ -32,7 +32,7 @@ int check_connected(sha1_iterate_fn fn, void *cb_data,\n \t\topt = &defaults;\n \ttransport = opt->transport;\n \n-\tif (fn(cb_data, sha1)) {\n+\tif (fn(cb_data, &oid)) {\n \t\tif (opt->err_fd)\n \t\t\tclose(opt->err_fd);\n \t\treturn err;\n@@ -77,7 +77,7 @@ int check_connected(sha1_iterate_fn fn, void *cb_data,\n \n \tsigchain_push(SIGPIPE, SIG_IGN);\n \n-\tcommit[40] = '\\n';\n+\tcommit[GIT_SHA1_HEXSZ] = '\\n';\n \tdo {\n \t\t/*\n \t\t * If index-pack already checked that:\n@@ -87,17 +87,17 @@ int check_connected(sha1_iterate_fn fn, void *cb_data,\n \t\t * are sure the ref is good and not sending it to\n \t\t * rev-list for verification.\n \t\t */\n-\t\tif (new_pack && find_pack_entry_one(sha1, new_pack))\n+\t\tif (new_pack && find_pack_entry_one(oid.hash, new_pack))\n \t\t\tcontinue;\n \n-\t\tmemcpy(commit, sha1_to_hex(sha1), 40);\n-\t\tif (write_in_full(rev_list.in, commit, 41) < 0) {\n+\t\tmemcpy(commit, oid_to_hex(&oid), GIT_SHA1_HEXSZ);\n+\t\tif (write_in_full(rev_list.in, commit, GIT_SHA1_HEXSZ + 1) < 0) {\n \t\t\tif (errno != EPIPE && errno != EINVAL)\n \t\t\t\terror_errno(_(\"failed write to rev-list\"));\n \t\t\terr = -1;\n \t\t\tbreak;\n \t\t}\n-\t} while (!fn(cb_data, sha1));\n+\t} while (!fn(cb_data, &oid));\n \n \tif (close(rev_list.in))\n \t\terr = error_errno(_(\"failed to close rev-list's stdin\"));\ndiff --git a/connected.h b/connected.h\nindex 4ca325f79d..a53f03a61a 100644\n--- a/connected.h\n+++ b/connected.h\n@@ -8,7 +8,7 @@ struct transport;\n  * When called after returning the name for the last object, return -1\n  * to signal EOF, otherwise return 0.\n  */\n-typedef int (*sha1_iterate_fn)(void *, unsigned char [20]);\n+typedef int (*oid_iterate_fn)(void *, struct object_id *oid);\n \n /*\n  * Named-arguments struct for check_connected. All arguments are\n@@ -51,7 +51,7 @@ struct check_connected_options {\n  *\n  * If \"opt\" is NULL, behaves as if CHECK_CONNECTED_INIT was passed.\n  */\n-int check_connected(sha1_iterate_fn fn, void *cb_data,\n+int check_connected(oid_iterate_fn fn, void *cb_data,\n \t\t    struct check_connected_options *opt);\n \n #endif /* CONNECTED_H */\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329330","messageId":"20171001220831.214705-12-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 11/24] refs: convert dwim_log to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:18Z","receivedAt":"2017-10-01T22:09:12Z","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 | 4 ++--\n reflog-walk.c    | 2 +-\n refs.c           | 8 ++++----\n refs.h           | 2 +-\n sha1_name.c      | 2 +-\n 5 files changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 302fafbeef..cd4c4847b7 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -602,7 +602,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)\n \tfor (; i < argc; i++) {\n \t\tchar *ref;\n \t\tstruct object_id oid;\n-\t\tif (!dwim_log(argv[i], strlen(argv[i]), oid.hash, &ref)) {\n+\t\tif (!dwim_log(argv[i], strlen(argv[i]), &oid, &ref)) {\n \t\t\tstatus |= error(\"%s points nowhere!\", argv[i]);\n \t\t\tcontinue;\n \t\t}\n@@ -668,7 +668,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)\n \t\t\tcontinue;\n \t\t}\n \n-\t\tif (!dwim_log(argv[i], spec - argv[i], oid.hash, &ref)) {\n+\t\tif (!dwim_log(argv[i], spec - argv[i], &oid, &ref)) {\n \t\t\tstatus |= error(\"no reflog for '%s'\", argv[i]);\n \t\t\tcontinue;\n \t\t}\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex 1a602a214d..65f8a6b340 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -163,7 +163,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,\n \t\t\tstruct object_id oid;\n \t\t\tchar *b;\n \t\t\tint ret = dwim_log(branch, strlen(branch),\n-\t\t\t\t\t   oid.hash, &b);\n+\t\t\t\t\t   &oid, &b);\n \t\t\tif (ret > 1)\n \t\t\t\tfree(b);\n \t\t\telse if (ret == 1) {\ndiff --git a/refs.c b/refs.c\nindex db683248c7..c158a2d107 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -496,7 +496,7 @@ int expand_ref(const char *str, int len, struct object_id *oid, char **ref)\n \treturn refs_found;\n }\n \n-int dwim_log(const char *str, int len, unsigned char *sha1, char **log)\n+int dwim_log(const char *str, int len, struct object_id *oid, char **log)\n {\n \tchar *last_branch = substitute_branch_name(&str, &len);\n \tconst char **p;\n@@ -505,13 +505,13 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)\n \n \t*log = NULL;\n \tfor (p = ref_rev_parse_rules; *p; p++) {\n-\t\tunsigned char hash[20];\n+\t\tstruct object_id hash;\n \t\tconst char *ref, *it;\n \n \t\tstrbuf_reset(&path);\n \t\tstrbuf_addf(&path, *p, len, str);\n \t\tref = resolve_ref_unsafe(path.buf, RESOLVE_REF_READING,\n-\t\t\t\t\t hash, NULL);\n+\t\t\t\t\t hash.hash, NULL);\n \t\tif (!ref)\n \t\t\tcontinue;\n \t\tif (reflog_exists(path.buf))\n@@ -522,7 +522,7 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)\n \t\t\tcontinue;\n \t\tif (!logs_found++) {\n \t\t\t*log = xstrdup(it);\n-\t\t\thashcpy(sha1, hash);\n+\t\t\toidcpy(oid, &hash);\n \t\t}\n \t\tif (!warn_ambiguous_refs)\n \t\t\tbreak;\ndiff --git a/refs.h b/refs.h\nindex 832a77183c..8159b7b067 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -141,7 +141,7 @@ int refname_match(const char *abbrev_name, const char *full_name);\n \n int expand_ref(const char *str, int len, struct object_id *oid, char **ref);\n int dwim_ref(const char *str, int len, struct object_id *oid, char **ref);\n-int dwim_log(const char *str, int len, unsigned char *sha1, char **ref);\n+int dwim_log(const char *str, int len, struct object_id *oid, char **ref);\n \n /*\n  * A ref_transaction represents a collection of reference updates that\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 28bad3e74b..7de12743f3 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -656,7 +656,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,\n \t\t/* allow \"@{...}\" to mean the current branch reflog */\n \t\trefs_found = dwim_ref(\"HEAD\", 4, oid, &real_ref);\n \telse if (reflog_len)\n-\t\trefs_found = dwim_log(str, len, oid->hash, &real_ref);\n+\t\trefs_found = dwim_log(str, len, oid, &real_ref);\n \telse\n \t\trefs_found = dwim_ref(str, len, oid, &real_ref);\n \n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329331","messageId":"20171001220831.214705-16-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 15/24] refs: convert read_ref_at to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:22Z","receivedAt":"2017-10-01T22:09:14Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the callers and internals, including struct read_ref_at_cb, of\nread_ref_at to use struct object_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/show-branch.c |  5 ++---\n refs.c                | 34 +++++++++++++++++-----------------\n refs.h                |  2 +-\n sha1_name.c           |  3 +--\n 4 files changed, 21 insertions(+), 23 deletions(-)\n\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 722a7f4bec..8ef8ad10c5 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -731,7 +731,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\t\t\t/* Ah, that is a date spec... */\n \t\t\t\ttimestamp_t at;\n \t\t\t\tat = approxidate(reflog_base);\n-\t\t\t\tread_ref_at(ref, flags, at, -1, oid.hash, NULL,\n+\t\t\t\tread_ref_at(ref, flags, at, -1, &oid, NULL,\n \t\t\t\t\t    NULL, NULL, &base);\n \t\t\t}\n \t\t}\n@@ -743,8 +743,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\t\ttimestamp_t timestamp;\n \t\t\tint tz;\n \n-\t\t\tif (read_ref_at(ref, flags, 0, base+i, oid.hash, &logmsg,\n-\t\t\t\t\t&timestamp, &tz, NULL)) {\n+\t\t\tif (read_ref_at(ref, flags, 0, base + i, &oid, &logmsg, &timestamp, &tz, NULL)) {\n \t\t\t\treflog = i;\n \t\t\t\tbreak;\n \t\t\t}\ndiff --git a/refs.c b/refs.c\nindex 6cbe2c1c6b..684dd75deb 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -734,11 +734,11 @@ struct read_ref_at_cb {\n \ttimestamp_t at_time;\n \tint cnt;\n \tint reccnt;\n-\tunsigned char *sha1;\n+\tstruct object_id *oid;\n \tint found_it;\n \n-\tunsigned char osha1[20];\n-\tunsigned char nsha1[20];\n+\tstruct object_id ooid;\n+\tstruct object_id noid;\n \tint tz;\n \ttimestamp_t date;\n \tchar **msg;\n@@ -770,25 +770,25 @@ static int read_ref_at_ent(struct object_id *ooid, struct object_id *noid,\n \t\t * we have not yet updated cb->[n|o]sha1 so they still\n \t\t * hold the values for the previous record.\n \t\t */\n-\t\tif (!is_null_sha1(cb->osha1)) {\n-\t\t\thashcpy(cb->sha1, noid->hash);\n-\t\t\tif (hashcmp(cb->osha1, noid->hash))\n+\t\tif (!is_null_oid(&cb->ooid)) {\n+\t\t\toidcpy(cb->oid, noid);\n+\t\t\tif (oidcmp(&cb->ooid, noid))\n \t\t\t\twarning(\"Log for ref %s has gap after %s.\",\n \t\t\t\t\tcb->refname, show_date(cb->date, cb->tz, DATE_MODE(RFC2822)));\n \t\t}\n \t\telse if (cb->date == cb->at_time)\n-\t\t\thashcpy(cb->sha1, noid->hash);\n-\t\telse if (hashcmp(noid->hash, cb->sha1))\n+\t\t\toidcpy(cb->oid, noid);\n+\t\telse if (oidcmp(noid, cb->oid))\n \t\t\twarning(\"Log for ref %s unexpectedly ended on %s.\",\n \t\t\t\tcb->refname, show_date(cb->date, cb->tz,\n \t\t\t\t\t\t       DATE_MODE(RFC2822)));\n-\t\thashcpy(cb->osha1, ooid->hash);\n-\t\thashcpy(cb->nsha1, noid->hash);\n+\t\toidcpy(&cb->ooid, ooid);\n+\t\toidcpy(&cb->noid, noid);\n \t\tcb->found_it = 1;\n \t\treturn 1;\n \t}\n-\thashcpy(cb->osha1, ooid->hash);\n-\thashcpy(cb->nsha1, noid->hash);\n+\toidcpy(&cb->ooid, ooid);\n+\toidcpy(&cb->noid, noid);\n \tif (cb->cnt > 0)\n \t\tcb->cnt--;\n \treturn 0;\n@@ -808,15 +808,15 @@ static int read_ref_at_ent_oldest(struct object_id *ooid, struct object_id *noid\n \t\t*cb->cutoff_tz = tz;\n \tif (cb->cutoff_cnt)\n \t\t*cb->cutoff_cnt = cb->reccnt;\n-\thashcpy(cb->sha1, ooid->hash);\n-\tif (is_null_sha1(cb->sha1))\n-\t\thashcpy(cb->sha1, noid->hash);\n+\toidcpy(cb->oid, ooid);\n+\tif (is_null_oid(cb->oid))\n+\t\toidcpy(cb->oid, noid);\n \t/* We just want the first entry */\n \treturn 1;\n }\n \n int read_ref_at(const char *refname, unsigned int flags, timestamp_t at_time, int cnt,\n-\t\tunsigned char *sha1, char **msg,\n+\t\tstruct object_id *oid, char **msg,\n \t\ttimestamp_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt)\n {\n \tstruct read_ref_at_cb cb;\n@@ -829,7 +829,7 @@ int read_ref_at(const char *refname, unsigned int flags, timestamp_t at_time, in\n \tcb.cutoff_time = cutoff_time;\n \tcb.cutoff_tz = cutoff_tz;\n \tcb.cutoff_cnt = cutoff_cnt;\n-\tcb.sha1 = sha1;\n+\tcb.oid = oid;\n \n \tfor_each_reflog_ent_reverse(refname, read_ref_at_ent, &cb);\n \ndiff --git a/refs.h b/refs.h\nindex 832ade2b13..3afecd2e8a 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -363,7 +363,7 @@ int safe_create_reflog(const char *refname, int force_create, struct strbuf *err\n /** Reads log for the value of ref during at_time. **/\n int read_ref_at(const char *refname, unsigned int flags,\n \t\ttimestamp_t at_time, int cnt,\n-\t\tunsigned char *sha1, char **msg,\n+\t\tstruct object_id *oid, char **msg,\n \t\ttimestamp_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt);\n \n /** Check if a particular reflog exists */\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 7de12743f3..f0ec3f0454 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -697,8 +697,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,\n \t\t\t\treturn -1;\n \t\t\t}\n \t\t}\n-\t\tif (read_ref_at(real_ref, flags, at_time, nth, oid->hash, NULL,\n-\t\t\t\t&co_time, &co_tz, &co_cnt)) {\n+\t\tif (read_ref_at(real_ref, flags, at_time, nth, oid, NULL, &co_time, &co_tz, &co_cnt)) {\n \t\t\tif (!len) {\n \t\t\t\tif (starts_with(real_ref, \"refs/heads/\")) {\n \t\t\t\t\tstr = real_ref + 11;\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329332","messageId":"20171001220831.214705-18-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 17/24] sha1_file: convert index_path and index_fd to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:24Z","receivedAt":"2017-10-01T22:09:16Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert these two functions and the functions that underlie them to take\npointers to struct object_id.  This is a prerequisite to convert\nresolve_gitlink_ref.  Fix a stray tab in the middle of the index_mem\ncall in index_pipe by converting it to a space.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n sha1_file.c | 30 +++++++++++++++---------------\n 1 file changed, 15 insertions(+), 15 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 5a2014811f..793fd2d194 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1660,7 +1660,7 @@ static void check_tag(const void *buf, size_t size)\n \t\tdie(\"corrupt tag\");\n }\n \n-static int index_mem(unsigned char *sha1, void *buf, size_t size,\n+static int index_mem(struct object_id *oid, void *buf, size_t size,\n \t\t     enum object_type type,\n \t\t     const char *path, unsigned flags)\n {\n@@ -1691,15 +1691,15 @@ static int index_mem(unsigned char *sha1, void *buf, size_t size,\n \t}\n \n \tif (write_object)\n-\t\tret = write_sha1_file(buf, size, typename(type), sha1);\n+\t\tret = write_sha1_file(buf, size, typename(type), oid->hash);\n \telse\n-\t\tret = hash_sha1_file(buf, size, typename(type), sha1);\n+\t\tret = hash_sha1_file(buf, size, typename(type), oid->hash);\n \tif (re_allocated)\n \t\tfree(buf);\n \treturn ret;\n }\n \n-static int index_stream_convert_blob(unsigned char *sha1, int fd,\n+static int index_stream_convert_blob(struct object_id *oid, int fd,\n \t\t\t\t     const char *path, unsigned flags)\n {\n \tint ret;\n@@ -1714,22 +1714,22 @@ static int index_stream_convert_blob(unsigned char *sha1, int fd,\n \n \tif (write_object)\n \t\tret = write_sha1_file(sbuf.buf, sbuf.len, typename(OBJ_BLOB),\n-\t\t\t\t      sha1);\n+\t\t\t\t      oid->hash);\n \telse\n \t\tret = hash_sha1_file(sbuf.buf, sbuf.len, typename(OBJ_BLOB),\n-\t\t\t\t     sha1);\n+\t\t\t\t     oid->hash);\n \tstrbuf_release(&sbuf);\n \treturn ret;\n }\n \n-static int index_pipe(unsigned char *sha1, int fd, enum object_type type,\n+static int index_pipe(struct object_id *oid, int fd, enum object_type type,\n \t\t      const char *path, unsigned flags)\n {\n \tstruct strbuf sbuf = STRBUF_INIT;\n \tint ret;\n \n \tif (strbuf_read(&sbuf, fd, 4096) >= 0)\n-\t\tret = index_mem(sha1, sbuf.buf, sbuf.len, type,\tpath, flags);\n+\t\tret = index_mem(oid, sbuf.buf, sbuf.len, type, path, flags);\n \telse\n \t\tret = -1;\n \tstrbuf_release(&sbuf);\n@@ -1738,24 +1738,24 @@ static int index_pipe(unsigned char *sha1, int fd, enum object_type type,\n \n #define SMALL_FILE_SIZE (32*1024)\n \n-static int index_core(unsigned char *sha1, int fd, size_t size,\n+static int index_core(struct object_id *oid, int fd, size_t size,\n \t\t      enum object_type type, const char *path,\n \t\t      unsigned flags)\n {\n \tint ret;\n \n \tif (!size) {\n-\t\tret = index_mem(sha1, \"\", size, type, path, flags);\n+\t\tret = index_mem(oid, \"\", size, type, path, flags);\n \t} else if (size <= SMALL_FILE_SIZE) {\n \t\tchar *buf = xmalloc(size);\n \t\tif (size == read_in_full(fd, buf, size))\n-\t\t\tret = index_mem(sha1, buf, size, type, path, flags);\n+\t\t\tret = index_mem(oid, buf, size, type, path, flags);\n \t\telse\n \t\t\tret = error_errno(\"short read\");\n \t\tfree(buf);\n \t} else {\n \t\tvoid *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);\n-\t\tret = index_mem(sha1, buf, size, type, path, flags);\n+\t\tret = index_mem(oid, buf, size, type, path, flags);\n \t\tmunmap(buf, size);\n \t}\n \treturn ret;\n@@ -1793,12 +1793,12 @@ int index_fd(struct object_id *oid, int fd, struct stat *st,\n \t * die() for large files.\n \t */\n \tif (type == OBJ_BLOB && path && would_convert_to_git_filter_fd(path))\n-\t\tret = index_stream_convert_blob(oid->hash, fd, path, flags);\n+\t\tret = index_stream_convert_blob(oid, fd, path, flags);\n \telse if (!S_ISREG(st->st_mode))\n-\t\tret = index_pipe(oid->hash, fd, type, path, flags);\n+\t\tret = index_pipe(oid, fd, type, path, flags);\n \telse if (st->st_size <= big_file_threshold || type != OBJ_BLOB ||\n \t\t (path && would_convert_to_git(&the_index, path)))\n-\t\tret = index_core(oid->hash, fd, xsize_t(st->st_size), type, path,\n+\t\tret = index_core(oid, fd, xsize_t(st->st_size), type, path,\n \t\t\t\t flags);\n \telse\n \t\tret = index_stream(oid, fd, xsize_t(st->st_size), type, path,\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329333","messageId":"20171001220831.214705-25-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 24/24] refs/files-backend: convert static functions to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:31Z","receivedAt":"2017-10-01T22:09:19Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert several static functions to take pointers to struct object_id.\nChange the relevant parameters to write_packed_entry to be const, as we\ndon't modify them.  Rename lock_ref_sha1_basic to lock_ref_oid_basic to\nreflect its new argument.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n refs/files-backend.c | 48 ++++++++++++++++++++++++------------------------\n 1 file changed, 24 insertions(+), 24 deletions(-)\n\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 7281f27f62..84d8e3da99 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -811,7 +811,7 @@ static struct ref_iterator *files_ref_iterator_begin(\n  * return a negative value.\n  */\n static int verify_lock(struct ref_store *ref_store, struct ref_lock *lock,\n-\t\t       const unsigned char *old_sha1, int mustexist,\n+\t\t       const struct object_id *old_oid, int mustexist,\n \t\t       struct strbuf *err)\n {\n \tassert(err);\n@@ -819,7 +819,7 @@ static int verify_lock(struct ref_store *ref_store, struct ref_lock *lock,\n \tif (refs_read_ref_full(ref_store, lock->ref_name,\n \t\t\t       mustexist ? RESOLVE_REF_READING : 0,\n \t\t\t       &lock->old_oid, NULL)) {\n-\t\tif (old_sha1) {\n+\t\tif (old_oid) {\n \t\t\tint save_errno = errno;\n \t\t\tstrbuf_addf(err, \"can't verify ref '%s'\", lock->ref_name);\n \t\t\terrno = save_errno;\n@@ -829,11 +829,11 @@ static int verify_lock(struct ref_store *ref_store, struct ref_lock *lock,\n \t\t\treturn 0;\n \t\t}\n \t}\n-\tif (old_sha1 && hashcmp(lock->old_oid.hash, old_sha1)) {\n+\tif (old_oid && oidcmp(&lock->old_oid, old_oid)) {\n \t\tstrbuf_addf(err, \"ref '%s' is at %s but expected %s\",\n \t\t\t    lock->ref_name,\n \t\t\t    oid_to_hex(&lock->old_oid),\n-\t\t\t    sha1_to_hex(old_sha1));\n+\t\t\t    oid_to_hex(old_oid));\n \t\terrno = EBUSY;\n \t\treturn -1;\n \t}\n@@ -863,22 +863,22 @@ static int create_reflock(const char *path, void *cb)\n  * Locks a ref returning the lock on success and NULL on failure.\n  * On failure errno is set to something meaningful.\n  */\n-static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,\n-\t\t\t\t\t    const char *refname,\n-\t\t\t\t\t    const unsigned char *old_sha1,\n-\t\t\t\t\t    const struct string_list *extras,\n-\t\t\t\t\t    const struct string_list *skip,\n-\t\t\t\t\t    unsigned int flags, int *type,\n-\t\t\t\t\t    struct strbuf *err)\n+static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs,\n+\t\t\t\t\t   const char *refname,\n+\t\t\t\t\t   const struct object_id *old_oid,\n+\t\t\t\t\t   const struct string_list *extras,\n+\t\t\t\t\t   const struct string_list *skip,\n+\t\t\t\t\t   unsigned int flags, int *type,\n+\t\t\t\t\t   struct strbuf *err)\n {\n \tstruct strbuf ref_file = STRBUF_INIT;\n \tstruct ref_lock *lock;\n \tint last_errno = 0;\n-\tint mustexist = (old_sha1 && !is_null_sha1(old_sha1));\n+\tint mustexist = (old_oid && !is_null_oid(old_oid));\n \tint resolve_flags = RESOLVE_REF_NO_RECURSE;\n \tint resolved;\n \n-\tfiles_assert_main_repository(refs, \"lock_ref_sha1_basic\");\n+\tfiles_assert_main_repository(refs, \"lock_ref_oid_basic\");\n \tassert(err);\n \n \tlock = xcalloc(1, sizeof(struct ref_lock));\n@@ -944,7 +944,7 @@ static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,\n \t\tgoto error_return;\n \t}\n \n-\tif (verify_lock(&refs->base, lock, old_sha1, mustexist, err)) {\n+\tif (verify_lock(&refs->base, lock, old_oid, mustexist, err)) {\n \t\tlast_errno = errno;\n \t\tgoto error_return;\n \t}\n@@ -1349,8 +1349,8 @@ static int files_rename_ref(struct ref_store *ref_store,\n \n \tlogmoved = log;\n \n-\tlock = lock_ref_sha1_basic(refs, newrefname, NULL, NULL, NULL,\n-\t\t\t\t   REF_NODEREF, NULL, &err);\n+\tlock = lock_ref_oid_basic(refs, newrefname, NULL, NULL, NULL,\n+\t\t\t\t  REF_NODEREF, NULL, &err);\n \tif (!lock) {\n \t\terror(\"unable to rename '%s' to '%s': %s\", oldrefname, newrefname, err.buf);\n \t\tstrbuf_release(&err);\n@@ -1369,8 +1369,8 @@ static int files_rename_ref(struct ref_store *ref_store,\n \tgoto out;\n \n  rollback:\n-\tlock = lock_ref_sha1_basic(refs, oldrefname, NULL, NULL, NULL,\n-\t\t\t\t   REF_NODEREF, NULL, &err);\n+\tlock = lock_ref_oid_basic(refs, oldrefname, NULL, NULL, NULL,\n+\t\t\t\t  REF_NODEREF, NULL, &err);\n \tif (!lock) {\n \t\terror(\"unable to lock %s for rollback: %s\", oldrefname, err.buf);\n \t\tstrbuf_release(&err);\n@@ -1769,9 +1769,9 @@ static int files_create_symref(struct ref_store *ref_store,\n \tstruct ref_lock *lock;\n \tint ret;\n \n-\tlock = lock_ref_sha1_basic(refs, refname, NULL,\n-\t\t\t\t   NULL, NULL, REF_NODEREF, NULL,\n-\t\t\t\t   &err);\n+\tlock = lock_ref_oid_basic(refs, refname, NULL,\n+\t\t\t\t  NULL, NULL, REF_NODEREF, NULL,\n+\t\t\t\t  &err);\n \tif (!lock) {\n \t\terror(\"%s\", err.buf);\n \t\tstrbuf_release(&err);\n@@ -2943,9 +2943,9 @@ static int files_reflog_expire(struct ref_store *ref_store,\n \t * reference itself, plus we might need to update the\n \t * reference if --updateref was specified:\n \t */\n-\tlock = lock_ref_sha1_basic(refs, refname, oid->hash,\n-\t\t\t\t   NULL, NULL, REF_NODEREF,\n-\t\t\t\t   &type, &err);\n+\tlock = lock_ref_oid_basic(refs, refname, oid,\n+\t\t\t\t  NULL, NULL, REF_NODEREF,\n+\t\t\t\t  &type, &err);\n \tif (!lock) {\n \t\terror(\"cannot lock ref '%s': %s\", refname, err.buf);\n \t\tstrbuf_release(&err);\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329334","messageId":"20171001220831.214705-24-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 23/24] refs: convert read_raw_ref backends to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:30Z","receivedAt":"2017-10-01T22:09:20Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the unsigned char * parameter to struct object_id * for\nfiles_read_raw_ref and packed_read_raw-ref.  Update the documentation.\nSwitch from using get_sha1_hex and a hard-coded 40 to using\nparse_oid_hex.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n refs.c                |  8 ++++----\n refs/files-backend.c  | 13 +++++++------\n refs/packed-backend.c |  4 ++--\n refs/refs-internal.h  | 10 +++++-----\n 4 files changed, 18 insertions(+), 17 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex e014d8aa71..eebd7cb263 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1375,10 +1375,10 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)\n }\n \n int refs_read_raw_ref(struct ref_store *ref_store,\n-\t\t      const char *refname, unsigned char *sha1,\n+\t\t      const char *refname, struct object_id *oid,\n \t\t      struct strbuf *referent, unsigned int *type)\n {\n-\treturn ref_store->be->read_raw_ref(ref_store, refname, sha1, referent, type);\n+\treturn ref_store->be->read_raw_ref(ref_store, refname, oid, referent, type);\n }\n \n /* This function needs to return a meaningful errno on failure */\n@@ -1421,7 +1421,7 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,\n \t\tunsigned int read_flags = 0;\n \n \t\tif (refs_read_raw_ref(refs, refname,\n-\t\t\t\t      oid->hash, &sb_refname, &read_flags)) {\n+\t\t\t\t      oid, &sb_refname, &read_flags)) {\n \t\t\t*flags |= read_flags;\n \t\t\tif (errno != ENOENT || (resolve_flags & RESOLVE_REF_READING))\n \t\t\t\treturn NULL;\n@@ -1843,7 +1843,7 @@ int refs_verify_refname_available(struct ref_store *refs,\n \t\tif (skip && string_list_has_string(skip, dirname.buf))\n \t\t\tcontinue;\n \n-\t\tif (!refs_read_raw_ref(refs, dirname.buf, oid.hash, &referent, &type)) {\n+\t\tif (!refs_read_raw_ref(refs, dirname.buf, &oid, &referent, &type)) {\n \t\t\tstrbuf_addf(err, \"'%s' exists; cannot create '%s'\",\n \t\t\t\t    dirname.buf, refname);\n \t\t\tgoto cleanup;\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 417c662d5d..7281f27f62 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -261,7 +261,7 @@ static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs)\n }\n \n static int files_read_raw_ref(struct ref_store *ref_store,\n-\t\t\t      const char *refname, unsigned char *sha1,\n+\t\t\t      const char *refname, struct object_id *oid,\n \t\t\t      struct strbuf *referent, unsigned int *type)\n {\n \tstruct files_ref_store *refs =\n@@ -270,6 +270,7 @@ static int files_read_raw_ref(struct ref_store *ref_store,\n \tstruct strbuf sb_path = STRBUF_INIT;\n \tconst char *path;\n \tconst char *buf;\n+\tconst char *p;\n \tstruct stat st;\n \tint fd;\n \tint ret = -1;\n@@ -304,7 +305,7 @@ static int files_read_raw_ref(struct ref_store *ref_store,\n \t\tif (errno != ENOENT)\n \t\t\tgoto out;\n \t\tif (refs_read_raw_ref(refs->packed_ref_store, refname,\n-\t\t\t\t      sha1, referent, type)) {\n+\t\t\t\t      oid, referent, type)) {\n \t\t\terrno = ENOENT;\n \t\t\tgoto out;\n \t\t}\n@@ -344,7 +345,7 @@ static int files_read_raw_ref(struct ref_store *ref_store,\n \t\t * packed ref:\n \t\t */\n \t\tif (refs_read_raw_ref(refs->packed_ref_store, refname,\n-\t\t\t\t      sha1, referent, type)) {\n+\t\t\t\t      oid, referent, type)) {\n \t\t\terrno = EISDIR;\n \t\t\tgoto out;\n \t\t}\n@@ -390,8 +391,8 @@ static int files_read_raw_ref(struct ref_store *ref_store,\n \t * Please note that FETCH_HEAD has additional\n \t * data after the sha.\n \t */\n-\tif (get_sha1_hex(buf, sha1) ||\n-\t    (buf[40] != '\\0' && !isspace(buf[40]))) {\n+\tif (parse_oid_hex(buf, oid, &p) ||\n+\t    (*p != '\\0' && !isspace(*p))) {\n \t\t*type |= REF_ISBROKEN;\n \t\terrno = EINVAL;\n \t\tgoto out;\n@@ -545,7 +546,7 @@ static int lock_raw_ref(struct files_ref_store *refs,\n \t */\n \n \tif (files_read_raw_ref(&refs->base, refname,\n-\t\t\t       lock->old_oid.hash, referent, type)) {\n+\t\t\t       &lock->old_oid, referent, type)) {\n \t\tif (errno == ENOENT) {\n \t\t\tif (mustexist) {\n \t\t\t\t/* Garden variety missing reference. */\ndiff --git a/refs/packed-backend.c b/refs/packed-backend.c\nindex 25e6fc4ffe..c1960c4cfa 100644\n--- a/refs/packed-backend.c\n+++ b/refs/packed-backend.c\n@@ -319,7 +319,7 @@ static struct ref_entry *get_packed_ref(struct packed_ref_store *refs,\n }\n \n static int packed_read_raw_ref(struct ref_store *ref_store,\n-\t\t\t       const char *refname, unsigned char *sha1,\n+\t\t\t       const char *refname, struct object_id *oid,\n \t\t\t       struct strbuf *referent, unsigned int *type)\n {\n \tstruct packed_ref_store *refs =\n@@ -335,7 +335,7 @@ static int packed_read_raw_ref(struct ref_store *ref_store,\n \t\treturn -1;\n \t}\n \n-\thashcpy(sha1, entry->u.value.oid.hash);\n+\toidcpy(oid, &entry->u.value.oid);\n \t*type = REF_ISPACKED;\n \treturn 0;\n }\ndiff --git a/refs/refs-internal.h b/refs/refs-internal.h\nindex cf84da33d5..d2bcaef321 100644\n--- a/refs/refs-internal.h\n+++ b/refs/refs-internal.h\n@@ -181,7 +181,7 @@ struct ref_update {\n };\n \n int refs_read_raw_ref(struct ref_store *ref_store,\n-\t\t      const char *refname, unsigned char *sha1,\n+\t\t      const char *refname, struct object_id *oid,\n \t\t      struct strbuf *referent, unsigned int *type);\n \n /*\n@@ -603,13 +603,13 @@ typedef int reflog_expire_fn(struct ref_store *ref_store,\n  * Read a reference from the specified reference store, non-recursively.\n  * Set type to describe the reference, and:\n  *\n- * - If refname is the name of a normal reference, fill in sha1\n+ * - If refname is the name of a normal reference, fill in oid\n  *   (leaving referent unchanged).\n  *\n  * - If refname is the name of a symbolic reference, write the full\n  *   name of the reference to which it refers (e.g.\n  *   \"refs/heads/master\") to referent and set the REF_ISSYMREF bit in\n- *   type (leaving sha1 unchanged). The caller is responsible for\n+ *   type (leaving oid unchanged). The caller is responsible for\n  *   validating that referent is a valid reference name.\n  *\n  * WARNING: refname might be used as part of a filename, so it is\n@@ -621,7 +621,7 @@ typedef int reflog_expire_fn(struct ref_store *ref_store,\n  *\n  * Return 0 on success. If the ref doesn't exist, set errno to ENOENT\n  * and return -1. If the ref exists but is neither a symbolic ref nor\n- * a sha1, it is broken; set REF_ISBROKEN in type, set errno to\n+ * an object ID, it is broken; set REF_ISBROKEN in type, set errno to\n  * EINVAL, and return -1. If there is another error reading the ref,\n  * set errno appropriately and return -1.\n  *\n@@ -638,7 +638,7 @@ typedef int reflog_expire_fn(struct ref_store *ref_store,\n  *   refname will still be valid and unchanged.\n  */\n typedef int read_raw_ref_fn(struct ref_store *ref_store,\n-\t\t\t    const char *refname, unsigned char *sha1,\n+\t\t\t    const char *refname, struct object_id *oid,\n \t\t\t    struct strbuf *referent, unsigned int *type);\n \n struct ref_storage_be {\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329335","messageId":"20171001220831.214705-23-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 22/24] refs: convert peel_object to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:29Z","receivedAt":"2017-10-01T22:09:29Z","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 refs.c                | 8 ++++----\n refs/files-backend.c  | 2 +-\n refs/packed-backend.c | 4 ++--\n refs/ref-cache.c      | 2 +-\n refs/refs-internal.h  | 4 ++--\n 5 files changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 751c49772e..e014d8aa71 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -252,12 +252,12 @@ static int filter_refs(const char *refname, const struct object_id *oid,\n \treturn filter->fn(refname, oid, flags, filter->cb_data);\n }\n \n-enum peel_status peel_object(const unsigned char *name, unsigned char *sha1)\n+enum peel_status peel_object(const struct object_id *name, struct object_id *oid)\n {\n-\tstruct object *o = lookup_unknown_object(name);\n+\tstruct object *o = lookup_unknown_object(name->hash);\n \n \tif (o->type == OBJ_NONE) {\n-\t\tint type = sha1_object_info(name, NULL);\n+\t\tint type = sha1_object_info(name->hash, NULL);\n \t\tif (type < 0 || !object_as_type(o, type, 0))\n \t\t\treturn PEEL_INVALID;\n \t}\n@@ -269,7 +269,7 @@ enum peel_status peel_object(const unsigned char *name, unsigned char *sha1)\n \tif (!o)\n \t\treturn PEEL_INVALID;\n \n-\thashcpy(sha1, o->oid.hash);\n+\toidcpy(oid, &o->oid);\n \treturn PEEL_PEELED;\n }\n \ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 61f3690299..417c662d5d 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -675,7 +675,7 @@ static int files_peel_ref(struct ref_store *ref_store,\n \t    !refs_peel_ref(refs->packed_ref_store, refname, oid))\n \t\treturn 0;\n \n-\treturn peel_object(base.hash, oid->hash);\n+\treturn peel_object(&base, oid);\n }\n \n struct files_ref_iterator {\ndiff --git a/refs/packed-backend.c b/refs/packed-backend.c\nindex a450efd21e..25e6fc4ffe 100644\n--- a/refs/packed-backend.c\n+++ b/refs/packed-backend.c\n@@ -716,8 +716,8 @@ static int write_with_updates(struct packed_ref_store *refs,\n \t\t\ti++;\n \t\t} else {\n \t\t\tstruct object_id peeled;\n-\t\t\tint peel_error = peel_object(update->new_oid.hash,\n-\t\t\t\t\t\t     peeled.hash);\n+\t\t\tint peel_error = peel_object(&update->new_oid,\n+\t\t\t\t\t\t     &peeled);\n \n \t\t\tif (write_packed_entry(out, update->refname,\n \t\t\t\t\t       update->new_oid.hash,\ndiff --git a/refs/ref-cache.c b/refs/ref-cache.c\nindex 76bb723c86..e36702ed06 100644\n--- a/refs/ref-cache.c\n+++ b/refs/ref-cache.c\n@@ -509,7 +509,7 @@ enum peel_status peel_entry(struct ref_entry *entry, int repeel)\n \tif (entry->flag & REF_ISSYMREF)\n \t\treturn PEEL_IS_SYMREF;\n \n-\tstatus = peel_object(entry->u.value.oid.hash, entry->u.value.peeled.hash);\n+\tstatus = peel_object(&entry->u.value.oid, &entry->u.value.peeled);\n \tif (status == PEEL_PEELED || status == PEEL_NON_TAG)\n \t\tentry->flag |= REF_KNOWS_PEELED;\n \treturn status;\ndiff --git a/refs/refs-internal.h b/refs/refs-internal.h\nindex 0cbce76f21..cf84da33d5 100644\n--- a/refs/refs-internal.h\n+++ b/refs/refs-internal.h\n@@ -120,11 +120,11 @@ enum peel_status {\n /*\n  * Peel the named object; i.e., if the object is a tag, resolve the\n  * tag recursively until a non-tag is found.  If successful, store the\n- * result to sha1 and return PEEL_PEELED.  If the object is not a tag\n+ * result to oid and return PEEL_PEELED.  If the object is not a tag\n  * or is not valid, return PEEL_NON_TAG or PEEL_INVALID, respectively,\n  * and leave sha1 unchanged.\n  */\n-enum peel_status peel_object(const unsigned char *name, unsigned char *sha1);\n+enum peel_status peel_object(const struct object_id *name, struct object_id *oid);\n \n /*\n  * Copy the reflog message msg to buf, which has been allocated sufficiently\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329336","messageId":"20171001220831.214705-17-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 16/24] refs: convert reflog_expire parameter to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:23Z","receivedAt":"2017-10-01T22:09:33Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"reflog_expire already used struct object_id internally, but it did not\ntake it as a parameter.  Adjust the parameter (and the callers) to pass\na pointer to struct object_id instead of a pointer to unsigned char.\nRemove the temporary inserted earlier as it is no longer required.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/reflog.c      | 6 +++---\n refs.c                | 8 ++++----\n refs.h                | 6 +++---\n refs/files-backend.c  | 9 +++------\n refs/packed-backend.c | 2 +-\n refs/refs-internal.h  | 2 +-\n 6 files changed, 15 insertions(+), 18 deletions(-)\n\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex cd4c4847b7..ab31a3b6aa 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -589,7 +589,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)\n \t\tfor (i = 0; i < collected.nr; i++) {\n \t\t\tstruct collected_reflog *e = collected.e[i];\n \t\t\tset_reflog_expiry_param(&cb.cmd, explicit_expiry, e->reflog);\n-\t\t\tstatus |= reflog_expire(e->reflog, e->oid.hash, flags,\n+\t\t\tstatus |= reflog_expire(e->reflog, &e->oid, flags,\n \t\t\t\t\t\treflog_expiry_prepare,\n \t\t\t\t\t\tshould_expire_reflog_ent,\n \t\t\t\t\t\treflog_expiry_cleanup,\n@@ -607,7 +607,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)\n \t\t\tcontinue;\n \t\t}\n \t\tset_reflog_expiry_param(&cb.cmd, explicit_expiry, ref);\n-\t\tstatus |= reflog_expire(ref, oid.hash, flags,\n+\t\tstatus |= reflog_expire(ref, &oid, flags,\n \t\t\t\t\treflog_expiry_prepare,\n \t\t\t\t\tshould_expire_reflog_ent,\n \t\t\t\t\treflog_expiry_cleanup,\n@@ -683,7 +683,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)\n \t\t\tcb.cmd.expire_total = 0;\n \t\t}\n \n-\t\tstatus |= reflog_expire(ref, oid.hash, flags,\n+\t\tstatus |= reflog_expire(ref, &oid, flags,\n \t\t\t\t\treflog_expiry_prepare,\n \t\t\t\t\tshould_expire_reflog_ent,\n \t\t\t\t\treflog_expiry_cleanup,\ndiff --git a/refs.c b/refs.c\nindex 684dd75deb..d2fd0d2a69 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1973,19 +1973,19 @@ int delete_reflog(const char *refname)\n }\n \n int refs_reflog_expire(struct ref_store *refs,\n-\t\t       const char *refname, const unsigned char *sha1,\n+\t\t       const char *refname, const struct object_id *oid,\n \t\t       unsigned int flags,\n \t\t       reflog_expiry_prepare_fn prepare_fn,\n \t\t       reflog_expiry_should_prune_fn should_prune_fn,\n \t\t       reflog_expiry_cleanup_fn cleanup_fn,\n \t\t       void *policy_cb_data)\n {\n-\treturn refs->be->reflog_expire(refs, refname, sha1, flags,\n+\treturn refs->be->reflog_expire(refs, refname, oid, flags,\n \t\t\t\t       prepare_fn, should_prune_fn,\n \t\t\t\t       cleanup_fn, policy_cb_data);\n }\n \n-int reflog_expire(const char *refname, const unsigned char *sha1,\n+int reflog_expire(const char *refname, const struct object_id *oid,\n \t\t  unsigned int flags,\n \t\t  reflog_expiry_prepare_fn prepare_fn,\n \t\t  reflog_expiry_should_prune_fn should_prune_fn,\n@@ -1993,7 +1993,7 @@ int reflog_expire(const char *refname, const unsigned char *sha1,\n \t\t  void *policy_cb_data)\n {\n \treturn refs_reflog_expire(get_main_ref_store(),\n-\t\t\t\t  refname, sha1, flags,\n+\t\t\t\t  refname, oid, flags,\n \t\t\t\t  prepare_fn, should_prune_fn,\n \t\t\t\t  cleanup_fn, policy_cb_data);\n }\ndiff --git a/refs.h b/refs.h\nindex 3afecd2e8a..1bc241424d 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -696,20 +696,20 @@ typedef int reflog_expiry_should_prune_fn(struct object_id *ooid,\n typedef void reflog_expiry_cleanup_fn(void *cb_data);\n \n /*\n- * Expire reflog entries for the specified reference. sha1 is the old\n+ * Expire reflog entries for the specified reference. oid is the old\n  * value of the reference. flags is a combination of the constants in\n  * enum expire_reflog_flags. The three function pointers are described\n  * above. On success, return zero.\n  */\n int refs_reflog_expire(struct ref_store *refs,\n \t\t       const char *refname,\n-\t\t       const unsigned char *sha1,\n+\t\t       const struct object_id *oid,\n \t\t       unsigned int flags,\n \t\t       reflog_expiry_prepare_fn prepare_fn,\n \t\t       reflog_expiry_should_prune_fn should_prune_fn,\n \t\t       reflog_expiry_cleanup_fn cleanup_fn,\n \t\t       void *policy_cb_data);\n-int reflog_expire(const char *refname, const unsigned char *sha1,\n+int reflog_expire(const char *refname, const struct object_id *oid,\n \t\t  unsigned int flags,\n \t\t  reflog_expiry_prepare_fn prepare_fn,\n \t\t  reflog_expiry_should_prune_fn should_prune_fn,\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex a7e4b9e1e9..4400e18eee 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -2914,7 +2914,7 @@ static int expire_reflog_ent(struct object_id *ooid, struct object_id *noid,\n }\n \n static int files_reflog_expire(struct ref_store *ref_store,\n-\t\t\t       const char *refname, const unsigned char *sha1,\n+\t\t\t       const char *refname, const struct object_id *oid,\n \t\t\t       unsigned int flags,\n \t\t\t       reflog_expiry_prepare_fn prepare_fn,\n \t\t\t       reflog_expiry_should_prune_fn should_prune_fn,\n@@ -2931,7 +2931,6 @@ 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@@ -2943,7 +2942,7 @@ static int files_reflog_expire(struct ref_store *ref_store,\n \t * reference itself, plus we might need to update the\n \t * reference if --updateref was specified:\n \t */\n-\tlock = lock_ref_sha1_basic(refs, refname, sha1,\n+\tlock = lock_ref_sha1_basic(refs, refname, oid->hash,\n \t\t\t\t   NULL, NULL, REF_NODEREF,\n \t\t\t\t   &type, &err);\n \tif (!lock) {\n@@ -2981,9 +2980,7 @@ static int files_reflog_expire(struct ref_store *ref_store,\n \t\t}\n \t}\n \n-\thashcpy(oid.hash, sha1);\n-\n-\t(*prepare_fn)(refname, &oid, cb.policy_cb);\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 \ndiff --git a/refs/packed-backend.c b/refs/packed-backend.c\nindex d4bb4ba357..a450efd21e 100644\n--- a/refs/packed-backend.c\n+++ b/refs/packed-backend.c\n@@ -1006,7 +1006,7 @@ static int packed_delete_reflog(struct ref_store *ref_store,\n }\n \n static int packed_reflog_expire(struct ref_store *ref_store,\n-\t\t\t\tconst char *refname, const unsigned char *sha1,\n+\t\t\t\tconst char *refname, const struct object_id *oid,\n \t\t\t\tunsigned int flags,\n \t\t\t\treflog_expiry_prepare_fn prepare_fn,\n \t\t\t\treflog_expiry_should_prune_fn should_prune_fn,\ndiff --git a/refs/refs-internal.h b/refs/refs-internal.h\nindex f0bedbd80b..0cbce76f21 100644\n--- a/refs/refs-internal.h\n+++ b/refs/refs-internal.h\n@@ -592,7 +592,7 @@ typedef int create_reflog_fn(struct ref_store *ref_store, const char *refname,\n \t\t\t     int force_create, struct strbuf *err);\n typedef int delete_reflog_fn(struct ref_store *ref_store, const char *refname);\n typedef int reflog_expire_fn(struct ref_store *ref_store,\n-\t\t\t     const char *refname, const unsigned char *sha1,\n+\t\t\t     const char *refname, const struct object_id *oid,\n \t\t\t     unsigned int flags,\n \t\t\t     reflog_expiry_prepare_fn prepare_fn,\n \t\t\t     reflog_expiry_should_prune_fn should_prune_fn,\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329337","messageId":"20171001220831.214705-21-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 20/24] worktree: convert struct worktree to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:27Z","receivedAt":"2017-10-01T22:09:35Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the head_sha1 member to be head_oid instead.  This is required\nto convert resolve_ref_unsafe.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/worktree.c | 6 +++---\n worktree.c         | 2 +-\n worktree.h         | 2 +-\n 3 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex de26849f55..d9fe6f694e 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -392,7 +392,7 @@ static void show_worktree_porcelain(struct worktree *wt)\n \tif (wt->is_bare)\n \t\tprintf(\"bare\\n\");\n \telse {\n-\t\tprintf(\"HEAD %s\\n\", sha1_to_hex(wt->head_sha1));\n+\t\tprintf(\"HEAD %s\\n\", oid_to_hex(&wt->head_oid));\n \t\tif (wt->is_detached)\n \t\t\tprintf(\"detached\\n\");\n \t\telse if (wt->head_ref)\n@@ -412,7 +412,7 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)\n \t\tstrbuf_addstr(&sb, \"(bare)\");\n \telse {\n \t\tstrbuf_addf(&sb, \"%-*s \", abbrev_len,\n-\t\t\t\tfind_unique_abbrev(wt->head_sha1, DEFAULT_ABBREV));\n+\t\t\t\tfind_unique_abbrev(wt->head_oid.hash, DEFAULT_ABBREV));\n \t\tif (wt->is_detached)\n \t\t\tstrbuf_addstr(&sb, \"(detached HEAD)\");\n \t\telse if (wt->head_ref) {\n@@ -437,7 +437,7 @@ static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen)\n \n \t\tif (path_len > *maxlen)\n \t\t\t*maxlen = path_len;\n-\t\tsha1_len = strlen(find_unique_abbrev(wt[i]->head_sha1, *abbrev));\n+\t\tsha1_len = strlen(find_unique_abbrev(wt[i]->head_oid.hash, *abbrev));\n \t\tif (sha1_len > *abbrev)\n \t\t\t*abbrev = sha1_len;\n \t}\ndiff --git a/worktree.c b/worktree.c\nindex 70015629dc..cb35db03fa 100644\n--- a/worktree.c\n+++ b/worktree.c\n@@ -31,7 +31,7 @@ static void add_head_info(struct worktree *wt)\n \ttarget = refs_resolve_ref_unsafe(get_worktree_ref_store(wt),\n \t\t\t\t\t \"HEAD\",\n \t\t\t\t\t 0,\n-\t\t\t\t\t wt->head_sha1, &flags);\n+\t\t\t\t\t wt->head_oid.hash, &flags);\n \tif (!target)\n \t\treturn;\n \ndiff --git a/worktree.h b/worktree.h\nindex 9276c81ae7..c28a880e18 100644\n--- a/worktree.h\n+++ b/worktree.h\n@@ -8,7 +8,7 @@ struct worktree {\n \tchar *id;\n \tchar *head_ref;\t\t/* NULL if HEAD is broken or detached */\n \tchar *lock_reason;\t/* internal use */\n-\tunsigned char head_sha1[20];\n+\tstruct object_id head_oid;\n \tint is_detached;\n \tint is_bare;\n \tint is_current;\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329338","messageId":"20171001220831.214705-22-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 21/24] refs: convert resolve_ref_unsafe to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:28Z","receivedAt":"2017-10-01T22:09:37Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert resolve_ref_unsafe to take a pointer to struct object_id by\nconverting one remaining caller to use struct object_id, converting the\ndeclaration and definition, and applying the following semantic patch:\n\n@@\nexpression E1, E2, E3, E4;\n@@\n- resolve_ref_unsafe(E1, E2, E3.hash, E4)\n+ resolve_ref_unsafe(E1, E2, &E3, E4)\n\n@@\nexpression E1, E2, E3, E4;\n@@\n- resolve_ref_unsafe(E1, E2, E3->hash, E4)\n+ resolve_ref_unsafe(E1, E2, E3, E4)\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n blame.c                   |  4 ++--\n builtin/fsck.c            |  2 +-\n refs.c                    | 28 ++++++++++++++--------------\n refs.h                    |  4 ++--\n refs/files-backend.c      |  8 ++++----\n sequencer.c               |  2 +-\n t/helper/test-ref-store.c |  6 +++---\n transport-helper.c        |  7 +++----\n worktree.c                |  2 +-\n 9 files changed, 31 insertions(+), 32 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex f575e9cbf4..c3060de2f8 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -166,7 +166,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\n \tcommit->date = now;\n \tparent_tail = &commit->parents;\n \n-\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, head_oid.hash, NULL))\n+\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, &head_oid, NULL))\n \t\tdie(\"no such ref: HEAD\");\n \n \tparent_tail = append_parent(parent_tail, &head_oid);\n@@ -1689,7 +1689,7 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,\n \t\treturn NULL;\n \n \t/* Do we have HEAD? */\n-\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, head_oid.hash, NULL))\n+\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, &head_oid, NULL))\n \t\treturn NULL;\n \thead_commit = lookup_commit_reference_gently(&head_oid, 1);\n \tif (!head_commit)\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 56afe405b8..5f91116d73 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -555,7 +555,7 @@ static int fsck_head_link(void)\n \tif (verbose)\n \t\tfprintf(stderr, \"Checking HEAD link\\n\");\n \n-\thead_points_at = resolve_ref_unsafe(\"HEAD\", 0, head_oid.hash, NULL);\n+\thead_points_at = resolve_ref_unsafe(\"HEAD\", 0, &head_oid, NULL);\n \tif (!head_points_at) {\n \t\terrors_found |= ERROR_REFS;\n \t\treturn error(\"Invalid HEAD\");\ndiff --git a/refs.c b/refs.c\nindex 3329d47d16..751c49772e 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -199,7 +199,7 @@ char *refs_resolve_refdup(struct ref_store *refs,\n \tconst char *result;\n \n \tresult = refs_resolve_ref_unsafe(refs, refname, resolve_flags,\n-\t\t\t\t\t oid->hash, flags);\n+\t\t\t\t\t oid, flags);\n \treturn xstrdup_or_null(result);\n }\n \n@@ -221,7 +221,7 @@ struct ref_filter {\n int refs_read_ref_full(struct ref_store *refs, const char *refname,\n \t\t       int resolve_flags, struct object_id *oid, int *flags)\n {\n-\tif (refs_resolve_ref_unsafe(refs, refname, resolve_flags, oid->hash, flags))\n+\tif (refs_resolve_ref_unsafe(refs, refname, resolve_flags, oid, flags))\n \t\treturn 0;\n \treturn -1;\n }\n@@ -480,7 +480,7 @@ int expand_ref(const char *str, int len, struct object_id *oid, char **ref)\n \t\tstrbuf_reset(&fullref);\n \t\tstrbuf_addf(&fullref, *p, len, str);\n \t\tr = resolve_ref_unsafe(fullref.buf, RESOLVE_REF_READING,\n-\t\t\t\t       this_result->hash, &flag);\n+\t\t\t\t       this_result, &flag);\n \t\tif (r) {\n \t\t\tif (!refs_found++)\n \t\t\t\t*ref = xstrdup(r);\n@@ -511,7 +511,7 @@ int dwim_log(const char *str, int len, struct object_id *oid, char **log)\n \t\tstrbuf_reset(&path);\n \t\tstrbuf_addf(&path, *p, len, str);\n \t\tref = resolve_ref_unsafe(path.buf, RESOLVE_REF_READING,\n-\t\t\t\t\t hash.hash, NULL);\n+\t\t\t\t\t &hash, NULL);\n \t\tif (!ref)\n \t\t\tcontinue;\n \t\tif (reflog_exists(path.buf))\n@@ -1385,15 +1385,15 @@ int refs_read_raw_ref(struct ref_store *ref_store,\n const char *refs_resolve_ref_unsafe(struct ref_store *refs,\n \t\t\t\t    const char *refname,\n \t\t\t\t    int resolve_flags,\n-\t\t\t\t    unsigned char *sha1, int *flags)\n+\t\t\t\t    struct object_id *oid, int *flags)\n {\n \tstatic struct strbuf sb_refname = STRBUF_INIT;\n \tstruct object_id unused_oid;\n \tint unused_flags;\n \tint symref_count;\n \n-\tif (!sha1)\n-\t\tsha1 = unused_oid.hash;\n+\tif (!oid)\n+\t\toid = &unused_oid;\n \tif (!flags)\n \t\tflags = &unused_flags;\n \n@@ -1421,11 +1421,11 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,\n \t\tunsigned int read_flags = 0;\n \n \t\tif (refs_read_raw_ref(refs, refname,\n-\t\t\t\t      sha1, &sb_refname, &read_flags)) {\n+\t\t\t\t      oid->hash, &sb_refname, &read_flags)) {\n \t\t\t*flags |= read_flags;\n \t\t\tif (errno != ENOENT || (resolve_flags & RESOLVE_REF_READING))\n \t\t\t\treturn NULL;\n-\t\t\thashclr(sha1);\n+\t\t\toidclr(oid);\n \t\t\tif (*flags & REF_BAD_NAME)\n \t\t\t\t*flags |= REF_ISBROKEN;\n \t\t\treturn refname;\n@@ -1435,7 +1435,7 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,\n \n \t\tif (!(read_flags & REF_ISSYMREF)) {\n \t\t\tif (*flags & REF_BAD_NAME) {\n-\t\t\t\thashclr(sha1);\n+\t\t\t\toidclr(oid);\n \t\t\t\t*flags |= REF_ISBROKEN;\n \t\t\t}\n \t\t\treturn refname;\n@@ -1443,7 +1443,7 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,\n \n \t\trefname = sb_refname.buf;\n \t\tif (resolve_flags & RESOLVE_REF_NO_RECURSE) {\n-\t\t\thashclr(sha1);\n+\t\t\toidclr(oid);\n \t\t\treturn refname;\n \t\t}\n \t\tif (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {\n@@ -1470,10 +1470,10 @@ int refs_init_db(struct strbuf *err)\n }\n \n const char *resolve_ref_unsafe(const char *refname, int resolve_flags,\n-\t\t\t       unsigned char *sha1, int *flags)\n+\t\t\t       struct object_id *oid, int *flags)\n {\n \treturn refs_resolve_ref_unsafe(get_main_ref_store(), refname,\n-\t\t\t\t       resolve_flags, sha1, flags);\n+\t\t\t\t       resolve_flags, oid, flags);\n }\n \n int resolve_gitlink_ref(const char *submodule, const char *refname,\n@@ -1487,7 +1487,7 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,\n \tif (!refs)\n \t\treturn -1;\n \n-\tif (!refs_resolve_ref_unsafe(refs, refname, 0, oid->hash, &flags) ||\n+\tif (!refs_resolve_ref_unsafe(refs, refname, 0, oid, &flags) ||\n \t    is_null_oid(oid))\n \t\treturn -1;\n \treturn 0;\ndiff --git a/refs.h b/refs.h\nindex bb0dcd97af..4eedc880c6 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -62,10 +62,10 @@ struct worktree;\n const char *refs_resolve_ref_unsafe(struct ref_store *refs,\n \t\t\t\t    const char *refname,\n \t\t\t\t    int resolve_flags,\n-\t\t\t\t    unsigned char *sha1,\n+\t\t\t\t    struct object_id *oid,\n \t\t\t\t    int *flags);\n const char *resolve_ref_unsafe(const char *refname, int resolve_flags,\n-\t\t\t       unsigned char *sha1, int *flags);\n+\t\t\t       struct object_id *oid, int *flags);\n \n char *refs_resolve_refdup(struct ref_store *refs,\n \t\t\t  const char *refname, int resolve_flags,\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 4400e18eee..61f3690299 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -189,7 +189,7 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,\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     oid.hash, &flag)) {\n+\t\t\t\t\t\t     &oid, &flag)) {\n \t\t\t\toidclr(&oid);\n \t\t\t\tflag |= REF_ISBROKEN;\n \t\t\t} else if (is_null_oid(&oid)) {\n@@ -890,7 +890,7 @@ static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,\n \tfiles_ref_path(refs, &ref_file, refname);\n \tresolved = !!refs_resolve_ref_unsafe(&refs->base,\n \t\t\t\t\t     refname, resolve_flags,\n-\t\t\t\t\t     lock->old_oid.hash, type);\n+\t\t\t\t\t     &lock->old_oid, type);\n \tif (!resolved && errno == EISDIR) {\n \t\t/*\n \t\t * we are trying to lock foo but we used to\n@@ -909,7 +909,7 @@ static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,\n \t\t}\n \t\tresolved = !!refs_resolve_ref_unsafe(&refs->base,\n \t\t\t\t\t\t     refname, resolve_flags,\n-\t\t\t\t\t\t     lock->old_oid.hash, type);\n+\t\t\t\t\t\t     &lock->old_oid, type);\n \t}\n \tif (!resolved) {\n \t\tlast_errno = errno;\n@@ -1286,7 +1286,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_oid.hash, &flag)) {\n+\t\t\t\t&orig_oid, &flag)) {\n \t\tret = error(\"refname %s not found\", oldrefname);\n \t\tgoto out;\n \t}\ndiff --git a/sequencer.c b/sequencer.c\nindex f1f895774a..982fc35caf 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -488,7 +488,7 @@ static int is_index_unchanged(void)\n \tstruct object_id head_oid;\n \tstruct commit *head_commit;\n \n-\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, head_oid.hash, NULL))\n+\tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, &head_oid, NULL))\n \t\treturn error(_(\"could not resolve HEAD commit\\n\"));\n \n \thead_commit = lookup_commit(&head_oid);\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex cea3285ada..d846c88ed2 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -127,15 +127,15 @@ static int cmd_for_each_ref(struct ref_store *refs, const char **argv)\n \n static int cmd_resolve_ref(struct ref_store *refs, const char **argv)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tconst char *refname = notnull(*argv++, \"refname\");\n \tint resolve_flags = arg_flags(*argv++, \"resolve-flags\");\n \tint flags;\n \tconst char *ref;\n \n \tref = refs_resolve_ref_unsafe(refs, refname, resolve_flags,\n-\t\t\t\t      sha1, &flags);\n-\tprintf(\"%s %s 0x%x\\n\", sha1_to_hex(sha1), ref, flags);\n+\t\t\t\t      &oid, &flags);\n+\tprintf(\"%s %s 0x%x\\n\", oid_to_hex(&oid), ref, flags);\n \treturn ref ? 0 : 1;\n }\n \ndiff --git a/transport-helper.c b/transport-helper.c\nindex 640ce5a492..bf05a2dcf1 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -942,10 +942,9 @@ static int push_refs_with_export(struct transport *transport,\n \t\t\t\t\tint flag;\n \n \t\t\t\t\t/* Follow symbolic refs (mainly for HEAD). */\n-\t\t\t\t\tname = resolve_ref_unsafe(\n-\t\t\t\t\t\t ref->peer_ref->name,\n-\t\t\t\t\t\t RESOLVE_REF_READING,\n-\t\t\t\t\t\t oid.hash, &flag);\n+\t\t\t\t\tname = resolve_ref_unsafe(ref->peer_ref->name,\n+\t\t\t\t\t\t\t\t  RESOLVE_REF_READING,\n+\t\t\t\t\t\t\t\t  &oid, &flag);\n \t\t\t\t\tif (!name || !(flag & REF_ISSYMREF))\n \t\t\t\t\t\tname = ref->peer_ref->name;\n \ndiff --git a/worktree.c b/worktree.c\nindex cb35db03fa..2799abd555 100644\n--- a/worktree.c\n+++ b/worktree.c\n@@ -31,7 +31,7 @@ static void add_head_info(struct worktree *wt)\n \ttarget = refs_resolve_ref_unsafe(get_worktree_ref_store(wt),\n \t\t\t\t\t \"HEAD\",\n \t\t\t\t\t 0,\n-\t\t\t\t\t wt->head_oid.hash, &flags);\n+\t\t\t\t\t &wt->head_oid, &flags);\n \tif (!target)\n \t\treturn;\n \n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329339","messageId":"20171001220831.214705-15-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 14/24] refs: convert peel_ref to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:21Z","receivedAt":"2017-10-01T22:09:44Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert peel_ref (and its corresponding backend) to struct object_id.\n\nThis transformation was done with an update to the declaration,\ndefinition, and test helper and the following semantic patch:\n\n@@\nexpression E1, E2;\n@@\n- peel_ref(E1, E2.hash)\n+ peel_ref(E1, &E2)\n\n@@\nexpression E1, E2;\n@@\n- peel_ref(E1, E2->hash)\n+ peel_ref(E1, E2)\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/describe.c        | 2 +-\n builtin/pack-objects.c    | 4 ++--\n builtin/show-ref.c        | 2 +-\n refs.c                    | 8 ++++----\n refs.h                    | 4 ++--\n refs/files-backend.c      | 8 ++++----\n refs/packed-backend.c     | 4 ++--\n refs/refs-internal.h      | 2 +-\n t/helper/test-ref-store.c | 6 +++---\n upload-pack.c             | 2 +-\n 10 files changed, 21 insertions(+), 21 deletions(-)\n\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 29075dbd0f..352f8821fd 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -181,7 +181,7 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi\n \t}\n \n \t/* Is it annotated? */\n-\tif (!peel_ref(path, peeled.hash)) {\n+\tif (!peel_ref(path, &peeled)) {\n \t\tis_annotated = !!oidcmp(oid, &peeled);\n \t} else {\n \t\toidcpy(&peeled, oid);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex cde4c96f3d..a2c6029750 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -562,7 +562,7 @@ static int mark_tagged(const char *path, const struct object_id *oid, int flag,\n \n \tif (entry)\n \t\tentry->tagged = 1;\n-\tif (!peel_ref(path, peeled.hash)) {\n+\tif (!peel_ref(path, &peeled)) {\n \t\tentry = packlist_find(&to_pack, peeled.hash, NULL);\n \t\tif (entry)\n \t\t\tentry->tagged = 1;\n@@ -2371,7 +2371,7 @@ static int add_ref_tag(const char *path, const struct object_id *oid, int flag,\n \tstruct object_id peeled;\n \n \tif (starts_with(path, \"refs/tags/\") && /* is a tag? */\n-\t    !peel_ref(path, peeled.hash)    && /* peelable? */\n+\t    !peel_ref(path, &peeled)    && /* peelable? */\n \t    packlist_find(&to_pack, peeled.hash, NULL))      /* object packed? */\n \t\tadd_tag_chain(oid);\n \treturn 0;\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex cbb8cfc7d2..41e5e71cad 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -38,7 +38,7 @@ static void show_one(const char *refname, const struct object_id *oid)\n \tif (!deref_tags)\n \t\treturn;\n \n-\tif (!peel_ref(refname, peeled.hash)) {\n+\tif (!peel_ref(refname, &peeled)) {\n \t\thex = find_unique_abbrev(peeled.hash, abbrev);\n \t\tprintf(\"%s %s^{}\\n\", hex, refname);\n \t}\ndiff --git a/refs.c b/refs.c\nindex c158a2d107..6cbe2c1c6b 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1676,14 +1676,14 @@ int refs_pack_refs(struct ref_store *refs, unsigned int flags)\n }\n \n int refs_peel_ref(struct ref_store *refs, const char *refname,\n-\t\t  unsigned char *sha1)\n+\t\t  struct object_id *oid)\n {\n-\treturn refs->be->peel_ref(refs, refname, sha1);\n+\treturn refs->be->peel_ref(refs, refname, oid);\n }\n \n-int peel_ref(const char *refname, unsigned char *sha1)\n+int peel_ref(const char *refname, struct object_id *oid)\n {\n-\treturn refs_peel_ref(get_main_ref_store(), refname, sha1);\n+\treturn refs_peel_ref(get_main_ref_store(), refname, oid);\n }\n \n int refs_create_symref(struct ref_store *refs,\ndiff --git a/refs.h b/refs.h\nindex 8159b7b067..832ade2b13 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -120,8 +120,8 @@ extern int refs_init_db(struct strbuf *err);\n  * ultimately resolve to a peelable tag.\n  */\n int refs_peel_ref(struct ref_store *refs, const char *refname,\n-\t\t  unsigned char *sha1);\n-int peel_ref(const char *refname, unsigned char *sha1);\n+\t\t  struct object_id *oid);\n+int peel_ref(const char *refname, struct object_id *oid);\n \n /**\n  * Resolve refname in the nested \"gitlink\" repository in the specified\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 148b98490f..a7e4b9e1e9 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -642,7 +642,7 @@ static int lock_raw_ref(struct files_ref_store *refs,\n }\n \n static int files_peel_ref(struct ref_store *ref_store,\n-\t\t\t  const char *refname, unsigned char *sha1)\n+\t\t\t  const char *refname, struct object_id *oid)\n {\n \tstruct files_ref_store *refs =\n \t\tfiles_downcast(ref_store, REF_STORE_READ | REF_STORE_ODB,\n@@ -655,7 +655,7 @@ static int files_peel_ref(struct ref_store *ref_store,\n \n \t\tif (ref_iterator_peel(current_ref_iter, &peeled))\n \t\t\treturn -1;\n-\t\thashcpy(sha1, peeled.hash);\n+\t\toidcpy(oid, &peeled);\n \t\treturn 0;\n \t}\n \n@@ -672,10 +672,10 @@ static int files_peel_ref(struct ref_store *ref_store,\n \t * have REF_KNOWS_PEELED.\n \t */\n \tif (flag & REF_ISPACKED &&\n-\t    !refs_peel_ref(refs->packed_ref_store, refname, sha1))\n+\t    !refs_peel_ref(refs->packed_ref_store, refname, oid))\n \t\treturn 0;\n \n-\treturn peel_object(base.hash, sha1);\n+\treturn peel_object(base.hash, oid->hash);\n }\n \n struct files_ref_iterator {\ndiff --git a/refs/packed-backend.c b/refs/packed-backend.c\nindex 3bc47ffd5e..d4bb4ba357 100644\n--- a/refs/packed-backend.c\n+++ b/refs/packed-backend.c\n@@ -341,7 +341,7 @@ static int packed_read_raw_ref(struct ref_store *ref_store,\n }\n \n static int packed_peel_ref(struct ref_store *ref_store,\n-\t\t\t   const char *refname, unsigned char *sha1)\n+\t\t\t   const char *refname, struct object_id *oid)\n {\n \tstruct packed_ref_store *refs =\n \t\tpacked_downcast(ref_store, REF_STORE_READ | REF_STORE_ODB,\n@@ -351,7 +351,7 @@ static int packed_peel_ref(struct ref_store *ref_store,\n \tif (!r || peel_entry(r, 0))\n \t\treturn -1;\n \n-\thashcpy(sha1, r->u.value.peeled.hash);\n+\toidcpy(oid, &r->u.value.peeled);\n \treturn 0;\n }\n \ndiff --git a/refs/refs-internal.h b/refs/refs-internal.h\nindex 6636a13a62..f0bedbd80b 100644\n--- a/refs/refs-internal.h\n+++ b/refs/refs-internal.h\n@@ -549,7 +549,7 @@ typedef int ref_transaction_commit_fn(struct ref_store *refs,\n \n typedef int pack_refs_fn(struct ref_store *ref_store, unsigned int flags);\n typedef int peel_ref_fn(struct ref_store *ref_store,\n-\t\t\tconst char *refname, unsigned char *sha1);\n+\t\t\tconst char *refname, struct object_id *oid);\n typedef int create_symref_fn(struct ref_store *ref_store,\n \t\t\t     const char *ref_target,\n \t\t\t     const char *refs_heads_master,\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex af8dba9560..cea3285ada 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -72,12 +72,12 @@ static int cmd_pack_refs(struct ref_store *refs, const char **argv)\n static int cmd_peel_ref(struct ref_store *refs, const char **argv)\n {\n \tconst char *refname = notnull(*argv++, \"refname\");\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tint ret;\n \n-\tret = refs_peel_ref(refs, refname, sha1);\n+\tret = refs_peel_ref(refs, refname, &oid);\n \tif (!ret)\n-\t\tputs(sha1_to_hex(sha1));\n+\t\tputs(oid_to_hex(&oid));\n \treturn ret;\n }\n \ndiff --git a/upload-pack.c b/upload-pack.c\nindex 030eba5a0c..6d5f3c0d39 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -955,7 +955,7 @@ static int send_ref(const char *refname, const struct object_id *oid,\n \t\tpacket_write_fmt(1, \"%s %s\\n\", oid_to_hex(oid), refname_nons);\n \t}\n \tcapabilities = NULL;\n-\tif (!peel_ref(refname, peeled.hash))\n+\tif (!peel_ref(refname, &peeled))\n \t\tpacket_write_fmt(1, \"%s %s^{}\\n\", oid_to_hex(&peeled), refname_nons);\n \treturn 0;\n }\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329340","messageId":"20171001220831.214705-19-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 18/24] Convert remaining callers of resolve_gitlink_ref to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:25Z","receivedAt":"2017-10-01T22:09:46Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n diff-lib.c     | 4 ++--\n dir.c          | 8 ++++----\n read-cache.c   | 6 +++---\n unpack-trees.c | 8 ++++----\n 4 files changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 4e0980caa8..af4f1b7865 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -36,7 +36,7 @@ static int check_removed(const struct cache_entry *ce, struct stat *st)\n \tif (has_symlink_leading_path(ce->name, ce_namelen(ce)))\n \t\treturn 1;\n \tif (S_ISDIR(st->st_mode)) {\n-\t\tunsigned char sub[20];\n+\t\tstruct object_id sub;\n \n \t\t/*\n \t\t * If ce is already a gitlink, we can have a plain\n@@ -50,7 +50,7 @@ static int check_removed(const struct cache_entry *ce, struct stat *st)\n \t\t * a directory --- the blob was removed!\n \t\t */\n \t\tif (!S_ISGITLINK(ce->ce_mode) &&\n-\t\t    resolve_gitlink_ref(ce->name, \"HEAD\", sub))\n+\t\t    resolve_gitlink_ref(ce->name, \"HEAD\", sub.hash))\n \t\t\treturn 1;\n \t}\n \treturn 0;\ndiff --git a/dir.c b/dir.c\nindex 1d17b800cf..a4198ba7fd 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1390,8 +1390,8 @@ static enum path_treatment treat_directory(struct dir_struct *dir,\n \t\tif (dir->flags & DIR_SHOW_OTHER_DIRECTORIES)\n \t\t\tbreak;\n \t\tif (!(dir->flags & DIR_NO_GITLINKS)) {\n-\t\t\tunsigned char sha1[20];\n-\t\t\tif (resolve_gitlink_ref(dirname, \"HEAD\", sha1) == 0)\n+\t\t\tstruct object_id oid;\n+\t\t\tif (resolve_gitlink_ref(dirname, \"HEAD\", oid.hash) == 0)\n \t\t\t\treturn path_untracked;\n \t\t}\n \t\treturn path_recurse;\n@@ -2279,10 +2279,10 @@ static int remove_dir_recurse(struct strbuf *path, int flag, int *kept_up)\n \tint ret = 0, original_len = path->len, len, kept_down = 0;\n \tint only_empty = (flag & REMOVE_DIR_EMPTY_ONLY);\n \tint keep_toplevel = (flag & REMOVE_DIR_KEEP_TOPLEVEL);\n-\tunsigned char submodule_head[20];\n+\tstruct object_id submodule_head;\n \n \tif ((flag & REMOVE_DIR_KEEP_NESTED_GIT) &&\n-\t    !resolve_gitlink_ref(path->buf, \"HEAD\", submodule_head)) {\n+\t    !resolve_gitlink_ref(path->buf, \"HEAD\", submodule_head.hash)) {\n \t\t/* Do not descend and nuke a nested git work tree. */\n \t\tif (kept_up)\n \t\t\t*kept_up = 1;\ndiff --git a/read-cache.c b/read-cache.c\nindex 65f4fe8375..131485b3a6 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -191,7 +191,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)\n \n static int ce_compare_gitlink(const struct cache_entry *ce)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \n \t/*\n \t * We don't actually require that the .git directory\n@@ -201,9 +201,9 @@ static int ce_compare_gitlink(const struct cache_entry *ce)\n \t *\n \t * If so, we consider it always to match.\n \t */\n-\tif (resolve_gitlink_ref(ce->name, \"HEAD\", sha1) < 0)\n+\tif (resolve_gitlink_ref(ce->name, \"HEAD\", oid.hash) < 0)\n \t\treturn 0;\n-\treturn hashcmp(sha1, ce->oid.hash);\n+\treturn oidcmp(&oid, &ce->oid);\n }\n \n static int ce_modified_check_fs(const struct cache_entry *ce, struct stat *st)\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 71b70ccb12..0dc76eddfe 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -1541,15 +1541,15 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,\n \tint cnt = 0;\n \n \tif (S_ISGITLINK(ce->ce_mode)) {\n-\t\tunsigned char sha1[20];\n-\t\tint sub_head = resolve_gitlink_ref(ce->name, \"HEAD\", sha1);\n+\t\tstruct object_id oid;\n+\t\tint sub_head = resolve_gitlink_ref(ce->name, \"HEAD\", oid.hash);\n \t\t/*\n \t\t * If we are not going to update the submodule, then\n \t\t * we don't care.\n \t\t */\n-\t\tif (!sub_head && !hashcmp(sha1, ce->oid.hash))\n+\t\tif (!sub_head && !oidcmp(&oid, &ce->oid))\n \t\t\treturn 0;\n-\t\treturn verify_clean_submodule(sub_head ? NULL : sha1_to_hex(sha1),\n+\t\treturn verify_clean_submodule(sub_head ? NULL : oid_to_hex(&oid),\n \t\t\t\t\t      ce, error_type, o);\n \t}\n \n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329341","messageId":"20171001220831.214705-20-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 19/24] refs: convert resolve_gitlink_ref to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:26Z","receivedAt":"2017-10-01T22:09:48Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the declaration and definition of resolve_gitlink_ref to use\nstruct object_id and apply the following semantic patch:\n\n@@\nexpression E1, E2, E3;\n@@\n- resolve_gitlink_ref(E1, E2, E3.hash)\n+ resolve_gitlink_ref(E1, E2, &E3)\n\n@@\nexpression E1, E2, E3;\n@@\n- resolve_gitlink_ref(E1, E2, E3->hash)\n+ resolve_gitlink_ref(E1, E2, E3)\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/update-index.c | 4 ++--\n combine-diff.c         | 2 +-\n diff-lib.c             | 2 +-\n dir.c                  | 4 ++--\n read-cache.c           | 2 +-\n refs.c                 | 6 +++---\n refs.h                 | 2 +-\n sha1_file.c            | 2 +-\n unpack-trees.c         | 2 +-\n 9 files changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 24f4b28951..fefbe60167 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -328,7 +328,7 @@ static int process_directory(const char *path, int len, struct stat *st)\n \t\tif (S_ISGITLINK(ce->ce_mode)) {\n \n \t\t\t/* Do nothing to the index if there is no HEAD! */\n-\t\t\tif (resolve_gitlink_ref(path, \"HEAD\", oid.hash) < 0)\n+\t\t\tif (resolve_gitlink_ref(path, \"HEAD\", &oid) < 0)\n \t\t\t\treturn 0;\n \n \t\t\treturn add_one_path(ce, path, len, st);\n@@ -354,7 +354,7 @@ static int process_directory(const char *path, int len, struct stat *st)\n \t}\n \n \t/* No match - should we add it as a gitlink? */\n-\tif (!resolve_gitlink_ref(path, \"HEAD\", oid.hash))\n+\tif (!resolve_gitlink_ref(path, \"HEAD\", &oid))\n \t\treturn add_one_path(NULL, path, len, st);\n \n \t/* Error out. */\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 9e163d5ada..82f6070977 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1014,7 +1014,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\telem->mode = canon_mode(st.st_mode);\n \t\t} else if (S_ISDIR(st.st_mode)) {\n \t\t\tstruct object_id oid;\n-\t\t\tif (resolve_gitlink_ref(elem->path, \"HEAD\", oid.hash) < 0)\n+\t\t\tif (resolve_gitlink_ref(elem->path, \"HEAD\", &oid) < 0)\n \t\t\t\tresult = grab_blob(&elem->oid, elem->mode,\n \t\t\t\t\t\t   &result_size, NULL, NULL);\n \t\t\telse\ndiff --git a/diff-lib.c b/diff-lib.c\nindex af4f1b7865..d2ea02f4d7 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -50,7 +50,7 @@ static int check_removed(const struct cache_entry *ce, struct stat *st)\n \t\t * a directory --- the blob was removed!\n \t\t */\n \t\tif (!S_ISGITLINK(ce->ce_mode) &&\n-\t\t    resolve_gitlink_ref(ce->name, \"HEAD\", sub.hash))\n+\t\t    resolve_gitlink_ref(ce->name, \"HEAD\", &sub))\n \t\t\treturn 1;\n \t}\n \treturn 0;\ndiff --git a/dir.c b/dir.c\nindex a4198ba7fd..f09a31e102 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1391,7 +1391,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,\n \t\t\tbreak;\n \t\tif (!(dir->flags & DIR_NO_GITLINKS)) {\n \t\t\tstruct object_id oid;\n-\t\t\tif (resolve_gitlink_ref(dirname, \"HEAD\", oid.hash) == 0)\n+\t\t\tif (resolve_gitlink_ref(dirname, \"HEAD\", &oid) == 0)\n \t\t\t\treturn path_untracked;\n \t\t}\n \t\treturn path_recurse;\n@@ -2282,7 +2282,7 @@ static int remove_dir_recurse(struct strbuf *path, int flag, int *kept_up)\n \tstruct object_id submodule_head;\n \n \tif ((flag & REMOVE_DIR_KEEP_NESTED_GIT) &&\n-\t    !resolve_gitlink_ref(path->buf, \"HEAD\", submodule_head.hash)) {\n+\t    !resolve_gitlink_ref(path->buf, \"HEAD\", &submodule_head)) {\n \t\t/* Do not descend and nuke a nested git work tree. */\n \t\tif (kept_up)\n \t\t\t*kept_up = 1;\ndiff --git a/read-cache.c b/read-cache.c\nindex 131485b3a6..7766196aff 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -201,7 +201,7 @@ static int ce_compare_gitlink(const struct cache_entry *ce)\n \t *\n \t * If so, we consider it always to match.\n \t */\n-\tif (resolve_gitlink_ref(ce->name, \"HEAD\", oid.hash) < 0)\n+\tif (resolve_gitlink_ref(ce->name, \"HEAD\", &oid) < 0)\n \t\treturn 0;\n \treturn oidcmp(&oid, &ce->oid);\n }\ndiff --git a/refs.c b/refs.c\nindex d2fd0d2a69..3329d47d16 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1477,7 +1477,7 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags,\n }\n \n int resolve_gitlink_ref(const char *submodule, const char *refname,\n-\t\t\tunsigned char *sha1)\n+\t\t\tstruct object_id *oid)\n {\n \tstruct ref_store *refs;\n \tint flags;\n@@ -1487,8 +1487,8 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,\n \tif (!refs)\n \t\treturn -1;\n \n-\tif (!refs_resolve_ref_unsafe(refs, refname, 0, sha1, &flags) ||\n-\t    is_null_sha1(sha1))\n+\tif (!refs_resolve_ref_unsafe(refs, refname, 0, oid->hash, &flags) ||\n+\t    is_null_oid(oid))\n \t\treturn -1;\n \treturn 0;\n }\ndiff --git a/refs.h b/refs.h\nindex 1bc241424d..bb0dcd97af 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -130,7 +130,7 @@ int peel_ref(const char *refname, struct object_id *oid);\n  * otherwise, return a non-zero value.\n  */\n int resolve_gitlink_ref(const char *submodule, const char *refname,\n-\t\t\tunsigned char *sha1);\n+\t\t\tstruct object_id *oid);\n \n /*\n  * Return true iff abbrev_name is a possible abbreviation for\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 793fd2d194..f8c82ce2a2 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1832,7 +1832,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne\n \t\tstrbuf_release(&sb);\n \t\tbreak;\n \tcase S_IFDIR:\n-\t\treturn resolve_gitlink_ref(path, \"HEAD\", oid->hash);\n+\t\treturn resolve_gitlink_ref(path, \"HEAD\", oid);\n \tdefault:\n \t\treturn error(\"%s: unsupported file type\", path);\n \t}\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 0dc76eddfe..25740cb593 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -1542,7 +1542,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,\n \n \tif (S_ISGITLINK(ce->ce_mode)) {\n \t\tstruct object_id oid;\n-\t\tint sub_head = resolve_gitlink_ref(ce->name, \"HEAD\", oid.hash);\n+\t\tint sub_head = resolve_gitlink_ref(ce->name, \"HEAD\", &oid);\n \t\t/*\n \t\t * If we are not going to update the submodule, then\n \t\t * we don't care.\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329342","messageId":"20171001220831.214705-10-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 09/24] refs: convert dwim_ref and expand_ref to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:16Z","receivedAt":"2017-10-01T22:09:52Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"All of the callers of these functions just pass the hash member of a\nstruct object_id, so convert them to use a pointer to struct object_id\ndirectly.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n archive.c             |  2 +-\n branch.c              |  2 +-\n builtin/fast-export.c |  2 +-\n builtin/log.c         |  2 +-\n builtin/merge-base.c  |  2 +-\n builtin/merge.c       |  2 +-\n builtin/rev-parse.c   |  2 +-\n builtin/show-branch.c |  2 +-\n bundle.c              |  2 +-\n refs.c                | 14 +++++++-------\n refs.h                |  4 ++--\n remote.c              |  3 +--\n sha1_name.c           |  6 +++---\n upload-pack.c         |  2 +-\n wt-status.c           |  2 +-\n 15 files changed, 24 insertions(+), 25 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 1e41f4bbeb..0b7b62af0c 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -371,7 +371,7 @@ static void parse_treeish_arg(const char **argv,\n \t\tconst char *colon = strchrnul(name, ':');\n \t\tint refnamelen = colon - name;\n \n-\t\tif (!dwim_ref(name, refnamelen, oid.hash, &ref))\n+\t\tif (!dwim_ref(name, refnamelen, &oid, &ref))\n \t\t\tdie(\"no such ref: %.*s\", refnamelen, name);\n \t\tfree(ref);\n \t}\ndiff --git a/branch.c b/branch.c\nindex 45029ea142..62f7b0d8c2 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -264,7 +264,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), oid.hash, &real_ref)) {\n+\tswitch (dwim_ref(start_name, strlen(start_name), &oid, &real_ref)) {\n \tcase 0:\n \t\t/* Not branching from any existing branch */\n \t\tif (explicit_tracking)\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 2fb60d6d48..d74c73f777 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -823,7 +823,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)\n \t\tif (e->flags & UNINTERESTING)\n \t\t\tcontinue;\n \n-\t\tif (dwim_ref(e->name, strlen(e->name), oid.hash, &full_name) != 1)\n+\t\tif (dwim_ref(e->name, strlen(e->name), &oid, &full_name) != 1)\n \t\t\tcontinue;\n \n \t\tif (refspecs) {\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d81a09051e..ba9d4cd786 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -975,7 +975,7 @@ static char *find_branch_name(struct rev_info *rev)\n \t\treturn NULL;\n \tref = rev->cmdline.rev[positive].name;\n \ttip_oid = &rev->cmdline.rev[positive].item->oid;\n-\tif (dwim_ref(ref, strlen(ref), branch_oid.hash, &full_ref) &&\n+\tif (dwim_ref(ref, strlen(ref), &branch_oid, &full_ref) &&\n \t    skip_prefix(full_ref, \"refs/heads/\", &v) &&\n \t    !oidcmp(tip_oid, &branch_oid))\n \t\tbranch = xstrdup(v);\ndiff --git a/builtin/merge-base.c b/builtin/merge-base.c\nindex 6dbd167d3b..e99f5405ce 100644\n--- a/builtin/merge-base.c\n+++ b/builtin/merge-base.c\n@@ -156,7 +156,7 @@ static int handle_fork_point(int argc, const char **argv)\n \tstruct commit_list *bases;\n \tint i, ret = 0;\n \n-\tswitch (dwim_ref(argv[0], strlen(argv[0]), oid.hash, &refname)) {\n+\tswitch (dwim_ref(argv[0], strlen(argv[0]), &oid, &refname)) {\n \tcase 0:\n \t\tdie(\"No such ref: '%s'\", argv[0]);\n \tcase 1:\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 99d2df965f..6071dbfe34 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -454,7 +454,7 @@ static void merge_name(const char *remote, struct strbuf *msg)\n \tif (!remote_head)\n \t\tdie(_(\"'%s' does not point to a commit\"), remote);\n \n-\tif (dwim_ref(remote, strlen(remote), branch_head.hash, &found_ref) > 0) {\n+\tif (dwim_ref(remote, strlen(remote), &branch_head, &found_ref) > 0) {\n \t\tif (starts_with(found_ref, \"refs/heads/\")) {\n \t\t\tstrbuf_addf(msg, \"%s\\t\\tbranch '%s' of .\\n\",\n \t\t\t\t    oid_to_hex(&branch_head), remote);\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex b9c13d3d9d..ad20a948f0 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -133,7 +133,7 @@ static void show_rev(int type, const struct object_id *oid, const char *name)\n \t\t\tstruct object_id discard;\n \t\t\tchar *full;\n \n-\t\t\tswitch (dwim_ref(name, strlen(name), discard.hash, &full)) {\n+\t\t\tswitch (dwim_ref(name, strlen(name), &discard, &full)) {\n \t\t\tcase 0:\n \t\t\t\t/*\n \t\t\t\t * Not found -- not a ref.  We could\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 0237be4975..722a7f4bec 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -720,7 +720,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\t\tdie(Q_(\"only %d entry can be shown at one time.\",\n \t\t\t       \"only %d entries can be shown at one time.\",\n \t\t\t       MAX_REVS), MAX_REVS);\n-\t\tif (!dwim_ref(*av, strlen(*av), oid.hash, &ref))\n+\t\tif (!dwim_ref(*av, strlen(*av), &oid, &ref))\n \t\t\tdie(_(\"no such ref %s\"), *av);\n \n \t\t/* Has the base been specified? */\ndiff --git a/bundle.c b/bundle.c\nindex 12658c5c9f..93290962c9 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -338,7 +338,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)\n \n \t\tif (e->item->flags & UNINTERESTING)\n \t\t\tcontinue;\n-\t\tif (dwim_ref(e->name, strlen(e->name), oid.hash, &ref) != 1)\n+\t\tif (dwim_ref(e->name, strlen(e->name), &oid, &ref) != 1)\n \t\t\tgoto skip_write_ref;\n \t\tif (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flag))\n \t\t\tflag = 0;\ndiff --git a/refs.c b/refs.c\nindex d6f8587b57..db683248c7 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -456,15 +456,15 @@ static char *substitute_branch_name(const char **string, int *len)\n \treturn NULL;\n }\n \n-int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)\n+int dwim_ref(const char *str, int len, struct object_id *oid, char **ref)\n {\n \tchar *last_branch = substitute_branch_name(&str, &len);\n-\tint   refs_found  = expand_ref(str, len, sha1, ref);\n+\tint   refs_found  = expand_ref(str, len, oid, ref);\n \tfree(last_branch);\n \treturn refs_found;\n }\n \n-int expand_ref(const char *str, int len, unsigned char *sha1, char **ref)\n+int expand_ref(const char *str, int len, struct object_id *oid, char **ref)\n {\n \tconst char **p, *r;\n \tint refs_found = 0;\n@@ -472,15 +472,15 @@ int expand_ref(const char *str, int len, unsigned char *sha1, char **ref)\n \n \t*ref = NULL;\n \tfor (p = ref_rev_parse_rules; *p; p++) {\n-\t\tunsigned char sha1_from_ref[20];\n-\t\tunsigned char *this_result;\n+\t\tstruct object_id oid_from_ref;\n+\t\tstruct object_id *this_result;\n \t\tint flag;\n \n-\t\tthis_result = refs_found ? sha1_from_ref : sha1;\n+\t\tthis_result = refs_found ? &oid_from_ref : oid;\n \t\tstrbuf_reset(&fullref);\n \t\tstrbuf_addf(&fullref, *p, len, str);\n \t\tr = resolve_ref_unsafe(fullref.buf, RESOLVE_REF_READING,\n-\t\t\t\t       this_result, &flag);\n+\t\t\t\t       this_result->hash, &flag);\n \t\tif (r) {\n \t\t\tif (!refs_found++)\n \t\t\t\t*ref = xstrdup(r);\ndiff --git a/refs.h b/refs.h\nindex a2032b8397..832a77183c 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -139,8 +139,8 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,\n  */\n int refname_match(const char *abbrev_name, const char *full_name);\n \n-int expand_ref(const char *str, int len, unsigned char *sha1, char **ref);\n-int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref);\n+int expand_ref(const char *str, int len, struct object_id *oid, char **ref);\n+int dwim_ref(const char *str, int len, struct object_id *oid, char **ref);\n int dwim_log(const char *str, int len, unsigned char *sha1, char **ref);\n \n /*\ndiff --git a/remote.c b/remote.c\nindex 698a890a83..439d3b32f2 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1628,8 +1628,7 @@ static void set_merge(struct branch *ret)\n \t\tif (!remote_find_tracking(remote, ret->merge[i]) ||\n \t\t    strcmp(ret->remote_name, \".\"))\n \t\t\tcontinue;\n-\t\tif (dwim_ref(ret->merge_name[i], strlen(ret->merge_name[i]),\n-\t\t\t     oid.hash, &ref) == 1)\n+\t\tif (dwim_ref(ret->merge_name[i], strlen(ret->merge_name[i]), &oid, &ref) == 1)\n \t\t\tret->merge[i]->dst = ref;\n \t\telse\n \t\t\tret->merge[i]->dst = xstrdup(ret->merge_name[i]);\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 134ac9742f..28bad3e74b 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -603,7 +603,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,\n \n \tif (len == GIT_SHA1_HEXSZ && !get_oid_hex(str, oid)) {\n \t\tif (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {\n-\t\t\trefs_found = dwim_ref(str, len, tmp_oid.hash, &real_ref);\n+\t\t\trefs_found = dwim_ref(str, len, &tmp_oid, &real_ref);\n \t\t\tif (refs_found > 0) {\n \t\t\t\twarning(warn_msg, len, str);\n \t\t\t\tif (advice_object_name_warning)\n@@ -654,11 +654,11 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,\n \n \tif (!len && reflog_len)\n \t\t/* allow \"@{...}\" to mean the current branch reflog */\n-\t\trefs_found = dwim_ref(\"HEAD\", 4, oid->hash, &real_ref);\n+\t\trefs_found = dwim_ref(\"HEAD\", 4, oid, &real_ref);\n \telse if (reflog_len)\n \t\trefs_found = dwim_log(str, len, oid->hash, &real_ref);\n \telse\n-\t\trefs_found = dwim_ref(str, len, oid->hash, &real_ref);\n+\t\trefs_found = dwim_ref(str, len, oid, &real_ref);\n \n \tif (!refs_found)\n \t\treturn -1;\ndiff --git a/upload-pack.c b/upload-pack.c\nindex e25f725c0f..030eba5a0c 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -787,7 +787,7 @@ static void receive_needs(void)\n \t\tif (skip_prefix(line, \"deepen-not \", &arg)) {\n \t\t\tchar *ref = NULL;\n \t\t\tstruct object_id oid;\n-\t\t\tif (expand_ref(arg, strlen(arg), oid.hash, &ref) != 1)\n+\t\t\tif (expand_ref(arg, strlen(arg), &oid, &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);\ndiff --git a/wt-status.c b/wt-status.c\nindex 6d7d675a5b..280518a89b 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1451,7 +1451,7 @@ static void wt_status_get_detached_from(struct wt_status_state *state)\n \t\treturn;\n \t}\n \n-\tif (dwim_ref(cb.buf.buf, cb.buf.len, oid.hash, &ref) == 1 &&\n+\tif (dwim_ref(cb.buf.buf, cb.buf.len, &oid, &ref) == 1 &&\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-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329343","messageId":"20171001220831.214705-14-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 13/24] builtin/pack-objects: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:20Z","receivedAt":"2017-10-01T22:09:55Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is one of the last unconverted callers to peel_ref.  While we're\nfixing that, convert the rest of the file, since it will need to be\nconverted at some point anyway.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/pack-objects.c | 131 +++++++++++++++++++++++++------------------------\n 1 file changed, 66 insertions(+), 65 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 180c17904b..cde4c96f3d 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -151,7 +151,7 @@ static unsigned long do_compress(void **pptr, unsigned long size)\n }\n \n static unsigned long write_large_blob_data(struct git_istream *st, struct sha1file *f,\n-\t\t\t\t\t   const unsigned char *sha1)\n+\t\t\t\t\t   const struct object_id *oid)\n {\n \tgit_zstream stream;\n \tunsigned char ibuf[1024 * 16];\n@@ -165,7 +165,7 @@ static unsigned long write_large_blob_data(struct git_istream *st, struct sha1fi\n \t\tint zret = Z_OK;\n \t\treadlen = read_istream(st, ibuf, sizeof(ibuf));\n \t\tif (readlen == -1)\n-\t\t\tdie(_(\"unable to read %s\"), sha1_to_hex(sha1));\n+\t\t\tdie(_(\"unable to read %s\"), oid_to_hex(oid));\n \n \t\tstream.next_in = ibuf;\n \t\tstream.avail_in = readlen;\n@@ -339,7 +339,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.oid.hash);\n+\t\tdatalen = write_large_blob_data(st, f, &entry->idx.oid);\n \t\tclose_istream(st);\n \t} else {\n \t\tsha1write(f, buf, datalen);\n@@ -557,13 +557,13 @@ static enum write_one_status write_one(struct sha1file *f,\n static int mark_tagged(const char *path, const struct object_id *oid, int flag,\n \t\t       void *cb_data)\n {\n-\tunsigned char peeled[20];\n+\tstruct object_id peeled;\n \tstruct object_entry *entry = packlist_find(&to_pack, oid->hash, NULL);\n \n \tif (entry)\n \t\tentry->tagged = 1;\n-\tif (!peel_ref(path, peeled)) {\n-\t\tentry = packlist_find(&to_pack, peeled, NULL);\n+\tif (!peel_ref(path, peeled.hash)) {\n+\t\tentry = packlist_find(&to_pack, peeled.hash, NULL);\n \t\tif (entry)\n \t\t\tentry->tagged = 1;\n \t}\n@@ -792,7 +792,7 @@ static void write_pack_file(void)\n \twrite_order = compute_write_order();\n \n \tdo {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tchar *pack_tmp_name = NULL;\n \n \t\tif (pack_to_stdout)\n@@ -823,13 +823,13 @@ static void write_pack_file(void)\n \t\t * If so, rewrite it like in fast-import\n \t\t */\n \t\tif (pack_to_stdout) {\n-\t\t\tsha1close(f, sha1, CSUM_CLOSE);\n+\t\t\tsha1close(f, oid.hash, CSUM_CLOSE);\n \t\t} else if (nr_written == nr_remaining) {\n-\t\t\tsha1close(f, sha1, CSUM_FSYNC);\n+\t\t\tsha1close(f, oid.hash, CSUM_FSYNC);\n \t\t} else {\n-\t\t\tint fd = sha1close(f, sha1, 0);\n-\t\t\tfixup_pack_header_footer(fd, sha1, pack_tmp_name,\n-\t\t\t\t\t\t nr_written, sha1, offset);\n+\t\t\tint fd = sha1close(f, oid.hash, 0);\n+\t\t\tfixup_pack_header_footer(fd, oid.hash, pack_tmp_name,\n+\t\t\t\t\t\t nr_written, oid.hash, offset);\n \t\t\tclose(fd);\n \t\t\tif (write_bitmap_index) {\n \t\t\t\twarning(_(no_split_warning));\n@@ -863,16 +863,16 @@ static void write_pack_file(void)\n \t\t\tstrbuf_addf(&tmpname, \"%s-\", base_name);\n \n \t\t\tif (write_bitmap_index) {\n-\t\t\t\tbitmap_writer_set_checksum(sha1);\n+\t\t\t\tbitmap_writer_set_checksum(oid.hash);\n \t\t\t\tbitmap_writer_build_type_index(written_list, nr_written);\n \t\t\t}\n \n \t\t\tfinish_tmp_packfile(&tmpname, pack_tmp_name,\n \t\t\t\t\t    written_list, nr_written,\n-\t\t\t\t\t    &pack_idx_opts, sha1);\n+\t\t\t\t\t    &pack_idx_opts, oid.hash);\n \n \t\t\tif (write_bitmap_index) {\n-\t\t\t\tstrbuf_addf(&tmpname, \"%s.bitmap\", sha1_to_hex(sha1));\n+\t\t\t\tstrbuf_addf(&tmpname, \"%s.bitmap\", oid_to_hex(&oid));\n \n \t\t\t\tstop_progress(&progress_state);\n \n@@ -887,7 +887,7 @@ static void write_pack_file(void)\n \n \t\t\tstrbuf_release(&tmpname);\n \t\t\tfree(pack_tmp_name);\n-\t\t\tputs(sha1_to_hex(sha1));\n+\t\t\tputs(oid_to_hex(&oid));\n \t\t}\n \n \t\t/* mark written objects as written to previous pack */\n@@ -928,13 +928,13 @@ static int no_try_delta(const char *path)\n  * found the item, since that saves us from having to look it up again a\n  * few lines later when we want to add the new entry.\n  */\n-static int have_duplicate_entry(const unsigned char *sha1,\n+static int have_duplicate_entry(const struct object_id *oid,\n \t\t\t\tint exclude,\n \t\t\t\tuint32_t *index_pos)\n {\n \tstruct object_entry *entry;\n \n-\tentry = packlist_find(&to_pack, sha1, index_pos);\n+\tentry = packlist_find(&to_pack, oid->hash, index_pos);\n \tif (!entry)\n \t\treturn 0;\n \n@@ -990,7 +990,7 @@ static int want_found_object(int exclude, struct packed_git *p)\n  * function finds if there is any pack that has the object and returns the pack\n  * and its offset in these variables.\n  */\n-static int want_object_in_pack(const unsigned char *sha1,\n+static int want_object_in_pack(const struct object_id *oid,\n \t\t\t       int exclude,\n \t\t\t       struct packed_git **found_pack,\n \t\t\t       off_t *found_offset)\n@@ -998,7 +998,7 @@ static int want_object_in_pack(const unsigned char *sha1,\n \tstruct mru_entry *entry;\n \tint want;\n \n-\tif (!exclude && local && has_loose_object_nonlocal(sha1))\n+\tif (!exclude && local && has_loose_object_nonlocal(oid->hash))\n \t\treturn 0;\n \n \t/*\n@@ -1019,7 +1019,7 @@ static int want_object_in_pack(const unsigned char *sha1,\n \t\tif (p == *found_pack)\n \t\t\toffset = *found_offset;\n \t\telse\n-\t\t\toffset = find_pack_entry_one(sha1, p);\n+\t\t\toffset = find_pack_entry_one(oid->hash, p);\n \n \t\tif (offset) {\n \t\t\tif (!*found_pack) {\n@@ -1039,7 +1039,7 @@ static int want_object_in_pack(const unsigned char *sha1,\n \treturn 1;\n }\n \n-static void create_object_entry(const unsigned char *sha1,\n+static void create_object_entry(const struct object_id *oid,\n \t\t\t\tenum object_type type,\n \t\t\t\tuint32_t hash,\n \t\t\t\tint exclude,\n@@ -1050,7 +1050,7 @@ static void create_object_entry(const unsigned char *sha1,\n {\n \tstruct object_entry *entry;\n \n-\tentry = packlist_alloc(&to_pack, sha1, index_pos);\n+\tentry = packlist_alloc(&to_pack, oid->hash, index_pos);\n \tentry->hash = hash;\n \tif (type)\n \t\tentry->type = type;\n@@ -1070,17 +1070,17 @@ static const char no_closure_warning[] = N_(\n \"disabling bitmap writing, as some objects are not being packed\"\n );\n \n-static int add_object_entry(const unsigned char *sha1, enum object_type type,\n+static int add_object_entry(const struct object_id *oid, enum object_type type,\n \t\t\t    const char *name, int exclude)\n {\n \tstruct packed_git *found_pack = NULL;\n \toff_t found_offset = 0;\n \tuint32_t index_pos;\n \n-\tif (have_duplicate_entry(sha1, exclude, &index_pos))\n+\tif (have_duplicate_entry(oid, exclude, &index_pos))\n \t\treturn 0;\n \n-\tif (!want_object_in_pack(sha1, exclude, &found_pack, &found_offset)) {\n+\tif (!want_object_in_pack(oid, exclude, &found_pack, &found_offset)) {\n \t\t/* The pack is missing an object, so it will not have closure */\n \t\tif (write_bitmap_index) {\n \t\t\twarning(_(no_closure_warning));\n@@ -1089,7 +1089,7 @@ static int add_object_entry(const unsigned char *sha1, enum object_type type,\n \t\treturn 0;\n \t}\n \n-\tcreate_object_entry(sha1, type, pack_name_hash(name),\n+\tcreate_object_entry(oid, type, pack_name_hash(name),\n \t\t\t    exclude, name && no_try_delta(name),\n \t\t\t    index_pos, found_pack, found_offset);\n \n@@ -1104,20 +1104,20 @@ static int add_object_entry_from_bitmap(const struct object_id *oid,\n {\n \tuint32_t index_pos;\n \n-\tif (have_duplicate_entry(oid->hash, 0, &index_pos))\n+\tif (have_duplicate_entry(oid, 0, &index_pos))\n \t\treturn 0;\n \n-\tif (!want_object_in_pack(oid->hash, 0, &pack, &offset))\n+\tif (!want_object_in_pack(oid, 0, &pack, &offset))\n \t\treturn 0;\n \n-\tcreate_object_entry(oid->hash, type, name_hash, 0, 0, index_pos, pack, offset);\n+\tcreate_object_entry(oid, type, name_hash, 0, 0, index_pos, pack, offset);\n \n \tdisplay_progress(progress_state, nr_result);\n \treturn 1;\n }\n \n struct pbase_tree_cache {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tint ref;\n \tint temporary;\n \tvoid *tree_data;\n@@ -1125,9 +1125,9 @@ struct pbase_tree_cache {\n };\n \n static struct pbase_tree_cache *(pbase_tree_cache[256]);\n-static int pbase_tree_cache_ix(const unsigned char *sha1)\n+static int pbase_tree_cache_ix(const struct object_id *oid)\n {\n-\treturn sha1[0] % ARRAY_SIZE(pbase_tree_cache);\n+\treturn oid->hash[0] % ARRAY_SIZE(pbase_tree_cache);\n }\n static int pbase_tree_cache_ix_incr(int ix)\n {\n@@ -1144,14 +1144,14 @@ static struct pbase_tree {\n \tstruct pbase_tree_cache pcache;\n } *pbase_tree;\n \n-static struct pbase_tree_cache *pbase_tree_get(const unsigned char *sha1)\n+static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n {\n \tstruct pbase_tree_cache *ent, *nent;\n \tvoid *data;\n \tunsigned long size;\n \tenum object_type type;\n \tint neigh;\n-\tint my_ix = pbase_tree_cache_ix(sha1);\n+\tint my_ix = pbase_tree_cache_ix(oid);\n \tint available_ix = -1;\n \n \t/* pbase-tree-cache acts as a limited hashtable.\n@@ -1160,7 +1160,7 @@ static struct pbase_tree_cache *pbase_tree_get(const unsigned char *sha1)\n \t */\n \tfor (neigh = 0; neigh < 8; neigh++) {\n \t\tent = pbase_tree_cache[my_ix];\n-\t\tif (ent && !hashcmp(ent->sha1, sha1)) {\n+\t\tif (ent && !oidcmp(&ent->oid, oid)) {\n \t\t\tent->ref++;\n \t\t\treturn ent;\n \t\t}\n@@ -1176,7 +1176,7 @@ static struct pbase_tree_cache *pbase_tree_get(const unsigned char *sha1)\n \t/* Did not find one.  Either we got a bogus request or\n \t * we need to read and perhaps cache.\n \t */\n-\tdata = read_sha1_file(sha1, &type, &size);\n+\tdata = read_sha1_file(oid->hash, &type, &size);\n \tif (!data)\n \t\treturn NULL;\n \tif (type != OBJ_TREE) {\n@@ -1202,7 +1202,7 @@ static struct pbase_tree_cache *pbase_tree_get(const unsigned char *sha1)\n \t\tfree(ent->tree_data);\n \t\tnent = ent;\n \t}\n-\thashcpy(nent->sha1, sha1);\n+\toidcpy(&nent->oid, oid);\n \tnent->tree_data = data;\n \tnent->tree_size = size;\n \tnent->ref = 1;\n@@ -1247,7 +1247,7 @@ static void add_pbase_object(struct tree_desc *tree,\n \t\tif (cmp < 0)\n \t\t\treturn;\n \t\tif (name[cmplen] != '/') {\n-\t\t\tadd_object_entry(entry.oid->hash,\n+\t\t\tadd_object_entry(entry.oid,\n \t\t\t\t\t object_type(entry.mode),\n \t\t\t\t\t fullname, 1);\n \t\t\treturn;\n@@ -1258,7 +1258,7 @@ static void add_pbase_object(struct tree_desc *tree,\n \t\t\tconst char *down = name+cmplen+1;\n \t\t\tint downlen = name_cmp_len(down);\n \n-\t\t\ttree = pbase_tree_get(entry.oid->hash);\n+\t\t\ttree = pbase_tree_get(entry.oid);\n \t\t\tif (!tree)\n \t\t\t\treturn;\n \t\t\tinit_tree_desc(&sub, tree->tree_data, tree->tree_size);\n@@ -1317,7 +1317,7 @@ static void add_preferred_base_object(const char *name)\n \tcmplen = name_cmp_len(name);\n \tfor (it = pbase_tree; it; it = it->next) {\n \t\tif (cmplen == 0) {\n-\t\t\tadd_object_entry(it->pcache.sha1, OBJ_TREE, NULL, 1);\n+\t\t\tadd_object_entry(&it->pcache.oid, OBJ_TREE, NULL, 1);\n \t\t}\n \t\telse {\n \t\t\tstruct tree_desc tree;\n@@ -1327,22 +1327,22 @@ static void add_preferred_base_object(const char *name)\n \t}\n }\n \n-static void add_preferred_base(unsigned char *sha1)\n+static void add_preferred_base(struct object_id *oid)\n {\n \tstruct pbase_tree *it;\n \tvoid *data;\n \tunsigned long size;\n-\tunsigned char tree_sha1[20];\n+\tstruct object_id tree_oid;\n \n \tif (window <= num_preferred_base++)\n \t\treturn;\n \n-\tdata = read_object_with_reference(sha1, tree_type, &size, tree_sha1);\n+\tdata = read_object_with_reference(oid->hash, tree_type, &size, tree_oid.hash);\n \tif (!data)\n \t\treturn;\n \n \tfor (it = pbase_tree; it; it = it->next) {\n-\t\tif (!hashcmp(it->pcache.sha1, tree_sha1)) {\n+\t\tif (!oidcmp(&it->pcache.oid, &tree_oid)) {\n \t\t\tfree(data);\n \t\t\treturn;\n \t\t}\n@@ -1352,7 +1352,7 @@ static void add_preferred_base(unsigned char *sha1)\n \tit->next = pbase_tree;\n \tpbase_tree = it;\n \n-\thashcpy(it->pcache.sha1, tree_sha1);\n+\toidcpy(&it->pcache.oid, &tree_oid);\n \tit->pcache.tree_data = data;\n \tit->pcache.tree_size = size;\n }\n@@ -2357,7 +2357,7 @@ static void add_tag_chain(const struct object_id *oid)\n \t\t\tdie(\"unable to pack objects reachable from tag %s\",\n \t\t\t    oid_to_hex(oid));\n \n-\t\tadd_object_entry(tag->object.oid.hash, OBJ_TAG, NULL, 0);\n+\t\tadd_object_entry(&tag->object.oid, OBJ_TAG, NULL, 0);\n \n \t\tif (tag->tagged->type != OBJ_TAG)\n \t\t\treturn;\n@@ -2505,8 +2505,9 @@ static int git_pack_config(const char *k, const char *v, void *cb)\n \n static void read_object_list_from_stdin(void)\n {\n-\tchar line[40 + 1 + PATH_MAX + 2];\n-\tunsigned char sha1[20];\n+\tchar line[GIT_MAX_HEXSZ + 1 + PATH_MAX + 2];\n+\tstruct object_id oid;\n+\tconst char *p;\n \n \tfor (;;) {\n \t\tif (!fgets(line, sizeof(line), stdin)) {\n@@ -2520,17 +2521,17 @@ static void read_object_list_from_stdin(void)\n \t\t\tcontinue;\n \t\t}\n \t\tif (line[0] == '-') {\n-\t\t\tif (get_sha1_hex(line+1, sha1))\n+\t\t\tif (get_oid_hex(line+1, &oid))\n \t\t\t\tdie(\"expected edge sha1, got garbage:\\n %s\",\n \t\t\t\t    line);\n-\t\t\tadd_preferred_base(sha1);\n+\t\t\tadd_preferred_base(&oid);\n \t\t\tcontinue;\n \t\t}\n-\t\tif (get_sha1_hex(line, sha1))\n+\t\tif (parse_oid_hex(line, &oid, &p))\n \t\t\tdie(\"expected sha1, got garbage:\\n %s\", line);\n \n-\t\tadd_preferred_base_object(line+41);\n-\t\tadd_object_entry(sha1, 0, line+41, 0);\n+\t\tadd_preferred_base_object(p + 1);\n+\t\tadd_object_entry(&oid, 0, p + 1, 0);\n \t}\n }\n \n@@ -2538,7 +2539,7 @@ static void read_object_list_from_stdin(void)\n \n static void show_commit(struct commit *commit, void *data)\n {\n-\tadd_object_entry(commit->object.oid.hash, OBJ_COMMIT, NULL, 0);\n+\tadd_object_entry(&commit->object.oid, OBJ_COMMIT, NULL, 0);\n \tcommit->object.flags |= OBJECT_ADDED;\n \n \tif (write_bitmap_index)\n@@ -2548,13 +2549,13 @@ static void show_commit(struct commit *commit, void *data)\n static void show_object(struct object *obj, const char *name, void *data)\n {\n \tadd_preferred_base_object(name);\n-\tadd_object_entry(obj->oid.hash, obj->type, name, 0);\n+\tadd_object_entry(&obj->oid, obj->type, name, 0);\n \tobj->flags |= OBJECT_ADDED;\n }\n \n static void show_edge(struct commit *commit)\n {\n-\tadd_preferred_base(commit->object.oid.hash);\n+\tadd_preferred_base(&commit->object.oid);\n }\n \n struct in_pack_object {\n@@ -2601,7 +2602,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)\n \tmemset(&in_pack, 0, sizeof(in_pack));\n \n \tfor (p = packed_git; p; p = p->next) {\n-\t\tconst unsigned char *sha1;\n+\t\tstruct object_id oid;\n \t\tstruct object *o;\n \n \t\tif (!p->pack_local || p->pack_keep)\n@@ -2614,8 +2615,8 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)\n \t\t\t   in_pack.alloc);\n \n \t\tfor (i = 0; i < p->num_objects; i++) {\n-\t\t\tsha1 = nth_packed_object_sha1(p, i);\n-\t\t\to = lookup_unknown_object(sha1);\n+\t\t\tnth_packed_object_oid(&oid, p, i);\n+\t\t\to = lookup_unknown_object(oid.hash);\n \t\t\tif (!(o->flags & OBJECT_ADDED))\n \t\t\t\tmark_in_pack_object(o, p, &in_pack);\n \t\t\to->flags |= OBJECT_ADDED;\n@@ -2626,7 +2627,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)\n \t\tQSORT(in_pack.array, in_pack.nr, ofscmp);\n \t\tfor (i = 0; i < in_pack.nr; i++) {\n \t\t\tstruct object *o = in_pack.array[i].object;\n-\t\t\tadd_object_entry(o->oid.hash, o->type, \"\", 0);\n+\t\t\tadd_object_entry(&o->oid, o->type, \"\", 0);\n \t\t}\n \t}\n \tfree(in_pack.array);\n@@ -2642,7 +2643,7 @@ static int add_loose_object(const struct object_id *oid, const char *path,\n \t\treturn 0;\n \t}\n \n-\tadd_object_entry(oid->hash, type, \"\", 0);\n+\tadd_object_entry(oid, type, \"\", 0);\n \treturn 0;\n }\n \n@@ -2658,7 +2659,7 @@ static void add_unreachable_loose_objects(void)\n \t\t\t\t      NULL, NULL, NULL);\n }\n \n-static int has_sha1_pack_kept_or_nonlocal(const unsigned char *sha1)\n+static int has_sha1_pack_kept_or_nonlocal(const struct object_id *oid)\n {\n \tstatic struct packed_git *last_found = (void *)1;\n \tstruct packed_git *p;\n@@ -2667,7 +2668,7 @@ static int has_sha1_pack_kept_or_nonlocal(const unsigned char *sha1)\n \n \twhile (p) {\n \t\tif ((!p->pack_local || p->pack_keep) &&\n-\t\t\tfind_pack_entry_one(sha1, p)) {\n+\t\t\tfind_pack_entry_one(oid->hash, p)) {\n \t\t\tlast_found = p;\n \t\t\treturn 1;\n \t\t}\n@@ -2718,7 +2719,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)\n \t\tfor (i = 0; i < p->num_objects; i++) {\n \t\t\tnth_packed_object_oid(&oid, p, i);\n \t\t\tif (!packlist_find(&to_pack, oid.hash, NULL) &&\n-\t\t\t    !has_sha1_pack_kept_or_nonlocal(oid.hash) &&\n+\t\t\t    !has_sha1_pack_kept_or_nonlocal(&oid) &&\n \t\t\t    !loosened_object_can_be_discarded(&oid, p->mtime))\n \t\t\t\tif (force_object_loose(oid.hash, p->mtime))\n \t\t\t\t\tdie(\"unable to force loose object\");\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329344","messageId":"20171001220831.214705-11-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 10/24] builtin/reflog: convert remaining unsigned char uses to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:17Z","receivedAt":"2017-10-01T22:09:59Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the remaining uses of unsigned char [20] to struct object_id.\nThis conversion is needed for dwim_log.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/reflog.c | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 2067cca5b1..302fafbeef 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -42,7 +42,7 @@ struct expire_reflog_policy_cb {\n };\n \n struct collected_reflog {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tchar reflog[FLEX_ARRAY];\n };\n \n@@ -385,7 +385,7 @@ static int collect_reflog(const char *ref, const struct object_id *oid, int unus\n \tstruct collect_reflog_cb *cb = cb_data;\n \n \tFLEX_ALLOC_STR(e, reflog, ref);\n-\thashcpy(e->sha1, oid->hash);\n+\toidcpy(&e->oid, oid);\n \tALLOC_GROW(cb->e, cb->nr + 1, cb->alloc);\n \tcb->e[cb->nr++] = e;\n \treturn 0;\n@@ -589,7 +589,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)\n \t\tfor (i = 0; i < collected.nr; i++) {\n \t\t\tstruct collected_reflog *e = collected.e[i];\n \t\t\tset_reflog_expiry_param(&cb.cmd, explicit_expiry, e->reflog);\n-\t\t\tstatus |= reflog_expire(e->reflog, e->sha1, flags,\n+\t\t\tstatus |= reflog_expire(e->reflog, e->oid.hash, flags,\n \t\t\t\t\t\treflog_expiry_prepare,\n \t\t\t\t\t\tshould_expire_reflog_ent,\n \t\t\t\t\t\treflog_expiry_cleanup,\n@@ -601,13 +601,13 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)\n \n \tfor (; i < argc; i++) {\n \t\tchar *ref;\n-\t\tunsigned char sha1[20];\n-\t\tif (!dwim_log(argv[i], strlen(argv[i]), sha1, &ref)) {\n+\t\tstruct object_id oid;\n+\t\tif (!dwim_log(argv[i], strlen(argv[i]), oid.hash, &ref)) {\n \t\t\tstatus |= error(\"%s points nowhere!\", argv[i]);\n \t\t\tcontinue;\n \t\t}\n \t\tset_reflog_expiry_param(&cb.cmd, explicit_expiry, ref);\n-\t\tstatus |= reflog_expire(ref, sha1, flags,\n+\t\tstatus |= reflog_expire(ref, oid.hash, flags,\n \t\t\t\t\treflog_expiry_prepare,\n \t\t\t\t\tshould_expire_reflog_ent,\n \t\t\t\t\treflog_expiry_cleanup,\n@@ -659,7 +659,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)\n \n \tfor ( ; i < argc; i++) {\n \t\tconst char *spec = strstr(argv[i], \"@{\");\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tchar *ep, *ref;\n \t\tint recno;\n \n@@ -668,7 +668,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)\n \t\t\tcontinue;\n \t\t}\n \n-\t\tif (!dwim_log(argv[i], spec - argv[i], sha1, &ref)) {\n+\t\tif (!dwim_log(argv[i], spec - argv[i], oid.hash, &ref)) {\n \t\t\tstatus |= error(\"no reflog for '%s'\", argv[i]);\n \t\t\tcontinue;\n \t\t}\n@@ -683,7 +683,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)\n \t\t\tcb.cmd.expire_total = 0;\n \t\t}\n \n-\t\tstatus |= reflog_expire(ref, sha1, flags,\n+\t\tstatus |= reflog_expire(ref, oid.hash, flags,\n \t\t\t\t\treflog_expiry_prepare,\n \t\t\t\t\tshould_expire_reflog_ent,\n \t\t\t\t\treflog_expiry_cleanup,\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329345","messageId":"20171001220831.214705-13-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 12/24] pack-bitmap: convert traverse_bitmap_commit_list to object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:19Z","receivedAt":"2017-10-01T22:10:03Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert traverse_bitmap_commit_list and the callbacks it takes to use a\npointer to struct object_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/pack-objects.c | 8 ++++----\n builtin/rev-list.c     | 4 ++--\n pack-bitmap.c          | 8 ++++----\n pack-bitmap.h          | 2 +-\n 4 files changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 5ee2c48ffb..180c17904b 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1097,20 +1097,20 @@ static int add_object_entry(const unsigned char *sha1, enum object_type type,\n \treturn 1;\n }\n \n-static int add_object_entry_from_bitmap(const unsigned char *sha1,\n+static int add_object_entry_from_bitmap(const struct object_id *oid,\n \t\t\t\t\tenum object_type type,\n \t\t\t\t\tint flags, uint32_t name_hash,\n \t\t\t\t\tstruct packed_git *pack, off_t offset)\n {\n \tuint32_t index_pos;\n \n-\tif (have_duplicate_entry(sha1, 0, &index_pos))\n+\tif (have_duplicate_entry(oid->hash, 0, &index_pos))\n \t\treturn 0;\n \n-\tif (!want_object_in_pack(sha1, 0, &pack, &offset))\n+\tif (!want_object_in_pack(oid->hash, 0, &pack, &offset))\n \t\treturn 0;\n \n-\tcreate_object_entry(sha1, type, name_hash, 0, 0, index_pos, pack, offset);\n+\tcreate_object_entry(oid->hash, type, name_hash, 0, 0, index_pos, pack, offset);\n \n \tdisplay_progress(progress_state, nr_result);\n \treturn 1;\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex c1c74d4a79..9bf8d5991c 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -258,14 +258,14 @@ static int show_bisect_vars(struct rev_list_info *info, int reaches, int all)\n }\n \n static int show_object_fast(\n-\tconst unsigned char *sha1,\n+\tconst struct object_id *oid,\n \tenum object_type type,\n \tint exclude,\n \tuint32_t name_hash,\n \tstruct packed_git *found_pack,\n \toff_t found_offset)\n {\n-\tfprintf(stdout, \"%s\\n\", sha1_to_hex(sha1));\n+\tfprintf(stdout, \"%s\\n\", oid_to_hex(oid));\n \treturn 1;\n }\n \ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex 42e3d5f4f2..9270983e5f 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -587,7 +587,7 @@ static void show_extended_objects(struct bitmap *objects,\n \t\t\tcontinue;\n \n \t\tobj = eindex->objects[i];\n-\t\tshow_reach(obj->oid.hash, obj->type, 0, eindex->hashes[i], NULL, 0);\n+\t\tshow_reach(&obj->oid, obj->type, 0, eindex->hashes[i], NULL, 0);\n \t}\n }\n \n@@ -612,7 +612,7 @@ static void show_objects_for_type(\n \t\teword_t word = objects->words[i] & filter;\n \n \t\tfor (offset = 0; offset < BITS_IN_EWORD; ++offset) {\n-\t\t\tconst unsigned char *sha1;\n+\t\t\tstruct object_id oid;\n \t\t\tstruct revindex_entry *entry;\n \t\t\tuint32_t hash = 0;\n \n@@ -625,12 +625,12 @@ static void show_objects_for_type(\n \t\t\t\tcontinue;\n \n \t\t\tentry = &bitmap_git.pack->revindex[pos + offset];\n-\t\t\tsha1 = nth_packed_object_sha1(bitmap_git.pack, entry->nr);\n+\t\t\tnth_packed_object_oid(&oid, bitmap_git.pack, entry->nr);\n \n \t\t\tif (bitmap_git.hashes)\n \t\t\t\thash = get_be32(bitmap_git.hashes + entry->nr);\n \n-\t\t\tshow_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);\n+\t\t\tshow_reach(&oid, object_type, 0, hash, bitmap_git.pack, entry->offset);\n \t\t}\n \n \t\tpos += BITS_IN_EWORD;\ndiff --git a/pack-bitmap.h b/pack-bitmap.h\nindex 0adcef77b5..3742a00e14 100644\n--- a/pack-bitmap.h\n+++ b/pack-bitmap.h\n@@ -27,7 +27,7 @@ enum pack_bitmap_flags {\n };\n \n typedef int (*show_reachable_fn)(\n-\tconst unsigned char *sha1,\n+\tconst struct object_id *oid,\n \tenum object_type type,\n \tint flags,\n \tuint32_t hash,\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329346","messageId":"20171001220831.214705-5-sandals@crustytoothpaste.net","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"[PATCH 04/24] refs: convert update_ref and refs_update_ref to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-01T22:08:11Z","receivedAt":"2017-10-01T22:10:07Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert update_ref, refs_update_ref, and write_pseudoref to use struct\nobject_id.  Update the existing callers as well.  Remove update_ref_oid,\nas it is no longer needed.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n bisect.c                  |  6 ++++--\n builtin/am.c              | 14 +++++++-------\n builtin/checkout.c        |  3 +--\n builtin/clone.c           | 14 +++++++-------\n builtin/merge.c           | 13 ++++++-------\n builtin/notes.c           | 10 +++++-----\n builtin/pull.c            |  2 +-\n builtin/reset.c           |  4 ++--\n builtin/update-ref.c      |  2 +-\n notes-cache.c             |  3 +--\n notes-utils.c             |  2 +-\n refs.c                    | 39 ++++++++++++++++-----------------------\n refs.h                    |  5 +----\n sequencer.c               |  9 +++------\n t/helper/test-ref-store.c | 10 +++++-----\n transport-helper.c        |  3 ++-\n transport.c               |  4 ++--\n 17 files changed, 65 insertions(+), 78 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex 96beeb5d13..e8470a2e0f 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -685,11 +685,13 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)\n \tchar bisect_rev_hex[GIT_MAX_HEXSZ + 1];\n \n \tmemcpy(bisect_rev_hex, oid_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1);\n-\tupdate_ref(NULL, \"BISECT_EXPECTED_REV\", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n+\tupdate_ref(NULL, \"BISECT_EXPECTED_REV\", bisect_rev, NULL, 0,\n+\t\t   UPDATE_REFS_DIE_ON_ERR);\n \n \targv_checkout[2] = bisect_rev_hex;\n \tif (no_checkout) {\n-\t\tupdate_ref(NULL, \"BISECT_HEAD\", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n+\t\tupdate_ref(NULL, \"BISECT_HEAD\", bisect_rev, NULL, 0,\n+\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n \t} else {\n \t\tint res;\n \t\tres = run_command_v_opt(argv_checkout, RUN_GIT_CMD);\ndiff --git a/builtin/am.c b/builtin/am.c\nindex d7513f5375..32120f42df 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1068,8 +1068,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,\n \tif (!get_oid(\"HEAD\", &curr_head)) {\n \t\twrite_state_text(state, \"abort-safety\", oid_to_hex(&curr_head));\n \t\tif (!state->rebasing)\n-\t\t\tupdate_ref_oid(\"am\", \"ORIG_HEAD\", &curr_head, NULL, 0,\n-\t\t\t\t\tUPDATE_REFS_DIE_ON_ERR);\n+\t\t\tupdate_ref(\"am\", \"ORIG_HEAD\", &curr_head, NULL, 0,\n+\t\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n \t} else {\n \t\twrite_state_text(state, \"abort-safety\", \"\");\n \t\tif (!state->rebasing)\n@@ -1686,8 +1686,8 @@ static void do_commit(const struct am_state *state)\n \tstrbuf_addf(&sb, \"%s: %.*s\", reflog_msg, linelen(state->msg),\n \t\t\tstate->msg);\n \n-\tupdate_ref_oid(sb.buf, \"HEAD\", &commit, old_oid, 0,\n-\t\t\tUPDATE_REFS_DIE_ON_ERR);\n+\tupdate_ref(sb.buf, \"HEAD\", &commit, old_oid, 0,\n+\t\t   UPDATE_REFS_DIE_ON_ERR);\n \n \tif (state->rebasing) {\n \t\tFILE *fp = xfopen(am_path(state, \"rewritten\"), \"a\");\n@@ -2147,9 +2147,9 @@ static void am_abort(struct am_state *state)\n \tclean_index(&curr_head, &orig_head);\n \n \tif (has_orig_head)\n-\t\tupdate_ref_oid(\"am --abort\", \"HEAD\", &orig_head,\n-\t\t\t\thas_curr_head ? &curr_head : NULL, 0,\n-\t\t\t\tUPDATE_REFS_DIE_ON_ERR);\n+\t\tupdate_ref(\"am --abort\", \"HEAD\", &orig_head,\n+\t\t\t   has_curr_head ? &curr_head : NULL, 0,\n+\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n \telse if (curr_branch)\n \t\tdelete_ref(NULL, curr_branch, NULL, REF_NODEREF);\n \ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 3345a0d16f..fd0dec401e 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -664,8 +664,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,\n \tif (!strcmp(new->name, \"HEAD\") && !new->path && !opts->force_detach) {\n \t\t/* Nothing to do. */\n \t} else if (opts->force_detach || !new->path) {\t/* No longer on any branch. */\n-\t\tupdate_ref(msg.buf, \"HEAD\", new->commit->object.oid.hash, NULL,\n-\t\t\t   REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);\n+\t\tupdate_ref(msg.buf, \"HEAD\", &new->commit->object.oid, NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);\n \t\tif (!opts->quiet) {\n \t\t\tif (old->path &&\n \t\t\t    advice_detached_head && !opts->force_detach)\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex dbddd98f80..4135621aa3 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -610,8 +610,8 @@ static void write_followtags(const struct ref *refs, const char *msg)\n \t\t\tcontinue;\n \t\tif (!has_object_file(&ref->old_oid))\n \t\t\tcontinue;\n-\t\tupdate_ref(msg, ref->name, ref->old_oid.hash,\n-\t\t\t   NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n+\t\tupdate_ref(msg, ref->name, &ref->old_oid, NULL, 0,\n+\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n \t}\n }\n \n@@ -682,23 +682,23 @@ static void update_head(const struct ref *our, const struct ref *remote,\n \t\tif (create_symref(\"HEAD\", our->name, NULL) < 0)\n \t\t\tdie(_(\"unable to update HEAD\"));\n \t\tif (!option_bare) {\n-\t\t\tupdate_ref(msg, \"HEAD\", our->old_oid.hash, NULL, 0,\n+\t\t\tupdate_ref(msg, \"HEAD\", &our->old_oid, NULL, 0,\n \t\t\t\t   UPDATE_REFS_DIE_ON_ERR);\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);\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);\n+\t\tupdate_ref(msg, \"HEAD\", &c->object.oid, NULL, REF_NODEREF,\n+\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n \t} else if (remote) {\n \t\t/*\n \t\t * We know remote HEAD points to a non-branch, or\n \t\t * HEAD points to a branch but we don't know which one.\n \t\t * Detach HEAD in all these cases.\n \t\t */\n-\t\tupdate_ref(msg, \"HEAD\", remote->old_oid.hash,\n-\t\t\t   NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);\n+\t\tupdate_ref(msg, \"HEAD\", &remote->old_oid, NULL, REF_NODEREF,\n+\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n \t}\n }\n \ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex ab5ffe85e8..99d4b873f0 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -405,9 +405,8 @@ static void finish(struct commit *head_commit,\n \t\t\tprintf(_(\"No merge message -- not updating HEAD\\n\"));\n \t\telse {\n \t\t\tconst char *argv_gc_auto[] = { \"gc\", \"--auto\", NULL };\n-\t\t\tupdate_ref(reflog_message.buf, \"HEAD\",\n-\t\t\t\tnew_head->hash, head->hash, 0,\n-\t\t\t\tUPDATE_REFS_DIE_ON_ERR);\n+\t\t\tupdate_ref(reflog_message.buf, \"HEAD\", new_head, head,\n+\t\t\t\t   0, UPDATE_REFS_DIE_ON_ERR);\n \t\t\t/*\n \t\t\t * We ignore errors in 'gc --auto', since the\n \t\t\t * user should see them.\n@@ -1261,8 +1260,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\t\tdie(_(\"Can merge only exactly one commit into empty head\"));\n \t\tremote_head_oid = &remoteheads->item->object.oid;\n \t\tread_empty(remote_head_oid->hash, 0);\n-\t\tupdate_ref(\"initial pull\", \"HEAD\", remote_head_oid->hash,\n-\t\t\t   NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n+\t\tupdate_ref(\"initial pull\", \"HEAD\", remote_head_oid, NULL, 0,\n+\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n \t\tgoto done;\n \t}\n \n@@ -1357,8 +1356,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\tfree(list);\n \t}\n \n-\tupdate_ref(\"updating ORIG_HEAD\", \"ORIG_HEAD\", head_commit->object.oid.hash,\n-\t\t   NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n+\tupdate_ref(\"updating ORIG_HEAD\", \"ORIG_HEAD\",\n+\t\t   &head_commit->object.oid, NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n \n \tif (remoteheads && !common) {\n \t\t/* No common ancestors found. */\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 8e54f2d146..8276af419b 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -736,8 +736,8 @@ static int merge_commit(struct notes_merge_options *o)\n \tformat_commit_message(partial, \"%s\", &msg, &pretty_ctx);\n \tstrbuf_trim(&msg);\n \tstrbuf_insert(&msg, 0, \"notes: \", 7);\n-\tupdate_ref(msg.buf, o->local_ref, oid.hash,\n-\t\t   is_null_oid(&parent_oid) ? NULL : parent_oid.hash,\n+\tupdate_ref(msg.buf, o->local_ref, &oid,\n+\t\t   is_null_oid(&parent_oid) ? NULL : &parent_oid,\n \t\t   0, UPDATE_REFS_DIE_ON_ERR);\n \n \tfree_notes(t);\n@@ -850,12 +850,12 @@ static int merge(int argc, const char **argv, const char *prefix)\n \n \tif (result >= 0) /* Merge resulted (trivially) in result_oid */\n \t\t/* Update default notes ref with new commit */\n-\t\tupdate_ref(msg.buf, default_notes_ref(), result_oid.hash, NULL,\n-\t\t\t   0, UPDATE_REFS_DIE_ON_ERR);\n+\t\tupdate_ref(msg.buf, default_notes_ref(), &result_oid, NULL, 0,\n+\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n \telse { /* Merge has unresolved conflicts */\n \t\tconst struct worktree *wt;\n \t\t/* Update .git/NOTES_MERGE_PARTIAL with partial merge result */\n-\t\tupdate_ref(msg.buf, \"NOTES_MERGE_PARTIAL\", result_oid.hash, NULL,\n+\t\tupdate_ref(msg.buf, \"NOTES_MERGE_PARTIAL\", &result_oid, NULL,\n \t\t\t   0, UPDATE_REFS_DIE_ON_ERR);\n \t\t/* Store ref-to-be-updated into .git/NOTES_MERGE_REF */\n \t\twt = find_shared_symref(\"NOTES_MERGE_REF\", default_notes_ref());\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 6f772e8a22..9b2d67fe43 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -544,7 +544,7 @@ static int pull_into_void(const struct object_id *merge_head,\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+\tif (update_ref(\"initial pull\", \"HEAD\", merge_head, curr_head, 0, UPDATE_REFS_DIE_ON_ERR))\n \t\treturn 1;\n \n \treturn 0;\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 5f3632e05b..d4003f76ab 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -266,12 +266,12 @@ static int reset_refs(const char *rev, const struct object_id *oid)\n \tif (!get_oid(\"HEAD\", &oid_orig)) {\n \t\torig = &oid_orig;\n \t\tset_reflog_message(&msg, \"updating ORIG_HEAD\", NULL);\n-\t\tupdate_ref_oid(msg.buf, \"ORIG_HEAD\", orig, old_orig, 0,\n+\t\tupdate_ref(msg.buf, \"ORIG_HEAD\", orig, old_orig, 0,\n \t\t\t   UPDATE_REFS_MSG_ON_ERR);\n \t} else if (old_orig)\n \t\tdelete_ref(NULL, \"ORIG_HEAD\", old_orig, 0);\n \tset_reflog_message(&msg, \"updating HEAD\", rev);\n-\tupdate_ref_status = update_ref_oid(msg.buf, \"HEAD\", oid, orig, 0,\n+\tupdate_ref_status = update_ref(msg.buf, \"HEAD\", oid, orig, 0,\n \t\t\t\t       UPDATE_REFS_MSG_ON_ERR);\n \tstrbuf_release(&msg);\n \treturn update_ref_status;\ndiff --git a/builtin/update-ref.c b/builtin/update-ref.c\nindex bf0f80ebae..f491cf1a92 100644\n--- a/builtin/update-ref.c\n+++ b/builtin/update-ref.c\n@@ -437,7 +437,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)\n \t\t\t\t  (oldval && !is_null_oid(&oldoid)) ? &oldoid : NULL,\n \t\t\t\t  flags);\n \telse\n-\t\treturn update_ref(msg, refname, oid.hash, oldval ? oldoid.hash : NULL,\n+\t\treturn update_ref(msg, refname, &oid, oldval ? &oldoid : NULL,\n \t\t\t\t  flags | create_reflog_flag,\n \t\t\t\t  UPDATE_REFS_DIE_ON_ERR);\n }\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 29b4cede5f..927b6645db 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -59,8 +59,7 @@ int notes_cache_write(struct notes_cache *c)\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_oid.hash,\n-\t\t       NULL, 0, UPDATE_REFS_QUIET_ON_ERR) < 0)\n+\tif (update_ref(\"update notes cache\", c->tree.update_ref, &commit_oid, NULL, 0, UPDATE_REFS_QUIET_ON_ERR) < 0)\n \t\treturn -1;\n \n \treturn 0;\ndiff --git a/notes-utils.c b/notes-utils.c\nindex 9765deb41a..3a7008948c 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -49,7 +49,7 @@ void commit_notes(struct notes_tree *t, const char *msg)\n \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_oid.hash, NULL, 0,\n+\tupdate_ref(buf.buf, t->update_ref, &commit_oid, NULL, 0,\n \t\t   UPDATE_REFS_DIE_ON_ERR);\n \n \tstrbuf_release(&buf);\ndiff --git a/refs.c b/refs.c\nindex 0a5b68d6fb..66d66af126 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -574,8 +574,8 @@ long get_files_ref_lock_timeout_ms(void)\n \treturn timeout_ms;\n }\n \n-static int write_pseudoref(const char *pseudoref, const unsigned char *sha1,\n-\t\t\t   const unsigned char *old_sha1, struct strbuf *err)\n+static int write_pseudoref(const char *pseudoref, const struct object_id *oid,\n+\t\t\t   const struct object_id *old_oid, struct strbuf *err)\n {\n \tconst char *filename;\n \tint fd;\n@@ -583,7 +583,7 @@ static int write_pseudoref(const char *pseudoref, const unsigned char *sha1,\n \tstruct strbuf buf = STRBUF_INIT;\n \tint ret = -1;\n \n-\tstrbuf_addf(&buf, \"%s\\n\", sha1_to_hex(sha1));\n+\tstrbuf_addf(&buf, \"%s\\n\", oid_to_hex(oid));\n \n \tfilename = git_path(\"%s\", pseudoref);\n \tfd = hold_lock_file_for_update_timeout(&lock, filename,\n@@ -595,12 +595,12 @@ static int write_pseudoref(const char *pseudoref, const unsigned char *sha1,\n \t\tgoto done;\n \t}\n \n-\tif (old_sha1) {\n-\t\tunsigned char actual_old_sha1[20];\n+\tif (old_oid) {\n+\t\tstruct object_id actual_old_oid;\n \n-\t\tif (read_ref(pseudoref, actual_old_sha1))\n+\t\tif (read_ref(pseudoref, actual_old_oid.hash))\n \t\t\tdie(\"could not read ref '%s'\", pseudoref);\n-\t\tif (hashcmp(actual_old_sha1, old_sha1)) {\n+\t\tif (oidcmp(&actual_old_oid, old_oid)) {\n \t\t\tstrbuf_addf(err, \"unexpected sha1 when writing '%s'\", pseudoref);\n \t\t\trollback_lock_file(&lock);\n \t\t\tgoto done;\n@@ -985,17 +985,10 @@ int ref_transaction_verify(struct ref_transaction *transaction,\n \t\t\t\t      flags, NULL, err);\n }\n \n-int update_ref_oid(const char *msg, const char *refname,\n-\t       const struct object_id *new_oid, const struct object_id *old_oid,\n-\t       unsigned int flags, enum action_on_err onerr)\n-{\n-\treturn update_ref(msg, refname, new_oid ? new_oid->hash : NULL,\n-\t\told_oid ? old_oid->hash : NULL, flags, onerr);\n-}\n \n int refs_update_ref(struct ref_store *refs, const char *msg,\n-\t\t    const char *refname, const unsigned char *new_sha1,\n-\t\t    const unsigned char *old_sha1, unsigned int flags,\n+\t\t    const char *refname, const struct object_id *new_oid,\n+\t\t    const struct object_id *old_oid, unsigned int flags,\n \t\t    enum action_on_err onerr)\n {\n \tstruct ref_transaction *t = NULL;\n@@ -1003,12 +996,12 @@ int refs_update_ref(struct ref_store *refs, const char *msg,\n \tint ret = 0;\n \n \tif (ref_type(refname) == REF_TYPE_PSEUDOREF) {\n-\t\tassert(refs == get_main_ref_store());\n-\t\tret = write_pseudoref(refname, new_sha1, old_sha1, &err);\n+\t\tret = write_pseudoref(refname, new_oid, old_oid, &err);\n \t} else {\n \t\tt = ref_store_transaction_begin(refs, &err);\n \t\tif (!t ||\n-\t\t    ref_transaction_update(t, refname, new_sha1, old_sha1,\n+\t\t    ref_transaction_update(t, refname, new_oid ? new_oid->hash : NULL,\n+\t\t\t\t\t   old_oid ? old_oid->hash : NULL,\n \t\t\t\t\t   flags, msg, &err) ||\n \t\t    ref_transaction_commit(t, &err)) {\n \t\t\tret = 1;\n@@ -1038,12 +1031,12 @@ int refs_update_ref(struct ref_store *refs, const char *msg,\n }\n \n int update_ref(const char *msg, const char *refname,\n-\t       const unsigned char *new_sha1,\n-\t       const unsigned char *old_sha1,\n+\t       const struct object_id *new_oid,\n+\t       const struct object_id *old_oid,\n \t       unsigned int flags, enum action_on_err onerr)\n {\n-\treturn refs_update_ref(get_main_ref_store(), msg, refname, new_sha1,\n-\t\t\t       old_sha1, flags, onerr);\n+\treturn refs_update_ref(get_main_ref_store(), msg, refname, new_oid,\n+\t\t\t       old_oid, flags, onerr);\n }\n \n char *shorten_unambiguous_ref(const char *refname, int strict)\ndiff --git a/refs.h b/refs.h\nindex 07e9907b31..369614d392 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -636,12 +636,9 @@ void ref_transaction_free(struct ref_transaction *transaction);\n  * argument.\n  */\n int refs_update_ref(struct ref_store *refs, const char *msg, const char *refname,\n-\t\t    const unsigned char *new_sha1, const unsigned char *old_sha1,\n+\t\t    const struct object_id *new_oid, const struct object_id *old_oid,\n \t\t    unsigned int flags, enum action_on_err onerr);\n int update_ref(const char *msg, const char *refname,\n-\t       const unsigned char *new_sha1, const unsigned char *old_sha1,\n-\t       unsigned int flags, enum action_on_err onerr);\n-int update_ref_oid(const char *msg, const char *refname,\n \t       const struct object_id *new_oid, const struct object_id *old_oid,\n \t       unsigned int flags, enum action_on_err onerr);\n \ndiff --git a/sequencer.c b/sequencer.c\nindex 60636ce54b..b349474bd3 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1114,12 +1114,10 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t * write it at all.\n \t */\n \tif (command == TODO_PICK && !opts->no_commit && (res == 0 || res == 1) &&\n-\t    update_ref(NULL, \"CHERRY_PICK_HEAD\", commit->object.oid.hash, NULL,\n-\t\t       REF_NODEREF, UPDATE_REFS_MSG_ON_ERR))\n+\t    update_ref(NULL, \"CHERRY_PICK_HEAD\", &commit->object.oid, NULL, REF_NODEREF, UPDATE_REFS_MSG_ON_ERR))\n \t\tres = -1;\n \tif (command == TODO_REVERT && ((opts->no_commit && res == 0) || res == 1) &&\n-\t    update_ref(NULL, \"REVERT_HEAD\", commit->object.oid.hash, NULL,\n-\t\t       REF_NODEREF, UPDATE_REFS_MSG_ON_ERR))\n+\t    update_ref(NULL, \"REVERT_HEAD\", &commit->object.oid, NULL, REF_NODEREF, UPDATE_REFS_MSG_ON_ERR))\n \t\tres = -1;\n \n \tif (res) {\n@@ -2123,8 +2121,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)\n \t\t\t}\n \t\t\tmsg = reflog_message(opts, \"finish\", \"%s onto %s\",\n \t\t\t\thead_ref.buf, buf.buf);\n-\t\t\tif (update_ref(msg, head_ref.buf, head.hash, orig.hash,\n-\t\t\t\t\tREF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) {\n+\t\t\tif (update_ref(msg, head_ref.buf, &head, &orig, REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) {\n \t\t\t\tres = error(_(\"could not update %s\"),\n \t\t\t\t\thead_ref.buf);\n \t\t\t\tgoto cleanup_head_ref;\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 4624238641..af8dba9560 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -233,15 +233,15 @@ static int cmd_update_ref(struct ref_store *refs, const char **argv)\n \tconst char *new_sha1_buf = notnull(*argv++, \"old-sha1\");\n \tconst char *old_sha1_buf = notnull(*argv++, \"old-sha1\");\n \tunsigned int flags = arg_flags(*argv++, \"flags\");\n-\tunsigned char old_sha1[20];\n-\tunsigned char new_sha1[20];\n+\tstruct object_id old_oid;\n+\tstruct object_id new_oid;\n \n-\tif (get_sha1_hex(old_sha1_buf, old_sha1) ||\n-\t    get_sha1_hex(new_sha1_buf, new_sha1))\n+\tif (get_oid_hex(old_sha1_buf, &old_oid) ||\n+\t    get_oid_hex(new_sha1_buf, &new_oid))\n \t\tdie(\"not sha-1\");\n \n \treturn refs_update_ref(refs, msg, refname,\n-\t\t\t       new_sha1, old_sha1,\n+\t\t\t       &new_oid, &old_oid,\n \t\t\t       flags, UPDATE_REFS_DIE_ON_ERR);\n }\n \ndiff --git a/transport-helper.c b/transport-helper.c\nindex c948d5215c..f183601261 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -795,7 +795,8 @@ static int push_update_refs_status(struct helper_data *data,\n \t\tprivate = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);\n \t\tif (!private)\n \t\t\tcontinue;\n-\t\tupdate_ref(\"update by helper\", private, ref->new_oid.hash, NULL, 0, 0);\n+\t\tupdate_ref(\"update by helper\", private, &ref->new_oid, NULL,\n+\t\t\t   0, 0);\n \t\tfree(private);\n \t}\n \tstrbuf_release(&buf);\ndiff --git a/transport.c b/transport.c\nindex fb8c01e57a..09bd06e6e5 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -305,8 +305,8 @@ void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int v\n \t\tif (ref->deletion) {\n \t\t\tdelete_ref(NULL, rs.dst, NULL, 0);\n \t\t} else\n-\t\t\tupdate_ref(\"update by push\", rs.dst,\n-\t\t\t\t\tref->new_oid.hash, NULL, 0, 0);\n+\t\t\tupdate_ref(\"update by push\", rs.dst, &ref->new_oid,\n+\t\t\t\t   NULL, 0, 0);\n \t\tfree(rs.dst);\n \t}\n }\n-- \n2.14.2.822.g60be5d43e6\n\n"},{"id":"329484","messageId":"CAGZ79kaY36mo2bpohO8cknPShOBbZt_tpi_kjoxLHE=cFJ3ROw@mail.gmail.com","threadId":"46876","inReplyTo":"20171001220831.214705-5-sandals@crustytoothpaste.net","subject":"Re: [PATCH 04/24] refs: convert update_ref and refs_update_ref to use struct object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-10-02T22:37:38Z","receivedAt":"2017-10-02T22:37:44Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"> diff --git a/bisect.c b/bisect.c\n> index 96beeb5d13..e8470a2e0f 100644\n> --- a/bisect.c\n> +++ b/bisect.c\n> @@ -685,11 +685,13 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)\n>         char bisect_rev_hex[GIT_MAX_HEXSZ + 1];\n>\n>         memcpy(bisect_rev_hex, oid_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1);\n> -       update_ref(NULL, \"BISECT_EXPECTED_REV\", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n> +       update_ref(NULL, \"BISECT_EXPECTED_REV\", bisect_rev, NULL, 0,\n> +                  UPDATE_REFS_DIE_ON_ERR);\n\nThe number of characters decrease, yet the line gets an additional\nline break. While I don't mind this, the most interesting question that\ncomes to mind is whether you tried the new clang formatting options\nin tree to adapt the indentation? ;)\n\n> --- a/builtin/reset.c\n> +++ b/builtin/reset.c\n> @@ -266,12 +266,12 @@ static int reset_refs(const char *rev, const struct object_id *oid)\n>         if (!get_oid(\"HEAD\", &oid_orig)) {\n>                 orig = &oid_orig;\n>                 set_reflog_message(&msg, \"updating ORIG_HEAD\", NULL);\n> -               update_ref_oid(msg.buf, \"ORIG_HEAD\", orig, old_orig, 0,\n> +               update_ref(msg.buf, \"ORIG_HEAD\", orig, old_orig, 0,\n>                            UPDATE_REFS_MSG_ON_ERR);\n>         } else if (old_orig)\n>                 delete_ref(NULL, \"ORIG_HEAD\", old_orig, 0);\n>         set_reflog_message(&msg, \"updating HEAD\", rev);\n> -       update_ref_status = update_ref_oid(msg.buf, \"HEAD\", oid, orig, 0,\n> +       update_ref_status = update_ref(msg.buf, \"HEAD\", oid, orig, 0,\n>                                        UPDATE_REFS_MSG_ON_ERR);\n\nAt all the other places (of s/update_ref_oid/update_ref/) so far you re-indented\nthe second line to align. This doesn't align in the first place, so it\nshall be good.\n"},{"id":"329489","messageId":"CAGZ79kb1WjUUKV5aUoPf=x=nFqMhJssKudtHm+_LxY5=ky6r4A@mail.gmail.com","threadId":"46876","inReplyTo":"20171001220831.214705-7-sandals@crustytoothpaste.net","subject":"Re: [PATCH 06/24] Convert check_connected to use struct object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-10-02T23:00:54Z","receivedAt":"2017-10-02T23:01:01Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Sun, Oct 1, 2017 at 3:08 PM, brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n> Convert check_connected and the callbacks it takes to use struct\n> object_id.\n>\n\n> diff --git a/connected.c b/connected.c\n> index f416b05051..4a47f33270 100644\n> --- a/connected.c\n> +++ b/connected.c\n> @@ -16,13 +16,13 @@\n>   *\n>   * Returns 0 if everything is connected, non-zero otherwise.\n>   */\n> -int check_connected(sha1_iterate_fn fn, void *cb_data,\n> +int check_connected(oid_iterate_fn fn, void *cb_data,\n>                     struct check_connected_options *opt)\n>  {\n>         struct child_process rev_list = CHILD_PROCESS_INIT;\n>         struct check_connected_options defaults = CHECK_CONNECTED_INIT;\n> -       char commit[41];\n> -       unsigned char sha1[20];\n> +       char commit[GIT_MAX_HEXSZ + 1];\n> +       struct object_id oid;\n>         int err = 0;\n>         struct packed_git *new_pack = NULL;\n>         struct transport *transport;\n\n> @@ -77,7 +77,7 @@ int check_connected(sha1_iterate_fn fn, void *cb_data,\n>\n>         sigchain_push(SIGPIPE, SIG_IGN);\n>\n> -       commit[40] = '\\n';\n> +       commit[GIT_SHA1_HEXSZ] = '\\n';\n\nWhile we are using SHA1, this and below is correctly using\nGIT_SHA1_HEXSZ, but the array is defined as GIT_MAX_HEXSZ.\n\nUpon switching the hash function, we would plug in the\nGIT_NEWHASH_HEXSZ here, or if we do it dynamically\n(using a vtable for hash functions, to switch at run time)\nwe'd need to make the decision based on the hash function.\n\nMakes sense.\n\n>         do {\n>                 /*\n>                  * If index-pack already checked that:\n> @@ -87,17 +87,17 @@ int check_connected(sha1_iterate_fn fn, void *cb_data,\n>                  * are sure the ref is good and not sending it to\n>                  * rev-list for verification.\n>                  */\n> -               if (new_pack && find_pack_entry_one(sha1, new_pack))\n> +               if (new_pack && find_pack_entry_one(oid.hash, new_pack))\n>                         continue;\n>\n> -               memcpy(commit, sha1_to_hex(sha1), 40);\n> -               if (write_in_full(rev_list.in, commit, 41) < 0) {\n> +               memcpy(commit, oid_to_hex(&oid), GIT_SHA1_HEXSZ);\n> +               if (write_in_full(rev_list.in, commit, GIT_SHA1_HEXSZ + 1) < 0) {\n>                         if (errno != EPIPE && errno != EINVAL)\n>                                 error_errno(_(\"failed write to rev-list\"));\n>                         err = -1;\n>                         break;\n>                 }\n"},{"id":"329490","messageId":"20171002230816.GC5189@google.com","threadId":"46876","inReplyTo":"20171001220831.214705-5-sandals@crustytoothpaste.net","subject":"Re: [PATCH 04/24] refs: convert update_ref and refs_update_ref to use struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-02T23:08:16Z","receivedAt":"2017-10-02T23:08:27Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 10/01, brian m. carlson wrote:\n> Convert update_ref, refs_update_ref, and write_pseudoref to use struct\n> object_id.  Update the existing callers as well.  Remove update_ref_oid,\n> as it is no longer needed.\n> \n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> ---\n>  bisect.c                  |  6 ++++--\n>  builtin/am.c              | 14 +++++++-------\n>  builtin/checkout.c        |  3 +--\n>  builtin/clone.c           | 14 +++++++-------\n>  builtin/merge.c           | 13 ++++++-------\n>  builtin/notes.c           | 10 +++++-----\n>  builtin/pull.c            |  2 +-\n>  builtin/reset.c           |  4 ++--\n>  builtin/update-ref.c      |  2 +-\n>  notes-cache.c             |  3 +--\n>  notes-utils.c             |  2 +-\n>  refs.c                    | 39 ++++++++++++++++-----------------------\n>  refs.h                    |  5 +----\n>  sequencer.c               |  9 +++------\n>  t/helper/test-ref-store.c | 10 +++++-----\n>  transport-helper.c        |  3 ++-\n>  transport.c               |  4 ++--\n>  17 files changed, 65 insertions(+), 78 deletions(-)\n> \n> diff --git a/bisect.c b/bisect.c\n> index 96beeb5d13..e8470a2e0f 100644\n> --- a/bisect.c\n> +++ b/bisect.c\n> @@ -685,11 +685,13 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)\n>  \tchar bisect_rev_hex[GIT_MAX_HEXSZ + 1];\n>  \n>  \tmemcpy(bisect_rev_hex, oid_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1);\n> -\tupdate_ref(NULL, \"BISECT_EXPECTED_REV\", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n> +\tupdate_ref(NULL, \"BISECT_EXPECTED_REV\", bisect_rev, NULL, 0,\n> +\t\t   UPDATE_REFS_DIE_ON_ERR);\n>  \n>  \targv_checkout[2] = bisect_rev_hex;\n>  \tif (no_checkout) {\n> -\t\tupdate_ref(NULL, \"BISECT_HEAD\", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n> +\t\tupdate_ref(NULL, \"BISECT_HEAD\", bisect_rev, NULL, 0,\n> +\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n>  \t} else {\n>  \t\tint res;\n>  \t\tres = run_command_v_opt(argv_checkout, RUN_GIT_CMD);\n> diff --git a/builtin/am.c b/builtin/am.c\n> index d7513f5375..32120f42df 100644\n> --- a/builtin/am.c\n> +++ b/builtin/am.c\n> @@ -1068,8 +1068,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,\n>  \tif (!get_oid(\"HEAD\", &curr_head)) {\n>  \t\twrite_state_text(state, \"abort-safety\", oid_to_hex(&curr_head));\n>  \t\tif (!state->rebasing)\n> -\t\t\tupdate_ref_oid(\"am\", \"ORIG_HEAD\", &curr_head, NULL, 0,\n> -\t\t\t\t\tUPDATE_REFS_DIE_ON_ERR);\n> +\t\t\tupdate_ref(\"am\", \"ORIG_HEAD\", &curr_head, NULL, 0,\n> +\t\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n>  \t} else {\n>  \t\twrite_state_text(state, \"abort-safety\", \"\");\n>  \t\tif (!state->rebasing)\n> @@ -1686,8 +1686,8 @@ static void do_commit(const struct am_state *state)\n>  \tstrbuf_addf(&sb, \"%s: %.*s\", reflog_msg, linelen(state->msg),\n>  \t\t\tstate->msg);\n>  \n> -\tupdate_ref_oid(sb.buf, \"HEAD\", &commit, old_oid, 0,\n> -\t\t\tUPDATE_REFS_DIE_ON_ERR);\n> +\tupdate_ref(sb.buf, \"HEAD\", &commit, old_oid, 0,\n> +\t\t   UPDATE_REFS_DIE_ON_ERR);\n>  \n>  \tif (state->rebasing) {\n>  \t\tFILE *fp = xfopen(am_path(state, \"rewritten\"), \"a\");\n> @@ -2147,9 +2147,9 @@ static void am_abort(struct am_state *state)\n>  \tclean_index(&curr_head, &orig_head);\n>  \n>  \tif (has_orig_head)\n> -\t\tupdate_ref_oid(\"am --abort\", \"HEAD\", &orig_head,\n> -\t\t\t\thas_curr_head ? &curr_head : NULL, 0,\n> -\t\t\t\tUPDATE_REFS_DIE_ON_ERR);\n> +\t\tupdate_ref(\"am --abort\", \"HEAD\", &orig_head,\n> +\t\t\t   has_curr_head ? &curr_head : NULL, 0,\n> +\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n>  \telse if (curr_branch)\n>  \t\tdelete_ref(NULL, curr_branch, NULL, REF_NODEREF);\n>  \n> diff --git a/builtin/checkout.c b/builtin/checkout.c\n> index 3345a0d16f..fd0dec401e 100644\n> --- a/builtin/checkout.c\n> +++ b/builtin/checkout.c\n> @@ -664,8 +664,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,\n>  \tif (!strcmp(new->name, \"HEAD\") && !new->path && !opts->force_detach) {\n>  \t\t/* Nothing to do. */\n>  \t} else if (opts->force_detach || !new->path) {\t/* No longer on any branch. */\n> -\t\tupdate_ref(msg.buf, \"HEAD\", new->commit->object.oid.hash, NULL,\n> -\t\t\t   REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);\n> +\t\tupdate_ref(msg.buf, \"HEAD\", &new->commit->object.oid, NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);\n>  \t\tif (!opts->quiet) {\n>  \t\t\tif (old->path &&\n>  \t\t\t    advice_detached_head && !opts->force_detach)\n> diff --git a/builtin/clone.c b/builtin/clone.c\n> index dbddd98f80..4135621aa3 100644\n> --- a/builtin/clone.c\n> +++ b/builtin/clone.c\n> @@ -610,8 +610,8 @@ static void write_followtags(const struct ref *refs, const char *msg)\n>  \t\t\tcontinue;\n>  \t\tif (!has_object_file(&ref->old_oid))\n>  \t\t\tcontinue;\n> -\t\tupdate_ref(msg, ref->name, ref->old_oid.hash,\n> -\t\t\t   NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n> +\t\tupdate_ref(msg, ref->name, &ref->old_oid, NULL, 0,\n> +\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n>  \t}\n>  }\n>  \n> @@ -682,23 +682,23 @@ static void update_head(const struct ref *our, const struct ref *remote,\n>  \t\tif (create_symref(\"HEAD\", our->name, NULL) < 0)\n>  \t\t\tdie(_(\"unable to update HEAD\"));\n>  \t\tif (!option_bare) {\n> -\t\t\tupdate_ref(msg, \"HEAD\", our->old_oid.hash, NULL, 0,\n> +\t\t\tupdate_ref(msg, \"HEAD\", &our->old_oid, NULL, 0,\n>  \t\t\t\t   UPDATE_REFS_DIE_ON_ERR);\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);\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);\n> +\t\tupdate_ref(msg, \"HEAD\", &c->object.oid, NULL, REF_NODEREF,\n> +\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n>  \t} else if (remote) {\n>  \t\t/*\n>  \t\t * We know remote HEAD points to a non-branch, or\n>  \t\t * HEAD points to a branch but we don't know which one.\n>  \t\t * Detach HEAD in all these cases.\n>  \t\t */\n> -\t\tupdate_ref(msg, \"HEAD\", remote->old_oid.hash,\n> -\t\t\t   NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);\n> +\t\tupdate_ref(msg, \"HEAD\", &remote->old_oid, NULL, REF_NODEREF,\n> +\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n>  \t}\n>  }\n>  \n> diff --git a/builtin/merge.c b/builtin/merge.c\n> index ab5ffe85e8..99d4b873f0 100644\n> --- a/builtin/merge.c\n> +++ b/builtin/merge.c\n> @@ -405,9 +405,8 @@ static void finish(struct commit *head_commit,\n>  \t\t\tprintf(_(\"No merge message -- not updating HEAD\\n\"));\n>  \t\telse {\n>  \t\t\tconst char *argv_gc_auto[] = { \"gc\", \"--auto\", NULL };\n> -\t\t\tupdate_ref(reflog_message.buf, \"HEAD\",\n> -\t\t\t\tnew_head->hash, head->hash, 0,\n> -\t\t\t\tUPDATE_REFS_DIE_ON_ERR);\n> +\t\t\tupdate_ref(reflog_message.buf, \"HEAD\", new_head, head,\n> +\t\t\t\t   0, UPDATE_REFS_DIE_ON_ERR);\n>  \t\t\t/*\n>  \t\t\t * We ignore errors in 'gc --auto', since the\n>  \t\t\t * user should see them.\n> @@ -1261,8 +1260,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n>  \t\t\tdie(_(\"Can merge only exactly one commit into empty head\"));\n>  \t\tremote_head_oid = &remoteheads->item->object.oid;\n>  \t\tread_empty(remote_head_oid->hash, 0);\n> -\t\tupdate_ref(\"initial pull\", \"HEAD\", remote_head_oid->hash,\n> -\t\t\t   NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n> +\t\tupdate_ref(\"initial pull\", \"HEAD\", remote_head_oid, NULL, 0,\n> +\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n>  \t\tgoto done;\n>  \t}\n>  \n> @@ -1357,8 +1356,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n>  \t\tfree(list);\n>  \t}\n>  \n> -\tupdate_ref(\"updating ORIG_HEAD\", \"ORIG_HEAD\", head_commit->object.oid.hash,\n> -\t\t   NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n> +\tupdate_ref(\"updating ORIG_HEAD\", \"ORIG_HEAD\",\n> +\t\t   &head_commit->object.oid, NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n>  \n>  \tif (remoteheads && !common) {\n>  \t\t/* No common ancestors found. */\n> diff --git a/builtin/notes.c b/builtin/notes.c\n> index 8e54f2d146..8276af419b 100644\n> --- a/builtin/notes.c\n> +++ b/builtin/notes.c\n> @@ -736,8 +736,8 @@ static int merge_commit(struct notes_merge_options *o)\n>  \tformat_commit_message(partial, \"%s\", &msg, &pretty_ctx);\n>  \tstrbuf_trim(&msg);\n>  \tstrbuf_insert(&msg, 0, \"notes: \", 7);\n> -\tupdate_ref(msg.buf, o->local_ref, oid.hash,\n> -\t\t   is_null_oid(&parent_oid) ? NULL : parent_oid.hash,\n> +\tupdate_ref(msg.buf, o->local_ref, &oid,\n> +\t\t   is_null_oid(&parent_oid) ? NULL : &parent_oid,\n>  \t\t   0, UPDATE_REFS_DIE_ON_ERR);\n>  \n>  \tfree_notes(t);\n> @@ -850,12 +850,12 @@ static int merge(int argc, const char **argv, const char *prefix)\n>  \n>  \tif (result >= 0) /* Merge resulted (trivially) in result_oid */\n>  \t\t/* Update default notes ref with new commit */\n> -\t\tupdate_ref(msg.buf, default_notes_ref(), result_oid.hash, NULL,\n> -\t\t\t   0, UPDATE_REFS_DIE_ON_ERR);\n> +\t\tupdate_ref(msg.buf, default_notes_ref(), &result_oid, NULL, 0,\n> +\t\t\t   UPDATE_REFS_DIE_ON_ERR);\n>  \telse { /* Merge has unresolved conflicts */\n>  \t\tconst struct worktree *wt;\n>  \t\t/* Update .git/NOTES_MERGE_PARTIAL with partial merge result */\n> -\t\tupdate_ref(msg.buf, \"NOTES_MERGE_PARTIAL\", result_oid.hash, NULL,\n> +\t\tupdate_ref(msg.buf, \"NOTES_MERGE_PARTIAL\", &result_oid, NULL,\n>  \t\t\t   0, UPDATE_REFS_DIE_ON_ERR);\n>  \t\t/* Store ref-to-be-updated into .git/NOTES_MERGE_REF */\n>  \t\twt = find_shared_symref(\"NOTES_MERGE_REF\", default_notes_ref());\n> diff --git a/builtin/pull.c b/builtin/pull.c\n> index 6f772e8a22..9b2d67fe43 100644\n> --- a/builtin/pull.c\n> +++ b/builtin/pull.c\n> @@ -544,7 +544,7 @@ static int pull_into_void(const struct object_id *merge_head,\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> +\tif (update_ref(\"initial pull\", \"HEAD\", merge_head, curr_head, 0, UPDATE_REFS_DIE_ON_ERR))\n>  \t\treturn 1;\n>  \n>  \treturn 0;\n> diff --git a/builtin/reset.c b/builtin/reset.c\n> index 5f3632e05b..d4003f76ab 100644\n> --- a/builtin/reset.c\n> +++ b/builtin/reset.c\n> @@ -266,12 +266,12 @@ static int reset_refs(const char *rev, const struct object_id *oid)\n>  \tif (!get_oid(\"HEAD\", &oid_orig)) {\n>  \t\torig = &oid_orig;\n>  \t\tset_reflog_message(&msg, \"updating ORIG_HEAD\", NULL);\n> -\t\tupdate_ref_oid(msg.buf, \"ORIG_HEAD\", orig, old_orig, 0,\n> +\t\tupdate_ref(msg.buf, \"ORIG_HEAD\", orig, old_orig, 0,\n>  \t\t\t   UPDATE_REFS_MSG_ON_ERR);\n>  \t} else if (old_orig)\n>  \t\tdelete_ref(NULL, \"ORIG_HEAD\", old_orig, 0);\n>  \tset_reflog_message(&msg, \"updating HEAD\", rev);\n> -\tupdate_ref_status = update_ref_oid(msg.buf, \"HEAD\", oid, orig, 0,\n> +\tupdate_ref_status = update_ref(msg.buf, \"HEAD\", oid, orig, 0,\n>  \t\t\t\t       UPDATE_REFS_MSG_ON_ERR);\n>  \tstrbuf_release(&msg);\n>  \treturn update_ref_status;\n> diff --git a/builtin/update-ref.c b/builtin/update-ref.c\n> index bf0f80ebae..f491cf1a92 100644\n> --- a/builtin/update-ref.c\n> +++ b/builtin/update-ref.c\n> @@ -437,7 +437,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)\n>  \t\t\t\t  (oldval && !is_null_oid(&oldoid)) ? &oldoid : NULL,\n>  \t\t\t\t  flags);\n>  \telse\n> -\t\treturn update_ref(msg, refname, oid.hash, oldval ? oldoid.hash : NULL,\n> +\t\treturn update_ref(msg, refname, &oid, oldval ? &oldoid : NULL,\n>  \t\t\t\t  flags | create_reflog_flag,\n>  \t\t\t\t  UPDATE_REFS_DIE_ON_ERR);\n>  }\n> diff --git a/notes-cache.c b/notes-cache.c\n> index 29b4cede5f..927b6645db 100644\n> --- a/notes-cache.c\n> +++ b/notes-cache.c\n> @@ -59,8 +59,7 @@ int notes_cache_write(struct notes_cache *c)\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_oid.hash,\n> -\t\t       NULL, 0, UPDATE_REFS_QUIET_ON_ERR) < 0)\n> +\tif (update_ref(\"update notes cache\", c->tree.update_ref, &commit_oid, NULL, 0, UPDATE_REFS_QUIET_ON_ERR) < 0)\n\nThis line looks a little long.\n\n>  \t\treturn -1;\n>  \n>  \treturn 0;\n> diff --git a/notes-utils.c b/notes-utils.c\n> index 9765deb41a..3a7008948c 100644\n> --- a/notes-utils.c\n> +++ b/notes-utils.c\n> @@ -49,7 +49,7 @@ void commit_notes(struct notes_tree *t, const char *msg)\n>  \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_oid.hash, NULL, 0,\n> +\tupdate_ref(buf.buf, t->update_ref, &commit_oid, NULL, 0,\n>  \t\t   UPDATE_REFS_DIE_ON_ERR);\n>  \n>  \tstrbuf_release(&buf);\n> diff --git a/refs.c b/refs.c\n> index 0a5b68d6fb..66d66af126 100644\n> --- a/refs.c\n> +++ b/refs.c\n> @@ -574,8 +574,8 @@ long get_files_ref_lock_timeout_ms(void)\n>  \treturn timeout_ms;\n>  }\n>  \n> -static int write_pseudoref(const char *pseudoref, const unsigned char *sha1,\n> -\t\t\t   const unsigned char *old_sha1, struct strbuf *err)\n> +static int write_pseudoref(const char *pseudoref, const struct object_id *oid,\n> +\t\t\t   const struct object_id *old_oid, struct strbuf *err)\n>  {\n>  \tconst char *filename;\n>  \tint fd;\n> @@ -583,7 +583,7 @@ static int write_pseudoref(const char *pseudoref, const unsigned char *sha1,\n>  \tstruct strbuf buf = STRBUF_INIT;\n>  \tint ret = -1;\n>  \n> -\tstrbuf_addf(&buf, \"%s\\n\", sha1_to_hex(sha1));\n> +\tstrbuf_addf(&buf, \"%s\\n\", oid_to_hex(oid));\n>  \n>  \tfilename = git_path(\"%s\", pseudoref);\n>  \tfd = hold_lock_file_for_update_timeout(&lock, filename,\n> @@ -595,12 +595,12 @@ static int write_pseudoref(const char *pseudoref, const unsigned char *sha1,\n>  \t\tgoto done;\n>  \t}\n>  \n> -\tif (old_sha1) {\n> -\t\tunsigned char actual_old_sha1[20];\n> +\tif (old_oid) {\n> +\t\tstruct object_id actual_old_oid;\n>  \n> -\t\tif (read_ref(pseudoref, actual_old_sha1))\n> +\t\tif (read_ref(pseudoref, actual_old_oid.hash))\n>  \t\t\tdie(\"could not read ref '%s'\", pseudoref);\n> -\t\tif (hashcmp(actual_old_sha1, old_sha1)) {\n> +\t\tif (oidcmp(&actual_old_oid, old_oid)) {\n>  \t\t\tstrbuf_addf(err, \"unexpected sha1 when writing '%s'\", pseudoref);\n>  \t\t\trollback_lock_file(&lock);\n>  \t\t\tgoto done;\n> @@ -985,17 +985,10 @@ int ref_transaction_verify(struct ref_transaction *transaction,\n>  \t\t\t\t      flags, NULL, err);\n>  }\n>  \n> -int update_ref_oid(const char *msg, const char *refname,\n> -\t       const struct object_id *new_oid, const struct object_id *old_oid,\n> -\t       unsigned int flags, enum action_on_err onerr)\n> -{\n> -\treturn update_ref(msg, refname, new_oid ? new_oid->hash : NULL,\n> -\t\told_oid ? old_oid->hash : NULL, flags, onerr);\n> -}\n\nAfter this deletion I think there are 2 empty lines, one of them can\nprobably be removed.\n\n>  \n>  int refs_update_ref(struct ref_store *refs, const char *msg,\n> -\t\t    const char *refname, const unsigned char *new_sha1,\n> -\t\t    const unsigned char *old_sha1, unsigned int flags,\n> +\t\t    const char *refname, const struct object_id *new_oid,\n> +\t\t    const struct object_id *old_oid, unsigned int flags,\n>  \t\t    enum action_on_err onerr)\n>  {\n>  \tstruct ref_transaction *t = NULL;\n> @@ -1003,12 +996,12 @@ int refs_update_ref(struct ref_store *refs, const char *msg,\n>  \tint ret = 0;\n>  \n>  \tif (ref_type(refname) == REF_TYPE_PSEUDOREF) {\n> -\t\tassert(refs == get_main_ref_store());\n> -\t\tret = write_pseudoref(refname, new_sha1, old_sha1, &err);\n> +\t\tret = write_pseudoref(refname, new_oid, old_oid, &err);\n>  \t} else {\n>  \t\tt = ref_store_transaction_begin(refs, &err);\n>  \t\tif (!t ||\n> -\t\t    ref_transaction_update(t, refname, new_sha1, old_sha1,\n> +\t\t    ref_transaction_update(t, refname, new_oid ? new_oid->hash : NULL,\n> +\t\t\t\t\t   old_oid ? old_oid->hash : NULL,\n>  \t\t\t\t\t   flags, msg, &err) ||\n>  \t\t    ref_transaction_commit(t, &err)) {\n>  \t\t\tret = 1;\n> @@ -1038,12 +1031,12 @@ int refs_update_ref(struct ref_store *refs, const char *msg,\n>  }\n>  \n>  int update_ref(const char *msg, const char *refname,\n> -\t       const unsigned char *new_sha1,\n> -\t       const unsigned char *old_sha1,\n> +\t       const struct object_id *new_oid,\n> +\t       const struct object_id *old_oid,\n>  \t       unsigned int flags, enum action_on_err onerr)\n>  {\n> -\treturn refs_update_ref(get_main_ref_store(), msg, refname, new_sha1,\n> -\t\t\t       old_sha1, flags, onerr);\n> +\treturn refs_update_ref(get_main_ref_store(), msg, refname, new_oid,\n> +\t\t\t       old_oid, flags, onerr);\n>  }\n>  \n>  char *shorten_unambiguous_ref(const char *refname, int strict)\n> diff --git a/refs.h b/refs.h\n> index 07e9907b31..369614d392 100644\n> --- a/refs.h\n> +++ b/refs.h\n> @@ -636,12 +636,9 @@ void ref_transaction_free(struct ref_transaction *transaction);\n>   * argument.\n>   */\n>  int refs_update_ref(struct ref_store *refs, const char *msg, const char *refname,\n> -\t\t    const unsigned char *new_sha1, const unsigned char *old_sha1,\n> +\t\t    const struct object_id *new_oid, const struct object_id *old_oid,\n>  \t\t    unsigned int flags, enum action_on_err onerr);\n>  int update_ref(const char *msg, const char *refname,\n> -\t       const unsigned char *new_sha1, const unsigned char *old_sha1,\n> -\t       unsigned int flags, enum action_on_err onerr);\n> -int update_ref_oid(const char *msg, const char *refname,\n>  \t       const struct object_id *new_oid, const struct object_id *old_oid,\n>  \t       unsigned int flags, enum action_on_err onerr);\n>  \n> diff --git a/sequencer.c b/sequencer.c\n> index 60636ce54b..b349474bd3 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -1114,12 +1114,10 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n>  \t * write it at all.\n>  \t */\n>  \tif (command == TODO_PICK && !opts->no_commit && (res == 0 || res == 1) &&\n> -\t    update_ref(NULL, \"CHERRY_PICK_HEAD\", commit->object.oid.hash, NULL,\n> -\t\t       REF_NODEREF, UPDATE_REFS_MSG_ON_ERR))\n> +\t    update_ref(NULL, \"CHERRY_PICK_HEAD\", &commit->object.oid, NULL, REF_NODEREF, UPDATE_REFS_MSG_ON_ERR))\n>  \t\tres = -1;\n>  \tif (command == TODO_REVERT && ((opts->no_commit && res == 0) || res == 1) &&\n> -\t    update_ref(NULL, \"REVERT_HEAD\", commit->object.oid.hash, NULL,\n> -\t\t       REF_NODEREF, UPDATE_REFS_MSG_ON_ERR))\n> +\t    update_ref(NULL, \"REVERT_HEAD\", &commit->object.oid, NULL, REF_NODEREF, UPDATE_REFS_MSG_ON_ERR))\n>  \t\tres = -1;\n>  \n>  \tif (res) {\n> @@ -2123,8 +2121,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)\n>  \t\t\t}\n>  \t\t\tmsg = reflog_message(opts, \"finish\", \"%s onto %s\",\n>  \t\t\t\thead_ref.buf, buf.buf);\n> -\t\t\tif (update_ref(msg, head_ref.buf, head.hash, orig.hash,\n> -\t\t\t\t\tREF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) {\n> +\t\t\tif (update_ref(msg, head_ref.buf, &head, &orig, REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) {\n>  \t\t\t\tres = error(_(\"could not update %s\"),\n>  \t\t\t\t\thead_ref.buf);\n>  \t\t\t\tgoto cleanup_head_ref;\n> diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\n> index 4624238641..af8dba9560 100644\n> --- a/t/helper/test-ref-store.c\n> +++ b/t/helper/test-ref-store.c\n> @@ -233,15 +233,15 @@ static int cmd_update_ref(struct ref_store *refs, const char **argv)\n>  \tconst char *new_sha1_buf = notnull(*argv++, \"old-sha1\");\n>  \tconst char *old_sha1_buf = notnull(*argv++, \"old-sha1\");\n>  \tunsigned int flags = arg_flags(*argv++, \"flags\");\n> -\tunsigned char old_sha1[20];\n> -\tunsigned char new_sha1[20];\n> +\tstruct object_id old_oid;\n> +\tstruct object_id new_oid;\n>  \n> -\tif (get_sha1_hex(old_sha1_buf, old_sha1) ||\n> -\t    get_sha1_hex(new_sha1_buf, new_sha1))\n> +\tif (get_oid_hex(old_sha1_buf, &old_oid) ||\n> +\t    get_oid_hex(new_sha1_buf, &new_oid))\n>  \t\tdie(\"not sha-1\");\n>  \n>  \treturn refs_update_ref(refs, msg, refname,\n> -\t\t\t       new_sha1, old_sha1,\n> +\t\t\t       &new_oid, &old_oid,\n>  \t\t\t       flags, UPDATE_REFS_DIE_ON_ERR);\n>  }\n>  \n> diff --git a/transport-helper.c b/transport-helper.c\n> index c948d5215c..f183601261 100644\n> --- a/transport-helper.c\n> +++ b/transport-helper.c\n> @@ -795,7 +795,8 @@ static int push_update_refs_status(struct helper_data *data,\n>  \t\tprivate = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);\n>  \t\tif (!private)\n>  \t\t\tcontinue;\n> -\t\tupdate_ref(\"update by helper\", private, ref->new_oid.hash, NULL, 0, 0);\n> +\t\tupdate_ref(\"update by helper\", private, &ref->new_oid, NULL,\n> +\t\t\t   0, 0);\n>  \t\tfree(private);\n>  \t}\n>  \tstrbuf_release(&buf);\n> diff --git a/transport.c b/transport.c\n> index fb8c01e57a..09bd06e6e5 100644\n> --- a/transport.c\n> +++ b/transport.c\n> @@ -305,8 +305,8 @@ void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int v\n>  \t\tif (ref->deletion) {\n>  \t\t\tdelete_ref(NULL, rs.dst, NULL, 0);\n>  \t\t} else\n> -\t\t\tupdate_ref(\"update by push\", rs.dst,\n> -\t\t\t\t\tref->new_oid.hash, NULL, 0, 0);\n> +\t\t\tupdate_ref(\"update by push\", rs.dst, &ref->new_oid,\n> +\t\t\t\t   NULL, 0, 0);\n>  \t\tfree(rs.dst);\n>  \t}\n>  }\n> -- \n> 2.14.2.822.g60be5d43e6\n> \n\n-- \nBrandon Williams\n"},{"id":"329492","messageId":"CAGZ79kbULxhSAEx6x6+4Q5nCG4pT98AXVfLBMwQHf-Kx4Wzc=Q@mail.gmail.com","threadId":"46876","inReplyTo":"20171001220831.214705-14-sandals@crustytoothpaste.net","subject":"Re: [PATCH 13/24] builtin/pack-objects: convert to struct object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-10-02T23:20:38Z","receivedAt":"2017-10-02T23:20:44Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"> @@ -2520,17 +2521,17 @@ static void read_object_list_from_stdin(void)\n>                         continue;\n>                 }\n>                 if (line[0] == '-') {\n> -                       if (get_sha1_hex(line+1, sha1))\n> +                       if (get_oid_hex(line+1, &oid))\n>                                 die(\"expected edge sha1, got garbage:\\n %s\",\n>                                     line);\n...\n\n> -               if (get_sha1_hex(line, sha1))\n> +               if (parse_oid_hex(line, &oid, &p))\n>                         die(\"expected sha1, got garbage:\\n %s\", line);\n\nIdeally we do not forget about converting the die() calls, too.\n"},{"id":"329493","messageId":"20171002232635.GD5189@google.com","threadId":"46876","inReplyTo":"20171001220831.214705-16-sandals@crustytoothpaste.net","subject":"Re: [PATCH 15/24] refs: convert read_ref_at to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-02T23:26:35Z","receivedAt":"2017-10-02T23:26:43Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 10/01, brian m. carlson wrote:\n> Convert the callers and internals, including struct read_ref_at_cb, of\n> read_ref_at to use struct object_id.\n> \n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> ---\n>  builtin/show-branch.c |  5 ++---\n>  refs.c                | 34 +++++++++++++++++-----------------\n>  refs.h                |  2 +-\n>  sha1_name.c           |  3 +--\n>  4 files changed, 21 insertions(+), 23 deletions(-)\n> \n> diff --git a/builtin/show-branch.c b/builtin/show-branch.c\n> index 722a7f4bec..8ef8ad10c5 100644\n> --- a/builtin/show-branch.c\n> +++ b/builtin/show-branch.c\n> @@ -731,7 +731,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n>  \t\t\t\t/* Ah, that is a date spec... */\n>  \t\t\t\ttimestamp_t at;\n>  \t\t\t\tat = approxidate(reflog_base);\n> -\t\t\t\tread_ref_at(ref, flags, at, -1, oid.hash, NULL,\n> +\t\t\t\tread_ref_at(ref, flags, at, -1, &oid, NULL,\n>  \t\t\t\t\t    NULL, NULL, &base);\n>  \t\t\t}\n>  \t\t}\n> @@ -743,8 +743,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n>  \t\t\ttimestamp_t timestamp;\n>  \t\t\tint tz;\n>  \n> -\t\t\tif (read_ref_at(ref, flags, 0, base+i, oid.hash, &logmsg,\n> -\t\t\t\t\t&timestamp, &tz, NULL)) {\n> +\t\t\tif (read_ref_at(ref, flags, 0, base + i, &oid, &logmsg, &timestamp, &tz, NULL)) {\n\nThis line maybe got too long?\n\n> diff --git a/sha1_name.c b/sha1_name.c\n> index 7de12743f3..f0ec3f0454 100644\n> --- a/sha1_name.c\n> +++ b/sha1_name.c\n> @@ -697,8 +697,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,\n>  \t\t\t\treturn -1;\n>  \t\t\t}\n>  \t\t}\n> -\t\tif (read_ref_at(real_ref, flags, at_time, nth, oid->hash, NULL,\n> -\t\t\t\t&co_time, &co_tz, &co_cnt)) {\n> +\t\tif (read_ref_at(real_ref, flags, at_time, nth, oid, NULL, &co_time, &co_tz, &co_cnt)) {\n>  \t\t\tif (!len) {\n>  \t\t\t\tif (starts_with(real_ref, \"refs/heads/\")) {\n>  \t\t\t\t\tstr = real_ref + 11;\n\nThis one too.\n\n-- \nBrandon Williams\n"},{"id":"329494","messageId":"20171002233442.GE5189@google.com","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH 00/24] object_id part 10","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-02T23:34:42Z","receivedAt":"2017-10-02T23:34:50Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 10/01, brian m. carlson wrote:\n> This is the tenth in a series of patches to convert from unsigned char\n> [20] to struct object_id.  This series mostly involves changes to the\n> refs code.  After these changes, there are almost no references to\n> unsigned char in the main refs code.\n> \n> I've tried to update the code comments as I've touched them, but if I've\n> missed any, please point them out.  A big thank-you goes out to René\n> Scharfe, who did the work to make resolve_ref_unsafe optionally take a\n> NULL pointer; this dramatically reduced the size of one of the patches,\n> and allowed a few others to be dropped during the rebase.\n\nAside from a few unimportant style nits the series looks good to me!\n\n-- \nBrandon Williams\n"},{"id":"329495","messageId":"CAGZ79kaoCEzc-2ZV60J2GEfxJwLMNg1fFZctEctMiGMVSU+74g@mail.gmail.com","threadId":"46876","inReplyTo":"20171001220831.214705-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH 00/24] object_id part 10","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-10-02T23:34:44Z","receivedAt":"2017-10-02T23:34:51Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Sun, Oct 1, 2017 at 3:08 PM, brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n> This is the tenth in a series of patches to convert from unsigned char\n> [20] to struct object_id.  This series mostly involves changes to the\n> refs code.  After these changes, there are almost no references to\n> unsigned char in the main refs code.\n>\n> I've tried to update the code comments as I've touched them, but if I've\n> missed any, please point them out.  A big thank-you goes out to René\n> Scharfe, who did the work to make resolve_ref_unsafe optionally take a\n> NULL pointer; this dramatically reduced the size of one of the patches,\n> and allowed a few others to be dropped during the rebase.\n>\n> I apologize for the unintended bounced emails that occurred in late\n> August; my mail server (previously hosted at home) got knocked offline\n> because I was without Internet for over a week after Hurricane Harvey.\n> I've since relocated mail to New York, so that shouldn't happen again.\n\nI hope you are ok. (It's not just mail servers that don't like water, but\nother personal belongings, too)\n\n>\n> This series is available from the following URL:\n> https://github.com/bk2204/git.git object-id-part10\n>\n\nThe whole series has been\nReviewed-by: Stefan Beller <sbeller@google.com>\n"},{"id":"329512","messageId":"20171003012359.x4llfbs2mgcn7yd4@genre.crustytoothpaste.net","threadId":"46876","inReplyTo":"CAGZ79kaY36mo2bpohO8cknPShOBbZt_tpi_kjoxLHE=cFJ3ROw@mail.gmail.com","subject":"Re: [PATCH 04/24] refs: convert update_ref and refs_update_ref to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-03T01:23:59Z","receivedAt":"2017-10-03T01:24:13Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Mon, Oct 02, 2017 at 03:37:38PM -0700, Stefan Beller wrote:\n> > diff --git a/bisect.c b/bisect.c\n> > index 96beeb5d13..e8470a2e0f 100644\n> > --- a/bisect.c\n> > +++ b/bisect.c\n> > @@ -685,11 +685,13 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)\n> >         char bisect_rev_hex[GIT_MAX_HEXSZ + 1];\n> >\n> >         memcpy(bisect_rev_hex, oid_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1);\n> > -       update_ref(NULL, \"BISECT_EXPECTED_REV\", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n> > +       update_ref(NULL, \"BISECT_EXPECTED_REV\", bisect_rev, NULL, 0,\n> > +                  UPDATE_REFS_DIE_ON_ERR);\n> \n> The number of characters decrease, yet the line gets an additional\n> line break. While I don't mind this, the most interesting question that\n> comes to mind is whether you tried the new clang formatting options\n> in tree to adapt the indentation? ;)\n\nI didn't.  Sometimes I use Coccinelle to convert part of a patch and fix\nup the rest by hand, and it really likes to break lines at certain\npoints.  I expect that I'll do at least one reroll, so I'll fix this.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\nhttps://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"329513","messageId":"20171003014350.yjjtrs5gxqdumuyw@genre.crustytoothpaste.net","threadId":"46876","inReplyTo":"CAGZ79kaoCEzc-2ZV60J2GEfxJwLMNg1fFZctEctMiGMVSU+74g@mail.gmail.com","subject":"Re: [PATCH 00/24] object_id part 10","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-10-03T01:43:50Z","receivedAt":"2017-10-03T01:44:03Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Mon, Oct 02, 2017 at 04:34:44PM -0700, Stefan Beller wrote:\n> On Sun, Oct 1, 2017 at 3:08 PM, brian m. carlson\n> <sandals@crustytoothpaste.net> wrote:\n> > I apologize for the unintended bounced emails that occurred in late\n> > August; my mail server (previously hosted at home) got knocked offline\n> > because I was without Internet for over a week after Hurricane Harvey.\n> > I've since relocated mail to New York, so that shouldn't happen again.\n> \n> I hope you are ok. (It's not just mail servers that don't like water, but\n> other personal belongings, too)\n\nYes, we got a small amount of water in our garage, but overall we did\nvery well with only minor damage.  We and our families and friends were\nsafe the entire time.\n\nI've spent some time getting the damage fixed instead of coding; hence\nthe delay in this series.  Overall, though, the damage was minor and we\nwere very fortunate.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\nhttps://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"}]}