{"thread":{"id":"39625","subject":"[PATCH v2 01/10] refs: convert some internal functions to use object_id","startedAt":"2015-06-13T22:16:33Z","lastAt":"2015-08-03T23:45:36Z","messageCount":13,"participants":["brian m. carlson","Junio C Hamano","Michael Haggerty"],"isPatch":true,"patchVersion":2,"patchTotal":10},"messages":[{"id":"263768","messageId":"1434233803-422442-1-git-send-email-sandals@crustytoothpaste.net","threadId":"39625","inReplyTo":null,"subject":"[PATCH v2 00/10] object_id part 2","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2015-06-13T22:16:33Z","receivedAt":"2015-06-13T22:16:33Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is another series of conversions to struct object_id.\n\nThis series converts more of the refs code and struct object to use\nstruct object_id.  It introduces an additional helper function,\nhas_object_file, which is the equivalent of has_sha1_file.  The name was\nchosen to be slightly more logical than has_oid_file, although it can be\nchanged if desired.\n\nThe next-to-last patch in this series is the conversion of struct object\nto use struct object_id.  This is a necessarily large patch because of\nthe large number of places this code is used.  That patch will most\nlikely be too large to make it through to the list, so this series is\navailable in the object-id-part2 branch from:\n\nhttps://github.com/bk2204/git.git\nhttps://git.crustytoothpaste.net/git/bmc/git.git\n\nChanges from v1:\n* Rebase on newer master.\n* Drop parse_oid_hex.  It ended up not being very useful (only 4 uses\n  over 47 patches) and a better version, like the one Michael Haggerty\n  suggested, can be introduced later if it's beneficial.\n* Fix the code that caused the httpd unit tests to fail.  This series\n  passes the testsuite on each commit, including the httpd tests.\n* Convert the remaining places touched by the first patch to use\n  object_id.  These were split out into their own patches to keep\n  patches to a reasonable size.  Some of these were in the original\n  series, and some were not.\n* Convert remote.c as well.  As part of the previous item, I went\n  through remote.c and converted the places touched by the first patch,\n  and realized that it was trivial to convert the rest of the file.\n  This patch is at the end as we can get slightly better conversion by\n  doing it after the conversion of struct object, meaning we can avoid\n  making another pass later.  I blame Michael for the inspiration to do\n  this. :-)\n\nbrian m. carlson (10):\n  refs: convert some internal functions to use object_id\n  sha1_file: introduce has_object_file helper.\n  Convert struct ref to use object_id.\n  add_sought_entry_mem: convert to struct object_id\n  parse_fetch: convert to use struct object_id\n  get_remote_heads: convert to struct object_id\n  push_refs_with_export: convert to struct object_id\n  ref_newer: convert to use struct object_id\n  Convert struct object to object_id\n  remote: convert functions to struct object_id\n\n archive.c                |   6 +--\n bisect.c                 |  10 ++--\n branch.c                 |   2 +-\n builtin/blame.c          |  46 +++++++++---------\n builtin/branch.c         |   2 +-\n builtin/checkout.c       |  24 +++++-----\n builtin/clone.c          |  18 +++----\n builtin/commit-tree.c    |   4 +-\n builtin/commit.c         |   8 ++--\n builtin/describe.c       |  20 ++++----\n builtin/diff-tree.c      |  12 ++---\n builtin/diff.c           |  12 ++---\n builtin/fast-export.c    |  34 +++++++-------\n builtin/fetch-pack.c     |  14 +++---\n builtin/fetch.c          |  54 ++++++++++-----------\n builtin/fmt-merge-msg.c  |   6 +--\n builtin/for-each-ref.c   |  12 ++---\n builtin/fsck.c           |  34 +++++++-------\n builtin/grep.c           |   6 +--\n builtin/index-pack.c     |  10 ++--\n builtin/log.c            |  24 +++++-----\n builtin/ls-remote.c      |   2 +-\n builtin/merge-base.c     |   8 ++--\n builtin/merge-tree.c     |   6 +--\n builtin/merge.c          |  60 ++++++++++++------------\n builtin/name-rev.c       |  12 ++---\n builtin/notes.c          |   2 +-\n builtin/pack-objects.c   |  16 +++----\n builtin/receive-pack.c   |   2 +-\n builtin/reflog.c         |   4 +-\n builtin/remote.c         |  12 ++---\n builtin/replace.c        |   2 +-\n builtin/reset.c          |   6 +--\n builtin/rev-list.c       |  18 +++----\n builtin/rev-parse.c      |   4 +-\n builtin/shortlog.c       |   2 +-\n builtin/show-branch.c    |   8 ++--\n builtin/tag.c            |   4 +-\n builtin/unpack-objects.c |  10 ++--\n bundle.c                 |  10 ++--\n cache-tree.c             |   2 +-\n cache.h                  |   3 ++\n combine-diff.c           |   4 +-\n commit.c                 |  32 ++++++-------\n connect.c                |  22 +++++----\n decorate.c               |   2 +-\n diff-lib.c               |   2 +-\n fetch-pack.c             |  24 +++++-----\n fsck.c                   |  10 ++--\n http-backend.c           |   2 +-\n http-push.c              |  88 +++++++++++++++++-----------------\n http.c                   |   2 +-\n line-log.c               |   6 +--\n list-objects.c           |   4 +-\n log-tree.c               |  32 ++++++-------\n merge-blobs.c            |   4 +-\n merge-recursive.c        |  22 ++++-----\n merge.c                  |   2 +-\n notes-merge.c            |  24 +++++-----\n object.c                 |   8 ++--\n object.h                 |   2 +-\n pack-bitmap-write.c      |  16 +++----\n pack-bitmap.c            |  34 +++++++-------\n patch-ids.c              |   6 +--\n pretty.c                 |  18 +++----\n refs.c                   | 106 ++++++++++++++++++++---------------------\n remote-curl.c            |  20 ++++----\n remote.c                 | 120 +++++++++++++++++++++++------------------------\n remote.h                 |   8 ++--\n revision.c               |  48 +++++++++----------\n send-pack.c              |  16 +++----\n sequencer.c              |  38 +++++++--------\n server-info.c            |   2 +-\n sha1_file.c              |   5 ++\n sha1_name.c              |  20 ++++----\n shallow.c                |   6 +--\n submodule.c              |   8 ++--\n tag.c                    |  10 ++--\n test-match-trees.c       |   2 +-\n transport-helper.c       |  24 +++++-----\n transport.c              |  32 ++++++-------\n transport.h              |   8 ++--\n tree.c                   |  10 ++--\n upload-pack.c            |  26 +++++-----\n walker.c                 |  18 +++----\n wt-status.c              |   2 +-\n 86 files changed, 729 insertions(+), 717 deletions(-)\n\n-- \n2.4.0\n"},{"id":"263767","messageId":"1434233803-422442-2-git-send-email-sandals@crustytoothpaste.net","threadId":"39625","inReplyTo":"1434233803-422442-1-git-send-email-sandals@crustytoothpaste.net","subject":"[PATCH v2 01/10] refs: convert some internal functions to use object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2015-06-13T22:16:34Z","receivedAt":"2015-06-13T22:16:34Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert several internal functions in refs.c to use struct object_id,\nand use the GIT_SHA1_HEXSZ constants in parse_ref_line.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n refs.c | 104 ++++++++++++++++++++++++++++++++---------------------------------\n 1 file changed, 52 insertions(+), 52 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 26d1ac1..2087012 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1158,7 +1158,7 @@ static const char PACKED_REFS_HEADER[] =\n  * Return a pointer to the refname within the line (null-terminated),\n  * or NULL if there was a problem.\n  */\n-static const char *parse_ref_line(struct strbuf *line, unsigned char *sha1)\n+static const char *parse_ref_line(struct strbuf *line, struct object_id *oid)\n {\n \tconst char *ref;\n \n@@ -1170,15 +1170,15 @@ static const char *parse_ref_line(struct strbuf *line, unsigned char *sha1)\n \t *  +1 (space in between hex and name)\n \t *  +1 (newline at the end of the line)\n \t */\n-\tif (line->len <= 42)\n+\tif (line->len <= GIT_SHA1_HEXSZ + 2)\n \t\treturn NULL;\n \n-\tif (get_sha1_hex(line->buf, sha1) < 0)\n+\tif (get_oid_hex(line->buf, oid) < 0)\n \t\treturn NULL;\n-\tif (!isspace(line->buf[40]))\n+\tif (!isspace(line->buf[GIT_SHA1_HEXSZ]))\n \t\treturn NULL;\n \n-\tref = line->buf + 41;\n+\tref = line->buf + GIT_SHA1_HEXSZ + 1;\n \tif (isspace(*ref))\n \t\treturn NULL;\n \n@@ -1223,7 +1223,7 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)\n \tenum { PEELED_NONE, PEELED_TAGS, PEELED_FULLY } peeled = PEELED_NONE;\n \n \twhile (strbuf_getwholeline(&line, f, '\\n') != EOF) {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tconst char *refname;\n \t\tconst char *traits;\n \n@@ -1236,17 +1236,17 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)\n \t\t\tcontinue;\n \t\t}\n \n-\t\trefname = parse_ref_line(&line, sha1);\n+\t\trefname = parse_ref_line(&line, &oid);\n \t\tif (refname) {\n \t\t\tint flag = REF_ISPACKED;\n \n \t\t\tif (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {\n \t\t\t\tif (!refname_is_safe(refname))\n \t\t\t\t\tdie(\"packed refname is dangerous: %s\", refname);\n-\t\t\t\thashclr(sha1);\n+\t\t\t\toidclr(&oid);\n \t\t\t\tflag |= REF_BAD_NAME | REF_ISBROKEN;\n \t\t\t}\n-\t\t\tlast = create_ref_entry(refname, sha1, flag, 0);\n+\t\t\tlast = create_ref_entry(refname, oid.hash, flag, 0);\n \t\t\tif (peeled == PEELED_FULLY ||\n \t\t\t    (peeled == PEELED_TAGS && starts_with(refname, \"refs/tags/\")))\n \t\t\t\tlast->flag |= REF_KNOWS_PEELED;\n@@ -1257,8 +1257,8 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)\n \t\t    line.buf[0] == '^' &&\n \t\t    line.len == PEELED_LINE_LENGTH &&\n \t\t    line.buf[PEELED_LINE_LENGTH - 1] == '\\n' &&\n-\t\t    !get_sha1_hex(line.buf + 1, sha1)) {\n-\t\t\thashcpy(last->u.value.peeled.hash, sha1);\n+\t\t    !get_oid_hex(line.buf + 1, &oid)) {\n+\t\t\toidcpy(&last->u.value.peeled, &oid);\n \t\t\t/*\n \t\t\t * Regardless of what the file header said,\n \t\t\t * we definitely know the value of *this*\n@@ -1352,7 +1352,7 @@ static void read_loose_refs(const char *dirname, struct ref_dir *dir)\n \tstrbuf_add(&refname, dirname, dirnamelen);\n \n \twhile ((de = readdir(d)) != NULL) {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tstruct stat st;\n \t\tint flag;\n \t\tconst char *refdir;\n@@ -1374,27 +1374,27 @@ static void read_loose_refs(const char *dirname, struct ref_dir *dir)\n \t\t\t\t\t\t\t  refname.len, 1));\n \t\t} else {\n \t\t\tif (*refs->name) {\n-\t\t\t\thashclr(sha1);\n+\t\t\t\toidclr(&oid);\n \t\t\t\tflag = 0;\n-\t\t\t\tif (resolve_gitlink_ref(refs->name, refname.buf, sha1) < 0) {\n-\t\t\t\t\thashclr(sha1);\n+\t\t\t\tif (resolve_gitlink_ref(refs->name, refname.buf, oid.hash) < 0) {\n+\t\t\t\t\toidclr(&oid);\n \t\t\t\t\tflag |= REF_ISBROKEN;\n \t\t\t\t}\n \t\t\t} else if (read_ref_full(refname.buf,\n \t\t\t\t\t\t RESOLVE_REF_READING,\n-\t\t\t\t\t\t sha1, &flag)) {\n-\t\t\t\thashclr(sha1);\n+\t\t\t\t\t\t oid.hash, &flag)) {\n+\t\t\t\toidclr(&oid);\n \t\t\t\tflag |= REF_ISBROKEN;\n \t\t\t}\n \t\t\tif (check_refname_format(refname.buf,\n \t\t\t\t\t\t REFNAME_ALLOW_ONELEVEL)) {\n \t\t\t\tif (!refname_is_safe(refname.buf))\n \t\t\t\t\tdie(\"loose refname is dangerous: %s\", refname.buf);\n-\t\t\t\thashclr(sha1);\n+\t\t\t\toidclr(&oid);\n \t\t\t\tflag |= REF_BAD_NAME | REF_ISBROKEN;\n \t\t\t}\n \t\t\tadd_entry_to_dir(dir,\n-\t\t\t\t\t create_ref_entry(refname.buf, sha1, flag, 0));\n+\t\t\t\t\t create_ref_entry(refname.buf, oid.hash, flag, 0));\n \t\t}\n \t\tstrbuf_setlen(&refname, dirnamelen);\n \t}\n@@ -1752,8 +1752,8 @@ int read_ref(const char *refname, unsigned char *sha1)\n \n int ref_exists(const char *refname)\n {\n-\tunsigned char sha1[20];\n-\treturn !!resolve_ref_unsafe(refname, RESOLVE_REF_READING, sha1, NULL);\n+\tstruct object_id oid;\n+\treturn !!resolve_ref_unsafe(refname, RESOLVE_REF_READING, oid.hash, NULL);\n }\n \n static int filter_refs(const char *refname, const struct object_id *oid,\n@@ -1857,7 +1857,7 @@ static enum peel_status peel_entry(struct ref_entry *entry, int repeel)\n int peel_ref(const char *refname, unsigned char *sha1)\n {\n \tint flag;\n-\tunsigned char base[20];\n+\tstruct object_id base;\n \n \tif (current_ref && (current_ref->name == refname\n \t\t\t    || !strcmp(current_ref->name, refname))) {\n@@ -1867,7 +1867,7 @@ int peel_ref(const char *refname, unsigned char *sha1)\n \t\treturn 0;\n \t}\n \n-\tif (read_ref_full(refname, RESOLVE_REF_READING, base, &flag))\n+\tif (read_ref_full(refname, RESOLVE_REF_READING, base.hash, &flag))\n \t\treturn -1;\n \n \t/*\n@@ -1888,7 +1888,7 @@ int peel_ref(const char *refname, unsigned char *sha1)\n \t\t}\n \t}\n \n-\treturn peel_object(base, sha1);\n+\treturn peel_object(base.hash, sha1);\n }\n \n struct warn_if_dangling_data {\n@@ -2300,11 +2300,11 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)\n \t*ref = NULL;\n \tfor (p = ref_rev_parse_rules; *p; p++) {\n \t\tchar fullref[PATH_MAX];\n-\t\tunsigned char sha1_from_ref[20];\n+\t\tstruct object_id oid_from_ref;\n \t\tunsigned char *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.hash : sha1;\n \t\tmksnpath(fullref, sizeof(fullref), *p, len, str);\n \t\tr = resolve_ref_unsafe(fullref, RESOLVE_REF_READING,\n \t\t\t\t       this_result, &flag);\n@@ -2331,13 +2331,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 oid;\n \t\tchar path[PATH_MAX];\n \t\tconst char *ref, *it;\n \n \t\tmksnpath(path, sizeof(path), *p, len, str);\n \t\tref = resolve_ref_unsafe(path, RESOLVE_REF_READING,\n-\t\t\t\t\t hash, NULL);\n+\t\t\t\t\t oid.hash, NULL);\n \t\tif (!ref)\n \t\t\tcontinue;\n \t\tif (reflog_exists(path))\n@@ -2348,7 +2348,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\thashcpy(sha1, oid.hash);\n \t\t}\n \t\tif (!warn_ambiguous_refs)\n \t\t\tbreak;\n@@ -2491,12 +2491,12 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,\n  * Write an entry to the packed-refs file for the specified refname.\n  * If peeled is non-NULL, write it as the entry's peeled value.\n  */\n-static void write_packed_entry(FILE *fh, char *refname, unsigned char *sha1,\n-\t\t\t       unsigned char *peeled)\n+static void write_packed_entry(FILE *fh, char *refname, struct object_id *oid,\n+\t\t\t       struct object_id *peeled)\n {\n-\tfprintf_or_die(fh, \"%s %s\\n\", sha1_to_hex(sha1), refname);\n+\tfprintf_or_die(fh, \"%s %s\\n\", oid_to_hex(oid), refname);\n \tif (peeled)\n-\t\tfprintf_or_die(fh, \"^%s\\n\", sha1_to_hex(peeled));\n+\t\tfprintf_or_die(fh, \"^%s\\n\", oid_to_hex(peeled));\n }\n \n /*\n@@ -2509,9 +2509,9 @@ static int write_packed_entry_fn(struct ref_entry *entry, void *cb_data)\n \tif (peel_status != PEEL_PEELED && peel_status != PEEL_NON_TAG)\n \t\terror(\"internal error: %s is not a valid packed reference!\",\n \t\t      entry->name);\n-\twrite_packed_entry(cb_data, entry->name, entry->u.value.oid.hash,\n+\twrite_packed_entry(cb_data, entry->name, &entry->u.value.oid,\n \t\t\t   peel_status == PEEL_PEELED ?\n-\t\t\t   entry->u.value.peeled.hash : NULL);\n+\t\t\t   &entry->u.value.peeled : NULL);\n \treturn 0;\n }\n \n@@ -2901,7 +2901,7 @@ static int commit_ref_update(struct ref_lock *lock,\n \n int rename_ref(const char *oldrefname, const char *newrefname, const char *logmsg)\n {\n-\tunsigned char sha1[20], orig_sha1[20];\n+\tstruct object_id oid, orig_oid;\n \tint flag = 0, logmoved = 0;\n \tstruct ref_lock *lock;\n \tstruct stat loginfo;\n@@ -2913,7 +2913,7 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms\n \t\treturn error(\"reflog for %s is a symlink\", oldrefname);\n \n \tsymref = resolve_ref_unsafe(oldrefname, RESOLVE_REF_READING,\n-\t\t\t\t    orig_sha1, &flag);\n+\t\t\t\t    orig_oid.hash, &flag);\n \tif (flag & REF_ISSYMREF)\n \t\treturn error(\"refname %s is a symbolic ref, renaming it is not supported\",\n \t\t\toldrefname);\n@@ -2927,13 +2927,13 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms\n \t\treturn error(\"unable to move logfile logs/%s to \"TMP_RENAMED_LOG\": %s\",\n \t\t\toldrefname, strerror(errno));\n \n-\tif (delete_ref(oldrefname, orig_sha1, REF_NODEREF)) {\n+\tif (delete_ref(oldrefname, orig_oid.hash, REF_NODEREF)) {\n \t\terror(\"unable to delete old %s\", oldrefname);\n \t\tgoto rollback;\n \t}\n \n-\tif (!read_ref_full(newrefname, RESOLVE_REF_READING, sha1, NULL) &&\n-\t    delete_ref(newrefname, sha1, REF_NODEREF)) {\n+\tif (!read_ref_full(newrefname, RESOLVE_REF_READING, oid.hash, NULL) &&\n+\t    delete_ref(newrefname, oid.hash, REF_NODEREF)) {\n \t\tif (errno==EISDIR) {\n \t\t\tif (remove_empty_directories(git_path(\"%s\", newrefname))) {\n \t\t\t\terror(\"Directory not empty: %s\", newrefname);\n@@ -2956,10 +2956,10 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms\n \t\tstrbuf_release(&err);\n \t\tgoto rollback;\n \t}\n-\thashcpy(lock->old_oid.hash, orig_sha1);\n+\toidcpy(&lock->old_oid, &orig_oid);\n \n-\tif (write_ref_to_lockfile(lock, orig_sha1) ||\n-\t    commit_ref_update(lock, orig_sha1, logmsg)) {\n+\tif (write_ref_to_lockfile(lock, orig_oid.hash) ||\n+\t    commit_ref_update(lock, orig_oid.hash, logmsg)) {\n \t\terror(\"unable to write current sha1 into %s\", newrefname);\n \t\tgoto rollback;\n \t}\n@@ -2976,8 +2976,8 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms\n \n \tflag = log_all_ref_updates;\n \tlog_all_ref_updates = 0;\n-\tif (write_ref_to_lockfile(lock, orig_sha1) ||\n-\t    commit_ref_update(lock, orig_sha1, NULL))\n+\tif (write_ref_to_lockfile(lock, orig_oid.hash) ||\n+\t    commit_ref_update(lock, orig_oid.hash, NULL))\n \t\terror(\"unable to write current sha1 into %s\", oldrefname);\n \tlog_all_ref_updates = flag;\n \n@@ -3230,11 +3230,11 @@ static int commit_ref_update(struct ref_lock *lock,\n \t\t * check with HEAD only which should cover 99% of all usage\n \t\t * scenarios (even 100% of the default ones).\n \t\t */\n-\t\tunsigned char head_sha1[20];\n+\t\tstruct object_id head_oid;\n \t\tint head_flag;\n \t\tconst char *head_ref;\n \t\thead_ref = resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING,\n-\t\t\t\t\t      head_sha1, &head_flag);\n+\t\t\t\t\t      head_oid.hash, &head_flag);\n \t\tif (head_ref && (head_flag & REF_ISSYMREF) &&\n \t\t    !strcmp(head_ref, lock->ref_name))\n \t\t\tlog_ref_write(\"HEAD\", lock->old_oid.hash, sha1, logmsg);\n@@ -3255,10 +3255,10 @@ int create_symref(const char *ref_target, const char *refs_heads_master,\n \tchar ref[1000];\n \tint fd, len, written;\n \tchar *git_HEAD = git_pathdup(\"%s\", ref_target);\n-\tunsigned char old_sha1[20], new_sha1[20];\n+\tstruct object_id old_oid, new_oid;\n \n-\tif (logmsg && read_ref(ref_target, old_sha1))\n-\t\thashclr(old_sha1);\n+\tif (logmsg && read_ref(ref_target, old_oid.hash))\n+\t\toidclr(&old_oid);\n \n \tif (safe_create_leading_directories(git_HEAD) < 0)\n \t\treturn error(\"unable to create directory for %s\", git_HEAD);\n@@ -3304,8 +3304,8 @@ int create_symref(const char *ref_target, const char *refs_heads_master,\n #ifndef NO_SYMLINK_HEAD\n \tdone:\n #endif\n-\tif (logmsg && !read_ref(refs_heads_master, new_sha1))\n-\t\tlog_ref_write(ref_target, old_sha1, new_sha1, logmsg);\n+\tif (logmsg && !read_ref(refs_heads_master, new_oid.hash))\n+\t\tlog_ref_write(ref_target, old_oid.hash, new_oid.hash, logmsg);\n \n \tfree(git_HEAD);\n \treturn 0;\n-- \n2.4.0\n"},{"id":"263775","messageId":"1434233803-422442-3-git-send-email-sandals@crustytoothpaste.net","threadId":"39625","inReplyTo":"1434233803-422442-1-git-send-email-sandals@crustytoothpaste.net","subject":"[PATCH v2 02/10] sha1_file: introduce has_object_file helper.","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2015-06-13T22:16:35Z","receivedAt":"2015-06-13T22:16:35Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Add has_object_file, which is a wrapper around has_sha1_file, but for\nstruct object_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n cache.h     | 3 +++\n sha1_file.c | 5 +++++\n 2 files changed, 8 insertions(+)\n\ndiff --git a/cache.h b/cache.h\nindex 571c98f..fa1f067 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -946,6 +946,9 @@ extern int has_sha1_pack(const unsigned char *sha1);\n  */\n extern int has_sha1_file(const unsigned char *sha1);\n \n+/* Same as the above, except for struct object_id. */\n+extern int has_object_file(const struct object_id *oid);\n+\n /*\n  * Return true iff an alternate object database has a loose object\n  * with the specified name.  This function does not respect replace\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 5038475..2bad0cd 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -3180,6 +3180,11 @@ int has_sha1_file(const unsigned char *sha1)\n \treturn find_pack_entry(sha1, &e);\n }\n \n+int has_object_file(const struct object_id *oid)\n+{\n+\treturn has_sha1_file(oid->hash);\n+}\n+\n static void check_tree(const void *buf, size_t size)\n {\n \tstruct tree_desc desc;\n-- \n2.4.0\n"},{"id":"263776","messageId":"1434233803-422442-4-git-send-email-sandals@crustytoothpaste.net","threadId":"39625","inReplyTo":"1434233803-422442-1-git-send-email-sandals@crustytoothpaste.net","subject":"[PATCH v2 03/10] Convert struct ref to use object_id.","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2015-06-13T22:16:36Z","receivedAt":"2015-06-13T22:16:36Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Use struct object_id in three fields in struct ref and convert all the\nnecessary places that use it.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/clone.c        | 16 +++++++-------\n builtin/fetch-pack.c   |  4 ++--\n builtin/fetch.c        | 50 +++++++++++++++++++++----------------------\n builtin/ls-remote.c    |  2 +-\n builtin/receive-pack.c |  2 +-\n builtin/remote.c       | 12 +++++------\n connect.c              |  2 +-\n fetch-pack.c           | 18 ++++++++--------\n http-push.c            | 46 +++++++++++++++++++--------------------\n http.c                 |  2 +-\n remote-curl.c          | 10 ++++-----\n remote.c               | 58 +++++++++++++++++++++++++-------------------------\n remote.h               |  6 +++---\n send-pack.c            | 16 +++++++-------\n transport-helper.c     | 18 ++++++++--------\n transport.c            | 32 ++++++++++++++--------------\n transport.h            |  8 +++----\n walker.c               |  2 +-\n 18 files changed, 152 insertions(+), 152 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 00535d0..d164712 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -496,7 +496,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\tadd_packed_ref(r->peer_ref->name, r->old_sha1);\n+\t\tadd_packed_ref(r->peer_ref->name, r->old_oid.hash);\n \t}\n \n \tif (commit_packed_refs())\n@@ -511,9 +511,9 @@ static void write_followtags(const struct ref *refs, const char *msg)\n \t\t\tcontinue;\n \t\tif (ends_with(ref->name, \"^{}\"))\n \t\t\tcontinue;\n-\t\tif (!has_sha1_file(ref->old_sha1))\n+\t\tif (!has_object_file(&ref->old_oid))\n \t\t\tcontinue;\n-\t\tupdate_ref(msg, ref->name, ref->old_sha1,\n+\t\tupdate_ref(msg, ref->name, ref->old_oid.hash,\n \t\t\t   NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n \t}\n }\n@@ -533,7 +533,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_sha1);\n+\thashcpy(sha1, ref->old_oid.hash);\n \t*rm = ref->next;\n \treturn 0;\n }\n@@ -582,12 +582,12 @@ static void update_head(const struct ref *our, const struct ref *remote,\n \t\t/* Local default branch link */\n \t\tcreate_symref(\"HEAD\", our->name, NULL);\n \t\tif (!option_bare) {\n-\t\t\tupdate_ref(msg, \"HEAD\", our->old_sha1, NULL, 0,\n+\t\t\tupdate_ref(msg, \"HEAD\", our->old_oid.hash, 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_sha1);\n+\t\tstruct commit *c = lookup_commit_reference(our->old_oid.hash);\n \t\t/* --branch specifies a non-branch (i.e. tags), detach HEAD */\n \t\tupdate_ref(msg, \"HEAD\", c->object.sha1,\n \t\t\t   NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);\n@@ -597,7 +597,7 @@ static void update_head(const struct ref *our, const struct ref *remote,\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_sha1,\n+\t\tupdate_ref(msg, \"HEAD\", remote->old_oid.hash,\n \t\t\t   NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);\n \t}\n }\n@@ -948,7 +948,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\t * remote HEAD check.\n \t\t */\n \t\tfor (ref = refs; ref; ref = ref->next)\n-\t\t\tif (is_null_sha1(ref->old_sha1)) {\n+\t\t\tif (is_null_oid(&ref->old_oid)) {\n \t\t\t\tcomplete_refs_before_fetch = 0;\n \t\t\t\tbreak;\n \t\t\t}\ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex 4a6b340..19215b3 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -17,7 +17,7 @@ static void add_sought_entry_mem(struct ref ***sought, int *nr, int *alloc,\n \tunsigned char sha1[20];\n \n \tif (namelen > 41 && name[40] == ' ' && !get_sha1_hex(name, sha1)) {\n-\t\thashcpy(ref->old_sha1, sha1);\n+\t\thashcpy(ref->old_oid.hash, sha1);\n \t\tname += 41;\n \t\tnamelen -= 41;\n \t}\n@@ -210,7 +210,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n \n \twhile (ref) {\n \t\tprintf(\"%s %s\\n\",\n-\t\t       sha1_to_hex(ref->old_sha1), ref->name);\n+\t\t       oid_to_hex(&ref->old_oid), ref->name);\n \t\tref = ref->next;\n \t}\n \ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 8d5b2db..af42cde 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -195,7 +195,7 @@ static int will_fetch(struct ref **head, const unsigned char *sha1)\n {\n \tstruct ref *rm = *head;\n \twhile (rm) {\n-\t\tif (!hashcmp(rm->old_sha1, sha1))\n+\t\tif (!hashcmp(rm->old_oid.hash, sha1))\n \t\t\treturn 1;\n \t\trm = rm->next;\n \t}\n@@ -223,8 +223,8 @@ static void find_non_local_tags(struct transport *transport,\n \t\t * as one to ignore by setting util to NULL.\n \t\t */\n \t\tif (ends_with(ref->name, \"^{}\")) {\n-\t\t\tif (item && !has_sha1_file(ref->old_sha1) &&\n-\t\t\t    !will_fetch(head, ref->old_sha1) &&\n+\t\t\tif (item && !has_object_file(&ref->old_oid) &&\n+\t\t\t    !will_fetch(head, ref->old_oid.hash) &&\n \t\t\t    !has_sha1_file(item->util) &&\n \t\t\t    !will_fetch(head, item->util))\n \t\t\t\titem->util = NULL;\n@@ -250,7 +250,7 @@ static void find_non_local_tags(struct transport *transport,\n \t\t\tcontinue;\n \n \t\titem = string_list_insert(&remote_refs, ref->name);\n-\t\titem->util = (void *)ref->old_sha1;\n+\t\titem->util = (void *)&ref->old_oid;\n \t}\n \tstring_list_clear(&existing_refs, 1);\n \n@@ -272,7 +272,7 @@ static void find_non_local_tags(struct transport *transport,\n \t\t{\n \t\t\tstruct ref *rm = alloc_ref(item->string);\n \t\t\trm->peer_ref = alloc_ref(item->string);\n-\t\t\thashcpy(rm->old_sha1, item->util);\n+\t\t\toidcpy(&rm->old_oid, item->util);\n \t\t\t**tail = rm;\n \t\t\t*tail = &rm->next;\n \t\t}\n@@ -418,8 +418,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_sha1,\n-\t\t\t\t   check_old ? ref->old_sha1 : NULL,\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   0, msg, &err))\n \t\tgoto fail;\n \n@@ -452,11 +452,11 @@ static int update_local_ref(struct ref *ref,\n \tstruct branch *current_branch = branch_get(NULL);\n \tconst char *pretty_ref = prettify_refname(ref->name);\n \n-\ttype = sha1_object_info(ref->new_sha1, NULL);\n+\ttype = sha1_object_info(ref->new_oid.hash, NULL);\n \tif (type < 0)\n-\t\tdie(_(\"object %s not found\"), sha1_to_hex(ref->new_sha1));\n+\t\tdie(_(\"object %s not found\"), oid_to_hex(&ref->new_oid));\n \n-\tif (!hashcmp(ref->old_sha1, ref->new_sha1)) {\n+\tif (!oidcmp(&ref->old_oid, &ref->new_oid)) {\n \t\tif (verbosity > 0)\n \t\t\tstrbuf_addf(display, \"= %-*s %-*s -> %s\",\n \t\t\t\t    TRANSPORT_SUMMARY(_(\"[up to date]\")),\n@@ -467,7 +467,7 @@ static int update_local_ref(struct ref *ref,\n \tif (current_branch &&\n \t    !strcmp(ref->name, current_branch->name) &&\n \t    !(update_head_ok || is_bare_repository()) &&\n-\t    !is_null_sha1(ref->old_sha1)) {\n+\t    !is_null_oid(&ref->old_oid)) {\n \t\t/*\n \t\t * If this is the head, and it's not okay to update\n \t\t * the head, and the old value of the head isn't empty...\n@@ -479,7 +479,7 @@ static int update_local_ref(struct ref *ref,\n \t\treturn 1;\n \t}\n \n-\tif (!is_null_sha1(ref->old_sha1) &&\n+\tif (!is_null_oid(&ref->old_oid) &&\n \t    starts_with(ref->name, \"refs/tags/\")) {\n \t\tint r;\n \t\tr = s_update_ref(\"updating tag\", ref, 0);\n@@ -491,8 +491,8 @@ static int update_local_ref(struct ref *ref,\n \t\treturn r;\n \t}\n \n-\tcurrent = lookup_commit_reference_gently(ref->old_sha1, 1);\n-\tupdated = lookup_commit_reference_gently(ref->new_sha1, 1);\n+\tcurrent = lookup_commit_reference_gently(ref->old_oid.hash, 1);\n+\tupdated = lookup_commit_reference_gently(ref->new_oid.hash, 1);\n \tif (!current || !updated) {\n \t\tconst char *msg;\n \t\tconst char *what;\n@@ -516,7 +516,7 @@ static int update_local_ref(struct ref *ref,\n \n \t\tif ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&\n \t\t    (recurse_submodules != RECURSE_SUBMODULES_ON))\n-\t\t\tcheck_for_new_submodule_commits(ref->new_sha1);\n+\t\t\tcheck_for_new_submodule_commits(ref->new_oid.hash);\n \t\tr = s_update_ref(msg, ref, 0);\n \t\tstrbuf_addf(display, \"%c %-*s %-*s -> %s%s\",\n \t\t\t    r ? '!' : '*',\n@@ -531,10 +531,10 @@ static int update_local_ref(struct ref *ref,\n \t\tint r;\n \t\tstrcpy(quickref, find_unique_abbrev(current->object.sha1, DEFAULT_ABBREV));\n \t\tstrcat(quickref, \"..\");\n-\t\tstrcat(quickref, find_unique_abbrev(ref->new_sha1, DEFAULT_ABBREV));\n+\t\tstrcat(quickref, find_unique_abbrev(ref->new_oid.hash, DEFAULT_ABBREV));\n \t\tif ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&\n \t\t    (recurse_submodules != RECURSE_SUBMODULES_ON))\n-\t\t\tcheck_for_new_submodule_commits(ref->new_sha1);\n+\t\t\tcheck_for_new_submodule_commits(ref->new_oid.hash);\n \t\tr = s_update_ref(\"fast-forward\", ref, 1);\n \t\tstrbuf_addf(display, \"%c %-*s %-*s -> %s%s\",\n \t\t\t    r ? '!' : ' ',\n@@ -547,10 +547,10 @@ static int update_local_ref(struct ref *ref,\n \t\tint r;\n \t\tstrcpy(quickref, find_unique_abbrev(current->object.sha1, DEFAULT_ABBREV));\n \t\tstrcat(quickref, \"...\");\n-\t\tstrcat(quickref, find_unique_abbrev(ref->new_sha1, DEFAULT_ABBREV));\n+\t\tstrcat(quickref, find_unique_abbrev(ref->new_oid.hash, DEFAULT_ABBREV));\n \t\tif ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&\n \t\t    (recurse_submodules != RECURSE_SUBMODULES_ON))\n-\t\t\tcheck_for_new_submodule_commits(ref->new_sha1);\n+\t\t\tcheck_for_new_submodule_commits(ref->new_oid.hash);\n \t\tr = s_update_ref(\"forced-update\", ref, 1);\n \t\tstrbuf_addf(display, \"%c %-*s %-*s -> %s  (%s)\",\n \t\t\t    r ? '!' : '+',\n@@ -577,7 +577,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_sha1);\n+\thashcpy(sha1, ref->old_oid.hash);\n \treturn 0;\n }\n \n@@ -628,7 +628,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \t\t\t\tcontinue;\n \t\t\t}\n \n-\t\t\tcommit = lookup_commit_reference_gently(rm->old_sha1, 1);\n+\t\t\tcommit = lookup_commit_reference_gently(rm->old_oid.hash, 1);\n \t\t\tif (!commit)\n \t\t\t\trm->fetch_head_status = FETCH_HEAD_NOT_FOR_MERGE;\n \n@@ -638,8 +638,8 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \t\t\tif (rm->peer_ref) {\n \t\t\t\tref = xcalloc(1, sizeof(*ref) + strlen(rm->peer_ref->name) + 1);\n \t\t\t\tstrcpy(ref->name, rm->peer_ref->name);\n-\t\t\t\thashcpy(ref->old_sha1, rm->peer_ref->old_sha1);\n-\t\t\t\thashcpy(ref->new_sha1, rm->old_sha1);\n+\t\t\t\toidcpy(&ref->old_oid, &rm->peer_ref->old_oid);\n+\t\t\t\toidcpy(&ref->new_oid, &rm->old_oid);\n \t\t\t\tref->force = rm->peer_ref->force;\n \t\t\t}\n \n@@ -684,7 +684,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \t\t\t\t/* fall-through */\n \t\t\tcase FETCH_HEAD_MERGE:\n \t\t\t\tfprintf(fp, \"%s\\t%s\\t%s\",\n-\t\t\t\t\tsha1_to_hex(rm->old_sha1),\n+\t\t\t\t\toid_to_hex(&rm->old_oid),\n \t\t\t\t\tmerge_status_marker,\n \t\t\t\t\tnote.buf);\n \t\t\t\tfor (i = 0; i < url_len; ++i)\n@@ -917,7 +917,7 @@ static int do_fetch(struct transport *transport,\n \t\t\t\t\t\t   rm->peer_ref->name);\n \t\t\tif (peer_item) {\n \t\t\t\tstruct object_id *old_oid = peer_item->util;\n-\t\t\t\thashcpy(rm->peer_ref->old_sha1, old_oid->hash);\n+\t\t\t\toidcpy(&rm->peer_ref->old_oid, old_oid);\n \t\t\t}\n \t\t}\n \t}\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 4554dbc..db35e58 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -129,7 +129,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\t\tcontinue;\n \t\tif (!tail_match(pattern, ref->name))\n \t\t\tcontinue;\n-\t\tprintf(\"%s\t%s\\n\", sha1_to_hex(ref->old_sha1), ref->name);\n+\t\tprintf(\"%s\t%s\\n\", oid_to_hex(&ref->old_oid), ref->name);\n \t\tstatus = 0; /* we found something */\n \t}\n \treturn status;\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 94d0571..5941c78 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -222,7 +222,7 @@ static void show_one_alternate_sha1(const unsigned char sha1[20], void *unused)\n static void collect_one_alternate_ref(const struct ref *ref, void *data)\n {\n \tstruct sha1_array *sa = data;\n-\tsha1_array_append(sa, ref->old_sha1);\n+\tsha1_array_append(sa, ref->old_oid.hash);\n }\n \n static void write_head_info(void)\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex f4a6ec9..fa4d04c 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -395,7 +395,7 @@ static int get_push_ref_states(const struct ref *remote_refs,\n \n \t\tif (!ref->peer_ref)\n \t\t\tcontinue;\n-\t\thashcpy(ref->new_sha1, ref->peer_ref->new_sha1);\n+\t\toidcpy(&ref->new_oid, &ref->peer_ref->new_oid);\n \n \t\titem = string_list_append(&states->push,\n \t\t\t\t\t  abbrev_branch(ref->peer_ref->name));\n@@ -404,14 +404,14 @@ static int get_push_ref_states(const struct ref *remote_refs,\n \t\tinfo->forced = ref->force;\n \t\tinfo->dest = xstrdup(abbrev_branch(ref->name));\n \n-\t\tif (is_null_sha1(ref->new_sha1)) {\n+\t\tif (is_null_oid(&ref->new_oid)) {\n \t\t\tinfo->status = PUSH_STATUS_DELETE;\n-\t\t} else if (!hashcmp(ref->old_sha1, ref->new_sha1))\n+\t\t} else if (!oidcmp(&ref->old_oid, &ref->new_oid))\n \t\t\tinfo->status = PUSH_STATUS_UPTODATE;\n-\t\telse if (is_null_sha1(ref->old_sha1))\n+\t\telse if (is_null_oid(&ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_CREATE;\n-\t\telse if (has_sha1_file(ref->old_sha1) &&\n-\t\t\t ref_newer(ref->new_sha1, ref->old_sha1))\n+\t\telse if (has_object_file(&ref->old_oid) &&\n+\t\t\t ref_newer(ref->new_oid.hash, ref->old_oid.hash))\n \t\t\tinfo->status = PUSH_STATUS_FASTFORWARD;\n \t\telse\n \t\t\tinfo->status = PUSH_STATUS_OUTOFDATE;\ndiff --git a/connect.c b/connect.c\nindex c0144d8..f8b10eb 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -165,7 +165,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,\n \t\tif (!check_ref(name, flags))\n \t\t\tcontinue;\n \t\tref = alloc_ref(buffer + 41);\n-\t\thashcpy(ref->old_sha1, old_sha1);\n+\t\thashcpy(ref->old_oid.hash, old_sha1);\n \t\t*list = ref;\n \t\tlist = &ref->next;\n \t\tgot_at_least_one_head = 1;\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex a912935..c02ea87 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -238,7 +238,7 @@ static void send_request(struct fetch_pack_args *args,\n \n static void insert_one_alternate_ref(const struct ref *ref, void *unused)\n {\n-\trev_list_insert_ref(NULL, ref->old_sha1);\n+\trev_list_insert_ref(NULL, ref->old_oid.hash);\n }\n \n #define INITIAL_FLUSH 16\n@@ -280,7 +280,7 @@ static int find_common(struct fetch_pack_args *args,\n \n \tfetching = 0;\n \tfor ( ; refs ; refs = refs->next) {\n-\t\tunsigned char *remote = refs->old_sha1;\n+\t\tunsigned char *remote = refs->old_oid.hash;\n \t\tconst char *remote_hex;\n \t\tstruct object *o;\n \n@@ -570,7 +570,7 @@ static void filter_refs(struct fetch_pack_args *args,\n \t\t\t\tcontinue;\n \t\t\tif (get_sha1_hex(ref->name, sha1) ||\n \t\t\t    ref->name[40] != '\\0' ||\n-\t\t\t    hashcmp(sha1, ref->old_sha1))\n+\t\t\t    hashcmp(sha1, ref->old_oid.hash))\n \t\t\t\tcontinue;\n \n \t\t\tref->matched = 1;\n@@ -583,7 +583,7 @@ static void filter_refs(struct fetch_pack_args *args,\n \n static void mark_alternate_complete(const struct ref *ref, void *unused)\n {\n-\tmark_complete(ref->old_sha1);\n+\tmark_complete(ref->old_oid.hash);\n }\n \n static int everything_local(struct fetch_pack_args *args,\n@@ -599,10 +599,10 @@ static int everything_local(struct fetch_pack_args *args,\n \tfor (ref = *refs; ref; ref = ref->next) {\n \t\tstruct object *o;\n \n-\t\tif (!has_sha1_file(ref->old_sha1))\n+\t\tif (!has_object_file(&ref->old_oid))\n \t\t\tcontinue;\n \n-\t\to = parse_object(ref->old_sha1);\n+\t\to = parse_object(ref->old_oid.hash);\n \t\tif (!o)\n \t\t\tcontinue;\n \n@@ -630,7 +630,7 @@ static int everything_local(struct fetch_pack_args *args,\n \t * Don't mark them common yet; the server has to be told so first.\n \t */\n \tfor (ref = *refs; ref; ref = ref->next) {\n-\t\tstruct object *o = deref_tag(lookup_object(ref->old_sha1),\n+\t\tstruct object *o = deref_tag(lookup_object(ref->old_oid.hash),\n \t\t\t\t\t     NULL, 0);\n \n \t\tif (!o || o->type != OBJ_COMMIT || !(o->flags & COMPLETE))\n@@ -646,7 +646,7 @@ static int everything_local(struct fetch_pack_args *args,\n \tfilter_refs(args, refs, sought, nr_sought);\n \n \tfor (retval = 1, ref = *refs; ref ; ref = ref->next) {\n-\t\tconst unsigned char *remote = ref->old_sha1;\n+\t\tconst unsigned char *remote = ref->old_oid.hash;\n \t\tstruct object *o;\n \n \t\to = lookup_object(remote);\n@@ -987,7 +987,7 @@ static void update_shallow(struct fetch_pack_args *args,\n \tif (!si->nr_ours && !si->nr_theirs)\n \t\treturn;\n \tfor (i = 0; i < nr_sought; i++)\n-\t\tsha1_array_append(&ref, sought[i]->old_sha1);\n+\t\tsha1_array_append(&ref, sought[i]->old_oid.hash);\n \tsi->ref = &ref;\n \n \tif (args->update_shallow) {\ndiff --git a/http-push.c b/http-push.c\nindex c98dad2..d054fdb 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1437,11 +1437,11 @@ static void one_remote_ref(const char *refname)\n \t * Fetch a copy of the object if it doesn't exist locally - it\n \t * may be required for updating server info later.\n \t */\n-\tif (repo->can_update_info_refs && !has_sha1_file(ref->old_sha1)) {\n-\t\tobj = lookup_unknown_object(ref->old_sha1);\n+\tif (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {\n+\t\tobj = lookup_unknown_object(ref->old_oid.hash);\n \t\tif (obj) {\n \t\t\tfprintf(stderr,\t\"  fetch %s for %s\\n\",\n-\t\t\t\tsha1_to_hex(ref->old_sha1), refname);\n+\t\t\t\toid_to_hex(&ref->old_oid), refname);\n \t\t\tadd_fetch_request(obj);\n \t\t}\n \t}\n@@ -1474,11 +1474,11 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)\n \t\treturn;\n \t}\n \n-\to = parse_object(ref->old_sha1);\n+\to = parse_object(ref->old_oid.hash);\n \tif (!o) {\n \t\tfprintf(stderr,\n \t\t\t\"Unable to parse object %s for remote ref %s\\n\",\n-\t\t\tsha1_to_hex(ref->old_sha1), ls->dentry_name);\n+\t\t\toid_to_hex(&ref->old_oid), ls->dentry_name);\n \t\taborted = 1;\n \t\tfree(ref);\n \t\treturn;\n@@ -1487,7 +1487,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)\n \tlen = strlen(ls->dentry_name) + 42;\n \tref_info = xcalloc(len + 1, 1);\n \tsprintf(ref_info, \"%s\t%s\\n\",\n-\t\tsha1_to_hex(ref->old_sha1), ls->dentry_name);\n+\t\toid_to_hex(&ref->old_oid), ls->dentry_name);\n \tfwrite_buffer(ref_info, 1, len, buf);\n \tfree(ref_info);\n \n@@ -1591,7 +1591,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)\n static int verify_merge_base(unsigned char *head_sha1, struct ref *remote)\n {\n \tstruct commit *head = lookup_commit_or_die(head_sha1, \"HEAD\");\n-\tstruct commit *branch = lookup_commit_or_die(remote->old_sha1, remote->name);\n+\tstruct commit *branch = lookup_commit_or_die(remote->old_oid.hash, remote->name);\n \n \treturn in_merge_bases(branch, head);\n }\n@@ -1654,11 +1654,11 @@ static int delete_remote_branch(const char *pattern, int force)\n \t\t\treturn error(\"Remote HEAD resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", sha1_to_hex(head_sha1));\n \n \t\t/* Remote branch must resolve to a known object */\n-\t\tif (is_null_sha1(remote_ref->old_sha1))\n+\t\tif (is_null_oid(&remote_ref->old_oid))\n \t\t\treturn error(\"Unable to resolve remote branch %s\",\n \t\t\t\t     remote_ref->name);\n-\t\tif (!has_sha1_file(remote_ref->old_sha1))\n-\t\t\treturn error(\"Remote branch %s resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", remote_ref->name, sha1_to_hex(remote_ref->old_sha1));\n+\t\tif (!has_object_file(&remote_ref->old_oid))\n+\t\t\treturn error(\"Remote branch %s resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", remote_ref->name, oid_to_hex(&remote_ref->old_oid));\n \n \t\t/* Remote branch must be an ancestor of remote HEAD */\n \t\tif (!verify_merge_base(head_sha1, remote_ref)) {\n@@ -1874,7 +1874,7 @@ int main(int argc, char **argv)\n \t\tif (!ref->peer_ref)\n \t\t\tcontinue;\n \n-\t\tif (is_null_sha1(ref->peer_ref->new_sha1)) {\n+\t\tif (is_null_oid(&ref->peer_ref->new_oid)) {\n \t\t\tif (delete_remote_branch(ref->name, 1) == -1) {\n \t\t\t\terror(\"Could not remove %s\", ref->name);\n \t\t\t\tif (helper_status)\n@@ -1887,7 +1887,7 @@ int main(int argc, char **argv)\n \t\t\tcontinue;\n \t\t}\n \n-\t\tif (!hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) {\n+\t\tif (!oidcmp(&ref->old_oid, &ref->peer_ref->new_oid)) {\n \t\t\tif (push_verbosely)\n \t\t\t\tfprintf(stderr, \"'%s': up-to-date\\n\", ref->name);\n \t\t\tif (helper_status)\n@@ -1896,11 +1896,11 @@ int main(int argc, char **argv)\n \t\t}\n \n \t\tif (!force_all &&\n-\t\t    !is_null_sha1(ref->old_sha1) &&\n+\t\t    !is_null_oid(&ref->old_oid) &&\n \t\t    !ref->force) {\n-\t\t\tif (!has_sha1_file(ref->old_sha1) ||\n-\t\t\t    !ref_newer(ref->peer_ref->new_sha1,\n-\t\t\t\t       ref->old_sha1)) {\n+\t\t\tif (!has_object_file(&ref->old_oid) ||\n+\t\t\t    !ref_newer(ref->peer_ref->new_oid.hash,\n+\t\t\t\t       ref->old_oid.hash)) {\n \t\t\t\t/*\n \t\t\t\t * We do not have the remote ref, or\n \t\t\t\t * we know that the remote ref is not\n@@ -1921,10 +1921,10 @@ int main(int argc, char **argv)\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t}\n-\t\thashcpy(ref->new_sha1, ref->peer_ref->new_sha1);\n+\t\toidcpy(&ref->new_oid, &ref->peer_ref->new_oid);\n \t\tnew_refs++;\n-\t\tstrcpy(old_hex, sha1_to_hex(ref->old_sha1));\n-\t\tnew_hex = sha1_to_hex(ref->new_sha1);\n+\t\tstrcpy(old_hex, oid_to_hex(&ref->old_oid));\n+\t\tnew_hex = oid_to_hex(&ref->new_oid);\n \n \t\tfprintf(stderr, \"updating '%s'\", ref->name);\n \t\tif (strcmp(ref->name, ref->peer_ref->name))\n@@ -1949,14 +1949,14 @@ int main(int argc, char **argv)\n \n \t\t/* Set up revision info for this refspec */\n \t\tcommit_argc = 3;\n-\t\tnew_sha1_hex = xstrdup(sha1_to_hex(ref->new_sha1));\n+\t\tnew_sha1_hex = xstrdup(oid_to_hex(&ref->new_oid));\n \t\told_sha1_hex = NULL;\n \t\tcommit_argv[1] = \"--objects\";\n \t\tcommit_argv[2] = new_sha1_hex;\n-\t\tif (!push_all && !is_null_sha1(ref->old_sha1)) {\n+\t\tif (!push_all && !is_null_oid(&ref->old_oid)) {\n \t\t\told_sha1_hex = xmalloc(42);\n \t\t\tsprintf(old_sha1_hex, \"^%s\",\n-\t\t\t\tsha1_to_hex(ref->old_sha1));\n+\t\t\t\toid_to_hex(&ref->old_oid));\n \t\t\tcommit_argv[3] = old_sha1_hex;\n \t\t\tcommit_argc++;\n \t\t}\n@@ -1988,7 +1988,7 @@ int main(int argc, char **argv)\n \t\trun_request_queue();\n \n \t\t/* Update the remote branch if all went well */\n-\t\tif (aborted || !update_remote(ref->new_sha1, ref_lock))\n+\t\tif (aborted || !update_remote(ref->new_oid.hash, ref_lock))\n \t\t\trc = 1;\n \n \t\tif (!rc)\ndiff --git a/http.c b/http.c\nindex f0c5bbc..96b7863 100644\n--- a/http.c\n+++ b/http.c\n@@ -1338,7 +1338,7 @@ int http_fetch_ref(const char *base, struct ref *ref)\n \tif (http_get_strbuf(url, &buffer, &options) == HTTP_OK) {\n \t\tstrbuf_rtrim(&buffer);\n \t\tif (buffer.len == 40)\n-\t\t\tret = get_sha1_hex(buffer.buf, ref->old_sha1);\n+\t\t\tret = get_oid_hex(buffer.buf, &ref->old_oid);\n \t\telse if (starts_with(buffer.buf, \"ref: \")) {\n \t\t\tref->symref = xstrdup(buffer.buf + 5);\n \t\t\tret = 0;\ndiff --git a/remote-curl.c b/remote-curl.c\nindex af7b678..80cb4c7 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -168,7 +168,7 @@ static struct ref *parse_info_refs(struct discovery *heads)\n \t\t\t\t      strlen(ref_name) + 1);\n \t\t\tmemset(ref, 0, sizeof(struct ref));\n \t\t\tstrcpy(ref->name, ref_name);\n-\t\t\tget_sha1_hex(start, ref->old_sha1);\n+\t\t\tget_oid_hex(start, &ref->old_oid);\n \t\t\tif (!refs)\n \t\t\t\trefs = ref;\n \t\t\tif (last_ref)\n@@ -347,7 +347,7 @@ static void output_refs(struct ref *refs)\n \t\tif (posn->symref)\n \t\t\tprintf(\"@%s %s\\n\", posn->symref, posn->name);\n \t\telse\n-\t\t\tprintf(\"%s %s\\n\", sha1_to_hex(posn->old_sha1), posn->name);\n+\t\t\tprintf(\"%s %s\\n\", oid_to_hex(&posn->old_oid), posn->name);\n \t}\n \tprintf(\"\\n\");\n \tfflush(stdout);\n@@ -701,7 +701,7 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)\n \tif (options.depth)\n \t\tdie(\"dumb http transport does not support --depth\");\n \tfor (i = 0; i < nr_heads; i++)\n-\t\ttargets[i] = xstrdup(sha1_to_hex(to_fetch[i]->old_sha1));\n+\t\ttargets[i] = xstrdup(oid_to_hex(&to_fetch[i]->old_oid));\n \n \twalker = get_http_walker(url.buf);\n \twalker->get_all = 1;\n@@ -762,7 +762,7 @@ static int fetch_git(struct discovery *heads,\n \t\tif (!*ref->name)\n \t\t\tdie(\"cannot fetch by sha1 over smart http\");\n \t\tpacket_buf_write(&preamble, \"%s %s\\n\",\n-\t\t\t\t sha1_to_hex(ref->old_sha1), ref->name);\n+\t\t\t\t oid_to_hex(&ref->old_oid), ref->name);\n \t}\n \tpacket_buf_flush(&preamble);\n \n@@ -814,7 +814,7 @@ static void parse_fetch(struct strbuf *buf)\n \t\t\t\tdie(\"protocol error: expected sha/ref, got %s'\", p);\n \n \t\t\tref = alloc_ref(name);\n-\t\t\thashcpy(ref->old_sha1, old_sha1);\n+\t\t\thashcpy(ref->old_oid.hash, old_sha1);\n \n \t\t\t*list = ref;\n \t\t\tlist = &ref->next;\ndiff --git a/remote.c b/remote.c\nindex 26504b7..0574120 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1111,7 +1111,7 @@ static void tail_link_ref(struct ref *ref, struct ref ***tail)\n static struct ref *alloc_delete_ref(void)\n {\n \tstruct ref *ref = alloc_ref(\"(delete)\");\n-\thashclr(ref->new_sha1);\n+\toidclr(&ref->new_oid);\n \treturn ref;\n }\n \n@@ -1131,7 +1131,7 @@ static int try_explicit_object_name(const char *name,\n \n \tif (match) {\n \t\t*match = alloc_ref(name);\n-\t\thashcpy((*match)->new_sha1, sha1);\n+\t\thashcpy((*match)->new_oid.hash, sha1);\n \t}\n \treturn 0;\n }\n@@ -1226,7 +1226,7 @@ static int match_explicit(struct ref *src, struct ref *dst,\n \tcase 0:\n \t\tif (starts_with(dst_value, \"refs/\"))\n \t\t\tmatched_dst = make_linked_ref(dst_value, dst_tail);\n-\t\telse if (is_null_sha1(matched_src->new_sha1))\n+\t\telse if (is_null_oid(&matched_src->new_oid))\n \t\t\terror(\"unable to delete '%s': remote ref does not exist\",\n \t\t\t      dst_value);\n \t\telse if ((dst_guess = guess_ref(dst_value, matched_src)))\n@@ -1357,10 +1357,10 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \tmemset(&sent_tips, 0, sizeof(sent_tips));\n \tfor (ref = *dst; ref; ref = ref->next) {\n \t\tif (ref->peer_ref &&\n-\t\t    !is_null_sha1(ref->peer_ref->new_sha1))\n-\t\t\tadd_to_tips(&sent_tips, ref->peer_ref->new_sha1);\n+\t\t    !is_null_oid(&ref->peer_ref->new_oid))\n+\t\t\tadd_to_tips(&sent_tips, ref->peer_ref->new_oid.hash);\n \t\telse\n-\t\t\tadd_to_tips(&sent_tips, ref->old_sha1);\n+\t\t\tadd_to_tips(&sent_tips, ref->old_oid.hash);\n \t\tif (starts_with(ref->name, \"refs/tags/\"))\n \t\t\tstring_list_append(&dst_tag, ref->name);\n \t}\n@@ -1374,7 +1374,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \t\t\tcontinue; /* not a tag */\n \t\tif (string_list_has_string(&dst_tag, ref->name))\n \t\t\tcontinue; /* they already have it */\n-\t\tif (sha1_object_info(ref->new_sha1, NULL) != OBJ_TAG)\n+\t\tif (sha1_object_info(ref->new_oid.hash, NULL) != OBJ_TAG)\n \t\t\tcontinue; /* be conservative */\n \t\titem = string_list_append(&src_tag, ref->name);\n \t\titem->util = ref;\n@@ -1394,9 +1394,9 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \t\t\tstruct ref *dst_ref;\n \t\t\tstruct commit *commit;\n \n-\t\t\tif (is_null_sha1(ref->new_sha1))\n+\t\t\tif (is_null_oid(&ref->new_oid))\n \t\t\t\tcontinue;\n-\t\t\tcommit = lookup_commit_reference_gently(ref->new_sha1, 1);\n+\t\t\tcommit = lookup_commit_reference_gently(ref->new_oid.hash, 1);\n \t\t\tif (!commit)\n \t\t\t\t/* not pushing a commit, which is not an error */\n \t\t\t\tcontinue;\n@@ -1410,7 +1410,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \n \t\t\t/* Add it in */\n \t\t\tdst_ref = make_linked_ref(ref->name, dst_tail);\n-\t\t\thashcpy(dst_ref->new_sha1, ref->new_sha1);\n+\t\t\toidcpy(&dst_ref->new_oid, &ref->new_oid);\n \t\t\tdst_ref->peer_ref = copy_ref(ref);\n \t\t}\n \t}\n@@ -1517,7 +1517,7 @@ int match_push_refs(struct ref *src, struct ref **dst,\n \n \t\t\t/* Create a new one and link it */\n \t\t\tdst_peer = make_linked_ref(dst_name, &dst_tail);\n-\t\t\thashcpy(dst_peer->new_sha1, ref->new_sha1);\n+\t\t\toidcpy(&dst_peer->new_oid, &ref->new_oid);\n \t\t\tstring_list_insert(&dst_ref_index,\n \t\t\t\tdst_peer->name)->util = dst_peer;\n \t\t}\n@@ -1569,13 +1569,13 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n \t\tint reject_reason = 0;\n \n \t\tif (ref->peer_ref)\n-\t\t\thashcpy(ref->new_sha1, ref->peer_ref->new_sha1);\n+\t\t\toidcpy(&ref->new_oid, &ref->peer_ref->new_oid);\n \t\telse if (!send_mirror)\n \t\t\tcontinue;\n \n-\t\tref->deletion = is_null_sha1(ref->new_sha1);\n+\t\tref->deletion = is_null_oid(&ref->new_oid);\n \t\tif (!ref->deletion &&\n-\t\t\t!hashcmp(ref->old_sha1, ref->new_sha1)) {\n+\t\t\t!oidcmp(&ref->old_oid, &ref->new_oid)) {\n \t\t\tref->status = REF_STATUS_UPTODATE;\n \t\t\tcontinue;\n \t\t}\n@@ -1594,7 +1594,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n \t\t */\n \t\tif (ref->expect_old_sha1) {\n \t\t\tif (ref->expect_old_no_trackback ||\n-\t\t\t    hashcmp(ref->old_sha1, ref->old_sha1_expect))\n+\t\t\t    oidcmp(&ref->old_oid, &ref->old_oid_expect))\n \t\t\t\treject_reason = REF_STATUS_REJECT_STALE;\n \t\t}\n \n@@ -1618,15 +1618,15 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n \t\t *     passing the --force argument\n \t\t */\n \n-\t\telse if (!ref->deletion && !is_null_sha1(ref->old_sha1)) {\n+\t\telse if (!ref->deletion && !is_null_oid(&ref->old_oid)) {\n \t\t\tif (starts_with(ref->name, \"refs/tags/\"))\n \t\t\t\treject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;\n-\t\t\telse if (!has_sha1_file(ref->old_sha1))\n+\t\t\telse if (!has_object_file(&ref->old_oid))\n \t\t\t\treject_reason = REF_STATUS_REJECT_FETCH_FIRST;\n-\t\t\telse if (!lookup_commit_reference_gently(ref->old_sha1, 1) ||\n-\t\t\t\t !lookup_commit_reference_gently(ref->new_sha1, 1))\n+\t\t\telse if (!lookup_commit_reference_gently(ref->old_oid.hash, 1) ||\n+\t\t\t\t !lookup_commit_reference_gently(ref->new_oid.hash, 1))\n \t\t\t\treject_reason = REF_STATUS_REJECT_NEEDS_FORCE;\n-\t\t\telse if (!ref_newer(ref->new_sha1, ref->old_sha1))\n+\t\t\telse if (!ref_newer(ref->new_oid.hash, ref->old_oid.hash))\n \t\t\t\treject_reason = REF_STATUS_REJECT_NONFASTFORWARD;\n \t\t}\n \n@@ -1925,7 +1925,7 @@ int get_fetch_map(const struct ref *remote_refs,\n \n \t\tif (refspec->exact_sha1) {\n \t\t\tref_map = alloc_ref(name);\n-\t\t\tget_sha1_hex(name, ref_map->old_sha1);\n+\t\t\tget_oid_hex(name, &ref_map->old_oid);\n \t\t} else {\n \t\t\tref_map = get_remote_ref(remote_refs, name);\n \t\t}\n@@ -1966,7 +1966,7 @@ int resolve_remote_symref(struct ref *ref, struct ref *list)\n \t\treturn 0;\n \tfor (; list; list = list->next)\n \t\tif (!strcmp(ref->symref, list->name)) {\n-\t\t\thashcpy(ref->old_sha1, list->old_sha1);\n+\t\t\toidcpy(&ref->old_oid, &list->old_oid);\n \t\t\treturn 0;\n \t\t}\n \treturn 1;\n@@ -2181,7 +2181,7 @@ static int one_local_ref(const char *refname, const struct object_id *oid,\n \n \tlen = strlen(refname) + 1;\n \tref = xcalloc(1, sizeof(*ref) + len);\n-\thashcpy(ref->new_sha1, oid->hash);\n+\toidcpy(&ref->new_oid, oid);\n \tmemcpy(ref->name, refname, len);\n \t**local_tail = ref;\n \t*local_tail = &ref->next;\n@@ -2218,7 +2218,7 @@ struct ref *guess_remote_head(const struct ref *head,\n \t/* If refs/heads/master could be right, it is. */\n \tif (!all) {\n \t\tr = find_ref_by_name(refs, \"refs/heads/master\");\n-\t\tif (r && !hashcmp(r->old_sha1, head->old_sha1))\n+\t\tif (r && !oidcmp(&r->old_oid, &head->old_oid))\n \t\t\treturn copy_ref(r);\n \t}\n \n@@ -2226,7 +2226,7 @@ struct ref *guess_remote_head(const struct ref *head,\n \tfor (r = refs; r; r = r->next) {\n \t\tif (r != head &&\n \t\t    starts_with(r->name, \"refs/heads/\") &&\n-\t\t    !hashcmp(r->old_sha1, head->old_sha1)) {\n+\t\t    !oidcmp(&r->old_oid, &head->old_oid)) {\n \t\t\t*tail = copy_ref(r);\n \t\t\ttail = &((*tail)->next);\n \t\t\tif (!all)\n@@ -2274,7 +2274,7 @@ static int get_stale_heads_cb(const char *refname, const struct object_id *oid,\n \n \tif (stale) {\n \t\tstruct ref *ref = make_linked_ref(refname, &info->stale_refs_tail);\n-\t\thashcpy(ref->new_sha1, oid->hash);\n+\t\toidcpy(&ref->new_oid, oid);\n \t}\n \n clean_exit:\n@@ -2394,8 +2394,8 @@ static void apply_cas(struct push_cas_option *cas,\n \t\t\tcontinue;\n \t\tref->expect_old_sha1 = 1;\n \t\tif (!entry->use_tracking)\n-\t\t\thashcpy(ref->old_sha1_expect, cas->entry[i].expect);\n-\t\telse if (remote_tracking(remote, ref->name, ref->old_sha1_expect))\n+\t\t\thashcpy(ref->old_oid_expect.hash, cas->entry[i].expect);\n+\t\telse if (remote_tracking(remote, ref->name, ref->old_oid_expect.hash))\n \t\t\tref->expect_old_no_trackback = 1;\n \t\treturn;\n \t}\n@@ -2405,7 +2405,7 @@ static void apply_cas(struct push_cas_option *cas,\n \t\treturn;\n \n \tref->expect_old_sha1 = 1;\n-\tif (remote_tracking(remote, ref->name, ref->old_sha1_expect))\n+\tif (remote_tracking(remote, ref->name, ref->old_oid_expect.hash))\n \t\tref->expect_old_no_trackback = 1;\n }\n \ndiff --git a/remote.h b/remote.h\nindex 312b7ca..163ea5e 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -79,9 +79,9 @@ extern const struct refspec *tag_refspec;\n \n struct ref {\n \tstruct ref *next;\n-\tunsigned char old_sha1[20];\n-\tunsigned char new_sha1[20];\n-\tunsigned char old_sha1_expect[20]; /* used by expect-old */\n+\tstruct object_id old_oid;\n+\tstruct object_id new_oid;\n+\tstruct object_id old_oid_expect; /* used by expect-old */\n \tchar *symref;\n \tunsigned int\n \t\tforce:1,\ndiff --git a/send-pack.c b/send-pack.c\nindex 2a64fec..ae3a104 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -79,11 +79,11 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru\n \t\t\tbreak;\n \n \twhile (refs) {\n-\t\tif (!is_null_sha1(refs->old_sha1) &&\n-\t\t    !feed_object(refs->old_sha1, po.in, 1))\n+\t\tif (!is_null_oid(&refs->old_oid) &&\n+\t\t    !feed_object(refs->old_oid.hash, po.in, 1))\n \t\t\tbreak;\n-\t\tif (!is_null_sha1(refs->new_sha1) &&\n-\t\t    !feed_object(refs->new_sha1, po.in, 0))\n+\t\tif (!is_null_oid(&refs->new_oid) &&\n+\t\t    !feed_object(refs->new_oid.hash, po.in, 0))\n \t\t\tbreak;\n \t\trefs = refs->next;\n \t}\n@@ -261,8 +261,8 @@ static int generate_push_cert(struct strbuf *req_buf,\n \t\t\tcontinue;\n \t\tupdate_seen = 1;\n \t\tstrbuf_addf(&cert, \"%s %s %s\\n\",\n-\t\t\t    sha1_to_hex(ref->old_sha1),\n-\t\t\t    sha1_to_hex(ref->new_sha1),\n+\t\t\t    oid_to_hex(&ref->old_oid),\n+\t\t\t    oid_to_hex(&ref->new_oid),\n \t\t\t    ref->name);\n \t}\n \tif (!update_seen)\n@@ -458,8 +458,8 @@ int send_pack(struct send_pack_args *args,\n \t\tif (check_to_send_update(ref, args) < 0)\n \t\t\tcontinue;\n \n-\t\told_hex = sha1_to_hex(ref->old_sha1);\n-\t\tnew_hex = sha1_to_hex(ref->new_sha1);\n+\t\told_hex = oid_to_hex(&ref->old_oid);\n+\t\tnew_hex = oid_to_hex(&ref->new_oid);\n \t\tif (!cmds_sent) {\n \t\t\tpacket_buf_write(&req_buf,\n \t\t\t\t\t \"%s %s %s%c%s\",\ndiff --git a/transport-helper.c b/transport-helper.c\nindex 5d99a6b..4ca3e80 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -347,7 +347,7 @@ static int fetch_with_fetch(struct transport *transport,\n \t\t\tcontinue;\n \n \t\tstrbuf_addf(&buf, \"fetch %s %s\\n\",\n-\t\t\t    sha1_to_hex(posn->old_sha1),\n+\t\t\t    oid_to_hex(&posn->old_oid),\n \t\t\t    posn->symref ? posn->symref : posn->name);\n \t}\n \n@@ -490,7 +490,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\tread_ref(private, posn->old_sha1);\n+\t\t\tread_ref(private, posn->old_oid.hash);\n \t\t\tfree(private);\n \t\t}\n \t}\n@@ -756,7 +756,7 @@ 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_sha1, NULL, 0, 0);\n+\t\tupdate_ref(\"update by helper\", private, ref->new_oid.hash, NULL, 0, 0);\n \t\tfree(private);\n \t}\n \tstrbuf_release(&buf);\n@@ -803,7 +803,7 @@ static int push_refs_with_push(struct transport *transport,\n \t\t\tif (ref->peer_ref)\n \t\t\t\tstrbuf_addstr(&buf, ref->peer_ref->name);\n \t\t\telse\n-\t\t\t\tstrbuf_addstr(&buf, sha1_to_hex(ref->new_sha1));\n+\t\t\t\tstrbuf_addstr(&buf, oid_to_hex(&ref->new_oid));\n \t\t}\n \t\tstrbuf_addch(&buf, ':');\n \t\tstrbuf_addstr(&buf, ref->name);\n@@ -812,14 +812,14 @@ static int push_refs_with_push(struct transport *transport,\n \t\t/*\n \t\t * The \"--force-with-lease\" options without explicit\n \t\t * values to expect have already been expanded into\n-\t\t * the ref->old_sha1_expect[] field; we can ignore\n+\t\t * the ref->old_oid_expect[] field; we can ignore\n \t\t * transport->smart_options->cas altogether and instead\n \t\t * can enumerate them from the refs.\n \t\t */\n \t\tif (ref->expect_old_sha1) {\n \t\t\tstruct strbuf cas = STRBUF_INIT;\n \t\t\tstrbuf_addf(&cas, \"%s:%s\",\n-\t\t\t\t    ref->name, sha1_to_hex(ref->old_sha1_expect));\n+\t\t\t\t    ref->name, oid_to_hex(&ref->old_oid_expect));\n \t\t\tstring_list_append(&cas_options, strbuf_detach(&cas, NULL));\n \t\t}\n \t}\n@@ -883,7 +883,7 @@ static int push_refs_with_export(struct transport *transport,\n \t\tif (private && !get_sha1(private, sha1)) {\n \t\t\tstrbuf_addf(&buf, \"^%s\", private);\n \t\t\tstring_list_append(&revlist_args, strbuf_detach(&buf, NULL));\n-\t\t\thashcpy(ref->old_sha1, sha1);\n+\t\t\thashcpy(ref->old_oid.hash, sha1);\n \t\t}\n \t\tfree(private);\n \n@@ -1015,11 +1015,11 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)\n \t\tif (buf.buf[0] == '@')\n \t\t\t(*tail)->symref = xstrdup(buf.buf + 1);\n \t\telse if (buf.buf[0] != '?')\n-\t\t\tget_sha1_hex(buf.buf, (*tail)->old_sha1);\n+\t\t\tget_oid_hex(buf.buf, &(*tail)->old_oid);\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\tread_ref((*tail)->name, (*tail)->old_sha1);\n+\t\t\t\tread_ref((*tail)->name, (*tail)->old_oid.hash);\n \t\t\t}\n \t\t}\n \t\ttail = &((*tail)->next);\ndiff --git a/transport.c b/transport.c\nindex 40692f8..e880d94 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -79,7 +79,7 @@ static int read_loose_refs(struct strbuf *path, int name_offset,\n \t\t\t\tcontinue;\n \t\t\tnext = alloc_ref(path->buf + name_offset);\n \t\t\tif (read_in_full(fd, buffer, 40) != 40 ||\n-\t\t\t\t\tget_sha1_hex(buffer, next->old_sha1)) {\n+\t\t\t\t\tget_oid_hex(buffer, &next->old_oid)) {\n \t\t\t\tclose(fd);\n \t\t\t\tfree(next);\n \t\t\t\tcontinue;\n@@ -131,7 +131,7 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)\n \t\tif (!(*list)->next || cmp < 0) {\n \t\t\tstruct ref *next = alloc_ref(buffer + 41);\n \t\t\tbuffer[40] = '\\0';\n-\t\t\tif (get_sha1_hex(buffer, next->old_sha1)) {\n+\t\t\tif (get_oid_hex(buffer, &next->old_oid)) {\n \t\t\t\twarning (\"invalid SHA-1: %s\", buffer);\n \t\t\t\tfree(next);\n \t\t\t\tcontinue;\n@@ -162,7 +162,7 @@ static void set_upstreams(struct transport *transport, struct ref *refs,\n \t\t\tcontinue;\n \t\tif (!ref->peer_ref)\n \t\t\tcontinue;\n-\t\tif (is_null_sha1(ref->new_sha1))\n+\t\tif (is_null_oid(&ref->new_oid))\n \t\t\tcontinue;\n \n \t\t/* Follow symbolic refs (mainly for HEAD). */\n@@ -412,7 +412,7 @@ static struct ref *get_refs_from_bundle(struct transport *transport, int for_pus\n \tfor (i = 0; i < data->header.references.nr; i++) {\n \t\tstruct ref_list_entry *e = data->header.references.list + i;\n \t\tstruct ref *ref = alloc_ref(e->name);\n-\t\thashcpy(ref->old_sha1, e->sha1);\n+\t\thashcpy(ref->old_oid.hash, e->sha1);\n \t\tref->next = result;\n \t\tresult = ref;\n \t}\n@@ -611,7 +611,7 @@ void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int v\n \t\t\tdelete_ref(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_sha1, NULL, 0, 0);\n+\t\t\t\t\tref->new_oid.hash, NULL, 0, 0);\n \t\tfree(rs.dst);\n \t}\n }\n@@ -651,7 +651,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)\n {\n \tif (ref->deletion)\n \t\tprint_ref_status('-', \"[deleted]\", ref, NULL, NULL, porcelain);\n-\telse if (is_null_sha1(ref->old_sha1))\n+\telse if (is_null_oid(&ref->old_oid))\n \t\tprint_ref_status('*',\n \t\t\t(starts_with(ref->name, \"refs/tags/\") ? \"[new tag]\" :\n \t\t\t\"[new branch]\"),\n@@ -661,7 +661,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)\n \t\tchar type;\n \t\tconst char *msg;\n \n-\t\tstrcpy(quickref, status_abbrev(ref->old_sha1));\n+\t\tstrcpy(quickref, status_abbrev(ref->old_oid.hash));\n \t\tif (ref->forced_update) {\n \t\t\tstrcat(quickref, \"...\");\n \t\t\ttype = '+';\n@@ -671,7 +671,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)\n \t\t\ttype = ' ';\n \t\t\tmsg = NULL;\n \t\t}\n-\t\tstrcat(quickref, status_abbrev(ref->new_sha1));\n+\t\tstrcat(quickref, status_abbrev(ref->new_oid.hash));\n \n \t\tprint_ref_status(type, quickref, ref, ref->peer_ref, msg, porcelain);\n \t}\n@@ -1092,8 +1092,8 @@ static int run_pre_push_hook(struct transport *transport,\n \n \t\tstrbuf_reset(&buf);\n \t\tstrbuf_addf( &buf, \"%s %s %s %s\\n\",\n-\t\t\t r->peer_ref->name, sha1_to_hex(r->new_sha1),\n-\t\t\t r->name, sha1_to_hex(r->old_sha1));\n+\t\t\t r->peer_ref->name, oid_to_hex(&r->new_oid),\n+\t\t\t r->name, oid_to_hex(&r->old_oid));\n \n \t\tif (write_in_full(proc.in, buf.buf, buf.len) != buf.len) {\n \t\t\tret = -1;\n@@ -1173,8 +1173,8 @@ int transport_push(struct transport *transport,\n \t\tif ((flags & TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND) && !is_bare_repository()) {\n \t\t\tstruct ref *ref = remote_refs;\n \t\t\tfor (; ref; ref = ref->next)\n-\t\t\t\tif (!is_null_sha1(ref->new_sha1) &&\n-\t\t\t\t    !push_unpushed_submodules(ref->new_sha1,\n+\t\t\t\tif (!is_null_oid(&ref->new_oid) &&\n+\t\t\t\t    !push_unpushed_submodules(ref->new_oid.hash,\n \t\t\t\t\t    transport->remote->name))\n \t\t\t\t    die (\"Failed to push all needed submodules!\");\n \t\t}\n@@ -1185,8 +1185,8 @@ int transport_push(struct transport *transport,\n \t\t\tstruct string_list needs_pushing = STRING_LIST_INIT_DUP;\n \n \t\t\tfor (; ref; ref = ref->next)\n-\t\t\t\tif (!is_null_sha1(ref->new_sha1) &&\n-\t\t\t\t    find_unpushed_submodules(ref->new_sha1,\n+\t\t\t\tif (!is_null_oid(&ref->new_oid) &&\n+\t\t\t\t    find_unpushed_submodules(ref->new_oid.hash,\n \t\t\t\t\t    transport->remote->name, &needs_pushing))\n \t\t\t\t\tdie_with_unpushed_submodules(&needs_pushing);\n \t\t}\n@@ -1239,8 +1239,8 @@ int transport_fetch_refs(struct transport *transport, struct ref *refs)\n \tfor (rm = refs; rm; rm = rm->next) {\n \t\tnr_refs++;\n \t\tif (rm->peer_ref &&\n-\t\t    !is_null_sha1(rm->old_sha1) &&\n-\t\t    !hashcmp(rm->peer_ref->old_sha1, rm->old_sha1))\n+\t\t    !is_null_oid(&rm->old_oid) &&\n+\t\t    !oidcmp(&rm->peer_ref->old_oid, &rm->old_oid))\n \t\t\tcontinue;\n \t\tALLOC_GROW(heads, nr_heads + 1, nr_alloc);\n \t\theads[nr_heads++] = rm;\ndiff --git a/transport.h b/transport.h\nindex 18d2cf8..4a4aaac 100644\n--- a/transport.h\n+++ b/transport.h\n@@ -75,15 +75,15 @@ struct transport {\n \t/**\n \t * Push the objects and refs. Send the necessary objects, and\n \t * then, for any refs where peer_ref is set and\n-\t * peer_ref->new_sha1 is different from old_sha1, tell the\n-\t * remote side to update each ref in the list from old_sha1 to\n-\t * peer_ref->new_sha1.\n+\t * peer_ref->new_oid is different from old_oid, tell the\n+\t * remote side to update each ref in the list from old_oid to\n+\t * peer_ref->new_oid.\n \t *\n \t * Where possible, set the status for each ref appropriately.\n \t *\n \t * The transport must modify new_sha1 in the ref to the new\n \t * value if the remote accepted the change. Note that this\n-\t * could be a different value from peer_ref->new_sha1 if the\n+\t * could be a different value from peer_ref->new_oid if the\n \t * process involved generating new commits.\n \t **/\n \tint (*push_refs)(struct transport *transport, struct ref *refs, int flags);\ndiff --git a/walker.c b/walker.c\nindex 44a936c..14f71c0 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -191,7 +191,7 @@ static int interpret_target(struct walker *walker, char *target, unsigned char *\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_sha1);\n+\t\t\thashcpy(sha1, ref->old_oid.hash);\n \t\t\tfree(ref);\n \t\t\treturn 0;\n \t\t}\n-- \n2.4.0\n"},{"id":"263771","messageId":"1434233803-422442-5-git-send-email-sandals@crustytoothpaste.net","threadId":"39625","inReplyTo":"1434233803-422442-1-git-send-email-sandals@crustytoothpaste.net","subject":"[PATCH v2 04/10] add_sought_entry_mem: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2015-06-13T22:16:37Z","receivedAt":"2015-06-13T22:16:37Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert this function to use struct object_id.  Express several\nhardcoded constants in terms of GIT_SHA1_HEXSZ.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/fetch-pack.c | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex 19215b3..cf3019e 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -14,12 +14,14 @@ static void add_sought_entry_mem(struct ref ***sought, int *nr, int *alloc,\n \t\t\t\t const char *name, int namelen)\n {\n \tstruct ref *ref = xcalloc(1, sizeof(*ref) + namelen + 1);\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n+\tconst int chunksz = GIT_SHA1_HEXSZ + 1;\n \n-\tif (namelen > 41 && name[40] == ' ' && !get_sha1_hex(name, sha1)) {\n-\t\thashcpy(ref->old_oid.hash, sha1);\n-\t\tname += 41;\n-\t\tnamelen -= 41;\n+\tif (namelen > chunksz && name[chunksz - 1] == ' ' &&\n+\t\t!get_oid_hex(name, &oid)) {\n+\t\toidcpy(&ref->old_oid, &oid);\n+\t\tname += chunksz;\n+\t\tnamelen -= chunksz;\n \t}\n \n \tmemcpy(ref->name, name, namelen);\n-- \n2.4.0\n"},{"id":"263769","messageId":"1434233803-422442-6-git-send-email-sandals@crustytoothpaste.net","threadId":"39625","inReplyTo":"1434233803-422442-1-git-send-email-sandals@crustytoothpaste.net","subject":"[PATCH v2 05/10] parse_fetch: convert to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2015-06-13T22:16:38Z","receivedAt":"2015-06-13T22:16:38Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert the parse_fetch function to use struct object_id.  Remove the\nstrlen check as get_oid_hex will fail safely on receiving a too-short\nNUL-terminated string.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n remote-curl.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 80cb4c7..1709346 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -802,19 +802,19 @@ static void parse_fetch(struct strbuf *buf)\n \t\tif (skip_prefix(buf->buf, \"fetch \", &p)) {\n \t\t\tconst char *name;\n \t\t\tstruct ref *ref;\n-\t\t\tunsigned char old_sha1[20];\n+\t\t\tstruct object_id old_oid;\n \n-\t\t\tif (strlen(p) < 40 || get_sha1_hex(p, old_sha1))\n+\t\t\tif (get_oid_hex(p, &old_oid))\n \t\t\t\tdie(\"protocol error: expected sha/ref, got %s'\", p);\n-\t\t\tif (p[40] == ' ')\n-\t\t\t\tname = p + 41;\n-\t\t\telse if (!p[40])\n+\t\t\tif (p[GIT_SHA1_HEXSZ] == ' ')\n+\t\t\t\tname = p + GIT_SHA1_HEXSZ + 1;\n+\t\t\telse if (!p[GIT_SHA1_HEXSZ])\n \t\t\t\tname = \"\";\n \t\t\telse\n \t\t\t\tdie(\"protocol error: expected sha/ref, got %s'\", p);\n \n \t\t\tref = alloc_ref(name);\n-\t\t\thashcpy(ref->old_oid.hash, old_sha1);\n+\t\t\toidcpy(&ref->old_oid, &old_oid);\n \n \t\t\t*list = ref;\n \t\t\tlist = &ref->next;\n-- \n2.4.0\n"},{"id":"263773","messageId":"1434233803-422442-7-git-send-email-sandals@crustytoothpaste.net","threadId":"39625","inReplyTo":"1434233803-422442-1-git-send-email-sandals@crustytoothpaste.net","subject":"[PATCH v2 06/10] get_remote_heads: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2015-06-13T22:16:39Z","receivedAt":"2015-06-13T22:16:39Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Replace an unsigned char array with struct object_id and express several\nhard-coded constants in terms of GIT_SHA1_HEXSZ.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n connect.c | 22 ++++++++++++----------\n 1 file changed, 12 insertions(+), 10 deletions(-)\n\ndiff --git a/connect.c b/connect.c\nindex f8b10eb..7f005a7 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -119,7 +119,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,\n \t*list = NULL;\n \tfor (;;) {\n \t\tstruct ref *ref;\n-\t\tunsigned char old_sha1[20];\n+\t\tstruct object_id old_oid;\n \t\tchar *name;\n \t\tint len, name_len;\n \t\tchar *buffer = packet_buffer;\n@@ -138,34 +138,36 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,\n \t\tif (len > 4 && skip_prefix(buffer, \"ERR \", &arg))\n \t\t\tdie(\"remote error: %s\", arg);\n \n-\t\tif (len == 48 && skip_prefix(buffer, \"shallow \", &arg)) {\n-\t\t\tif (get_sha1_hex(arg, old_sha1))\n+\t\tif (len == GIT_SHA1_HEXSZ + strlen(\"shallow \") &&\n+\t\t\tskip_prefix(buffer, \"shallow \", &arg)) {\n+\t\t\tif (get_oid_hex(arg, &old_oid))\n \t\t\t\tdie(\"protocol error: expected shallow sha-1, got '%s'\", arg);\n \t\t\tif (!shallow_points)\n \t\t\t\tdie(\"repository on the other end cannot be shallow\");\n-\t\t\tsha1_array_append(shallow_points, old_sha1);\n+\t\t\tsha1_array_append(shallow_points, old_oid.hash);\n \t\t\tcontinue;\n \t\t}\n \n-\t\tif (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')\n+\t\tif (len < GIT_SHA1_HEXSZ + 2 || get_oid_hex(buffer, &old_oid) ||\n+\t\t\tbuffer[GIT_SHA1_HEXSZ] != ' ')\n \t\t\tdie(\"protocol error: expected sha/ref, got '%s'\", buffer);\n-\t\tname = buffer + 41;\n+\t\tname = buffer + GIT_SHA1_HEXSZ + 1;\n \n \t\tname_len = strlen(name);\n-\t\tif (len != name_len + 41) {\n+\t\tif (len != name_len + GIT_SHA1_HEXSZ + 1) {\n \t\t\tfree(server_capabilities);\n \t\t\tserver_capabilities = xstrdup(name + name_len + 1);\n \t\t}\n \n \t\tif (extra_have && !strcmp(name, \".have\")) {\n-\t\t\tsha1_array_append(extra_have, old_sha1);\n+\t\t\tsha1_array_append(extra_have, old_oid.hash);\n \t\t\tcontinue;\n \t\t}\n \n \t\tif (!check_ref(name, flags))\n \t\t\tcontinue;\n-\t\tref = alloc_ref(buffer + 41);\n-\t\thashcpy(ref->old_oid.hash, old_sha1);\n+\t\tref = alloc_ref(buffer + GIT_SHA1_HEXSZ + 1);\n+\t\toidcpy(&ref->old_oid, &old_oid);\n \t\t*list = ref;\n \t\tlist = &ref->next;\n \t\tgot_at_least_one_head = 1;\n-- \n2.4.0\n"},{"id":"263772","messageId":"1434233803-422442-8-git-send-email-sandals@crustytoothpaste.net","threadId":"39625","inReplyTo":"1434233803-422442-1-git-send-email-sandals@crustytoothpaste.net","subject":"[PATCH v2 07/10] push_refs_with_export: convert to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2015-06-13T22:16:40Z","receivedAt":"2015-06-13T22:16:40Z","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 transport-helper.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/transport-helper.c b/transport-helper.c\nindex 4ca3e80..1f28b82 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -877,13 +877,13 @@ static int push_refs_with_export(struct transport *transport,\n \n \tfor (ref = remote_refs; ref; ref = ref->next) {\n \t\tchar *private;\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \n \t\tprivate = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);\n-\t\tif (private && !get_sha1(private, sha1)) {\n+\t\tif (private && !get_sha1(private, oid.hash)) {\n \t\t\tstrbuf_addf(&buf, \"^%s\", private);\n \t\t\tstring_list_append(&revlist_args, strbuf_detach(&buf, NULL));\n-\t\t\thashcpy(ref->old_oid.hash, sha1);\n+\t\t\toidcpy(&ref->old_oid, &oid);\n \t\t}\n \t\tfree(private);\n \n@@ -897,7 +897,7 @@ static int push_refs_with_export(struct transport *transport,\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 sha1, &flag);\n+\t\t\t\t\t\t oid.hash, &flag);\n \t\t\t\t\tif (!name || !(flag & REF_ISSYMREF))\n \t\t\t\t\t\tname = ref->peer_ref->name;\n \n-- \n2.4.0\n"},{"id":"263774","messageId":"1434233803-422442-9-git-send-email-sandals@crustytoothpaste.net","threadId":"39625","inReplyTo":"1434233803-422442-1-git-send-email-sandals@crustytoothpaste.net","subject":"[PATCH v2 08/10] ref_newer: convert to use struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2015-06-13T22:16:41Z","receivedAt":"2015-06-13T22:16:41Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert ref_newer and its caller to use struct object_id instead of\nunsigned char *.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/remote.c | 2 +-\n http-push.c      | 4 ++--\n remote.c         | 8 ++++----\n remote.h         | 2 +-\n 4 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex fa4d04c..0efc388 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -411,7 +411,7 @@ static int get_push_ref_states(const struct ref *remote_refs,\n \t\telse if (is_null_oid(&ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_CREATE;\n \t\telse if (has_object_file(&ref->old_oid) &&\n-\t\t\t ref_newer(ref->new_oid.hash, ref->old_oid.hash))\n+\t\t\t ref_newer(&ref->new_oid, &ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_FASTFORWARD;\n \t\telse\n \t\t\tinfo->status = PUSH_STATUS_OUTOFDATE;\ndiff --git a/http-push.c b/http-push.c\nindex d054fdb..0e688a7 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1899,8 +1899,8 @@ int main(int argc, char **argv)\n \t\t    !is_null_oid(&ref->old_oid) &&\n \t\t    !ref->force) {\n \t\t\tif (!has_object_file(&ref->old_oid) ||\n-\t\t\t    !ref_newer(ref->peer_ref->new_oid.hash,\n-\t\t\t\t       ref->old_oid.hash)) {\n+\t\t\t    !ref_newer(&ref->peer_ref->new_oid,\n+\t\t\t\t       &ref->old_oid)) {\n \t\t\t\t/*\n \t\t\t\t * We do not have the remote ref, or\n \t\t\t\t * we know that the remote ref is not\ndiff --git a/remote.c b/remote.c\nindex 0574120..cb85c3e 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1626,7 +1626,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n \t\t\telse if (!lookup_commit_reference_gently(ref->old_oid.hash, 1) ||\n \t\t\t\t !lookup_commit_reference_gently(ref->new_oid.hash, 1))\n \t\t\t\treject_reason = REF_STATUS_REJECT_NEEDS_FORCE;\n-\t\t\telse if (!ref_newer(ref->new_oid.hash, ref->old_oid.hash))\n+\t\t\telse if (!ref_newer(&ref->new_oid, &ref->old_oid))\n \t\t\t\treject_reason = REF_STATUS_REJECT_NONFASTFORWARD;\n \t\t}\n \n@@ -1982,7 +1982,7 @@ static void unmark_and_free(struct commit_list *list, unsigned int mark)\n \t}\n }\n \n-int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1)\n+int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)\n {\n \tstruct object *o;\n \tstruct commit *old, *new;\n@@ -1993,12 +1993,12 @@ int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1)\n \t * Both new and old must be commit-ish and new is descendant of\n \t * old.  Otherwise we require --force.\n \t */\n-\to = deref_tag(parse_object(old_sha1), NULL, 0);\n+\to = deref_tag(parse_object(old_oid->hash), NULL, 0);\n \tif (!o || o->type != OBJ_COMMIT)\n \t\treturn 0;\n \told = (struct commit *) o;\n \n-\to = deref_tag(parse_object(new_sha1), NULL, 0);\n+\to = deref_tag(parse_object(new_oid->hash), NULL, 0);\n \tif (!o || o->type != OBJ_COMMIT)\n \t\treturn 0;\n \tnew = (struct commit *) o;\ndiff --git a/remote.h b/remote.h\nindex 163ea5e..4a039ba 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -150,7 +150,7 @@ extern struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,\n \t\t\t\t     struct sha1_array *shallow);\n \n int resolve_remote_symref(struct ref *ref, struct ref *list);\n-int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1);\n+int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);\n \n /*\n  * Remove and free all but the first of any entries in the input list\n-- \n2.4.0\n"},{"id":"263770","messageId":"1434233803-422442-11-git-send-email-sandals@crustytoothpaste.net","threadId":"39625","inReplyTo":"1434233803-422442-1-git-send-email-sandals@crustytoothpaste.net","subject":"[PATCH v2 10/10] remote: convert functions to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2015-06-13T22:16:43Z","receivedAt":"2015-06-13T22:16:43Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert several unsigned char arrays to use struct object_id instead,\nand change hard-coded 40-based constants to use GIT_SHA1_HEXSZ as well.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n remote.c | 64 ++++++++++++++++++++++++++++++++--------------------------------\n 1 file changed, 32 insertions(+), 32 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex c72d796..92dc8d6 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -492,7 +492,7 @@ static void alias_all_urls(void)\n static void read_config(void)\n {\n \tstatic int loaded;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tconst char *head_ref;\n \tint flag;\n \n@@ -501,7 +501,7 @@ static void read_config(void)\n \tloaded = 1;\n \n \tcurrent_branch = NULL;\n-\thead_ref = resolve_ref_unsafe(\"HEAD\", 0, sha1, &flag);\n+\thead_ref = resolve_ref_unsafe(\"HEAD\", 0, oid.hash, &flag);\n \tif (head_ref && (flag & REF_ISSYMREF) &&\n \t    skip_prefix(head_ref, \"refs/heads/\", &head_ref)) {\n \t\tcurrent_branch = make_branch(head_ref, 0);\n@@ -580,12 +580,12 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp\n \t\tflags = REFNAME_ALLOW_ONELEVEL | (is_glob ? REFNAME_REFSPEC_PATTERN : 0);\n \n \t\tif (fetch) {\n-\t\t\tunsigned char unused[40];\n+\t\t\tstruct object_id unused;\n \n \t\t\t/* LHS */\n \t\t\tif (!*rs[i].src)\n \t\t\t\t; /* empty is ok; it means \"HEAD\" */\n-\t\t\telse if (llen == 40 && !get_sha1_hex(rs[i].src, unused))\n+\t\t\telse if (llen == GIT_SHA1_HEXSZ && !get_oid_hex(rs[i].src, &unused))\n \t\t\t\trs[i].exact_sha1 = 1; /* ok */\n \t\t\telse if (!check_refname_format(rs[i].src, flags))\n \t\t\t\t; /* valid looking ref is ok */\n@@ -1118,7 +1118,7 @@ static struct ref *alloc_delete_ref(void)\n static int try_explicit_object_name(const char *name,\n \t\t\t\t    struct ref **match)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \n \tif (!*name) {\n \t\tif (match)\n@@ -1126,12 +1126,12 @@ static int try_explicit_object_name(const char *name,\n \t\treturn 0;\n \t}\n \n-\tif (get_sha1(name, sha1))\n+\tif (get_sha1(name, oid.hash))\n \t\treturn -1;\n \n \tif (match) {\n \t\t*match = alloc_ref(name);\n-\t\thashcpy((*match)->new_oid.hash, sha1);\n+\t\toidcpy(&(*match)->new_oid, &oid);\n \t}\n \treturn 0;\n }\n@@ -1146,10 +1146,10 @@ static struct ref *make_linked_ref(const char *name, struct ref ***tail)\n static char *guess_ref(const char *name, struct ref *peer)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \n \tconst char *r = resolve_ref_unsafe(peer->name, RESOLVE_REF_READING,\n-\t\t\t\t\t   sha1, NULL);\n+\t\t\t\t\t   oid.hash, NULL);\n \tif (!r)\n \t\treturn NULL;\n \n@@ -1207,12 +1207,12 @@ static int match_explicit(struct ref *src, struct ref *dst,\n \t\treturn -1;\n \n \tif (!dst_value) {\n-\t\tunsigned char sha1[20];\n+\t\tstruct object_id oid;\n \t\tint flag;\n \n \t\tdst_value = resolve_ref_unsafe(matched_src->name,\n \t\t\t\t\t       RESOLVE_REF_READING,\n-\t\t\t\t\t       sha1, &flag);\n+\t\t\t\t\t       oid.hash, &flag);\n \t\tif (!dst_value ||\n \t\t    ((flag & REF_ISSYMREF) &&\n \t\t     !starts_with(dst_value, \"refs/heads/\")))\n@@ -1328,13 +1328,13 @@ struct tips {\n \tint nr, alloc;\n };\n \n-static void add_to_tips(struct tips *tips, const unsigned char *sha1)\n+static void add_to_tips(struct tips *tips, const struct object_id *oid)\n {\n \tstruct commit *commit;\n \n-\tif (is_null_sha1(sha1))\n+\tif (is_null_oid(oid))\n \t\treturn;\n-\tcommit = lookup_commit_reference_gently(sha1, 1);\n+\tcommit = lookup_commit_reference_gently(oid->hash, 1);\n \tif (!commit || (commit->object.flags & TMP_MARK))\n \t\treturn;\n \tcommit->object.flags |= TMP_MARK;\n@@ -1358,9 +1358,9 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \tfor (ref = *dst; ref; ref = ref->next) {\n \t\tif (ref->peer_ref &&\n \t\t    !is_null_oid(&ref->peer_ref->new_oid))\n-\t\t\tadd_to_tips(&sent_tips, ref->peer_ref->new_oid.hash);\n+\t\t\tadd_to_tips(&sent_tips, &ref->peer_ref->new_oid);\n \t\telse\n-\t\t\tadd_to_tips(&sent_tips, ref->old_oid.hash);\n+\t\t\tadd_to_tips(&sent_tips, &ref->old_oid);\n \t\tif (starts_with(ref->name, \"refs/tags/\"))\n \t\t\tstring_list_append(&dst_tag, ref->name);\n \t}\n@@ -1645,7 +1645,7 @@ static void set_merge(struct branch *ret)\n {\n \tstruct remote *remote;\n \tchar *ref;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tint i;\n \n \tif (!ret)\n@@ -1671,7 +1671,7 @@ static void set_merge(struct branch *ret)\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     sha1, &ref) == 1)\n+\t\t\t     oid.hash, &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]);\n@@ -1831,10 +1831,10 @@ const char *branch_get_push(struct branch *branch, struct strbuf *err)\n \n static int ignore_symref_update(const char *refname)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tint flag;\n \n-\tif (!resolve_ref_unsafe(refname, 0, sha1, &flag))\n+\tif (!resolve_ref_unsafe(refname, 0, oid.hash, &flag))\n \t\treturn 0; /* non-existing refs are OK */\n \treturn (flag & REF_ISSYMREF);\n }\n@@ -2033,9 +2033,9 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)\n int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,\n \t\t       const char **upstream_name)\n {\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \tstruct commit *ours, *theirs;\n-\tchar symmetric[84];\n+\tchar symmetric[GIT_SHA1_HEXSZ * 2 + 4];\n \tstruct rev_info revs;\n \tconst char *rev_argv[10], *base;\n \tint rev_argc;\n@@ -2048,15 +2048,15 @@ 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, sha1))\n+\tif (read_ref(base, oid.hash))\n \t\treturn -1;\n-\ttheirs = lookup_commit_reference(sha1);\n+\ttheirs = lookup_commit_reference(oid.hash);\n \tif (!theirs)\n \t\treturn -1;\n \n-\tif (read_ref(branch->refname, sha1))\n+\tif (read_ref(branch->refname, oid.hash))\n \t\treturn -1;\n-\tours = lookup_commit_reference(sha1);\n+\tours = lookup_commit_reference(oid.hash);\n \tif (!ours)\n \t\treturn -1;\n \n@@ -2075,8 +2075,8 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,\n \trev_argv[rev_argc] = NULL;\n \n \tstrcpy(symmetric, oid_to_hex(&ours->object.oid));\n-\tstrcpy(symmetric + 40, \"...\");\n-\tstrcpy(symmetric + 43, oid_to_hex(&theirs->object.oid));\n+\tstrcpy(symmetric + GIT_SHA1_HEXSZ, \"...\");\n+\tstrcpy(symmetric + GIT_SHA1_HEXSZ + 3, oid_to_hex(&theirs->object.oid));\n \n \tinit_revisions(&revs, NULL);\n \tsetup_revisions(rev_argc, rev_argv, &revs, NULL);\n@@ -2369,14 +2369,14 @@ int is_empty_cas(const struct push_cas_option *cas)\n  * If we cannot do so, return negative to signal an error.\n  */\n static int remote_tracking(struct remote *remote, const char *refname,\n-\t\t\t   unsigned char sha1[20])\n+\t\t\t   struct object_id *oid)\n {\n \tchar *dst;\n \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, sha1))\n+\tif (read_ref(dst, oid->hash))\n \t\treturn -1; /* we know what the tracking ref is but we cannot read it */\n \treturn 0;\n }\n@@ -2395,7 +2395,7 @@ static void apply_cas(struct push_cas_option *cas,\n \t\tref->expect_old_sha1 = 1;\n \t\tif (!entry->use_tracking)\n \t\t\thashcpy(ref->old_oid_expect.hash, cas->entry[i].expect);\n-\t\telse if (remote_tracking(remote, ref->name, ref->old_oid_expect.hash))\n+\t\telse if (remote_tracking(remote, ref->name, &ref->old_oid_expect))\n \t\t\tref->expect_old_no_trackback = 1;\n \t\treturn;\n \t}\n@@ -2405,7 +2405,7 @@ static void apply_cas(struct push_cas_option *cas,\n \t\treturn;\n \n \tref->expect_old_sha1 = 1;\n-\tif (remote_tracking(remote, ref->name, ref->old_oid_expect.hash))\n+\tif (remote_tracking(remote, ref->name, &ref->old_oid_expect))\n \t\tref->expect_old_no_trackback = 1;\n }\n \n-- \n2.4.0\n"},{"id":"263913","messageId":"xmqq4mm87h7e.fsf@gitster.dls.corp.google.com","threadId":"39625","inReplyTo":"1434233803-422442-4-git-send-email-sandals@crustytoothpaste.net","subject":"Re: [PATCH v2 03/10] Convert struct ref to use object_id.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-15T22:13:57Z","receivedAt":"2015-06-15T22:13:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> Use struct object_id in three fields in struct ref and convert all the\n> necessary places that use it.\n>\n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> ---\n>  builtin/clone.c        | 16 +++++++-------\n>  builtin/fetch-pack.c   |  4 ++--\n>  builtin/fetch.c        | 50 +++++++++++++++++++++----------------------\n>  builtin/ls-remote.c    |  2 +-\n>  builtin/receive-pack.c |  2 +-\n>  builtin/remote.c       | 12 +++++------\n>  connect.c              |  2 +-\n>  fetch-pack.c           | 18 ++++++++--------\n>  http-push.c            | 46 +++++++++++++++++++--------------------\n>  http.c                 |  2 +-\n>  remote-curl.c          | 10 ++++-----\n>  remote.c               | 58 +++++++++++++++++++++++++-------------------------\n>  remote.h               |  6 +++---\n>  send-pack.c            | 16 +++++++-------\n>  transport-helper.c     | 18 ++++++++--------\n>  transport.c            | 32 ++++++++++++++--------------\n>  transport.h            |  8 +++----\n>  walker.c               |  2 +-\n>  18 files changed, 152 insertions(+), 152 deletions(-)\n\nWhew.  This was a big patch.\n\nI've eyeballed it and did not find anything questionable.  Thanks.\n"},{"id":"267299","messageId":"55BEA8E4.7040902@alum.mit.edu","threadId":"39625","inReplyTo":"1434233803-422442-1-git-send-email-sandals@crustytoothpaste.net","subject":"Re: [PATCH v2 00/10] object_id part 2","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2015-08-02T23:33:56Z","receivedAt":"2015-08-02T23:33:56Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 06/14/2015 12:16 AM, brian m. carlson wrote:\n> This is another series of conversions to struct object_id.\n> \n> This series converts more of the refs code and struct object to use\n> struct object_id.  It introduces an additional helper function,\n> has_object_file, which is the equivalent of has_sha1_file.  The name was\n> chosen to be slightly more logical than has_oid_file, although it can be\n> changed if desired.\n> \n> The next-to-last patch in this series is the conversion of struct object\n> to use struct object_id.  This is a necessarily large patch because of\n> the large number of places this code is used.  That patch will most\n> likely be too large to make it through to the list, so this series is\n> available in the object-id-part2 branch from:\n\nFWIW I've skimmed patches 01-08 inclusive and nothing jumped out at me.\n\nBrian, what was your experience when writing these patches? Did they\ntend to work as soon as they compiled without errors (i.e., not super\nrisky) or did you often have test suite failures that you had to go back\nand fix (i.e., risky)? If the latter, what kinds of code patterns tended\nto be problematic? Your answers might help reviewers decide how much\ndiligence is needed when reviewing these patches and what kind of\nchanges to inspect extra carefully. Because doing a thorough review of\nall of the patches would be quite a bit of work.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\n"},{"id":"267375","messageId":"20150803234536.GC581651@vauxhall.crustytoothpaste.net","threadId":"39625","inReplyTo":"55BEA8E4.7040902@alum.mit.edu","subject":"Re: [PATCH v2 00/10] object_id part 2","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2015-08-03T23:45:36Z","receivedAt":"2015-08-03T23:45:36Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Mon, Aug 03, 2015 at 01:33:56AM +0200, Michael Haggerty wrote:\n> Brian, what was your experience when writing these patches? Did they\n> tend to work as soon as they compiled without errors (i.e., not super\n> risky) or did you often have test suite failures that you had to go back\n> and fix (i.e., risky)? If the latter, what kinds of code patterns tended\n> to be problematic? Your answers might help reviewers decide how much\n> diligence is needed when reviewing these patches and what kind of\n> changes to inspect extra carefully. Because doing a thorough review of\n> all of the patches would be quite a bit of work.\n\nIn this particular branch, I think I may have had one bad patch.  (I'm\ntrying to recall because I've been working on patches for part 3 in the\nmean time, and they all seem to group together.)  In general, over all\nmy patches, the conversions I've had to fix the most have been the ones\nto use the GIT_SHA1_* constants, because it's very easy to get\noff-by-one errors in there or mess up the values such that things break.\nExtra effort on those, or additional suggestions on how to make them\ncleaner and less brittle, both now and in the future, would be welcome.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\n+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187\n"}]}