{"thread":{"id":"48799","subject":"[PATCH v3 00/32] object-store: lookup_commit","startedAt":"2018-06-29T01:22:36Z","lastAt":"2018-07-03T18:13:19Z","messageCount":42,"participants":["Stefan Beller","Derrick Stolee","Junio C Hamano","Brandon Williams"],"isPatch":true,"patchVersion":3,"patchTotal":32},"messages":[{"id":"351290","messageId":"20180629012222.167426-1-sbeller@google.com","threadId":"48799","inReplyTo":null,"subject":"[PATCH v3 00/32] object-store: lookup_commit","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:21:50Z","receivedAt":"2018-06-29T01:22:36Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This continues the elimination of global variables in the object store and\nteaches lookup_commit[_reference] and alike to handle a_repository.\n\nThis is also available as\nhttps://github.com/stefanbeller/git/tree/object-store-lookup-commit\nor applies on top of 02f70d63027 (Merge branch 'sb/object-store-grafts'\ninto next, 2018-06-28).\n\nPicking a base for this one is really hard, as nearly all series currently\ncooking or in flight collide with it on one or two lines. (lookup_* is used\nheavily, who would have thought?); I really needed 'sb/object-store-grafts'\nto build on; and there is only one other series before that in current next,\nwhich this series would have conflicted with, if not based on top of it.\n\nIn \"The state of the object store series\" [1], this was tentatively named\n\"sb/object-store-lookup\".\n\nThanks,\nStefan\n\n[1] https://public-inbox.org/git/CAGZ79kZtEZA1rvgfSCS+m4dsrB86Cf-XiePWQmeU-kCNxP_NLQ@mail.gmail.com/\n\n\nv2 https://public-inbox.org/git/20180613230522.55335-1-sbeller@google.com/\n* removed mentions of cooci patches\n* added forward declaration of commit buffer slabs.\n* dropped 3 patches that add the repository to lookup_unkonwn_object,\n  parse_commit and parse_commit_gently, but were not converting those\n  functions. We'll convert these in the next series, as this series is\n  growing big already.\n* This series can be found as branch 'object-store-lookup-commit' on github,\n  it applies on top of nd/commit-util-to-slab merged with sb/object-store-grafts\n\nv1, https://public-inbox.org/git/20180530004810.30076-1-sbeller@google.com/\n\nThis applies on the merge of nd/commit-util-to-slab and sb/object-store-grafts,\nand is available at http://github.com/stefanbeller/ as branch object-store-lookup-commit\nas the merge has some merge conflicts as well as syntactical conflicts (upload-pack.c\nand fetch-pack.c introduce new calls of functions that would want to take a repository struct\nin the object-store-grafts series)\n\nAs layed out in https://public-inbox.org/git/20180517225154.9200-1-sbeller@google.com/\nthis is getting close to finishing the set of object store series though the last\nunfinished part of this RFC hints at new work on the plate:\n* To give this series a nice polish, we'd want to convert parse_commit, too.\n  But that requires the conversion of the new commit graph. Maybe we need\n  to split this series into 2. \n* Once this is in good shape we can talk about converting parts of the revision\n  walking code,\n* which then can be used by the submodule code as the end goal for the\n  object store series.\n\nThanks,\nStefan\n\n\nStefan Beller (32):\n  object: add repository argument to parse_object\n  object: add repository argument to lookup_object\n  object: add repository argument to parse_object_buffer\n  object: add repository argument to object_as_type\n  blob: add repository argument to lookup_blob\n  tree: add repository argument to lookup_tree\n  commit: add repository argument to lookup_commit_reference_gently\n  commit: add repository argument to lookup_commit_reference\n  commit: add repository argument to lookup_commit\n  commit: add repository argument to parse_commit_buffer\n  commit: add repository argument to set_commit_buffer\n  commit: add repository argument to get_cached_commit_buffer\n  tag: add repository argument to lookup_tag\n  tag: add repository argument to parse_tag_buffer\n  tag: add repository argument to deref_tag\n  object: allow object_as_type to handle arbitrary repositories\n  object: allow lookup_object to handle arbitrary repositories\n  blob: allow lookup_blob to handle arbitrary repositories\n  tree: allow lookup_tree to handle arbitrary repositories\n  commit: allow lookup_commit to handle arbitrary repositories\n  tag: allow lookup_tag to handle arbitrary repositories\n  tag: allow parse_tag_buffer to handle arbitrary repositories\n  commit.c: allow parse_commit_buffer to handle arbitrary repositories\n  commit-slabs: remove realloc counter outside of slab struct\n  commit.c: migrate the commit buffer to the parsed object store\n  commit.c: allow set_commit_buffer to handle arbitrary repositories\n  commit.c: allow get_cached_commit_buffer to handle arbitrary\n    repositories\n  object.c: allow parse_object_buffer to handle arbitrary repositories\n  object.c: allow parse_object to handle arbitrary repositories\n  tag.c: allow deref_tag to handle arbitrary repositories\n  commit.c: allow lookup_commit_reference_gently to handle arbitrary\n    repositories\n  commit.c: allow lookup_commit_reference to handle arbitrary\n    repositories\n\n archive.c                |  2 +-\n bisect.c                 |  2 +-\n blame.c                  | 13 ++++---\n blob.c                   | 10 ++---\n blob.h                   |  2 +-\n branch.c                 |  2 +-\n builtin/am.c             |  9 +++--\n builtin/branch.c         |  7 ++--\n builtin/checkout.c       |  6 +--\n builtin/clone.c          |  3 +-\n builtin/commit-tree.c    |  4 +-\n builtin/describe.c       | 13 ++++---\n builtin/diff-tree.c      |  9 +++--\n builtin/diff.c           |  7 ++--\n builtin/fast-export.c    | 14 ++++---\n builtin/fetch.c          |  9 +++--\n builtin/fmt-merge-msg.c  |  9 +++--\n builtin/fsck.c           | 21 +++++++----\n builtin/grep.c           |  3 +-\n builtin/index-pack.c     |  5 ++-\n builtin/log.c            | 10 +++--\n builtin/merge-base.c     |  7 ++--\n builtin/merge-tree.c     |  3 +-\n builtin/name-rev.c       | 13 ++++---\n builtin/notes.c          |  3 +-\n builtin/pack-objects.c   |  2 +-\n builtin/prune.c          |  2 +-\n builtin/pull.c           | 15 +++++---\n builtin/receive-pack.c   |  6 +--\n builtin/reflog.c         | 15 +++++---\n builtin/replace.c        |  8 ++--\n builtin/reset.c          |  4 +-\n builtin/rev-list.c       |  2 +-\n builtin/rev-parse.c      |  6 +--\n builtin/show-branch.c    |  5 ++-\n builtin/tag.c            |  2 +-\n builtin/unpack-objects.c |  7 ++--\n builtin/verify-commit.c  |  4 +-\n bundle.c                 | 10 +++--\n cache-tree.c             |  3 +-\n commit-graph.c           | 14 +++----\n commit-slab-impl.h       |  3 --\n commit.c                 | 80 +++++++++++++++++++++++++---------------\n commit.h                 | 18 ++++++---\n fast-import.c            |  6 ++-\n fetch-pack.c             | 39 ++++++++++++--------\n fsck.c                   |  9 +++--\n http-backend.c           |  4 +-\n http-push.c              | 16 +++++---\n line-log.c               |  2 +-\n list-objects.c           |  4 +-\n log-tree.c               | 13 ++++---\n merge-recursive.c        | 17 +++++----\n notes-cache.c            |  3 +-\n notes-merge.c            |  5 ++-\n notes-utils.c            |  4 +-\n object.c                 | 61 ++++++++++++++++--------------\n object.h                 | 12 ++++--\n packfile.c               |  2 +-\n parse-options-cb.c       |  2 +-\n pretty.c                 |  4 +-\n reachable.c              |  8 ++--\n ref-filter.c             | 12 ++++--\n reflog-walk.c            |  3 +-\n refs.c                   |  2 +-\n refs/files-backend.c     |  2 +-\n remote.c                 | 19 ++++++----\n revision.c               | 26 ++++++-------\n sequencer.c              | 14 +++----\n server-info.c            |  4 +-\n sha1-file.c              |  4 +-\n sha1-name.c              | 33 +++++++++--------\n shallow.c                | 30 +++++++++------\n submodule.c              |  4 +-\n tag.c                    | 28 +++++++-------\n tag.h                    |  7 ++--\n tree.c                   | 19 +++++-----\n tree.h                   |  2 +-\n upload-pack.c            | 17 +++++----\n walker.c                 | 12 ++++--\n wt-status.c              |  2 +-\n 81 files changed, 485 insertions(+), 358 deletions(-)\n\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351291","messageId":"20180629012222.167426-3-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 02/32] object: add repository argument to lookup_object","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:21:52Z","receivedAt":"2018-06-29T01:22:41Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow callers of lookup_object to be more\nspecific about which repository to handle. This is a small mechanical\nchange; it doesn't change the implementation to handle repositories\nother than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n blob.c                   |  2 +-\n builtin/fast-export.c    |  5 +++--\n builtin/fsck.c           |  5 +++--\n builtin/name-rev.c       |  3 ++-\n builtin/prune.c          |  2 +-\n builtin/unpack-objects.c |  2 +-\n commit.c                 |  2 +-\n fetch-pack.c             | 13 +++++++------\n http-push.c              |  2 +-\n object.c                 |  8 ++++----\n object.h                 |  3 ++-\n reachable.c              |  4 ++--\n tag.c                    |  2 +-\n tree.c                   |  2 +-\n upload-pack.c            |  2 +-\n 15 files changed, 31 insertions(+), 26 deletions(-)\n\ndiff --git a/blob.c b/blob.c\nindex 458dafa811e..75b737a761e 100644\n--- a/blob.c\n+++ b/blob.c\n@@ -7,7 +7,7 @@ const char *blob_type = \"blob\";\n \n struct blob *lookup_blob(const struct object_id *oid)\n {\n-\tstruct object *obj = lookup_object(oid->hash);\n+\tstruct object *obj = lookup_object(the_repository, oid->hash);\n \tif (!obj)\n \t\treturn create_object(the_repository, oid->hash,\n \t\t\t\t     alloc_blob_node(the_repository));\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex a16aeaa826f..e39c4e2c1d0 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -230,7 +230,7 @@ static void export_blob(const struct object_id *oid)\n \tif (is_null_oid(oid))\n \t\treturn;\n \n-\tobject = lookup_object(oid->hash);\n+\tobject = lookup_object(the_repository, oid->hash);\n \tif (object && object->flags & SHOWN)\n \t\treturn;\n \n@@ -402,7 +402,8 @@ static void show_filemodify(struct diff_queue_struct *q,\n \t\t\t\t\t\t   anonymize_sha1(&spec->oid) :\n \t\t\t\t\t\t   spec->oid.hash));\n \t\t\telse {\n-\t\t\t\tstruct object *object = lookup_object(spec->oid.hash);\n+\t\t\t\tstruct object *object = lookup_object(the_repository,\n+\t\t\t\t\t\t\t\t      spec->oid.hash);\n \t\t\t\tprintf(\"M %06o :%d \", spec->mode,\n \t\t\t\t       get_object_mark(object));\n \t\t\t}\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 2b0930101d3..12d01e91747 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -410,7 +410,7 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,\n \tstruct object *obj;\n \n \tif (!is_null_oid(oid)) {\n-\t\tobj = lookup_object(oid->hash);\n+\t\tobj = lookup_object(the_repository, oid->hash);\n \t\tif (obj && (obj->flags & HAS_OBJ)) {\n \t\t\tif (timestamp && name_objects)\n \t\t\t\tadd_decoration(fsck_walk_options.object_names,\n@@ -763,7 +763,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)\n \t\tconst char *arg = argv[i];\n \t\tstruct object_id oid;\n \t\tif (!get_oid(arg, &oid)) {\n-\t\t\tstruct object *obj = lookup_object(oid.hash);\n+\t\t\tstruct object *obj = lookup_object(the_repository,\n+\t\t\t\t\t\t\t   oid.hash);\n \n \t\t\tif (!obj || !(obj->flags & HAS_OBJ)) {\n \t\t\t\tif (is_promisor_object(&oid))\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex de54fa93e4f..f6eb419a029 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -379,7 +379,8 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n \t\t\t*(p+1) = 0;\n \t\t\tif (!get_oid(p - (GIT_SHA1_HEXSZ - 1), &oid)) {\n \t\t\t\tstruct object *o =\n-\t\t\t\t\tlookup_object(oid.hash);\n+\t\t\t\t\tlookup_object(the_repository,\n+\t\t\t\t\t\t      oid.hash);\n \t\t\t\tif (o)\n \t\t\t\t\tname = get_rev_name(o, &buf);\n \t\t\t}\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 70ec35aa058..72b0621b768 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -40,7 +40,7 @@ static int prune_object(const struct object_id *oid, const char *fullpath,\n \t * Do we know about this object?\n \t * It must have been reachable\n \t */\n-\tif (lookup_object(oid->hash))\n+\tif (lookup_object(the_repository, oid->hash))\n \t\treturn 0;\n \n \tif (lstat(fullpath, &st)) {\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex cf585fcc5ee..335b5ed9a0f 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -331,7 +331,7 @@ static int resolve_against_held(unsigned nr, const struct object_id *base,\n {\n \tstruct object *obj;\n \tstruct obj_buffer *obj_buffer;\n-\tobj = lookup_object(base->hash);\n+\tobj = lookup_object(the_repository, base->hash);\n \tif (!obj)\n \t\treturn 0;\n \tobj_buffer = lookup_object_buffer(obj);\ndiff --git a/commit.c b/commit.c\nindex a29070a8133..b4dbfd889a3 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -54,7 +54,7 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref\n \n struct commit *lookup_commit(const struct object_id *oid)\n {\n-\tstruct object *obj = lookup_object(oid->hash);\n+\tstruct object *obj = lookup_object(the_repository, oid->hash);\n \tif (!obj)\n \t\treturn create_object(the_repository, oid->hash,\n \t\t\t\t     alloc_commit_node(the_repository));\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 6b406f1d008..771eb8ae471 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -362,7 +362,7 @@ static int find_common(struct fetch_pack_args *args,\n \t\t * interested in the case we *know* the object is\n \t\t * reachable and we have already scanned it.\n \t\t */\n-\t\tif (((o = lookup_object(remote->hash)) != NULL) &&\n+\t\tif (((o = lookup_object(the_repository, remote->hash)) != NULL) &&\n \t\t\t\t(o->flags & COMPLETE)) {\n \t\t\tcontinue;\n \t\t}\n@@ -436,7 +436,7 @@ static int find_common(struct fetch_pack_args *args,\n \t\t\tif (skip_prefix(line, \"unshallow \", &arg)) {\n \t\t\t\tif (get_oid_hex(arg, &oid))\n \t\t\t\t\tdie(_(\"invalid unshallow line: %s\"), line);\n-\t\t\t\tif (!lookup_object(oid.hash))\n+\t\t\t\tif (!lookup_object(the_repository, oid.hash))\n \t\t\t\t\tdie(_(\"object not found: %s\"), line);\n \t\t\t\t/* make sure that it is parsed as shallow */\n \t\t\t\tif (!parse_object(the_repository, &oid))\n@@ -801,7 +801,8 @@ static int everything_local(struct fetch_pack_args *args,\n \t\t * Don't mark them common yet; the server has to be told so first.\n \t\t */\n \t\tfor (ref = *refs; ref; ref = ref->next) {\n-\t\t\tstruct object *o = deref_tag(lookup_object(ref->old_oid.hash),\n+\t\t\tstruct object *o = deref_tag(lookup_object(the_repository,\n+\t\t\t\t\t\t     ref->old_oid.hash),\n \t\t\t\t\t\t     NULL, 0);\n \n \t\t\tif (!o || o->type != OBJ_COMMIT || !(o->flags & COMPLETE))\n@@ -821,7 +822,7 @@ static int everything_local(struct fetch_pack_args *args,\n \t\tconst struct object_id *remote = &ref->old_oid;\n \t\tstruct object *o;\n \n-\t\to = lookup_object(remote->hash);\n+\t\to = lookup_object(the_repository, remote->hash);\n \t\tif (!o || !(o->flags & COMPLETE)) {\n \t\t\tretval = 0;\n \t\t\tprint_verbose(args, \"want %s (%s)\", oid_to_hex(remote),\n@@ -1120,7 +1121,7 @@ static void add_wants(const struct ref *wants, struct strbuf *req_buf)\n \t\t * interested in the case we *know* the object is\n \t\t * reachable and we have already scanned it.\n \t\t */\n-\t\tif (((o = lookup_object(remote->hash)) != NULL) &&\n+\t\tif (((o = lookup_object(the_repository, remote->hash)) != NULL) &&\n \t\t    (o->flags & COMPLETE)) {\n \t\t\tcontinue;\n \t\t}\n@@ -1317,7 +1318,7 @@ static void receive_shallow_info(struct fetch_pack_args *args,\n \t\tif (skip_prefix(reader->line, \"unshallow \", &arg)) {\n \t\t\tif (get_oid_hex(arg, &oid))\n \t\t\t\tdie(_(\"invalid unshallow line: %s\"), reader->line);\n-\t\t\tif (!lookup_object(oid.hash))\n+\t\t\tif (!lookup_object(the_repository, oid.hash))\n \t\t\t\tdie(_(\"object not found: %s\"), reader->line);\n \t\t\t/* make sure that it is parsed as shallow */\n \t\t\tif (!parse_object(the_repository, &oid))\ndiff --git a/http-push.c b/http-push.c\nindex 37cbf0769ba..d2245cc7380 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -722,7 +722,7 @@ static void one_remote_object(const struct object_id *oid)\n {\n \tstruct object *obj;\n \n-\tobj = lookup_object(oid->hash);\n+\tobj = lookup_object(the_repository, oid->hash);\n \tif (!obj)\n \t\tobj = parse_object(the_repository, oid);\n \ndiff --git a/object.c b/object.c\nindex bf1d9c6b5ff..002ebb69e3b 100644\n--- a/object.c\n+++ b/object.c\n@@ -84,7 +84,7 @@ static void insert_obj_hash(struct object *obj, struct object **hash, unsigned i\n  * Look up the record for the given sha1 in the hash map stored in\n  * obj_hash.  Return NULL if it was not found.\n  */\n-struct object *lookup_object(const unsigned char *sha1)\n+struct object *lookup_object_the_repository(const unsigned char *sha1)\n {\n \tunsigned int i, first;\n \tstruct object *obj;\n@@ -179,7 +179,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)\n \n struct object *lookup_unknown_object(const unsigned char *sha1)\n {\n-\tstruct object *obj = lookup_object(sha1);\n+\tstruct object *obj = lookup_object(the_repository, sha1);\n \tif (!obj)\n \t\tobj = create_object(the_repository, sha1,\n \t\t\t\t    alloc_object_node(the_repository));\n@@ -255,7 +255,7 @@ struct object *parse_object_the_repository(const struct object_id *oid)\n \tvoid *buffer;\n \tstruct object *obj;\n \n-\tobj = lookup_object(oid->hash);\n+\tobj = lookup_object(the_repository, oid->hash);\n \tif (obj && obj->parsed)\n \t\treturn obj;\n \n@@ -267,7 +267,7 @@ struct object *parse_object_the_repository(const struct object_id *oid)\n \t\t\treturn NULL;\n \t\t}\n \t\tparse_blob_buffer(lookup_blob(oid), NULL, 0);\n-\t\treturn lookup_object(oid->hash);\n+\t\treturn lookup_object(the_repository, oid->hash);\n \t}\n \n \tbuffer = read_object_file(oid, &type, &size);\ndiff --git a/object.h b/object.h\nindex 882f47fbc89..f840a428859 100644\n--- a/object.h\n+++ b/object.h\n@@ -109,7 +109,8 @@ extern struct object *get_indexed_object(unsigned int);\n  * half-initialised objects, the caller is expected to initialize them\n  * by calling parse_object() on them.\n  */\n-struct object *lookup_object(const unsigned char *sha1);\n+#define lookup_object(r, s) lookup_object_##r(s)\n+struct object *lookup_object_the_repository(const unsigned char *sha1);\n \n extern void *create_object(struct repository *r, const unsigned char *sha1, void *obj);\n \ndiff --git a/reachable.c b/reachable.c\nindex ffb976c33c6..2ee55695595 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -108,7 +108,7 @@ static int add_recent_loose(const struct object_id *oid,\n \t\t\t    const char *path, void *data)\n {\n \tstruct stat st;\n-\tstruct object *obj = lookup_object(oid->hash);\n+\tstruct object *obj = lookup_object(the_repository, oid->hash);\n \n \tif (obj && obj->flags & SEEN)\n \t\treturn 0;\n@@ -133,7 +133,7 @@ static int add_recent_packed(const struct object_id *oid,\n \t\t\t     struct packed_git *p, uint32_t pos,\n \t\t\t     void *data)\n {\n-\tstruct object *obj = lookup_object(oid->hash);\n+\tstruct object *obj = lookup_object(the_repository, oid->hash);\n \n \tif (obj && obj->flags & SEEN)\n \t\treturn 0;\ndiff --git a/tag.c b/tag.c\nindex 7d282df0697..1b95eb9f07f 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -94,7 +94,7 @@ struct object *deref_tag_noverify(struct object *o)\n \n struct tag *lookup_tag(const struct object_id *oid)\n {\n-\tstruct object *obj = lookup_object(oid->hash);\n+\tstruct object *obj = lookup_object(the_repository, oid->hash);\n \tif (!obj)\n \t\treturn create_object(the_repository, oid->hash,\n \t\t\t\t     alloc_tag_node(the_repository));\ndiff --git a/tree.c b/tree.c\nindex 533b6e69755..73e8a8a948d 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -197,7 +197,7 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match,\n \n struct tree *lookup_tree(const struct object_id *oid)\n {\n-\tstruct object *obj = lookup_object(oid->hash);\n+\tstruct object *obj = lookup_object(the_repository, oid->hash);\n \tif (!obj)\n \t\treturn create_object(the_repository, oid->hash,\n \t\t\t\t     alloc_tree_node(the_repository));\ndiff --git a/upload-pack.c b/upload-pack.c\nindex d2b85112d08..45e3a94788f 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -570,7 +570,7 @@ static int get_reachable_list(struct object_array *src,\n \t\tif (parse_oid_hex(namebuf, &sha1, &p) || *p != '\\n')\n \t\t\tbreak;\n \n-\t\to = lookup_object(sha1.hash);\n+\t\to = lookup_object(the_repository, sha1.hash);\n \t\tif (o && o->type == OBJ_COMMIT) {\n \t\t\to->flags &= ~TMP_MARK;\n \t\t}\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351292","messageId":"20180629012222.167426-2-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 01/32] object: add repository argument to parse_object","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:21:51Z","receivedAt":"2018-06-29T01:22:43Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of parse_object\nto be more specific about which repository to act on. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/diff-tree.c     |  3 ++-\n builtin/diff.c          |  2 +-\n builtin/fast-export.c   |  2 +-\n builtin/fmt-merge-msg.c |  6 ++++--\n builtin/fsck.c          |  4 ++--\n builtin/log.c           |  3 ++-\n builtin/name-rev.c      |  7 ++++---\n builtin/receive-pack.c  |  6 +++---\n builtin/reflog.c        |  3 ++-\n builtin/rev-list.c      |  2 +-\n bundle.c                |  5 +++--\n commit.c                |  5 +++--\n fetch-pack.c            | 18 ++++++++++--------\n fsck.c                  |  3 ++-\n http-backend.c          |  2 +-\n http-push.c             |  6 ++++--\n log-tree.c              |  7 ++++---\n merge-recursive.c       |  4 +++-\n object.c                |  4 ++--\n object.h                |  3 ++-\n packfile.c              |  2 +-\n pretty.c                |  2 +-\n ref-filter.c            |  3 ++-\n reflog-walk.c           |  3 ++-\n refs/files-backend.c    |  2 +-\n remote.c                |  4 ++--\n revision.c              | 14 +++++++-------\n server-info.c           |  2 +-\n sha1-name.c             | 14 +++++++-------\n tag.c                   |  5 +++--\n tree.c                  |  5 +++--\n upload-pack.c           | 13 +++++++------\n walker.c                |  3 ++-\n 33 files changed, 95 insertions(+), 72 deletions(-)\n\ndiff --git a/builtin/diff-tree.c b/builtin/diff-tree.c\nindex 473615117e0..d8db8f682f0 100644\n--- a/builtin/diff-tree.c\n+++ b/builtin/diff-tree.c\n@@ -5,6 +5,7 @@\n #include \"log-tree.h\"\n #include \"builtin.h\"\n #include \"submodule.h\"\n+#include \"repository.h\"\n \n static struct rev_info log_tree_opt;\n \n@@ -68,7 +69,7 @@ static int diff_tree_stdin(char *line)\n \tline[len-1] = 0;\n \tif (parse_oid_hex(line, &oid, &p))\n \t\treturn -1;\n-\tobj = parse_object(&oid);\n+\tobj = parse_object(the_repository, &oid);\n \tif (!obj)\n \t\treturn -1;\n \tif (obj->type == OBJ_COMMIT)\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex b709b6e9842..d0421c90e29 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -400,7 +400,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\tconst char *name = entry->name;\n \t\tint flags = (obj->flags & UNINTERESTING);\n \t\tif (!obj->parsed)\n-\t\t\tobj = parse_object(&obj->oid);\n+\t\t\tobj = parse_object(the_repository, &obj->oid);\n \t\tobj = deref_tag(obj, NULL, 0);\n \t\tif (!obj)\n \t\t\tdie(_(\"invalid object '%s' given.\"), name);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 9ee6a4d2e8f..a16aeaa826f 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -801,7 +801,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)\n \n \t\t/* handle nested tags */\n \t\twhile (tag && tag->object.type == OBJ_TAG) {\n-\t\t\tparse_object(&tag->object.oid);\n+\t\t\tparse_object(the_repository, &tag->object.oid);\n \t\t\tstring_list_append(&extra_refs, full_name)->util = tag;\n \t\t\ttag = (struct tag *)tag->tagged;\n \t\t}\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 1b526adb3a9..5e44589b545 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -11,6 +11,7 @@\n #include \"branch.h\"\n #include \"fmt-merge-msg.h\"\n #include \"gpg-interface.h\"\n+#include \"repository.h\"\n \n static const char * const fmt_merge_msg_usage[] = {\n \tN_(\"git fmt-merge-msg [-m <message>] [--log[=<n>] | --no-log] [--file <file>]\"),\n@@ -343,7 +344,8 @@ static void shortlog(const char *name,\n \tconst struct object_id *oid = &origin_data->oid;\n \tint limit = opts->shortlog_len;\n \n-\tbranch = deref_tag(parse_object(oid), oid_to_hex(oid), GIT_SHA1_HEXSZ);\n+\tbranch = deref_tag(parse_object(the_repository, oid), oid_to_hex(oid),\n+\t\t\t   GIT_SHA1_HEXSZ);\n \tif (!branch || branch->type != OBJ_COMMIT)\n \t\treturn;\n \n@@ -563,7 +565,7 @@ static void find_merge_parents(struct merge_parents *result,\n \t\t * \"name\" here and we do not want to contaminate its\n \t\t * util field yet.\n \t\t */\n-\t\tobj = parse_object(&oid);\n+\t\tobj = parse_object(the_repository, &oid);\n \t\tparent = (struct commit *)peel_to_type(NULL, 0, obj, OBJ_COMMIT);\n \t\tif (!parent)\n \t\t\tcontinue;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 3ad4f160f99..2b0930101d3 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -452,7 +452,7 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid,\n {\n \tstruct object *obj;\n \n-\tobj = parse_object(oid);\n+\tobj = parse_object(the_repository, oid);\n \tif (!obj) {\n \t\tif (is_promisor_object(oid)) {\n \t\t\t/*\n@@ -614,7 +614,7 @@ static int fsck_cache_tree(struct cache_tree *it)\n \t\tfprintf(stderr, \"Checking cache tree\\n\");\n \n \tif (0 <= it->entry_count) {\n-\t\tstruct object *obj = parse_object(&it->oid);\n+\t\tstruct object *obj = parse_object(the_repository, &it->oid);\n \t\tif (!obj) {\n \t\t\terror(\"%s: invalid sha1 pointer in cache-tree\",\n \t\t\t      oid_to_hex(&it->oid));\ndiff --git a/builtin/log.c b/builtin/log.c\nindex c77af797555..05217596a2b 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -30,6 +30,7 @@\n #include \"gpg-interface.h\"\n #include \"progress.h\"\n #include \"commit-slab.h\"\n+#include \"repository.h\"\n \n #define MAIL_DEFAULT_WRAP 72\n \n@@ -619,7 +620,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \t\t\trev.shown_one = 1;\n \t\t\tif (ret)\n \t\t\t\tbreak;\n-\t\t\to = parse_object(&t->tagged->oid);\n+\t\t\to = parse_object(the_repository, &t->tagged->oid);\n \t\t\tif (!o)\n \t\t\t\tret = error(_(\"Could not read object %s\"),\n \t\t\t\t\t    oid_to_hex(&t->tagged->oid));\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 0eb440359dd..de54fa93e4f 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -1,5 +1,6 @@\n #include \"builtin.h\"\n #include \"cache.h\"\n+#include \"repository.h\"\n #include \"config.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n@@ -203,7 +204,7 @@ static int tipcmp(const void *a_, const void *b_)\n \n static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)\n {\n-\tstruct object *o = parse_object(oid);\n+\tstruct object *o = parse_object(the_repository, oid);\n \tstruct name_ref_data *data = cb_data;\n \tint can_abbreviate_output = data->tags_only && data->name_only;\n \tint deref = 0;\n@@ -261,7 +262,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo\n \t\tstruct tag *t = (struct tag *) o;\n \t\tif (!t->tagged)\n \t\t\tbreak; /* broken repository */\n-\t\to = parse_object(&t->tagged->oid);\n+\t\to = parse_object(the_repository, &t->tagged->oid);\n \t\tderef = 1;\n \t\ttaggerdate = t->date;\n \t}\n@@ -451,7 +452,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t}\n \n \t\tcommit = NULL;\n-\t\tobject = parse_object(&oid);\n+\t\tobject = parse_object(the_repository, &oid);\n \t\tif (object) {\n \t\t\tstruct object *peeled = deref_tag(object, *argv, 0);\n \t\t\tif (peeled && peeled->type == OBJ_COMMIT)\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 44c7c9ee827..400d31c18cc 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1108,8 +1108,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)\n \t\tstruct object *old_object, *new_object;\n \t\tstruct commit *old_commit, *new_commit;\n \n-\t\told_object = parse_object(old_oid);\n-\t\tnew_object = parse_object(new_oid);\n+\t\told_object = parse_object(the_repository, old_oid);\n+\t\tnew_object = parse_object(the_repository, new_oid);\n \n \t\tif (!old_object || !new_object ||\n \t\t    old_object->type != OBJ_COMMIT ||\n@@ -1132,7 +1132,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)\n \n \tif (is_null_oid(new_oid)) {\n \t\tstruct strbuf err = STRBUF_INIT;\n-\t\tif (!parse_object(old_oid)) {\n+\t\tif (!parse_object(the_repository, old_oid)) {\n \t\t\told_oid = NULL;\n \t\t\tif (ref_exists(name)) {\n \t\t\t\trp_warning(\"Allowing deletion of corrupt ref.\");\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 00911929952..948002b81ea 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -2,6 +2,7 @@\n #include \"config.h\"\n #include \"lockfile.h\"\n #include \"object-store.h\"\n+#include \"repository.h\"\n #include \"commit.h\"\n #include \"refs.h\"\n #include \"dir.h\"\n@@ -129,7 +130,7 @@ static int commit_is_complete(struct commit *commit)\n \t\tstruct commit_list *parent;\n \n \t\tc = (struct commit *)object_array_pop(&study);\n-\t\tif (!c->object.parsed && !parse_object(&c->object.oid))\n+\t\tif (!c->object.parsed && !parse_object(the_repository, &c->object.oid))\n \t\t\tc->object.flags |= INCOMPLETE;\n \n \t\tif (c->object.flags & INCOMPLETE) {\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex e9bd4e378ad..cbaaae83eae 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -239,7 +239,7 @@ static int finish_object(struct object *obj, const char *name, void *cb_data)\n \t\treturn 1;\n \t}\n \tif (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)\n-\t\tparse_object(&obj->oid);\n+\t\tparse_object(the_repository, &obj->oid);\n \treturn 0;\n }\n \ndiff --git a/bundle.c b/bundle.c\nindex ba18e25d028..8283fffd7cc 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -2,6 +2,7 @@\n #include \"lockfile.h\"\n #include \"bundle.h\"\n #include \"object-store.h\"\n+#include \"repository.h\"\n #include \"object.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n@@ -142,7 +143,7 @@ int verify_bundle(struct bundle_header *header, int verbose)\n \tinit_revisions(&revs, NULL);\n \tfor (i = 0; i < p->nr; i++) {\n \t\tstruct ref_list_entry *e = p->list + i;\n-\t\tstruct object *o = parse_object(&e->oid);\n+\t\tstruct object *o = parse_object(the_repository, &e->oid);\n \t\tif (o) {\n \t\t\to->flags |= PREREQ_MARK;\n \t\t\tadd_pending_object(&revs, o, e->name);\n@@ -167,7 +168,7 @@ int verify_bundle(struct bundle_header *header, int verbose)\n \n \tfor (i = 0; i < p->nr; i++) {\n \t\tstruct ref_list_entry *e = p->list + i;\n-\t\tstruct object *o = parse_object(&e->oid);\n+\t\tstruct object *o = parse_object(the_repository, &e->oid);\n \t\tassert(o); /* otherwise we'd have returned early */\n \t\tif (o->flags & SHOWN)\n \t\t\tcontinue;\ndiff --git a/commit.c b/commit.c\nindex a7c0b5f8c6c..a29070a8133 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -27,7 +27,8 @@ const char *commit_type = \"commit\";\n struct commit *lookup_commit_reference_gently(const struct object_id *oid,\n \t\t\t\t\t      int quiet)\n {\n-\tstruct object *obj = deref_tag(parse_object(oid), NULL, 0);\n+\tstruct object *obj = deref_tag(parse_object(the_repository, oid),\n+\t\t\t\t       NULL, 0);\n \n \tif (!obj)\n \t\treturn NULL;\n@@ -1692,7 +1693,7 @@ struct commit *get_merge_parent(const char *name)\n \tstruct object_id oid;\n \tif (get_oid(name, &oid))\n \t\treturn NULL;\n-\tobj = parse_object(&oid);\n+\tobj = parse_object(the_repository, &oid);\n \tcommit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);\n \tif (commit && !merge_remote_util(commit))\n \t\tset_merge_remote_desc(commit, name, obj);\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex dbd879ac7fd..6b406f1d008 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -84,7 +84,7 @@ static void cache_one_alternate(const char *refname,\n \t\t\t\tvoid *vcache)\n {\n \tstruct alternate_object_cache *cache = vcache;\n-\tstruct object *obj = parse_object(oid);\n+\tstruct object *obj = parse_object(the_repository, oid);\n \n \tif (!obj || (obj->flags & ALTERNATE))\n \t\treturn;\n@@ -126,7 +126,8 @@ static void rev_list_push(struct commit *commit, int mark)\n \n static int rev_list_insert_ref(const char *refname, const struct object_id *oid)\n {\n-\tstruct object *o = deref_tag(parse_object(oid), refname, 0);\n+\tstruct object *o = deref_tag(parse_object(the_repository, oid),\n+\t\t\t\t     refname, 0);\n \n \tif (o && o->type == OBJ_COMMIT)\n \t\trev_list_push((struct commit *)o, SEEN);\n@@ -143,7 +144,8 @@ static int rev_list_insert_ref_oid(const char *refname, const struct object_id *\n static int clear_marks(const char *refname, const struct object_id *oid,\n \t\t       int flag, void *cb_data)\n {\n-\tstruct object *o = deref_tag(parse_object(oid), refname, 0);\n+\tstruct object *o = deref_tag(parse_object(the_repository, oid),\n+\t\t\t\t     refname, 0);\n \n \tif (o && o->type == OBJ_COMMIT)\n \t\tclear_commit_marks((struct commit *)o,\n@@ -437,7 +439,7 @@ static int find_common(struct fetch_pack_args *args,\n \t\t\t\tif (!lookup_object(oid.hash))\n \t\t\t\t\tdie(_(\"object not found: %s\"), line);\n \t\t\t\t/* make sure that it is parsed as shallow */\n-\t\t\t\tif (!parse_object(&oid))\n+\t\t\t\tif (!parse_object(the_repository, &oid))\n \t\t\t\t\tdie(_(\"error in object: %s\"), line);\n \t\t\t\tif (unregister_shallow(&oid))\n \t\t\t\t\tdie(_(\"no shallow found: %s\"), line);\n@@ -570,14 +572,14 @@ static struct commit_list *complete;\n \n static int mark_complete(const struct object_id *oid)\n {\n-\tstruct object *o = parse_object(oid);\n+\tstruct object *o = parse_object(the_repository, oid);\n \n \twhile (o && o->type == OBJ_TAG) {\n \t\tstruct tag *t = (struct tag *) o;\n \t\tif (!t->tagged)\n \t\t\tbreak; /* broken repository */\n \t\to->flags |= COMPLETE;\n-\t\to = parse_object(&t->tagged->oid);\n+\t\to = parse_object(the_repository, &t->tagged->oid);\n \t}\n \tif (o && o->type == OBJ_COMMIT) {\n \t\tstruct commit *commit = (struct commit *)o;\n@@ -768,7 +770,7 @@ static int everything_local(struct fetch_pack_args *args,\n \n \t\tif (!has_object_file_with_flags(&ref->old_oid, flags))\n \t\t\tcontinue;\n-\t\to = parse_object(&ref->old_oid);\n+\t\to = parse_object(the_repository, &ref->old_oid);\n \t\tif (!o)\n \t\t\tcontinue;\n \n@@ -1318,7 +1320,7 @@ static void receive_shallow_info(struct fetch_pack_args *args,\n \t\t\tif (!lookup_object(oid.hash))\n \t\t\t\tdie(_(\"object not found: %s\"), reader->line);\n \t\t\t/* make sure that it is parsed as shallow */\n-\t\t\tif (!parse_object(&oid))\n+\t\t\tif (!parse_object(the_repository, &oid))\n \t\t\t\tdie(_(\"error in object: %s\"), reader->line);\n \t\t\tif (unregister_shallow(&oid))\n \t\t\t\tdie(_(\"no shallow found: %s\"), reader->line);\ndiff --git a/fsck.c b/fsck.c\nindex 4dfe65f7154..bb3d622fb93 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"object-store.h\"\n+#include \"repository.h\"\n #include \"object.h\"\n #include \"blob.h\"\n #include \"tree.h\"\n@@ -511,7 +512,7 @@ int fsck_walk(struct object *obj, void *data, struct fsck_options *options)\n \t\treturn -1;\n \n \tif (obj->type == OBJ_NONE)\n-\t\tparse_object(&obj->oid);\n+\t\tparse_object(the_repository, &obj->oid);\n \n \tswitch (obj->type) {\n \tcase OBJ_BLOB:\ndiff --git a/http-backend.c b/http-backend.c\nindex adaef16fadf..50ba4d53d54 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -436,7 +436,7 @@ static int show_text_ref(const char *name, const struct object_id *oid,\n {\n \tconst char *name_nons = strip_namespace(name);\n \tstruct strbuf *buf = cb_data;\n-\tstruct object *o = parse_object(oid);\n+\tstruct object *o = parse_object(the_repository, oid);\n \tif (!o)\n \t\treturn 0;\n \ndiff --git a/http-push.c b/http-push.c\nindex 7e38522098b..37cbf0769ba 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"repository.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"blob.h\"\n@@ -14,6 +15,7 @@\n #include \"packfile.h\"\n #include \"object-store.h\"\n \n+\n #ifdef EXPAT_NEEDS_XMLPARSE_H\n #include <xmlparse.h>\n #else\n@@ -722,7 +724,7 @@ static void one_remote_object(const struct object_id *oid)\n \n \tobj = lookup_object(oid->hash);\n \tif (!obj)\n-\t\tobj = parse_object(oid);\n+\t\tobj = parse_object(the_repository, oid);\n \n \t/* Ignore remote objects that don't exist locally */\n \tif (!obj)\n@@ -1459,7 +1461,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)\n \t\treturn;\n \t}\n \n-\to = parse_object(&ref->old_oid);\n+\to = parse_object(the_repository, &ref->old_oid);\n \tif (!o) {\n \t\tfprintf(stderr,\n \t\t\t\"Unable to parse object %s for remote ref %s\\n\",\ndiff --git a/log-tree.c b/log-tree.c\nindex 4a3907fea02..0eb7c6027fa 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -2,6 +2,7 @@\n #include \"config.h\"\n #include \"diff.h\"\n #include \"object-store.h\"\n+#include \"repository.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"graph.h\"\n@@ -98,13 +99,13 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,\n \t\t\twarning(\"invalid replace ref %s\", refname);\n \t\t\treturn 0;\n \t\t}\n-\t\tobj = parse_object(&original_oid);\n+\t\tobj = parse_object(the_repository, &original_oid);\n \t\tif (obj)\n \t\t\tadd_name_decoration(DECORATION_GRAFTED, \"replaced\", obj);\n \t\treturn 0;\n \t}\n \n-\tobj = parse_object(oid);\n+\tobj = parse_object(the_repository, oid);\n \tif (!obj)\n \t\treturn 0;\n \n@@ -125,7 +126,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,\n \t\tif (!obj)\n \t\t\tbreak;\n \t\tif (!obj->parsed)\n-\t\t\tparse_object(&obj->oid);\n+\t\t\tparse_object(the_repository, &obj->oid);\n \t\tadd_name_decoration(DECORATION_REF_TAG, refname, obj);\n \t}\n \treturn 0;\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 113c1d69625..85694398215 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -9,6 +9,7 @@\n #include \"lockfile.h\"\n #include \"cache-tree.h\"\n #include \"object-store.h\"\n+#include \"repository.h\"\n #include \"commit.h\"\n #include \"blob.h\"\n #include \"builtin.h\"\n@@ -3488,7 +3489,8 @@ static struct commit *get_ref(const struct object_id *oid, const char *name)\n {\n \tstruct object *object;\n \n-\tobject = deref_tag(parse_object(oid), name, strlen(name));\n+\tobject = deref_tag(parse_object(the_repository, oid), name,\n+\t\t\t   strlen(name));\n \tif (!object)\n \t\treturn NULL;\n \tif (object->type == OBJ_TREE)\ndiff --git a/object.c b/object.c\nindex 9b0f819fae3..bf1d9c6b5ff 100644\n--- a/object.c\n+++ b/object.c\n@@ -239,14 +239,14 @@ struct object *parse_object_buffer(const struct object_id *oid, enum object_type\n struct object *parse_object_or_die(const struct object_id *oid,\n \t\t\t\t   const char *name)\n {\n-\tstruct object *o = parse_object(oid);\n+\tstruct object *o = parse_object(the_repository, oid);\n \tif (o)\n \t\treturn o;\n \n \tdie(_(\"unable to parse object: %s\"), name ? name : oid_to_hex(oid));\n }\n \n-struct object *parse_object(const struct object_id *oid)\n+struct object *parse_object_the_repository(const struct object_id *oid)\n {\n \tunsigned long size;\n \tenum object_type type;\ndiff --git a/object.h b/object.h\nindex 1b96073601f..882f47fbc89 100644\n--- a/object.h\n+++ b/object.h\n@@ -120,7 +120,8 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet);\n  *\n  * Returns NULL if the object is missing or corrupt.\n  */\n-struct object *parse_object(const struct object_id *oid);\n+#define parse_object(r, oid) parse_object_##r(oid)\n+struct object *parse_object_the_repository(const struct object_id *oid);\n \n /*\n  * Like parse_object, but will die() instead of returning NULL. If the\ndiff --git a/packfile.c b/packfile.c\nindex 7cd45aa4b2a..6974903e581 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1934,7 +1934,7 @@ static int add_promisor_object(const struct object_id *oid,\n \t\t\t       void *set_)\n {\n \tstruct oidset *set = set_;\n-\tstruct object *obj = parse_object(oid);\n+\tstruct object *obj = parse_object(the_repository, oid);\n \tif (!obj)\n \t\treturn 1;\n \ndiff --git a/pretty.c b/pretty.c\nindex 703fa6ff7bf..cbd25b6ceae 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1146,7 +1146,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */\n \n \t/* these depend on the commit */\n \tif (!commit->object.parsed)\n-\t\tparse_object(&commit->object.oid);\n+\t\tparse_object(the_repository, &commit->object.oid);\n \n \tswitch (placeholder[0]) {\n \tcase 'H':\t\t/* commit hash */\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 0ab893a250f..044c28c5154 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -4,6 +4,7 @@\n #include \"refs.h\"\n #include \"wildmatch.h\"\n #include \"object-store.h\"\n+#include \"repository.h\"\n #include \"commit.h\"\n #include \"remote.h\"\n #include \"color.h\"\n@@ -1914,7 +1915,7 @@ static const struct object_id *match_points_at(struct oid_array *points_at,\n \n \tif (oid_array_lookup(points_at, oid) >= 0)\n \t\treturn oid;\n-\tobj = parse_object(oid);\n+\tobj = parse_object(the_repository, oid);\n \tif (!obj)\n \t\tdie(_(\"malformed object at '%s'\"), refname);\n \tif (obj->type == OBJ_TAG)\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex 5008bbf6ada..3561a8b9558 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -305,7 +305,8 @@ static struct commit *next_reflog_commit(struct commit_reflog *log)\n {\n \tfor (; log->recno >= 0; log->recno--) {\n \t\tstruct reflog_info *entry = &log->reflogs->items[log->recno];\n-\t\tstruct object *obj = parse_object(&entry->noid);\n+\t\tstruct object *obj = parse_object(the_repository,\n+\t\t\t\t\t\t  &entry->noid);\n \n \t\tif (obj && obj->type == OBJ_COMMIT)\n \t\t\treturn (struct commit *)obj;\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex a9a066dcfb6..55c2ae0bd59 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -1660,7 +1660,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock,\n \tstruct object *o;\n \tint fd;\n \n-\to = parse_object(oid);\n+\to = parse_object(the_repository, oid);\n \tif (!o) {\n \t\tstrbuf_addf(err,\n \t\t\t    \"trying to write ref '%s' with nonexistent object %s\",\ndiff --git a/remote.c b/remote.c\nindex 539285fbdf0..a5c04a0a7df 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1801,12 +1801,12 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)\n \t * Both new_commit and old_commit must be commit-ish and new_commit is descendant of\n \t * old_commit.  Otherwise we require --force.\n \t */\n-\to = deref_tag(parse_object(old_oid), NULL, 0);\n+\to = deref_tag(parse_object(the_repository, old_oid), NULL, 0);\n \tif (!o || o->type != OBJ_COMMIT)\n \t\treturn 0;\n \told_commit = (struct commit *) o;\n \n-\to = deref_tag(parse_object(new_oid), NULL, 0);\n+\to = deref_tag(parse_object(the_repository, new_oid), NULL, 0);\n \tif (!o || o->type != OBJ_COMMIT)\n \t\treturn 0;\n \tnew_commit = (struct commit *) o;\ndiff --git a/revision.c b/revision.c\nindex 72abe235e4a..8a2b2850cad 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -197,7 +197,7 @@ void add_head_to_pending(struct rev_info *revs)\n \tstruct object *obj;\n \tif (get_oid(\"HEAD\", &oid))\n \t\treturn;\n-\tobj = parse_object(&oid);\n+\tobj = parse_object(the_repository, &oid);\n \tif (!obj)\n \t\treturn;\n \tadd_pending_object(revs, obj, \"HEAD\");\n@@ -209,7 +209,7 @@ static struct object *get_reference(struct rev_info *revs, const char *name,\n {\n \tstruct object *object;\n \n-\tobject = parse_object(oid);\n+\tobject = parse_object(the_repository, oid);\n \tif (!object) {\n \t\tif (revs->ignore_missing)\n \t\t\treturn object;\n@@ -246,7 +246,7 @@ static struct commit *handle_commit(struct rev_info *revs,\n \t\t\tadd_pending_object(revs, object, tag->tag);\n \t\tif (!tag->tagged)\n \t\t\tdie(\"bad tag\");\n-\t\tobject = parse_object(&tag->tagged->oid);\n+\t\tobject = parse_object(the_repository, &tag->tagged->oid);\n \t\tif (!object) {\n \t\t\tif (revs->ignore_missing_links || (flags & UNINTERESTING))\n \t\t\t\treturn NULL;\n@@ -1249,7 +1249,7 @@ static void handle_one_reflog_commit(struct object_id *oid, void *cb_data)\n {\n \tstruct all_refs_cb *cb = cb_data;\n \tif (!is_null_oid(oid)) {\n-\t\tstruct object *o = parse_object(oid);\n+\t\tstruct object *o = parse_object(the_repository, oid);\n \t\tif (o) {\n \t\t\to->flags |= cb->all_flags;\n \t\t\t/* ??? CMDLINEFLAGS ??? */\n@@ -1577,8 +1577,8 @@ static int handle_dotdot_1(const char *arg, char *dotdot,\n \t\t*dotdot = '\\0';\n \t}\n \n-\ta_obj = parse_object(&a_oid);\n-\tb_obj = parse_object(&b_oid);\n+\ta_obj = parse_object(the_repository, &a_oid);\n+\tb_obj = parse_object(the_repository, &b_oid);\n \tif (!a_obj || !b_obj)\n \t\treturn dotdot_missing(arg, dotdot, revs, symmetric);\n \n@@ -2883,7 +2883,7 @@ static int mark_uninteresting(const struct object_id *oid,\n \t\t\t      uint32_t pos,\n \t\t\t      void *unused)\n {\n-\tstruct object *o = parse_object(oid);\n+\tstruct object *o = parse_object(the_repository, oid);\n \to->flags |= UNINTERESTING | SEEN;\n \treturn 0;\n }\ndiff --git a/server-info.c b/server-info.c\nindex 7ce6dcd67b7..2abd0dca088 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -56,7 +56,7 @@ static int add_info_ref(const char *path, const struct object_id *oid,\n \t\t\tint flag, void *cb_data)\n {\n \tFILE *fp = cb_data;\n-\tstruct object *o = parse_object(oid);\n+\tstruct object *o = parse_object(the_repository, oid);\n \tif (!o)\n \t\treturn -1;\n \ndiff --git a/sha1-name.c b/sha1-name.c\nindex 60d9ef3c7e7..dd19abaafd4 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -239,7 +239,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da\n \t\treturn 0;\n \n \t/* We need to do this the hard way... */\n-\tobj = deref_tag(parse_object(oid), NULL, 0);\n+\tobj = deref_tag(parse_object(the_repository, oid), NULL, 0);\n \tif (obj && obj->type == OBJ_COMMIT)\n \t\treturn 1;\n \treturn 0;\n@@ -263,7 +263,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_\n \t\treturn 0;\n \n \t/* We need to do this the hard way... */\n-\tobj = deref_tag(parse_object(oid), NULL, 0);\n+\tobj = deref_tag(parse_object(the_repository, oid), NULL, 0);\n \tif (obj && (obj->type == OBJ_TREE || obj->type == OBJ_COMMIT))\n \t\treturn 1;\n \treturn 0;\n@@ -891,7 +891,7 @@ struct object *peel_to_type(const char *name, int namelen,\n \tif (name && !namelen)\n \t\tnamelen = strlen(name);\n \twhile (1) {\n-\t\tif (!o || (!o->parsed && !parse_object(&o->oid)))\n+\t\tif (!o || (!o->parsed && !parse_object(the_repository, &o->oid)))\n \t\t\treturn NULL;\n \t\tif (expected_type == OBJ_ANY || o->type == expected_type)\n \t\t\treturn o;\n@@ -964,12 +964,12 @@ static int peel_onion(const char *name, int len, struct object_id *oid,\n \tif (get_oid_1(name, sp - name - 2, &outer, lookup_flags))\n \t\treturn -1;\n \n-\to = parse_object(&outer);\n+\to = parse_object(the_repository, &outer);\n \tif (!o)\n \t\treturn -1;\n \tif (!expected_type) {\n \t\to = deref_tag(o, name, sp - name - 2);\n-\t\tif (!o || (!o->parsed && !parse_object(&o->oid)))\n+\t\tif (!o || (!o->parsed && !parse_object(the_repository, &o->oid)))\n \t\t\treturn -1;\n \t\toidcpy(oid, &o->oid);\n \t\treturn 0;\n@@ -1096,7 +1096,7 @@ static int handle_one_ref(const char *path, const struct object_id *oid,\n \t\t\t  int flag, void *cb_data)\n {\n \tstruct commit_list **list = cb_data;\n-\tstruct object *object = parse_object(oid);\n+\tstruct object *object = parse_object(the_repository, oid);\n \tif (!object)\n \t\treturn 0;\n \tif (object->type == OBJ_TAG) {\n@@ -1142,7 +1142,7 @@ static int get_oid_oneline(const char *prefix, struct object_id *oid,\n \t\tint matches;\n \n \t\tcommit = pop_most_recent_commit(&list, ONELINE_SEEN);\n-\t\tif (!parse_object(&commit->object.oid))\n+\t\tif (!parse_object(the_repository, &commit->object.oid))\n \t\t\tcontinue;\n \t\tbuf = get_commit_buffer(commit, NULL);\n \t\tp = strstr(buf, \"\\n\\n\");\ndiff --git a/tag.c b/tag.c\nindex 3be7206e920..7d282df0697 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -68,7 +68,8 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen)\n {\n \twhile (o && o->type == OBJ_TAG)\n \t\tif (((struct tag *)o)->tagged)\n-\t\t\to = parse_object(&((struct tag *)o)->tagged->oid);\n+\t\t\to = parse_object(the_repository,\n+\t\t\t\t\t &((struct tag *)o)->tagged->oid);\n \t\telse\n \t\t\to = NULL;\n \tif (!o && warn) {\n@@ -82,7 +83,7 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen)\n struct object *deref_tag_noverify(struct object *o)\n {\n \twhile (o && o->type == OBJ_TAG) {\n-\t\to = parse_object(&o->oid);\n+\t\to = parse_object(the_repository, &o->oid);\n \t\tif (o && o->type == OBJ_TAG && ((struct tag *)o)->tagged)\n \t\t\to = ((struct tag *)o)->tagged;\n \t\telse\ndiff --git a/tree.c b/tree.c\nindex bc7e99020d9..533b6e69755 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -8,6 +8,7 @@\n #include \"tag.h\"\n #include \"alloc.h\"\n #include \"tree-walk.h\"\n+#include \"repository.h\"\n \n const char *tree_type = \"tree\";\n \n@@ -244,7 +245,7 @@ void free_tree_buffer(struct tree *tree)\n \n struct tree *parse_tree_indirect(const struct object_id *oid)\n {\n-\tstruct object *obj = parse_object(oid);\n+\tstruct object *obj = parse_object(the_repository, oid);\n \tdo {\n \t\tif (!obj)\n \t\t\treturn NULL;\n@@ -257,6 +258,6 @@ struct tree *parse_tree_indirect(const struct object_id *oid)\n \t\telse\n \t\t\treturn NULL;\n \t\tif (!obj->parsed)\n-\t\t\tparse_object(&obj->oid);\n+\t\t\tparse_object(the_repository, &obj->oid);\n \t} while (1);\n }\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 936acabbdd1..d2b85112d08 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -3,6 +3,7 @@\n #include \"refs.h\"\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n+#include \"repository.h\"\n #include \"object-store.h\"\n #include \"tag.h\"\n #include \"object.h\"\n@@ -311,7 +312,7 @@ static int got_oid(const char *hex, struct object_id *oid)\n \tif (!has_object_file(oid))\n \t\treturn -1;\n \n-\to = parse_object(oid);\n+\to = parse_object(the_repository, oid);\n \tif (!o)\n \t\tdie(\"oops (%s)\", oid_to_hex(oid));\n \tif (o->type == OBJ_COMMIT) {\n@@ -349,7 +350,7 @@ static int reachable(struct commit *want)\n \t\t\tbreak;\n \t\t}\n \t\tif (!commit->object.parsed)\n-\t\t\tparse_object(&commit->object.oid);\n+\t\t\tparse_object(the_repository, &commit->object.oid);\n \t\tif (commit->object.flags & REACHABLE)\n \t\t\tcontinue;\n \t\tcommit->object.flags |= REACHABLE;\n@@ -800,7 +801,7 @@ static int process_shallow(const char *line, struct object_array *shallows)\n \t\tstruct object *object;\n \t\tif (get_oid_hex(arg, &oid))\n \t\t\tdie(\"invalid shallow line: %s\", line);\n-\t\tobject = parse_object(&oid);\n+\t\tobject = parse_object(the_repository, &oid);\n \t\tif (!object)\n \t\t\treturn 1;\n \t\tif (object->type != OBJ_COMMIT)\n@@ -926,7 +927,7 @@ static void receive_needs(void)\n \t\tif (allow_filter && parse_feature_request(features, \"filter\"))\n \t\t\tfilter_capability_requested = 1;\n \n-\t\to = parse_object(&oid_buf);\n+\t\to = parse_object(the_repository, &oid_buf);\n \t\tif (!o) {\n \t\t\tpacket_write_fmt(1,\n \t\t\t\t\t \"ERR upload-pack: not our ref %s\",\n@@ -1167,7 +1168,7 @@ static int parse_want(const char *line)\n \t\t\tdie(\"git upload-pack: protocol error, \"\n \t\t\t    \"expected to get oid, not '%s'\", line);\n \n-\t\to = parse_object(&oid);\n+\t\to = parse_object(the_repository, &oid);\n \t\tif (!o) {\n \t\t\tpacket_write_fmt(1,\n \t\t\t\t\t \"ERR upload-pack: not our ref %s\",\n@@ -1279,7 +1280,7 @@ static int process_haves(struct oid_array *haves, struct oid_array *common)\n \n \t\toid_array_append(common, oid);\n \n-\t\to = parse_object(oid);\n+\t\to = parse_object(the_repository, oid);\n \t\tif (!o)\n \t\t\tdie(\"oops (%s)\", oid_to_hex(oid));\n \t\tif (o->type == OBJ_COMMIT) {\ndiff --git a/walker.c b/walker.c\nindex 86359ab0ab6..63002b18875 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"walker.h\"\n+#include \"repository.h\"\n #include \"object-store.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n@@ -178,7 +179,7 @@ static int loop(struct walker *walker)\n \t\t\t}\n \t\t}\n \t\tif (!obj->type)\n-\t\t\tparse_object(&obj->oid);\n+\t\t\tparse_object(the_repository, &obj->oid);\n \t\tif (process_object(walker, obj))\n \t\t\treturn -1;\n \t}\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351293","messageId":"20180629012222.167426-4-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 03/32] object: add repository argument to parse_object_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:21:53Z","receivedAt":"2018-06-29T01:22:47Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of parse_object_buffer\nto be more specific about which repository to act on. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/fast-export.c    | 3 ++-\n builtin/fsck.c           | 7 +++++--\n builtin/index-pack.c     | 3 ++-\n builtin/unpack-objects.c | 3 ++-\n object.c                 | 5 +++--\n object.h                 | 3 ++-\n ref-filter.c             | 3 ++-\n 7 files changed, 18 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex e39c4e2c1d0..03a2e4b79e6 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -244,7 +244,8 @@ static void export_blob(const struct object_id *oid)\n \t\t\tdie (\"Could not read blob %s\", oid_to_hex(oid));\n \t\tif (check_object_signature(oid, buf, size, type_name(type)) < 0)\n \t\t\tdie(\"sha1 mismatch in blob %s\", oid_to_hex(oid));\n-\t\tobject = parse_object_buffer(oid, type, size, buf, &eaten);\n+\t\tobject = parse_object_buffer(the_repository, oid, type,\n+\t\t\t\t\t     size, buf, &eaten);\n \t}\n \n \tif (!object)\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 12d01e91747..09cf5333444 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -392,7 +392,8 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,\n \t * verify_packfile(), data_valid variable for details.\n \t */\n \tstruct object *obj;\n-\tobj = parse_object_buffer(oid, type, size, buffer, eaten);\n+\tobj = parse_object_buffer(the_repository, oid, type, size, buffer,\n+\t\t\t\t  eaten);\n \tif (!obj) {\n \t\terrors_found |= ERROR_OBJECT;\n \t\treturn error(\"%s: object corrupt or missing\", oid_to_hex(oid));\n@@ -525,7 +526,9 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)\n \tif (!contents && type != OBJ_BLOB)\n \t\tBUG(\"read_loose_object streamed a non-blob\");\n \n-\tobj = parse_object_buffer(oid, type, size, contents, &eaten);\n+\tobj = parse_object_buffer(the_repository, oid, type, size,\n+\t\t\t\t  contents, &eaten);\n+\n \tif (!obj) {\n \t\terrors_found |= ERROR_OBJECT;\n \t\terror(\"%s: object could not be parsed: %s\",\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 74fe2973e12..9c08cf3cead 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -851,7 +851,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\t\t * we do not need to free the memory here, as the\n \t\t\t * buf is deleted by the caller.\n \t\t\t */\n-\t\t\tobj = parse_object_buffer(oid, type, size, buf,\n+\t\t\tobj = parse_object_buffer(the_repository, oid, type,\n+\t\t\t\t\t\t  size, buf,\n \t\t\t\t\t\t  &eaten);\n \t\t\tif (!obj)\n \t\t\t\tdie(_(\"invalid %s\"), type_name(type));\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 335b5ed9a0f..75d1d5ea0b8 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -265,7 +265,8 @@ static void write_object(unsigned nr, enum object_type type,\n \t\tint eaten;\n \t\thash_object_file(buf, size, type_name(type), &obj_list[nr].oid);\n \t\tadded_object(nr, type, buf, size);\n-\t\tobj = parse_object_buffer(&obj_list[nr].oid, type, size, buf,\n+\t\tobj = parse_object_buffer(the_repository, &obj_list[nr].oid,\n+\t\t\t\t\t  type, size, buf,\n \t\t\t\t\t  &eaten);\n \t\tif (!obj)\n \t\t\tdie(\"invalid %s\", type_name(type));\ndiff --git a/object.c b/object.c\nindex 002ebb69e3b..49719694c14 100644\n--- a/object.c\n+++ b/object.c\n@@ -186,7 +186,7 @@ struct object *lookup_unknown_object(const unsigned char *sha1)\n \treturn obj;\n }\n \n-struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)\n+struct object *parse_object_buffer_the_repository(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)\n {\n \tstruct object *obj;\n \t*eaten_p = 0;\n@@ -278,7 +278,8 @@ struct object *parse_object_the_repository(const struct object_id *oid)\n \t\t\treturn NULL;\n \t\t}\n \n-\t\tobj = parse_object_buffer(oid, type, size, buffer, &eaten);\n+\t\tobj = parse_object_buffer(the_repository, oid, type, size,\n+\t\t\t\t\t  buffer, &eaten);\n \t\tif (!eaten)\n \t\t\tfree(buffer);\n \t\treturn obj;\ndiff --git a/object.h b/object.h\nindex f840a428859..2ba23c07a72 100644\n--- a/object.h\n+++ b/object.h\n@@ -135,7 +135,8 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name\n  * parsing it.  eaten_p indicates if the object has a borrowed copy\n  * of buffer and the caller should not free() it.\n  */\n-struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);\n+#define parse_object_buffer(r, o, t, s, b, e) parse_object_buffer_##r(o, t, s, b, e)\n+struct object *parse_object_buffer_the_repository(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);\n \n /** Returns the object, with potentially excess memory allocated. **/\n struct object *lookup_unknown_object(const unsigned  char *sha1);\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 044c28c5154..ec9479af1f8 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -807,7 +807,8 @@ static void *get_obj(const struct object_id *oid, struct object **obj, unsigned\n \tvoid *buf = read_object_file(oid, &type, sz);\n \n \tif (buf)\n-\t\t*obj = parse_object_buffer(oid, type, *sz, buf, eaten);\n+\t\t*obj = parse_object_buffer(the_repository, oid, type, *sz,\n+\t\t\t\t\t   buf, eaten);\n \telse\n \t\t*obj = NULL;\n \treturn buf;\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351294","messageId":"20180629012222.167426-6-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 05/32] blob: add repository argument to lookup_blob","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:21:55Z","receivedAt":"2018-06-29T01:22:52Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of lookup_blob\nto be more specific about which repository to act on. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n blob.c                   | 2 +-\n blob.h                   | 3 ++-\n builtin/fast-export.c    | 2 +-\n builtin/fsck.c           | 3 ++-\n builtin/index-pack.c     | 2 +-\n builtin/merge-tree.c     | 3 ++-\n builtin/unpack-objects.c | 2 +-\n fsck.c                   | 4 ++--\n http-push.c              | 3 ++-\n list-objects.c           | 2 +-\n object.c                 | 4 ++--\n reachable.c              | 2 +-\n revision.c               | 4 ++--\n tag.c                    | 2 +-\n walker.c                 | 3 ++-\n 15 files changed, 23 insertions(+), 18 deletions(-)\n\ndiff --git a/blob.c b/blob.c\nindex dada295698c..17b9314f0a0 100644\n--- a/blob.c\n+++ b/blob.c\n@@ -5,7 +5,7 @@\n \n const char *blob_type = \"blob\";\n \n-struct blob *lookup_blob(const struct object_id *oid)\n+struct blob *lookup_blob_the_repository(const struct object_id *oid)\n {\n \tstruct object *obj = lookup_object(the_repository, oid->hash);\n \tif (!obj)\ndiff --git a/blob.h b/blob.h\nindex 44606168310..08bc34487a0 100644\n--- a/blob.h\n+++ b/blob.h\n@@ -9,7 +9,8 @@ struct blob {\n \tstruct object object;\n };\n \n-struct blob *lookup_blob(const struct object_id *oid);\n+#define lookup_blob(r, o) lookup_blob_##r(o)\n+struct blob *lookup_blob_the_repository(const struct object_id *oid);\n \n int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);\n \ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 03a2e4b79e6..7d6b1d8aea2 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -236,7 +236,7 @@ static void export_blob(const struct object_id *oid)\n \n \tif (anonymize) {\n \t\tbuf = anonymize_blob(&size);\n-\t\tobject = (struct object *)lookup_blob(oid);\n+\t\tobject = (struct object *)lookup_blob(the_repository, oid);\n \t\teaten = 0;\n \t} else {\n \t\tbuf = read_object_file(oid, &type, &size);\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex a906fe4a82b..263191942d4 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -810,7 +810,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)\n \t\t\tmode = active_cache[i]->ce_mode;\n \t\t\tif (S_ISGITLINK(mode))\n \t\t\t\tcontinue;\n-\t\t\tblob = lookup_blob(&active_cache[i]->oid);\n+\t\t\tblob = lookup_blob(the_repository,\n+\t\t\t\t\t   &active_cache[i]->oid);\n \t\t\tif (!blob)\n \t\t\t\tcontinue;\n \t\t\tobj = &blob->object;\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 9c08cf3cead..de311febe30 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -832,7 +832,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \tif (strict || do_fsck_object) {\n \t\tread_lock();\n \t\tif (type == OBJ_BLOB) {\n-\t\t\tstruct blob *blob = lookup_blob(oid);\n+\t\t\tstruct blob *blob = lookup_blob(the_repository, oid);\n \t\t\tif (blob)\n \t\t\t\tblob->object.flags |= FLAG_CHECKED;\n \t\t\telse\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 8a8d5797520..f8023bae1e2 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -2,6 +2,7 @@\n #include \"tree-walk.h\"\n #include \"xdiff-interface.h\"\n #include \"object-store.h\"\n+#include \"repository.h\"\n #include \"blob.h\"\n #include \"exec-cmd.h\"\n #include \"merge-blobs.h\"\n@@ -170,7 +171,7 @@ static struct merge_list *create_entry(unsigned stage, unsigned mode, const stru\n \tres->stage = stage;\n \tres->path = path;\n \tres->mode = mode;\n-\tres->blob = lookup_blob(oid);\n+\tres->blob = lookup_blob(the_repository, oid);\n \treturn res;\n }\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 75d1d5ea0b8..716408e3a9d 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -254,7 +254,7 @@ static void write_object(unsigned nr, enum object_type type,\n \t\tadded_object(nr, type, buf, size);\n \t\tfree(buf);\n \n-\t\tblob = lookup_blob(&obj_list[nr].oid);\n+\t\tblob = lookup_blob(the_repository, &obj_list[nr].oid);\n \t\tif (blob)\n \t\t\tblob->object.flags |= FLAG_WRITTEN;\n \t\telse\ndiff --git a/fsck.c b/fsck.c\nindex bb3d622fb93..ea00f7228df 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -414,7 +414,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op\n \t\t\tresult = options->walk(obj, OBJ_TREE, data, options);\n \t\t}\n \t\telse if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) {\n-\t\t\tobj = (struct object *)lookup_blob(entry.oid);\n+\t\t\tobj = (struct object *)lookup_blob(the_repository, entry.oid);\n \t\t\tif (name && obj)\n \t\t\t\tput_object_name(options, obj, \"%s%s\", name,\n \t\t\t\t\tentry.path);\n@@ -1070,7 +1070,7 @@ int fsck_finish(struct fsck_options *options)\n \t\tif (oidset_contains(&gitmodules_done, oid))\n \t\t\tcontinue;\n \n-\t\tblob = lookup_blob(oid);\n+\t\tblob = lookup_blob(the_repository, oid);\n \t\tif (!blob) {\n \t\t\tstruct object *obj = lookup_unknown_object(oid->hash);\n \t\t\tret |= report(options, obj,\ndiff --git a/http-push.c b/http-push.c\nindex d2245cc7380..191b51cb591 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1314,7 +1314,8 @@ static struct object_list **process_tree(struct tree *tree,\n \t\t\tp = process_tree(lookup_tree(entry.oid), p);\n \t\t\tbreak;\n \t\tcase OBJ_BLOB:\n-\t\t\tp = process_blob(lookup_blob(entry.oid), p);\n+\t\t\tp = process_blob(lookup_blob(the_repository, entry.oid),\n+\t\t\t\t\t p);\n \t\t\tbreak;\n \t\tdefault:\n \t\t\t/* Subproject commit - not in this repository */\ndiff --git a/list-objects.c b/list-objects.c\nindex 3e5e1992eb0..04c45f66e88 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -167,7 +167,7 @@ static void process_tree(struct rev_info *revs,\n \t\t\t\t\tcb_data);\n \t\telse\n \t\t\tprocess_blob(revs,\n-\t\t\t\t     lookup_blob(entry.oid),\n+\t\t\t\t     lookup_blob(the_repository, entry.oid),\n \t\t\t\t     show, base, entry.path,\n \t\t\t\t     cb_data, filter_fn, filter_data);\n \t}\ndiff --git a/object.c b/object.c\nindex 404919043d4..fde816ad952 100644\n--- a/object.c\n+++ b/object.c\n@@ -193,7 +193,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e\n \n \tobj = NULL;\n \tif (type == OBJ_BLOB) {\n-\t\tstruct blob *blob = lookup_blob(oid);\n+\t\tstruct blob *blob = lookup_blob(the_repository, oid);\n \t\tif (blob) {\n \t\t\tif (parse_blob_buffer(blob, buffer, size))\n \t\t\t\treturn NULL;\n@@ -266,7 +266,7 @@ struct object *parse_object_the_repository(const struct object_id *oid)\n \t\t\terror(\"sha1 mismatch %s\", oid_to_hex(oid));\n \t\t\treturn NULL;\n \t\t}\n-\t\tparse_blob_buffer(lookup_blob(oid), NULL, 0);\n+\t\tparse_blob_buffer(lookup_blob(the_repository, oid), NULL, 0);\n \t\treturn lookup_object(the_repository, oid->hash);\n \t}\n \ndiff --git a/reachable.c b/reachable.c\nindex 2ee55695595..cc25f012e5d 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -91,7 +91,7 @@ static void add_recent_object(const struct object_id *oid,\n \t\tobj = (struct object *)lookup_tree(oid);\n \t\tbreak;\n \tcase OBJ_BLOB:\n-\t\tobj = (struct object *)lookup_blob(oid);\n+\t\tobj = (struct object *)lookup_blob(the_repository, oid);\n \t\tbreak;\n \tdefault:\n \t\tdie(\"unknown object type for %s: %s\",\ndiff --git a/revision.c b/revision.c\nindex 8a2b2850cad..e3824127567 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -66,7 +66,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree)\n \t\t\tmark_tree_uninteresting(lookup_tree(entry.oid));\n \t\t\tbreak;\n \t\tcase OBJ_BLOB:\n-\t\t\tmark_blob_uninteresting(lookup_blob(entry.oid));\n+\t\t\tmark_blob_uninteresting(lookup_blob(the_repository, entry.oid));\n \t\t\tbreak;\n \t\tdefault:\n \t\t\t/* Subproject commit - not in this repository */\n@@ -1348,7 +1348,7 @@ static void do_add_index_objects_to_pending(struct rev_info *revs,\n \t\tif (S_ISGITLINK(ce->ce_mode))\n \t\t\tcontinue;\n \n-\t\tblob = lookup_blob(&ce->oid);\n+\t\tblob = lookup_blob(the_repository, &ce->oid);\n \t\tif (!blob)\n \t\t\tdie(\"unable to add index blob to traversal\");\n \t\tadd_pending_object_with_path(revs, &blob->object, \"\",\ndiff --git a/tag.c b/tag.c\nindex a14a4f23037..a31ae75e960 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -154,7 +154,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n \tbufptr = nl + 1;\n \n \tif (!strcmp(type, blob_type)) {\n-\t\titem->tagged = (struct object *)lookup_blob(&oid);\n+\t\titem->tagged = (struct object *)lookup_blob(the_repository, &oid);\n \t} else if (!strcmp(type, tree_type)) {\n \t\titem->tagged = (struct object *)lookup_tree(&oid);\n \t} else if (!strcmp(type, commit_type)) {\ndiff --git a/walker.c b/walker.c\nindex 63002b18875..5b56c72a738 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -54,7 +54,8 @@ static int process_tree(struct walker *walker, struct tree *tree)\n \t\t\t\tobj = &tree->object;\n \t\t}\n \t\telse {\n-\t\t\tstruct blob *blob = lookup_blob(entry.oid);\n+\t\t\tstruct blob *blob = lookup_blob(the_repository,\n+\t\t\t\t\t\t\tentry.oid);\n \t\t\tif (blob)\n \t\t\t\tobj = &blob->object;\n \t\t}\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351295","messageId":"20180629012222.167426-5-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 04/32] object: add repository argument to object_as_type","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:21:54Z","receivedAt":"2018-06-29T01:22:53Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n blob.c         | 2 +-\n builtin/fsck.c | 2 +-\n commit.c       | 4 ++--\n object.c       | 2 +-\n object.h       | 3 ++-\n refs.c         | 2 +-\n tag.c          | 2 +-\n tree.c         | 2 +-\n 8 files changed, 10 insertions(+), 9 deletions(-)\n\ndiff --git a/blob.c b/blob.c\nindex 75b737a761e..dada295698c 100644\n--- a/blob.c\n+++ b/blob.c\n@@ -11,7 +11,7 @@ struct blob *lookup_blob(const struct object_id *oid)\n \tif (!obj)\n \t\treturn create_object(the_repository, oid->hash,\n \t\t\t\t     alloc_blob_node(the_repository));\n-\treturn object_as_type(obj, OBJ_BLOB, 0);\n+\treturn object_as_type(the_repository, obj, OBJ_BLOB, 0);\n }\n \n int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size)\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 09cf5333444..a906fe4a82b 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -70,7 +70,7 @@ static const char *printable_type(struct object *obj)\n \t\tenum object_type type = oid_object_info(the_repository,\n \t\t\t\t\t\t\t&obj->oid, NULL);\n \t\tif (type > 0)\n-\t\t\tobject_as_type(obj, type, 0);\n+\t\t\tobject_as_type(the_repository, obj, type, 0);\n \t}\n \n \tret = type_name(obj->type);\ndiff --git a/commit.c b/commit.c\nindex b4dbfd889a3..0d55600e643 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -32,7 +32,7 @@ struct commit *lookup_commit_reference_gently(const struct object_id *oid,\n \n \tif (!obj)\n \t\treturn NULL;\n-\treturn object_as_type(obj, OBJ_COMMIT, quiet);\n+\treturn object_as_type(the_repository, obj, OBJ_COMMIT, quiet);\n }\n \n struct commit *lookup_commit_reference(const struct object_id *oid)\n@@ -58,7 +58,7 @@ struct commit *lookup_commit(const struct object_id *oid)\n \tif (!obj)\n \t\treturn create_object(the_repository, oid->hash,\n \t\t\t\t     alloc_commit_node(the_repository));\n-\treturn object_as_type(obj, OBJ_COMMIT, 0);\n+\treturn object_as_type(the_repository, obj, OBJ_COMMIT, 0);\n }\n \n struct commit *lookup_commit_reference_by_name(const char *name)\ndiff --git a/object.c b/object.c\nindex 49719694c14..404919043d4 100644\n--- a/object.c\n+++ b/object.c\n@@ -158,7 +158,7 @@ void *create_object(struct repository *r, const unsigned char *sha1, void *o)\n \treturn obj;\n }\n \n-void *object_as_type(struct object *obj, enum object_type type, int quiet)\n+void *object_as_type_the_repository(struct object *obj, enum object_type type, int quiet)\n {\n \tif (obj->type == type)\n \t\treturn obj;\ndiff --git a/object.h b/object.h\nindex 2ba23c07a72..3faa89578fc 100644\n--- a/object.h\n+++ b/object.h\n@@ -114,7 +114,8 @@ struct object *lookup_object_the_repository(const unsigned char *sha1);\n \n extern void *create_object(struct repository *r, const unsigned char *sha1, void *obj);\n \n-void *object_as_type(struct object *obj, enum object_type type, int quiet);\n+#define object_as_type(r, o, t, q) object_as_type_##r(o, t, q)\n+void *object_as_type_the_repository(struct object *obj, enum object_type type, int quiet);\n \n /*\n  * Returns the object, having parsed it to find out what it is.\ndiff --git a/refs.c b/refs.c\nindex 3b4508a97aa..fcfd3171e83 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -305,7 +305,7 @@ enum peel_status peel_object(const struct object_id *name, struct object_id *oid\n \n \tif (o->type == OBJ_NONE) {\n \t\tint type = oid_object_info(the_repository, name, NULL);\n-\t\tif (type < 0 || !object_as_type(o, type, 0))\n+\t\tif (type < 0 || !object_as_type(the_repository, o, type, 0))\n \t\t\treturn PEEL_INVALID;\n \t}\n \ndiff --git a/tag.c b/tag.c\nindex 1b95eb9f07f..a14a4f23037 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -98,7 +98,7 @@ struct tag *lookup_tag(const struct object_id *oid)\n \tif (!obj)\n \t\treturn create_object(the_repository, oid->hash,\n \t\t\t\t     alloc_tag_node(the_repository));\n-\treturn object_as_type(obj, OBJ_TAG, 0);\n+\treturn object_as_type(the_repository, obj, OBJ_TAG, 0);\n }\n \n static timestamp_t parse_tag_date(const char *buf, const char *tail)\ndiff --git a/tree.c b/tree.c\nindex 73e8a8a948d..f31afb81be0 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -201,7 +201,7 @@ struct tree *lookup_tree(const struct object_id *oid)\n \tif (!obj)\n \t\treturn create_object(the_repository, oid->hash,\n \t\t\t\t     alloc_tree_node(the_repository));\n-\treturn object_as_type(obj, OBJ_TREE, 0);\n+\treturn object_as_type(the_repository, obj, OBJ_TREE, 0);\n }\n \n int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351296","messageId":"20180629012222.167426-9-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 08/32] commit: add repository argument to lookup_commit_reference","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:21:58Z","receivedAt":"2018-06-29T01:22:58Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow callers of lookup_commit_reference\nto be more specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n bisect.c              |  2 +-\n blame.c               |  2 +-\n branch.c              |  2 +-\n builtin/branch.c      |  7 ++++---\n builtin/clone.c       |  3 ++-\n builtin/describe.c    |  2 +-\n builtin/diff-tree.c   |  2 +-\n builtin/log.c         |  7 ++++---\n builtin/merge-base.c  |  5 +++--\n builtin/notes.c       |  3 ++-\n builtin/pull.c        | 15 ++++++++++-----\n builtin/replace.c     |  4 ++--\n builtin/reset.c       |  4 ++--\n builtin/rev-parse.c   |  6 +++---\n builtin/show-branch.c |  2 +-\n builtin/tag.c         |  2 +-\n bundle.c              |  3 ++-\n commit.c              |  6 +++---\n commit.h              |  4 +++-\n merge-recursive.c     |  6 +++---\n notes-merge.c         |  5 +++--\n parse-options-cb.c    |  2 +-\n remote.c              |  4 ++--\n revision.c            |  4 ++--\n sequencer.c           |  6 +++---\n sha1-name.c           |  4 ++--\n submodule.c           |  4 ++--\n 27 files changed, 65 insertions(+), 51 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex 6de1abd407b..e1275ba79e8 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -724,7 +724,7 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)\n \n static struct commit *get_commit_reference(const struct object_id *oid)\n {\n-\tstruct commit *r = lookup_commit_reference(oid);\n+\tstruct commit *r = lookup_commit_reference(the_repository, oid);\n \tif (!r)\n \t\tdie(_(\"Not a valid commit name %s\"), oid_to_hex(oid));\n \treturn r;\ndiff --git a/blame.c b/blame.c\nindex 5b022cc2254..8a0655a5997 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -119,7 +119,7 @@ static struct commit_list **append_parent(struct commit_list **tail, const struc\n {\n \tstruct commit *parent;\n \n-\tparent = lookup_commit_reference(oid);\n+\tparent = lookup_commit_reference(the_repository, oid);\n \tif (!parent)\n \t\tdie(\"no such commit %s\", oid_to_hex(oid));\n \treturn &commit_list_insert(parent, tail)->next;\ndiff --git a/branch.c b/branch.c\nindex 6a35dd31f2a..ecd710d7308 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -302,7 +302,7 @@ void create_branch(const char *name, const char *start_name,\n \t\tbreak;\n \t}\n \n-\tif ((commit = lookup_commit_reference(&oid)) == NULL)\n+\tif ((commit = lookup_commit_reference(the_repository, &oid)) == NULL)\n \t\tdie(_(\"Not a valid branch point: '%s'.\"), start_name);\n \toidcpy(&oid, &commit->object.oid);\n \ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 1876ca9e796..a50632fb23f 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -121,7 +121,8 @@ static int branch_merged(int kind, const char *name,\n \t\t    (reference_name = reference_name_to_free =\n \t\t     resolve_refdup(upstream, RESOLVE_REF_READING,\n \t\t\t\t    &oid, NULL)) != NULL)\n-\t\t\treference_rev = lookup_commit_reference(&oid);\n+\t\t\treference_rev = lookup_commit_reference(the_repository,\n+\t\t\t\t\t\t\t\t&oid);\n \t}\n \tif (!reference_rev)\n \t\treference_rev = head_rev;\n@@ -154,7 +155,7 @@ static int check_branch_commit(const char *branchname, const char *refname,\n \t\t\t       const struct object_id *oid, struct commit *head_rev,\n \t\t\t       int kinds, int force)\n {\n-\tstruct commit *rev = lookup_commit_reference(oid);\n+\tstruct commit *rev = lookup_commit_reference(the_repository, oid);\n \tif (!rev) {\n \t\terror(_(\"Couldn't look up commit object for '%s'\"), refname);\n \t\treturn -1;\n@@ -208,7 +209,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,\n \t}\n \n \tif (!force) {\n-\t\thead_rev = lookup_commit_reference(&head_oid);\n+\t\thead_rev = lookup_commit_reference(the_repository, &head_oid);\n \t\tif (!head_rev)\n \t\t\tdie(_(\"Couldn't look up commit object for HEAD\"));\n \t}\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 1d939af9d8c..4b3b48ee84a 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -696,7 +696,8 @@ static void update_head(const struct ref *our, const struct ref *remote,\n \t\t\tinstall_branch_config(0, head, option_origin, our->name);\n \t\t}\n \t} else if (our) {\n-\t\tstruct commit *c = lookup_commit_reference(&our->old_oid);\n+\t\tstruct commit *c = lookup_commit_reference(the_repository,\n+\t\t\t\t\t\t\t   &our->old_oid);\n \t\t/* --branch specifies a non-branch (i.e. tags), detach HEAD */\n \t\tupdate_ref(msg, \"HEAD\", &c->object.oid, NULL, REF_NO_DEREF,\n \t\t\t   UPDATE_REFS_DIE_ON_ERR);\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 0b5d8562331..c8ff64766d0 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -303,7 +303,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)\n \tunsigned long seen_commits = 0;\n \tunsigned int unannotated_cnt = 0;\n \n-\tcmit = lookup_commit_reference(oid);\n+\tcmit = lookup_commit_reference(the_repository, oid);\n \n \tn = find_commit_name(&cmit->object.oid);\n \tif (n && (tags || all || n->prio == 2)) {\ndiff --git a/builtin/diff-tree.c b/builtin/diff-tree.c\nindex 29901515a13..a5718d96ee2 100644\n--- a/builtin/diff-tree.c\n+++ b/builtin/diff-tree.c\n@@ -11,7 +11,7 @@ static struct rev_info log_tree_opt;\n \n static int diff_tree_commit_oid(const struct object_id *oid)\n {\n-\tstruct commit *commit = lookup_commit_reference(oid);\n+\tstruct commit *commit = lookup_commit_reference(the_repository, oid);\n \tif (!commit)\n \t\treturn -1;\n \treturn log_tree_commit(&log_tree_opt, commit);\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 05217596a2b..55a6286d7f4 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -907,8 +907,8 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)\n \to2 = rev->pending.objects[1].item;\n \tflags1 = o1->flags;\n \tflags2 = o2->flags;\n-\tc1 = lookup_commit_reference(&o1->oid);\n-\tc2 = lookup_commit_reference(&o2->oid);\n+\tc1 = lookup_commit_reference(the_repository, &o1->oid);\n+\tc2 = lookup_commit_reference(the_repository, &o2->oid);\n \n \tif ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))\n \t\tdie(_(\"Not a range.\"));\n@@ -1864,7 +1864,8 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)\n {\n \tstruct object_id oid;\n \tif (get_oid(arg, &oid) == 0) {\n-\t\tstruct commit *commit = lookup_commit_reference(&oid);\n+\t\tstruct commit *commit = lookup_commit_reference(the_repository,\n+\t\t\t\t\t\t\t\t&oid);\n \t\tif (commit) {\n \t\t\tcommit->object.flags |= flags;\n \t\t\tadd_pending_object(revs, &commit->object, arg);\ndiff --git a/builtin/merge-base.c b/builtin/merge-base.c\nindex 3b7600150b6..bbead6f33e5 100644\n--- a/builtin/merge-base.c\n+++ b/builtin/merge-base.c\n@@ -6,6 +6,7 @@\n #include \"diff.h\"\n #include \"revision.h\"\n #include \"parse-options.h\"\n+#include \"repository.h\"\n \n static int show_merge_base(struct commit **rev, int rev_nr, int show_all)\n {\n@@ -42,7 +43,7 @@ static struct commit *get_commit_reference(const char *arg)\n \n \tif (get_oid(arg, &revkey))\n \t\tdie(\"Not a valid object name %s\", arg);\n-\tr = lookup_commit_reference(&revkey);\n+\tr = lookup_commit_reference(the_repository, &revkey);\n \tif (!r)\n \t\tdie(\"Not a valid commit name %s\", arg);\n \n@@ -171,7 +172,7 @@ static int handle_fork_point(int argc, const char **argv)\n \tif (get_oid(commitname, &oid))\n \t\tdie(\"Not a valid object name: '%s'\", commitname);\n \n-\tderived = lookup_commit_reference(&oid);\n+\tderived = lookup_commit_reference(the_repository, &oid);\n \tmemset(&revs, 0, sizeof(revs));\n \trevs.initial = 1;\n \tfor_each_reflog_ent(refname, collect_one_reflog_ent, &revs);\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex a0a18400409..c05cd004abc 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -12,6 +12,7 @@\n #include \"builtin.h\"\n #include \"notes.h\"\n #include \"object-store.h\"\n+#include \"repository.h\"\n #include \"blob.h\"\n #include \"pretty.h\"\n #include \"refs.h\"\n@@ -711,7 +712,7 @@ static int merge_commit(struct notes_merge_options *o)\n \n \tif (get_oid(\"NOTES_MERGE_PARTIAL\", &oid))\n \t\tdie(_(\"failed to read ref NOTES_MERGE_PARTIAL\"));\n-\telse if (!(partial = lookup_commit_reference(&oid)))\n+\telse if (!(partial = lookup_commit_reference(the_repository, &oid)))\n \t\tdie(_(\"could not find commit from NOTES_MERGE_PARTIAL.\"));\n \telse if (parse_commit(partial))\n \t\tdie(_(\"could not parse commit from NOTES_MERGE_PARTIAL.\"));\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 7197b22b165..4e789353922 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -765,10 +765,13 @@ static int get_octopus_merge_base(struct object_id *merge_base,\n {\n \tstruct commit_list *revs = NULL, *result;\n \n-\tcommit_list_insert(lookup_commit_reference(curr_head), &revs);\n-\tcommit_list_insert(lookup_commit_reference(merge_head), &revs);\n+\tcommit_list_insert(lookup_commit_reference(the_repository, curr_head),\n+\t\t\t   &revs);\n+\tcommit_list_insert(lookup_commit_reference(the_repository, merge_head),\n+\t\t\t   &revs);\n \tif (!is_null_oid(fork_point))\n-\t\tcommit_list_insert(lookup_commit_reference(fork_point), &revs);\n+\t\tcommit_list_insert(lookup_commit_reference(the_repository, fork_point),\n+\t\t\t\t   &revs);\n \n \tresult = get_octopus_merge_bases(revs);\n \tfree_commit_list(revs);\n@@ -944,9 +947,11 @@ int cmd_pull(int argc, const char **argv, const char *prefix)\n \t\t\tstruct commit_list *list = NULL;\n \t\t\tstruct commit *merge_head, *head;\n \n-\t\t\thead = lookup_commit_reference(&orig_head);\n+\t\t\thead = lookup_commit_reference(the_repository,\n+\t\t\t\t\t\t       &orig_head);\n \t\t\tcommit_list_insert(head, &list);\n-\t\t\tmerge_head = lookup_commit_reference(&merge_heads.oid[0]);\n+\t\t\tmerge_head = lookup_commit_reference(the_repository,\n+\t\t\t\t\t\t\t     &merge_heads.oid[0]);\n \t\t\tif (is_descendant_of(merge_head, list)) {\n \t\t\t\t/* we can fast-forward this without invoking rebase */\n \t\t\t\topt_ff = \"--ff-only\";\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex deabda21012..0232f98f020 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -371,7 +371,7 @@ static int replace_parents(struct strbuf *buf, int argc, const char **argv)\n \t\t\treturn error(_(\"Not a valid object name: '%s'\"),\n \t\t\t\t     argv[i]);\n \t\t}\n-\t\tif (!lookup_commit_reference(&oid)) {\n+\t\tif (!lookup_commit_reference(the_repository, &oid)) {\n \t\t\tstrbuf_release(&new_parents);\n \t\t\treturn error(_(\"could not parse %s\"), argv[i]);\n \t\t}\n@@ -443,7 +443,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle)\n \n \tif (get_oid(old_ref, &old_oid) < 0)\n \t\treturn error(_(\"Not a valid object name: '%s'\"), old_ref);\n-\tcommit = lookup_commit_reference(&old_oid);\n+\tcommit = lookup_commit_reference(the_repository, &old_oid);\n \tif (!commit)\n \t\treturn error(_(\"could not parse %s\"), old_ref);\n \ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex ffe41c924b4..d9871e5b6c6 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -319,7 +319,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \t\tstruct commit *commit;\n \t\tif (get_oid_committish(rev, &oid))\n \t\t\tdie(_(\"Failed to resolve '%s' as a valid revision.\"), rev);\n-\t\tcommit = lookup_commit_reference(&oid);\n+\t\tcommit = lookup_commit_reference(the_repository, &oid);\n \t\tif (!commit)\n \t\t\tdie(_(\"Could not parse object '%s'.\"), rev);\n \t\toidcpy(&oid, &commit->object.oid);\n@@ -396,7 +396,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \t\tupdate_ref_status = reset_refs(rev, &oid);\n \n \t\tif (reset_type == HARD && !update_ref_status && !quiet)\n-\t\t\tprint_new_head_line(lookup_commit_reference(&oid));\n+\t\t\tprint_new_head_line(lookup_commit_reference(the_repository, &oid));\n \t}\n \tif (!pathspec.nr)\n \t\tremove_branch_state();\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex 2a6cb298bda..0f09bbbf65a 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -280,8 +280,8 @@ static int try_difference(const char *arg)\n \t\tif (symmetric) {\n \t\t\tstruct commit_list *exclude;\n \t\t\tstruct commit *a, *b;\n-\t\t\ta = lookup_commit_reference(&start_oid);\n-\t\t\tb = lookup_commit_reference(&end_oid);\n+\t\t\ta = lookup_commit_reference(the_repository, &start_oid);\n+\t\t\tb = lookup_commit_reference(the_repository, &end_oid);\n \t\t\tif (!a || !b) {\n \t\t\t\t*dotdot = '.';\n \t\t\t\treturn 0;\n@@ -333,7 +333,7 @@ static int try_parent_shorthands(const char *arg)\n \n \t*dotdot = 0;\n \tif (get_oid_committish(arg, &oid) ||\n-\t    !(commit = lookup_commit_reference(&oid))) {\n+\t    !(commit = lookup_commit_reference(the_repository, &oid))) {\n \t\t*dotdot = '^';\n \t\treturn 0;\n \t}\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 2456b47d344..4b9d3c0059b 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -831,7 +831,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\t\t       MAX_REVS), MAX_REVS);\n \t\tif (get_oid(ref_name[num_rev], &revkey))\n \t\t\tdie(_(\"'%s' is not a valid ref.\"), ref_name[num_rev]);\n-\t\tcommit = lookup_commit_reference(&revkey);\n+\t\tcommit = lookup_commit_reference(the_repository, &revkey);\n \t\tif (!commit)\n \t\t\tdie(_(\"cannot find commit %s (%s)\"),\n \t\t\t    ref_name[num_rev], oid_to_hex(&revkey));\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 9919b03b2d6..9a19ffb49f6 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -313,7 +313,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t\t}\n \t\tfree(buf);\n \n-\t\tif ((c = lookup_commit_reference(oid)) != NULL)\n+\t\tif ((c = lookup_commit_reference(the_repository, oid)) != NULL)\n \t\t\tstrbuf_addf(sb, \", %s\", show_date(c->date, 0, DATE_MODE(SHORT)));\n \t\tbreak;\n \tcase OBJ_TREE:\ndiff --git a/bundle.c b/bundle.c\nindex 0a9f4ee76b2..24cbe409863 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -375,7 +375,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)\n \t\t\t * in terms of a tag (e.g. v2.0 from the range\n \t\t\t * \"v1.0..v2.0\")?\n \t\t\t */\n-\t\t\tstruct commit *one = lookup_commit_reference(&oid);\n+\t\t\tstruct commit *one = lookup_commit_reference(the_repository,\n+\t\t\t\t\t\t\t\t     &oid);\n \t\t\tstruct object *obj;\n \n \t\t\tif (e->item == &(one->object)) {\ndiff --git a/commit.c b/commit.c\nindex 756d557b3c9..5e50a079324 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -35,14 +35,14 @@ struct commit *lookup_commit_reference_gently_the_repository(\n \treturn object_as_type(the_repository, obj, OBJ_COMMIT, quiet);\n }\n \n-struct commit *lookup_commit_reference(const struct object_id *oid)\n+struct commit *lookup_commit_reference_the_repository(const struct object_id *oid)\n {\n \treturn lookup_commit_reference_gently(the_repository, oid, 0);\n }\n \n struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name)\n {\n-\tstruct commit *c = lookup_commit_reference(oid);\n+\tstruct commit *c = lookup_commit_reference(the_repository, oid);\n \tif (!c)\n \t\tdie(_(\"could not parse %s\"), ref_name);\n \tif (oidcmp(oid, &c->object.oid)) {\n@@ -68,7 +68,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)\n \n \tif (get_oid_committish(name, &oid))\n \t\treturn NULL;\n-\tcommit = lookup_commit_reference(&oid);\n+\tcommit = lookup_commit_reference(the_repository, &oid);\n \tif (parse_commit(commit))\n \t\treturn NULL;\n \treturn commit;\ndiff --git a/commit.h b/commit.h\nindex 000d194f8aa..2a411134457 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -64,7 +64,9 @@ void add_name_decoration(enum decoration_type type, const char *name, struct obj\n const struct name_decoration *get_name_decoration(const struct object *obj);\n \n struct commit *lookup_commit(const struct object_id *oid);\n-struct commit *lookup_commit_reference(const struct object_id *oid);\n+#define lookup_commit_reference(r, o) \\\n+\t\tlookup_commit_reference_##r(o)\n+struct commit *lookup_commit_reference_the_repository(const struct object_id *oid);\n #define lookup_commit_reference_gently(r, o, q) \\\n \t\tlookup_commit_reference_gently_##r(o, q)\n struct commit *lookup_commit_reference_gently_the_repository(\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 666a3bc22fb..fa1981be972 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -1192,9 +1192,9 @@ static int merge_submodule(struct merge_options *o,\n \t\treturn 0;\n \t}\n \n-\tif (!(commit_base = lookup_commit_reference(base)) ||\n-\t    !(commit_a = lookup_commit_reference(a)) ||\n-\t    !(commit_b = lookup_commit_reference(b))) {\n+\tif (!(commit_base = lookup_commit_reference(the_repository, base)) ||\n+\t    !(commit_a = lookup_commit_reference(the_repository, a)) ||\n+\t    !(commit_b = lookup_commit_reference(the_repository, b))) {\n \t\toutput(o, 1, _(\"Failed to merge submodule %s (commits not present)\"), path);\n \t\treturn 0;\n \t}\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 9cc2ee16a8c..76ab19e7024 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -2,6 +2,7 @@\n #include \"commit.h\"\n #include \"refs.h\"\n #include \"object-store.h\"\n+#include \"repository.h\"\n #include \"diff.h\"\n #include \"diffcore.h\"\n #include \"xdiff-interface.h\"\n@@ -553,7 +554,7 @@ int notes_merge(struct notes_merge_options *o,\n \telse if (!check_refname_format(o->local_ref, 0) &&\n \t\tis_null_oid(&local_oid))\n \t\tlocal = NULL; /* local_oid == null_oid indicates unborn ref */\n-\telse if (!(local = lookup_commit_reference(&local_oid)))\n+\telse if (!(local = lookup_commit_reference(the_repository, &local_oid)))\n \t\tdie(\"Could not parse local commit %s (%s)\",\n \t\t    oid_to_hex(&local_oid), o->local_ref);\n \ttrace_printf(\"\\tlocal commit: %.7s\\n\", oid_to_hex(&local_oid));\n@@ -571,7 +572,7 @@ int notes_merge(struct notes_merge_options *o,\n \t\t\tdie(\"Failed to resolve remote notes ref '%s'\",\n \t\t\t    o->remote_ref);\n \t\t}\n-\t} else if (!(remote = lookup_commit_reference(&remote_oid))) {\n+\t} else if (!(remote = lookup_commit_reference(the_repository, &remote_oid))) {\n \t\tdie(\"Could not parse remote commit %s (%s)\",\n \t\t    oid_to_hex(&remote_oid), o->remote_ref);\n \t}\ndiff --git a/parse-options-cb.c b/parse-options-cb.c\nindex 0f9f311a7a9..e8236534ac8 100644\n--- a/parse-options-cb.c\n+++ b/parse-options-cb.c\n@@ -91,7 +91,7 @@ int parse_opt_commits(const struct option *opt, const char *arg, int unset)\n \t\treturn -1;\n \tif (get_oid(arg, &oid))\n \t\treturn error(\"malformed object name %s\", arg);\n-\tcommit = lookup_commit_reference(&oid);\n+\tcommit = lookup_commit_reference(the_repository, &oid);\n \tif (!commit)\n \t\treturn error(\"no such commit %s\", arg);\n \tcommit_list_insert(commit, opt->value);\ndiff --git a/remote.c b/remote.c\nindex 0f1a84d67a3..8c75c45fe65 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1865,13 +1865,13 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,\n \t/* Cannot stat if what we used to build on no longer exists */\n \tif (read_ref(base, &oid))\n \t\treturn -1;\n-\ttheirs = lookup_commit_reference(&oid);\n+\ttheirs = lookup_commit_reference(the_repository, &oid);\n \tif (!theirs)\n \t\treturn -1;\n \n \tif (read_ref(branch->refname, &oid))\n \t\treturn -1;\n-\tours = lookup_commit_reference(&oid);\n+\tours = lookup_commit_reference(the_repository, &oid);\n \tif (!ours)\n \t\treturn -1;\n \ndiff --git a/revision.c b/revision.c\nindex 02e1296e36d..4dbe406bed2 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1591,8 +1591,8 @@ static int handle_dotdot_1(const char *arg, char *dotdot,\n \t\tstruct commit *a, *b;\n \t\tstruct commit_list *exclude;\n \n-\t\ta = lookup_commit_reference(&a_obj->oid);\n-\t\tb = lookup_commit_reference(&b_obj->oid);\n+\t\ta = lookup_commit_reference(the_repository, &a_obj->oid);\n+\t\tb = lookup_commit_reference(the_repository, &b_obj->oid);\n \t\tif (!a || !b)\n \t\t\treturn dotdot_missing(arg, dotdot, revs, symmetric);\n \ndiff --git a/sequencer.c b/sequencer.c\nindex b4170b748cc..cc7b19199e8 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1176,7 +1176,7 @@ static int parse_head(struct commit **head)\n \tif (get_oid(\"HEAD\", &oid)) {\n \t\tcurrent_head = NULL;\n \t} else {\n-\t\tcurrent_head = lookup_commit_reference(&oid);\n+\t\tcurrent_head = lookup_commit_reference(the_repository, &oid);\n \t\tif (!current_head)\n \t\t\treturn error(_(\"could not parse HEAD\"));\n \t\tif (oidcmp(&oid, &current_head->object.oid)) {\n@@ -1511,7 +1511,7 @@ static int update_squash_messages(enum todo_command command,\n \n \t\tif (get_oid(\"HEAD\", &head))\n \t\t\treturn error(_(\"need a HEAD to fixup\"));\n-\t\tif (!(head_commit = lookup_commit_reference(&head)))\n+\t\tif (!(head_commit = lookup_commit_reference(the_repository, &head)))\n \t\t\treturn error(_(\"could not read HEAD\"));\n \t\tif (!(head_message = get_commit_buffer(head_commit, NULL)))\n \t\t\treturn error(_(\"could not read HEAD's commit message\"));\n@@ -2009,7 +2009,7 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)\n \tif (status < 0)\n \t\treturn -1;\n \n-\titem->commit = lookup_commit_reference(&commit_oid);\n+\titem->commit = lookup_commit_reference(the_repository, &commit_oid);\n \treturn !item->commit;\n }\n \ndiff --git a/sha1-name.c b/sha1-name.c\nindex 473611879bf..325915fb276 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -844,7 +844,7 @@ static int get_parent(const char *name, int len,\n \n \tif (ret)\n \t\treturn ret;\n-\tcommit = lookup_commit_reference(&oid);\n+\tcommit = lookup_commit_reference(the_repository, &oid);\n \tif (parse_commit(commit))\n \t\treturn -1;\n \tif (!idx) {\n@@ -872,7 +872,7 @@ static int get_nth_ancestor(const char *name, int len,\n \tret = get_oid_1(name, len, &oid, GET_OID_COMMITTISH);\n \tif (ret)\n \t\treturn ret;\n-\tcommit = lookup_commit_reference(&oid);\n+\tcommit = lookup_commit_reference(the_repository, &oid);\n \tif (!commit)\n \t\treturn -1;\n \ndiff --git a/submodule.c b/submodule.c\nindex 0998ea23458..6688dd5d459 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -517,8 +517,8 @@ static void show_submodule_header(struct diff_options *o, const char *path,\n \t * Attempt to lookup the commit references, and determine if this is\n \t * a fast forward or fast backwards update.\n \t */\n-\t*left = lookup_commit_reference(one);\n-\t*right = lookup_commit_reference(two);\n+\t*left = lookup_commit_reference(the_repository, one);\n+\t*right = lookup_commit_reference(the_repository, two);\n \n \t/*\n \t * Warn about missing commits in the submodule project, but only if\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351297","messageId":"20180629012222.167426-11-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 10/32] commit: add repository argument to parse_commit_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:00Z","receivedAt":"2018-06-29T01:23:03Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of parse_commit_buffer\nto be more specific about which repository to act on. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c    | 4 ++--\n commit.h    | 3 ++-\n object.c    | 2 +-\n sha1-file.c | 2 +-\n 4 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 4803c8be1df..75d0bdede84 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -363,7 +363,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n \treturn ret;\n }\n \n-int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size, int check_graph)\n+int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size, int check_graph)\n {\n \tconst char *tail = buffer;\n \tconst char *bufptr = buffer;\n@@ -448,7 +448,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)\n \t\treturn error(\"Object %s not a commit\",\n \t\t\t     oid_to_hex(&item->object.oid));\n \t}\n-\tret = parse_commit_buffer(item, buffer, size, 0);\n+\tret = parse_commit_buffer(the_repository, item, buffer, size, 0);\n \tif (save_commit_buffer && !ret) {\n \t\tset_commit_buffer(item, buffer, size);\n \t\treturn 0;\ndiff --git a/commit.h b/commit.h\nindex cd80dab59c1..f326c13622b 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -82,7 +82,8 @@ struct commit *lookup_commit_reference_by_name(const char *name);\n  */\n struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);\n \n-int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size, int check_graph);\n+#define parse_commit_buffer(r, i, b, s, g) parse_commit_buffer_##r(i, b, s, g)\n+int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size, int check_graph);\n int parse_commit_gently(struct commit *item, int quiet_on_missing);\n static inline int parse_commit(struct commit *item)\n {\ndiff --git a/object.c b/object.c\nindex 530c55e41e4..5494c0cbaa1 100644\n--- a/object.c\n+++ b/object.c\n@@ -214,7 +214,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e\n \t} else if (type == OBJ_COMMIT) {\n \t\tstruct commit *commit = lookup_commit(the_repository, oid);\n \t\tif (commit) {\n-\t\t\tif (parse_commit_buffer(commit, buffer, size, 1))\n+\t\t\tif (parse_commit_buffer(the_repository, commit, buffer, size, 1))\n \t\t\t\treturn NULL;\n \t\t\tif (!get_cached_commit_buffer(commit, NULL)) {\n \t\t\t\tset_commit_buffer(commit, buffer, size);\ndiff --git a/sha1-file.c b/sha1-file.c\nindex de4839e634c..75ba30b4ab1 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -1801,7 +1801,7 @@ static void check_commit(const void *buf, size_t size)\n {\n \tstruct commit c;\n \tmemset(&c, 0, sizeof(c));\n-\tif (parse_commit_buffer(&c, buf, size, 0))\n+\tif (parse_commit_buffer(the_repository, &c, buf, size, 0))\n \t\tdie(\"corrupt commit\");\n }\n \n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351298","messageId":"20180629012222.167426-7-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 06/32] tree: add repository argument to lookup_tree","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:21:56Z","receivedAt":"2018-06-29T01:23:05Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of lookup_tree\nto be more specific about which repository to act on. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/am.c        | 6 ++++--\n builtin/diff-tree.c | 2 +-\n builtin/diff.c      | 3 ++-\n builtin/reflog.c    | 2 +-\n cache-tree.c        | 3 ++-\n commit-graph.c      | 2 +-\n commit.c            | 2 +-\n fsck.c              | 2 +-\n http-push.c         | 3 ++-\n list-objects.c      | 2 +-\n merge-recursive.c   | 6 +++---\n object.c            | 2 +-\n reachable.c         | 2 +-\n revision.c          | 4 ++--\n sequencer.c         | 2 +-\n tag.c               | 2 +-\n tree.c              | 4 ++--\n tree.h              | 3 ++-\n walker.c            | 3 ++-\n 19 files changed, 31 insertions(+), 24 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 6273ea5195b..72e928cee79 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -32,6 +32,7 @@\n #include \"apply.h\"\n #include \"string-list.h\"\n #include \"packfile.h\"\n+#include \"repository.h\"\n \n /**\n  * Returns 1 if the file is empty or does not exist, 0 otherwise.\n@@ -1400,9 +1401,10 @@ static void write_index_patch(const struct am_state *state)\n \tFILE *fp;\n \n \tif (!get_oid_tree(\"HEAD\", &head))\n-\t\ttree = lookup_tree(&head);\n+\t\ttree = lookup_tree(the_repository, &head);\n \telse\n-\t\ttree = lookup_tree(the_hash_algo->empty_tree);\n+\t\ttree = lookup_tree(the_repository,\n+\t\t\t\t   the_repository->hash_algo->empty_tree);\n \n \tfp = xfopen(am_path(state, \"patch\"), \"w\");\n \tinit_revisions(&rev_info, NULL);\ndiff --git a/builtin/diff-tree.c b/builtin/diff-tree.c\nindex d8db8f682f0..29901515a13 100644\n--- a/builtin/diff-tree.c\n+++ b/builtin/diff-tree.c\n@@ -46,7 +46,7 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)\n \tstruct tree *tree2;\n \tif (!isspace(*p++) || parse_oid_hex(p, &oid, &p) || *p)\n \t\treturn error(\"Need exactly two trees, separated by a space\");\n-\ttree2 = lookup_tree(&oid);\n+\ttree2 = lookup_tree(the_repository, &oid);\n \tif (!tree2 || parse_tree(tree2))\n \t\treturn -1;\n \tprintf(\"%s %s\\n\", oid_to_hex(&tree1->object.oid),\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex d0421c90e29..7971530b9b3 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -386,7 +386,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\t\t\tadd_head_to_pending(&rev);\n \t\t\t\tif (!rev.pending.nr) {\n \t\t\t\t\tstruct tree *tree;\n-\t\t\t\t\ttree = lookup_tree(the_hash_algo->empty_tree);\n+\t\t\t\t\ttree = lookup_tree(the_repository,\n+\t\t\t\t\t\t\t   the_repository->hash_algo->empty_tree);\n \t\t\t\t\tadd_pending_object(&rev, &tree->object, \"HEAD\");\n \t\t\t\t}\n \t\t\t\tbreak;\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 948002b81ea..5e12c856049 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -66,7 +66,7 @@ static int tree_is_complete(const struct object_id *oid)\n \tint complete;\n \tstruct tree *tree;\n \n-\ttree = lookup_tree(oid);\n+\ttree = lookup_tree(the_repository, oid);\n \tif (!tree)\n \t\treturn 0;\n \tif (tree->object.flags & SEEN)\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 6b467119960..181d5919f0f 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -671,7 +671,8 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)\n \t\t\tcnt++;\n \t\telse {\n \t\t\tstruct cache_tree_sub *sub;\n-\t\t\tstruct tree *subtree = lookup_tree(entry.oid);\n+\t\t\tstruct tree *subtree = lookup_tree(the_repository,\n+\t\t\t\t\t\t\t   entry.oid);\n \t\t\tif (!subtree->object.parsed)\n \t\t\t\tparse_tree(subtree);\n \t\t\tsub = cache_tree_sub(it, entry.path);\ndiff --git a/commit-graph.c b/commit-graph.c\nindex b63a1fc85ea..d1a68f0128f 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -344,7 +344,7 @@ static struct tree *load_tree_for_commit(struct commit_graph *g, struct commit *\n \t\t\t\t\t   GRAPH_DATA_WIDTH * (c->graph_pos);\n \n \thashcpy(oid.hash, commit_data);\n-\tc->maybe_tree = lookup_tree(&oid);\n+\tc->maybe_tree = lookup_tree(the_repository, &oid);\n \n \treturn c->maybe_tree;\n }\ndiff --git a/commit.c b/commit.c\nindex 0d55600e643..2fa4220ac86 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -383,7 +383,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s\n \tif (get_oid_hex(bufptr + 5, &parent) < 0)\n \t\treturn error(\"bad tree pointer in commit %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\n-\titem->maybe_tree = lookup_tree(&parent);\n+\titem->maybe_tree = lookup_tree(the_repository, &parent);\n \tbufptr += tree_entry_len + 1; /* \"tree \" + \"hex sha1\" + \"\\n\" */\n \tpptr = &item->parents;\n \ndiff --git a/fsck.c b/fsck.c\nindex ea00f7228df..93459798bcb 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -407,7 +407,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op\n \t\t\tcontinue;\n \n \t\tif (S_ISDIR(entry.mode)) {\n-\t\t\tobj = (struct object *)lookup_tree(entry.oid);\n+\t\t\tobj = (struct object *)lookup_tree(the_repository, entry.oid);\n \t\t\tif (name && obj)\n \t\t\t\tput_object_name(options, obj, \"%s%s/\", name,\n \t\t\t\t\tentry.path);\ndiff --git a/http-push.c b/http-push.c\nindex 191b51cb591..f7b70c4efb1 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1311,7 +1311,8 @@ static struct object_list **process_tree(struct tree *tree,\n \twhile (tree_entry(&desc, &entry))\n \t\tswitch (object_type(entry.mode)) {\n \t\tcase OBJ_TREE:\n-\t\t\tp = process_tree(lookup_tree(entry.oid), p);\n+\t\t\tp = process_tree(lookup_tree(the_repository, entry.oid),\n+\t\t\t\t\t p);\n \t\t\tbreak;\n \t\tcase OBJ_BLOB:\n \t\t\tp = process_blob(lookup_blob(the_repository, entry.oid),\ndiff --git a/list-objects.c b/list-objects.c\nindex 04c45f66e88..782c0e189f9 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -158,7 +158,7 @@ static void process_tree(struct rev_info *revs,\n \n \t\tif (S_ISDIR(entry.mode))\n \t\t\tprocess_tree(revs,\n-\t\t\t\t     lookup_tree(entry.oid),\n+\t\t\t\t     lookup_tree(the_repository, entry.oid),\n \t\t\t\t     show, base, entry.path,\n \t\t\t\t     cb_data, filter_fn, filter_data);\n \t\telse if (S_ISGITLINK(entry.mode))\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 85694398215..666a3bc22fb 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -158,7 +158,7 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two,\n \t}\n \tif (!oidcmp(&two->object.oid, &shifted))\n \t\treturn two;\n-\treturn lookup_tree(&shifted);\n+\treturn lookup_tree(the_repository, &shifted);\n }\n \n static struct commit *make_virtual_commit(struct tree *tree, const char *comment)\n@@ -416,7 +416,7 @@ struct tree *write_tree_from_memory(struct merge_options *o)\n \t\treturn NULL;\n \t}\n \n-\tresult = lookup_tree(&active_cache_tree->oid);\n+\tresult = lookup_tree(the_repository, &active_cache_tree->oid);\n \n \treturn result;\n }\n@@ -3427,7 +3427,7 @@ int merge_recursive(struct merge_options *o,\n \t\t/* if there is no common ancestor, use an empty tree */\n \t\tstruct tree *tree;\n \n-\t\ttree = lookup_tree(the_hash_algo->empty_tree);\n+\t\ttree = lookup_tree(the_repository, the_repository->hash_algo->empty_tree);\n \t\tmerged_common_ancestors = make_virtual_commit(tree, \"ancestor\");\n \t}\n \ndiff --git a/object.c b/object.c\nindex fde816ad952..2acd3a03e39 100644\n--- a/object.c\n+++ b/object.c\n@@ -200,7 +200,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e\n \t\t\tobj = &blob->object;\n \t\t}\n \t} else if (type == OBJ_TREE) {\n-\t\tstruct tree *tree = lookup_tree(oid);\n+\t\tstruct tree *tree = lookup_tree(the_repository, oid);\n \t\tif (tree) {\n \t\t\tobj = &tree->object;\n \t\t\tif (!tree->buffer)\ndiff --git a/reachable.c b/reachable.c\nindex cc25f012e5d..6e9b810d2a5 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -88,7 +88,7 @@ static void add_recent_object(const struct object_id *oid,\n \t\tobj = parse_object_or_die(oid, NULL);\n \t\tbreak;\n \tcase OBJ_TREE:\n-\t\tobj = (struct object *)lookup_tree(oid);\n+\t\tobj = (struct object *)lookup_tree(the_repository, oid);\n \t\tbreak;\n \tcase OBJ_BLOB:\n \t\tobj = (struct object *)lookup_blob(the_repository, oid);\ndiff --git a/revision.c b/revision.c\nindex e3824127567..02e1296e36d 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -63,7 +63,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree)\n \twhile (tree_entry(&desc, &entry)) {\n \t\tswitch (object_type(entry.mode)) {\n \t\tcase OBJ_TREE:\n-\t\t\tmark_tree_uninteresting(lookup_tree(entry.oid));\n+\t\t\tmark_tree_uninteresting(lookup_tree(the_repository, entry.oid));\n \t\t\tbreak;\n \t\tcase OBJ_BLOB:\n \t\t\tmark_blob_uninteresting(lookup_blob(the_repository, entry.oid));\n@@ -1322,7 +1322,7 @@ static void add_cache_tree(struct cache_tree *it, struct rev_info *revs,\n \tint i;\n \n \tif (it->entry_count >= 0) {\n-\t\tstruct tree *tree = lookup_tree(&it->oid);\n+\t\tstruct tree *tree = lookup_tree(the_repository, &it->oid);\n \t\tadd_pending_object_with_path(revs, &tree->object, \"\",\n \t\t\t\t\t     040000, path->buf);\n \t}\ndiff --git a/sequencer.c b/sequencer.c\nindex 0a291c91fe8..4cf7afbab6d 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -433,7 +433,7 @@ static int read_oneliner(struct strbuf *buf,\n \n static struct tree *empty_tree(void)\n {\n-\treturn lookup_tree(the_hash_algo->empty_tree);\n+\treturn lookup_tree(the_repository, the_repository->hash_algo->empty_tree);\n }\n \n static int error_dirty_index(struct replay_opts *opts)\ndiff --git a/tag.c b/tag.c\nindex a31ae75e960..310102150ab 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -156,7 +156,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n \tif (!strcmp(type, blob_type)) {\n \t\titem->tagged = (struct object *)lookup_blob(the_repository, &oid);\n \t} else if (!strcmp(type, tree_type)) {\n-\t\titem->tagged = (struct object *)lookup_tree(&oid);\n+\t\titem->tagged = (struct object *)lookup_tree(the_repository, &oid);\n \t} else if (!strcmp(type, commit_type)) {\n \t\titem->tagged = (struct object *)lookup_commit(&oid);\n \t} else if (!strcmp(type, tag_type)) {\ndiff --git a/tree.c b/tree.c\nindex f31afb81be0..12b69606ab0 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -120,7 +120,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,\n \t\tlen = tree_entry_len(&entry);\n \t\tstrbuf_add(base, entry.path, len);\n \t\tstrbuf_addch(base, '/');\n-\t\tretval = read_tree_1(lookup_tree(&oid),\n+\t\tretval = read_tree_1(lookup_tree(the_repository, &oid),\n \t\t\t\t     base, stage, pathspec,\n \t\t\t\t     fn, context);\n \t\tstrbuf_setlen(base, oldlen);\n@@ -195,7 +195,7 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match,\n \treturn 0;\n }\n \n-struct tree *lookup_tree(const struct object_id *oid)\n+struct tree *lookup_tree_the_repository(const struct object_id *oid)\n {\n \tstruct object *obj = lookup_object(the_repository, oid->hash);\n \tif (!obj)\ndiff --git a/tree.h b/tree.h\nindex e2a80be4ef8..2ea21ed174b 100644\n--- a/tree.h\n+++ b/tree.h\n@@ -12,7 +12,8 @@ struct tree {\n \tunsigned long size;\n };\n \n-struct tree *lookup_tree(const struct object_id *oid);\n+#define lookup_tree(r, oid) lookup_tree_##r(oid)\n+struct tree *lookup_tree_the_repository(const struct object_id *oid);\n \n int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);\n \ndiff --git a/walker.c b/walker.c\nindex 5b56c72a738..a3a25667611 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -49,7 +49,8 @@ static int process_tree(struct walker *walker, struct tree *tree)\n \t\tif (S_ISGITLINK(entry.mode))\n \t\t\tcontinue;\n \t\tif (S_ISDIR(entry.mode)) {\n-\t\t\tstruct tree *tree = lookup_tree(entry.oid);\n+\t\t\tstruct tree *tree = lookup_tree(the_repository,\n+\t\t\t\t\t\t\tentry.oid);\n \t\t\tif (tree)\n \t\t\t\tobj = &tree->object;\n \t\t}\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351299","messageId":"20180629012222.167426-12-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 11/32] commit: add repository argument to set_commit_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:01Z","receivedAt":"2018-06-29T01:23:07Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow callers of set_commit_buffer to\nbe more specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n blame.c  | 2 +-\n commit.c | 4 ++--\n commit.h | 3 ++-\n object.c | 2 +-\n 4 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex 8a0655a5997..cf102276bea 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -158,7 +158,7 @@ static void set_commit_buffer_from_strbuf(struct commit *c, struct strbuf *sb)\n {\n \tsize_t len;\n \tvoid *buf = strbuf_detach(sb, &len);\n-\tset_commit_buffer(c, buf, len);\n+\tset_commit_buffer(the_repository, c, buf, len);\n }\n \n /*\ndiff --git a/commit.c b/commit.c\nindex 75d0bdede84..cdfb1a025b6 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -262,7 +262,7 @@ struct commit_buffer {\n define_commit_slab(buffer_slab, struct commit_buffer);\n static struct buffer_slab buffer_slab = COMMIT_SLAB_INIT(1, buffer_slab);\n \n-void set_commit_buffer(struct commit *commit, void *buffer, unsigned long size)\n+void set_commit_buffer_the_repository(struct commit *commit, void *buffer, unsigned long size)\n {\n \tstruct commit_buffer *v = buffer_slab_at(&buffer_slab, commit);\n \tv->buffer = buffer;\n@@ -450,7 +450,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)\n \t}\n \tret = parse_commit_buffer(the_repository, item, buffer, size, 0);\n \tif (save_commit_buffer && !ret) {\n-\t\tset_commit_buffer(item, buffer, size);\n+\t\tset_commit_buffer(the_repository, item, buffer, size);\n \t\treturn 0;\n \t}\n \tfree(buffer);\ndiff --git a/commit.h b/commit.h\nindex f326c13622b..7c14dfdc54b 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -95,7 +95,8 @@ void parse_commit_or_die(struct commit *item);\n  * Associate an object buffer with the commit. The ownership of the\n  * memory is handed over to the commit, and must be free()-able.\n  */\n-void set_commit_buffer(struct commit *, void *buffer, unsigned long size);\n+#define set_commit_buffer(r, c, b, s) set_commit_buffer_##r(c, b, s)\n+void set_commit_buffer_the_repository(struct commit *, void *buffer, unsigned long size);\n \n /*\n  * Get any cached object buffer associated with the commit. Returns NULL\ndiff --git a/object.c b/object.c\nindex 5494c0cbaa1..d1f77565af6 100644\n--- a/object.c\n+++ b/object.c\n@@ -217,7 +217,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e\n \t\t\tif (parse_commit_buffer(the_repository, commit, buffer, size, 1))\n \t\t\t\treturn NULL;\n \t\t\tif (!get_cached_commit_buffer(commit, NULL)) {\n-\t\t\t\tset_commit_buffer(commit, buffer, size);\n+\t\t\t\tset_commit_buffer(the_repository, commit, buffer, size);\n \t\t\t\t*eaten_p = 1;\n \t\t\t}\n \t\t\tobj = &commit->object;\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351300","messageId":"20180629012222.167426-13-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 12/32] commit: add repository argument to get_cached_commit_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:02Z","receivedAt":"2018-06-29T01:23:09Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow callers of get_cached_commit_buffer to\nbe more specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 4 ++--\n commit.h | 3 ++-\n object.c | 2 +-\n pretty.c | 2 +-\n 4 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex cdfb1a025b6..9e2899bd5ad 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -269,7 +269,7 @@ void set_commit_buffer_the_repository(struct commit *commit, void *buffer, unsig\n \tv->size = size;\n }\n \n-const void *get_cached_commit_buffer(const struct commit *commit, unsigned long *sizep)\n+const void *get_cached_commit_buffer_the_repository(const struct commit *commit, unsigned long *sizep)\n {\n \tstruct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit);\n \tif (!v) {\n@@ -284,7 +284,7 @@ const void *get_cached_commit_buffer(const struct commit *commit, unsigned long\n \n const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)\n {\n-\tconst void *ret = get_cached_commit_buffer(commit, sizep);\n+\tconst void *ret = get_cached_commit_buffer(the_repository, commit, sizep);\n \tif (!ret) {\n \t\tenum object_type type;\n \t\tunsigned long size;\ndiff --git a/commit.h b/commit.h\nindex 7c14dfdc54b..237607d64cb 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -102,7 +102,8 @@ void set_commit_buffer_the_repository(struct commit *, void *buffer, unsigned lo\n  * Get any cached object buffer associated with the commit. Returns NULL\n  * if none. The resulting memory should not be freed.\n  */\n-const void *get_cached_commit_buffer(const struct commit *, unsigned long *size);\n+#define get_cached_commit_buffer(r, c, s) get_cached_commit_buffer_##r(c, s)\n+const void *get_cached_commit_buffer_the_repository(const struct commit *, unsigned long *size);\n \n /*\n  * Get the commit's object contents, either from cache or by reading the object\ndiff --git a/object.c b/object.c\nindex d1f77565af6..f08a8874de3 100644\n--- a/object.c\n+++ b/object.c\n@@ -216,7 +216,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e\n \t\tif (commit) {\n \t\t\tif (parse_commit_buffer(the_repository, commit, buffer, size, 1))\n \t\t\t\treturn NULL;\n-\t\t\tif (!get_cached_commit_buffer(commit, NULL)) {\n+\t\t\tif (!get_cached_commit_buffer(the_repository, commit, NULL)) {\n \t\t\t\tset_commit_buffer(the_repository, commit, buffer, size);\n \t\t\t\t*eaten_p = 1;\n \t\t\t}\ndiff --git a/pretty.c b/pretty.c\nindex cbd25b6ceae..cde4fe07db0 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -630,7 +630,7 @@ const char *logmsg_reencode(const struct commit *commit,\n \t\t * the cached copy from get_commit_buffer, we need to duplicate it\n \t\t * to avoid munging the cached copy.\n \t\t */\n-\t\tif (msg == get_cached_commit_buffer(commit, NULL))\n+\t\tif (msg == get_cached_commit_buffer(the_repository, commit, NULL))\n \t\t\tout = xstrdup(msg);\n \t\telse\n \t\t\tout = (char *)msg;\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351301","messageId":"20180629012222.167426-15-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 14/32] tag: add repository argument to parse_tag_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:04Z","receivedAt":"2018-06-29T01:23:11Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of parse_tag_buffer\nto be more specific about which repository to act on. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/replace.c | 2 +-\n log-tree.c        | 2 +-\n object.c          | 2 +-\n sha1-file.c       | 2 +-\n tag.c             | 4 ++--\n tag.h             | 3 ++-\n 6 files changed, 8 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 0351b7c62cf..ef22d724bbc 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -405,7 +405,7 @@ static int check_one_mergetag(struct commit *commit,\n \ttag = lookup_tag(the_repository, &tag_oid);\n \tif (!tag)\n \t\treturn error(_(\"bad mergetag in commit '%s'\"), ref);\n-\tif (parse_tag_buffer(tag, extra->value, extra->len))\n+\tif (parse_tag_buffer(the_repository, tag, extra->value, extra->len))\n \t\treturn error(_(\"malformed mergetag in commit '%s'\"), ref);\n \n \t/* iterate over new parents */\ndiff --git a/log-tree.c b/log-tree.c\nindex 840423ca149..76475d0136b 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -503,7 +503,7 @@ static int show_one_mergetag(struct commit *commit,\n \t\treturn -1; /* error message already given */\n \n \tstrbuf_init(&verify_message, 256);\n-\tif (parse_tag_buffer(tag, extra->value, extra->len))\n+\tif (parse_tag_buffer(the_repository, tag, extra->value, extra->len))\n \t\tstrbuf_addstr(&verify_message, \"malformed mergetag\\n\");\n \telse if (is_common_merge(commit) &&\n \t\t !oidcmp(&tag->tagged->oid,\ndiff --git a/object.c b/object.c\nindex bcfcfd38760..e095d49b379 100644\n--- a/object.c\n+++ b/object.c\n@@ -225,7 +225,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e\n \t} else if (type == OBJ_TAG) {\n \t\tstruct tag *tag = lookup_tag(the_repository, oid);\n \t\tif (tag) {\n-\t\t\tif (parse_tag_buffer(tag, buffer, size))\n+\t\t\tif (parse_tag_buffer(the_repository, tag, buffer, size))\n \t\t\t       return NULL;\n \t\t\tobj = &tag->object;\n \t\t}\ndiff --git a/sha1-file.c b/sha1-file.c\nindex 75ba30b4ab1..c75ef771f8b 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -1809,7 +1809,7 @@ static void check_tag(const void *buf, size_t size)\n {\n \tstruct tag t;\n \tmemset(&t, 0, sizeof(t));\n-\tif (parse_tag_buffer(&t, buf, size))\n+\tif (parse_tag_buffer(the_repository, &t, buf, size))\n \t\tdie(\"corrupt tag\");\n }\n \ndiff --git a/tag.c b/tag.c\nindex 5b41fc71fad..4971fd4dfc9 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -126,7 +126,7 @@ void release_tag_memory(struct tag *t)\n \tt->date = 0;\n }\n \n-int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n+int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned long size)\n {\n \tstruct object_id oid;\n \tchar type[20];\n@@ -203,7 +203,7 @@ int parse_tag(struct tag *item)\n \t\treturn error(\"Object %s not a tag\",\n \t\t\t     oid_to_hex(&item->object.oid));\n \t}\n-\tret = parse_tag_buffer(item, data, size);\n+\tret = parse_tag_buffer(the_repository, item, data, size);\n \tfree(data);\n \treturn ret;\n }\ndiff --git a/tag.h b/tag.h\nindex 276c448cd55..149959c81ba 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -13,7 +13,8 @@ struct tag {\n };\n #define lookup_tag(r, o) lookup_tag_##r(o)\n extern struct tag *lookup_tag_the_repository(const struct object_id *oid);\n-extern int parse_tag_buffer(struct tag *item, const void *data, unsigned long size);\n+#define parse_tag_buffer(r, i, d, s) parse_tag_buffer_##r(i, d, s)\n+extern int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned long size);\n extern int parse_tag(struct tag *item);\n extern void release_tag_memory(struct tag *t);\n extern struct object *deref_tag(struct object *, const char *, int);\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351302","messageId":"20180629012222.167426-16-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 15/32] tag: add repository argument to deref_tag","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:05Z","receivedAt":"2018-06-29T01:23:14Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of deref_tag\nto be more specific about which repository to act on. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n blame.c                 |  6 +++---\n builtin/diff.c          |  2 +-\n builtin/fmt-merge-msg.c |  3 ++-\n builtin/grep.c          |  3 ++-\n builtin/name-rev.c      |  3 ++-\n commit.c                |  3 ++-\n fetch-pack.c            |  9 ++++++---\n http-backend.c          |  2 +-\n http-push.c             |  2 +-\n line-log.c              |  2 +-\n merge-recursive.c       |  3 ++-\n remote.c                |  6 ++++--\n server-info.c           |  2 +-\n sha1-name.c             | 11 +++++++----\n shallow.c               |  4 +++-\n tag.c                   |  2 +-\n tag.h                   |  3 ++-\n upload-pack.c           |  2 +-\n 18 files changed, 42 insertions(+), 26 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex cf102276bea..4229bcd384c 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -1674,7 +1674,7 @@ static struct commit *find_single_final(struct rev_info *revs,\n \t\tstruct object *obj = revs->pending.objects[i].item;\n \t\tif (obj->flags & UNINTERESTING)\n \t\t\tcontinue;\n-\t\tobj = deref_tag(obj, NULL, 0);\n+\t\tobj = deref_tag(the_repository, obj, NULL, 0);\n \t\tif (obj->type != OBJ_COMMIT)\n \t\t\tdie(\"Non commit %s?\", revs->pending.objects[i].name);\n \t\tif (found)\n@@ -1705,7 +1705,7 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,\n \n \t/* Is that sole rev a committish? */\n \tobj = revs->pending.objects[0].item;\n-\tobj = deref_tag(obj, NULL, 0);\n+\tobj = deref_tag(the_repository, obj, NULL, 0);\n \tif (obj->type != OBJ_COMMIT)\n \t\treturn NULL;\n \n@@ -1741,7 +1741,7 @@ static struct commit *find_single_initial(struct rev_info *revs,\n \t\tstruct object *obj = revs->pending.objects[i].item;\n \t\tif (!(obj->flags & UNINTERESTING))\n \t\t\tcontinue;\n-\t\tobj = deref_tag(obj, NULL, 0);\n+\t\tobj = deref_tag(the_repository, obj, NULL, 0);\n \t\tif (obj->type != OBJ_COMMIT)\n \t\t\tdie(\"Non commit %s?\", revs->pending.objects[i].name);\n \t\tif (found)\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex 7971530b9b3..361a3c3ed38 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -402,7 +402,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\tint flags = (obj->flags & UNINTERESTING);\n \t\tif (!obj->parsed)\n \t\t\tobj = parse_object(the_repository, &obj->oid);\n-\t\tobj = deref_tag(obj, NULL, 0);\n+\t\tobj = deref_tag(the_repository, obj, NULL, 0);\n \t\tif (!obj)\n \t\t\tdie(_(\"invalid object '%s' given.\"), name);\n \t\tif (obj->type == OBJ_COMMIT)\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 36318ef46e7..ff165c0fcd2 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -344,7 +344,8 @@ static void shortlog(const char *name,\n \tconst struct object_id *oid = &origin_data->oid;\n \tint limit = opts->shortlog_len;\n \n-\tbranch = deref_tag(parse_object(the_repository, oid), oid_to_hex(oid),\n+\tbranch = deref_tag(the_repository, parse_object(the_repository, oid),\n+\t\t\t   oid_to_hex(oid),\n \t\t\t   GIT_SHA1_HEXSZ);\n \tif (!branch || branch->type != OBJ_COMMIT)\n \t\treturn;\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex ee753a403eb..538a818e6dd 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -647,7 +647,8 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,\n \n \tfor (i = 0; i < nr; i++) {\n \t\tstruct object *real_obj;\n-\t\treal_obj = deref_tag(list->objects[i].item, NULL, 0);\n+\t\treal_obj = deref_tag(the_repository, list->objects[i].item,\n+\t\t\t\t     NULL, 0);\n \n \t\t/* load the gitmodules file for this rev */\n \t\tif (recurse_submodules) {\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex f6eb419a029..f1cb45c2274 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -455,7 +455,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\tcommit = NULL;\n \t\tobject = parse_object(the_repository, &oid);\n \t\tif (object) {\n-\t\t\tstruct object *peeled = deref_tag(object, *argv, 0);\n+\t\t\tstruct object *peeled = deref_tag(the_repository,\n+\t\t\t\t\t\t\t  object, *argv, 0);\n \t\t\tif (peeled && peeled->type == OBJ_COMMIT)\n \t\t\t\tcommit = (struct commit *)peeled;\n \t\t}\ndiff --git a/commit.c b/commit.c\nindex 9e2899bd5ad..aa5557dee84 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -27,7 +27,8 @@ const char *commit_type = \"commit\";\n struct commit *lookup_commit_reference_gently_the_repository(\n \t\tconst struct object_id *oid, int quiet)\n {\n-\tstruct object *obj = deref_tag(parse_object(the_repository, oid),\n+\tstruct object *obj = deref_tag(the_repository,\n+\t\t\t\t       parse_object(the_repository, oid),\n \t\t\t\t       NULL, 0);\n \n \tif (!obj)\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 9f3aa4a88fd..d60d83f174b 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -126,7 +126,8 @@ static void rev_list_push(struct commit *commit, int mark)\n \n static int rev_list_insert_ref(const char *refname, const struct object_id *oid)\n {\n-\tstruct object *o = deref_tag(parse_object(the_repository, oid),\n+\tstruct object *o = deref_tag(the_repository,\n+\t\t\t\t     parse_object(the_repository, oid),\n \t\t\t\t     refname, 0);\n \n \tif (o && o->type == OBJ_COMMIT)\n@@ -144,7 +145,8 @@ static int rev_list_insert_ref_oid(const char *refname, const struct object_id *\n static int clear_marks(const char *refname, const struct object_id *oid,\n \t\t       int flag, void *cb_data)\n {\n-\tstruct object *o = deref_tag(parse_object(the_repository, oid),\n+\tstruct object *o = deref_tag(the_repository,\n+\t\t\t\t     parse_object(the_repository, oid),\n \t\t\t\t     refname, 0);\n \n \tif (o && o->type == OBJ_COMMIT)\n@@ -802,7 +804,8 @@ static int everything_local(struct fetch_pack_args *args,\n \t\t * Don't mark them common yet; the server has to be told so first.\n \t\t */\n \t\tfor (ref = *refs; ref; ref = ref->next) {\n-\t\t\tstruct object *o = deref_tag(lookup_object(the_repository,\n+\t\t\tstruct object *o = deref_tag(the_repository,\n+\t\t\t\t\t\t     lookup_object(the_repository,\n \t\t\t\t\t\t     ref->old_oid.hash),\n \t\t\t\t\t\t     NULL, 0);\n \ndiff --git a/http-backend.c b/http-backend.c\nindex 50ba4d53d54..bd0442a805a 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -442,7 +442,7 @@ static int show_text_ref(const char *name, const struct object_id *oid,\n \n \tstrbuf_addf(buf, \"%s\\t%s\\n\", oid_to_hex(oid), name_nons);\n \tif (o->type == OBJ_TAG) {\n-\t\to = deref_tag(o, name, 0);\n+\t\to = deref_tag(the_repository, o, name, 0);\n \t\tif (!o)\n \t\t\treturn 0;\n \t\tstrbuf_addf(buf, \"%s\\t%s^{}\\n\", oid_to_hex(&o->oid),\ndiff --git a/http-push.c b/http-push.c\nindex f7b70c4efb1..5eaf551b51e 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1477,7 +1477,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)\n \t\t    oid_to_hex(&ref->old_oid), ls->dentry_name);\n \n \tif (o->type == OBJ_TAG) {\n-\t\to = deref_tag(o, ls->dentry_name, 0);\n+\t\to = deref_tag(the_repository, o, ls->dentry_name, 0);\n \t\tif (o)\n \t\t\tstrbuf_addf(buf, \"%s\\t%s^{}\\n\",\n \t\t\t\t    oid_to_hex(&o->oid), ls->dentry_name);\ndiff --git a/line-log.c b/line-log.c\nindex fa9cfd5bdbb..7fa0f16eba6 100644\n--- a/line-log.c\n+++ b/line-log.c\n@@ -479,7 +479,7 @@ static struct commit *check_single_commit(struct rev_info *revs)\n \t\tstruct object *obj = revs->pending.objects[i].item;\n \t\tif (obj->flags & UNINTERESTING)\n \t\t\tcontinue;\n-\t\tobj = deref_tag(obj, NULL, 0);\n+\t\tobj = deref_tag(the_repository, obj, NULL, 0);\n \t\tif (obj->type != OBJ_COMMIT)\n \t\t\tdie(\"Non commit %s?\", revs->pending.objects[i].name);\n \t\tif (commit)\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex fa1981be972..3d6b34b4f74 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -3489,7 +3489,8 @@ static struct commit *get_ref(const struct object_id *oid, const char *name)\n {\n \tstruct object *object;\n \n-\tobject = deref_tag(parse_object(the_repository, oid), name,\n+\tobject = deref_tag(the_repository, parse_object(the_repository, oid),\n+\t\t\t   name,\n \t\t\t   strlen(name));\n \tif (!object)\n \t\treturn NULL;\ndiff --git a/remote.c b/remote.c\nindex 8c75c45fe65..26b1fbd9a88 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1802,12 +1802,14 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)\n \t * Both new_commit and old_commit must be commit-ish and new_commit is descendant of\n \t * old_commit.  Otherwise we require --force.\n \t */\n-\to = deref_tag(parse_object(the_repository, old_oid), NULL, 0);\n+\to = deref_tag(the_repository, parse_object(the_repository, old_oid),\n+\t\t      NULL, 0);\n \tif (!o || o->type != OBJ_COMMIT)\n \t\treturn 0;\n \told_commit = (struct commit *) o;\n \n-\to = deref_tag(parse_object(the_repository, new_oid), NULL, 0);\n+\to = deref_tag(the_repository, parse_object(the_repository, new_oid),\n+\t\t      NULL, 0);\n \tif (!o || o->type != OBJ_COMMIT)\n \t\treturn 0;\n \tnew_commit = (struct commit *) o;\ndiff --git a/server-info.c b/server-info.c\nindex 2abd0dca088..41050c2449b 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -64,7 +64,7 @@ static int add_info_ref(const char *path, const struct object_id *oid,\n \t\treturn -1;\n \n \tif (o->type == OBJ_TAG) {\n-\t\to = deref_tag(o, path, 0);\n+\t\to = deref_tag(the_repository, o, path, 0);\n \t\tif (o)\n \t\t\tif (fprintf(fp, \"%s\t%s^{}\\n\",\n \t\t\t\toid_to_hex(&o->oid), path) < 0)\ndiff --git a/sha1-name.c b/sha1-name.c\nindex 5854bc75fe2..009faab4aef 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -239,7 +239,8 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da\n \t\treturn 0;\n \n \t/* We need to do this the hard way... */\n-\tobj = deref_tag(parse_object(the_repository, oid), NULL, 0);\n+\tobj = deref_tag(the_repository, parse_object(the_repository, oid),\n+\t\t\tNULL, 0);\n \tif (obj && obj->type == OBJ_COMMIT)\n \t\treturn 1;\n \treturn 0;\n@@ -263,7 +264,8 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_\n \t\treturn 0;\n \n \t/* We need to do this the hard way... */\n-\tobj = deref_tag(parse_object(the_repository, oid), NULL, 0);\n+\tobj = deref_tag(the_repository, parse_object(the_repository, oid),\n+\t\t\tNULL, 0);\n \tif (obj && (obj->type == OBJ_TREE || obj->type == OBJ_COMMIT))\n \t\treturn 1;\n \treturn 0;\n@@ -968,7 +970,7 @@ static int peel_onion(const char *name, int len, struct object_id *oid,\n \tif (!o)\n \t\treturn -1;\n \tif (!expected_type) {\n-\t\to = deref_tag(o, name, sp - name - 2);\n+\t\to = deref_tag(the_repository, o, name, sp - name - 2);\n \t\tif (!o || (!o->parsed && !parse_object(the_repository, &o->oid)))\n \t\t\treturn -1;\n \t\toidcpy(oid, &o->oid);\n@@ -1100,7 +1102,8 @@ static int handle_one_ref(const char *path, const struct object_id *oid,\n \tif (!object)\n \t\treturn 0;\n \tif (object->type == OBJ_TAG) {\n-\t\tobject = deref_tag(object, path, strlen(path));\n+\t\tobject = deref_tag(the_repository, object, path,\n+\t\t\t\t   strlen(path));\n \t\tif (!object)\n \t\t\treturn 0;\n \t}\ndiff --git a/shallow.c b/shallow.c\nindex e9ce55bba08..dbe8a2a2906 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -96,7 +96,9 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,\n \t\t\tif (i < heads->nr) {\n \t\t\t\tint **depth_slot;\n \t\t\t\tcommit = (struct commit *)\n-\t\t\t\t\tderef_tag(heads->objects[i++].item, NULL, 0);\n+\t\t\t\t\tderef_tag(the_repository,\n+\t\t\t\t\t\t  heads->objects[i++].item,\n+\t\t\t\t\t\t  NULL, 0);\n \t\t\t\tif (!commit || commit->object.type != OBJ_COMMIT) {\n \t\t\t\t\tcommit = NULL;\n \t\t\t\t\tcontinue;\ndiff --git a/tag.c b/tag.c\nindex 4971fd4dfc9..fbb4659325b 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -64,7 +64,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \treturn ret;\n }\n \n-struct object *deref_tag(struct object *o, const char *warn, int warnlen)\n+struct object *deref_tag_the_repository(struct object *o, const char *warn, int warnlen)\n {\n \twhile (o && o->type == OBJ_TAG)\n \t\tif (((struct tag *)o)->tagged)\ndiff --git a/tag.h b/tag.h\nindex 149959c81ba..45b0b08b1f6 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -17,7 +17,8 @@ extern struct tag *lookup_tag_the_repository(const struct object_id *oid);\n extern int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned long size);\n extern int parse_tag(struct tag *item);\n extern void release_tag_memory(struct tag *t);\n-extern struct object *deref_tag(struct object *, const char *, int);\n+#define deref_tag(r, o, w, l) deref_tag_##r(o, w, l)\n+extern struct object *deref_tag_the_repository(struct object *, const char *, int);\n extern struct object *deref_tag_noverify(struct object *);\n extern int gpg_verify_tag(const struct object_id *oid,\n \t\tconst char *name_to_report, unsigned flags);\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 45e3a94788f..4ca052d0b64 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -380,7 +380,7 @@ static int ok_to_give_up(void)\n \n \t\tif (want->flags & COMMON_KNOWN)\n \t\t\tcontinue;\n-\t\twant = deref_tag(want, \"a want line\", 0);\n+\t\twant = deref_tag(the_repository, want, \"a want line\", 0);\n \t\tif (!want || want->type != OBJ_COMMIT) {\n \t\t\t/* no way to tell if this is reachable by\n \t\t\t * looking at the ancestry chain alone, so\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351303","messageId":"20180629012222.167426-17-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 16/32] object: allow object_as_type to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:06Z","receivedAt":"2018-06-29T01:23:16Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n object.c | 4 ++--\n object.h | 3 +--\n 2 files changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/object.c b/object.c\nindex e095d49b379..f41f82c6725 100644\n--- a/object.c\n+++ b/object.c\n@@ -158,13 +158,13 @@ void *create_object(struct repository *r, const unsigned char *sha1, void *o)\n \treturn obj;\n }\n \n-void *object_as_type_the_repository(struct object *obj, enum object_type type, int quiet)\n+void *object_as_type(struct repository *r, struct object *obj, enum object_type type, int quiet)\n {\n \tif (obj->type == type)\n \t\treturn obj;\n \telse if (obj->type == OBJ_NONE) {\n \t\tif (type == OBJ_COMMIT)\n-\t\t\t((struct commit *)obj)->index = alloc_commit_index(the_repository);\n+\t\t\t((struct commit *)obj)->index = alloc_commit_index(r);\n \t\tobj->type = type;\n \t\treturn obj;\n \t}\ndiff --git a/object.h b/object.h\nindex 3faa89578fc..6f3271eb228 100644\n--- a/object.h\n+++ b/object.h\n@@ -114,8 +114,7 @@ struct object *lookup_object_the_repository(const unsigned char *sha1);\n \n extern void *create_object(struct repository *r, const unsigned char *sha1, void *obj);\n \n-#define object_as_type(r, o, t, q) object_as_type_##r(o, t, q)\n-void *object_as_type_the_repository(struct object *obj, enum object_type type, int quiet);\n+void *object_as_type(struct repository *r, struct object *obj, enum object_type type, int quiet);\n \n /*\n  * Returns the object, having parsed it to find out what it is.\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351304","messageId":"20180629012222.167426-18-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 17/32] object: allow lookup_object to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:07Z","receivedAt":"2018-06-29T01:23:19Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n object.c | 15 +++++++--------\n object.h |  3 +--\n 2 files changed, 8 insertions(+), 10 deletions(-)\n\ndiff --git a/object.c b/object.c\nindex f41f82c6725..9d74de95f5b 100644\n--- a/object.c\n+++ b/object.c\n@@ -84,21 +84,20 @@ static void insert_obj_hash(struct object *obj, struct object **hash, unsigned i\n  * Look up the record for the given sha1 in the hash map stored in\n  * obj_hash.  Return NULL if it was not found.\n  */\n-struct object *lookup_object_the_repository(const unsigned char *sha1)\n+struct object *lookup_object(struct repository *r, const unsigned char *sha1)\n {\n \tunsigned int i, first;\n \tstruct object *obj;\n \n-\tif (!the_repository->parsed_objects->obj_hash)\n+\tif (!r->parsed_objects->obj_hash)\n \t\treturn NULL;\n \n-\tfirst = i = hash_obj(sha1,\n-\t\t\t     the_repository->parsed_objects->obj_hash_size);\n-\twhile ((obj = the_repository->parsed_objects->obj_hash[i]) != NULL) {\n+\tfirst = i = hash_obj(sha1, r->parsed_objects->obj_hash_size);\n+\twhile ((obj = r->parsed_objects->obj_hash[i]) != NULL) {\n \t\tif (!hashcmp(sha1, obj->oid.hash))\n \t\t\tbreak;\n \t\ti++;\n-\t\tif (i == the_repository->parsed_objects->obj_hash_size)\n+\t\tif (i == r->parsed_objects->obj_hash_size)\n \t\t\ti = 0;\n \t}\n \tif (obj && i != first) {\n@@ -107,8 +106,8 @@ struct object *lookup_object_the_repository(const unsigned char *sha1)\n \t\t * that we do not need to walk the hash table the next\n \t\t * time we look for it.\n \t\t */\n-\t\tSWAP(the_repository->parsed_objects->obj_hash[i],\n-\t\t     the_repository->parsed_objects->obj_hash[first]);\n+\t\tSWAP(r->parsed_objects->obj_hash[i],\n+\t\t     r->parsed_objects->obj_hash[first]);\n \t}\n \treturn obj;\n }\ndiff --git a/object.h b/object.h\nindex 6f3271eb228..0d7d74129b6 100644\n--- a/object.h\n+++ b/object.h\n@@ -109,8 +109,7 @@ extern struct object *get_indexed_object(unsigned int);\n  * half-initialised objects, the caller is expected to initialize them\n  * by calling parse_object() on them.\n  */\n-#define lookup_object(r, s) lookup_object_##r(s)\n-struct object *lookup_object_the_repository(const unsigned char *sha1);\n+struct object *lookup_object(struct repository *r, const unsigned char *sha1);\n \n extern void *create_object(struct repository *r, const unsigned char *sha1, void *obj);\n \n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351305","messageId":"20180629012222.167426-19-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 18/32] blob: allow lookup_blob to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:08Z","receivedAt":"2018-06-29T01:23:23Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n blob.c | 10 +++++-----\n blob.h |  3 +--\n 2 files changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/blob.c b/blob.c\nindex 17b9314f0a0..342bdbb1bbe 100644\n--- a/blob.c\n+++ b/blob.c\n@@ -5,13 +5,13 @@\n \n const char *blob_type = \"blob\";\n \n-struct blob *lookup_blob_the_repository(const struct object_id *oid)\n+struct blob *lookup_blob(struct repository *r, const struct object_id *oid)\n {\n-\tstruct object *obj = lookup_object(the_repository, oid->hash);\n+\tstruct object *obj = lookup_object(r, oid->hash);\n \tif (!obj)\n-\t\treturn create_object(the_repository, oid->hash,\n-\t\t\t\t     alloc_blob_node(the_repository));\n-\treturn object_as_type(the_repository, obj, OBJ_BLOB, 0);\n+\t\treturn create_object(r, oid->hash,\n+\t\t\t\t     alloc_blob_node(r));\n+\treturn object_as_type(r, obj, OBJ_BLOB, 0);\n }\n \n int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size)\ndiff --git a/blob.h b/blob.h\nindex 08bc34487a0..16648720557 100644\n--- a/blob.h\n+++ b/blob.h\n@@ -9,8 +9,7 @@ struct blob {\n \tstruct object object;\n };\n \n-#define lookup_blob(r, o) lookup_blob_##r(o)\n-struct blob *lookup_blob_the_repository(const struct object_id *oid);\n+struct blob *lookup_blob(struct repository *r, const struct object_id *oid);\n \n int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);\n \n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351306","messageId":"20180629012222.167426-20-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 19/32] tree: allow lookup_tree to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:09Z","receivedAt":"2018-06-29T01:23:25Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n tree.c | 10 +++++-----\n tree.h |  3 +--\n 2 files changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/tree.c b/tree.c\nindex 45e89ff08eb..78d440a9c8f 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -195,13 +195,13 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match,\n \treturn 0;\n }\n \n-struct tree *lookup_tree_the_repository(const struct object_id *oid)\n+struct tree *lookup_tree(struct repository *r, const struct object_id *oid)\n {\n-\tstruct object *obj = lookup_object(the_repository, oid->hash);\n+\tstruct object *obj = lookup_object(r, oid->hash);\n \tif (!obj)\n-\t\treturn create_object(the_repository, oid->hash,\n-\t\t\t\t     alloc_tree_node(the_repository));\n-\treturn object_as_type(the_repository, obj, OBJ_TREE, 0);\n+\t\treturn create_object(r, oid->hash,\n+\t\t\t\t     alloc_tree_node(r));\n+\treturn object_as_type(r, obj, OBJ_TREE, 0);\n }\n \n int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)\ndiff --git a/tree.h b/tree.h\nindex 2ea21ed174b..d4807dc8058 100644\n--- a/tree.h\n+++ b/tree.h\n@@ -12,8 +12,7 @@ struct tree {\n \tunsigned long size;\n };\n \n-#define lookup_tree(r, oid) lookup_tree_##r(oid)\n-struct tree *lookup_tree_the_repository(const struct object_id *oid);\n+struct tree *lookup_tree(struct repository *r, const struct object_id *oid);\n \n int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);\n \n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351307","messageId":"20180629012222.167426-21-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 20/32] commit: allow lookup_commit to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:10Z","receivedAt":"2018-06-29T01:23:27Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 10 +++++-----\n commit.h |  3 +--\n 2 files changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex aa5557dee84..8749e151451 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -53,13 +53,13 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref\n \treturn c;\n }\n \n-struct commit *lookup_commit_the_repository(const struct object_id *oid)\n+struct commit *lookup_commit(struct repository *r, const struct object_id *oid)\n {\n-\tstruct object *obj = lookup_object(the_repository, oid->hash);\n+\tstruct object *obj = lookup_object(r, oid->hash);\n \tif (!obj)\n-\t\treturn create_object(the_repository, oid->hash,\n-\t\t\t\t     alloc_commit_node(the_repository));\n-\treturn object_as_type(the_repository, obj, OBJ_COMMIT, 0);\n+\t\treturn create_object(r, oid->hash,\n+\t\t\t\t     alloc_commit_node(r));\n+\treturn object_as_type(r, obj, OBJ_COMMIT, 0);\n }\n \n struct commit *lookup_commit_reference_by_name(const char *name)\ndiff --git a/commit.h b/commit.h\nindex 237607d64cb..27888d82468 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -63,8 +63,7 @@ enum decoration_type {\n void add_name_decoration(enum decoration_type type, const char *name, struct object *obj);\n const struct name_decoration *get_name_decoration(const struct object *obj);\n \n-#define lookup_commit(r, o) lookup_commit_##r(o)\n-struct commit *lookup_commit_the_repository(const struct object_id *oid);\n+struct commit *lookup_commit(struct repository *r, const struct object_id *oid);\n #define lookup_commit_reference(r, o) \\\n \t\tlookup_commit_reference_##r(o)\n struct commit *lookup_commit_reference_the_repository(const struct object_id *oid);\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351308","messageId":"20180629012222.167426-22-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 21/32] tag: allow lookup_tag to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:11Z","receivedAt":"2018-06-29T01:23:29Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n tag.c | 10 +++++-----\n tag.h |  3 +--\n 2 files changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/tag.c b/tag.c\nindex fbb4659325b..46b5882ee12 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -92,13 +92,13 @@ struct object *deref_tag_noverify(struct object *o)\n \treturn o;\n }\n \n-struct tag *lookup_tag_the_repository(const struct object_id *oid)\n+struct tag *lookup_tag(struct repository *r, const struct object_id *oid)\n {\n-\tstruct object *obj = lookup_object(the_repository, oid->hash);\n+\tstruct object *obj = lookup_object(r, oid->hash);\n \tif (!obj)\n-\t\treturn create_object(the_repository, oid->hash,\n-\t\t\t\t     alloc_tag_node(the_repository));\n-\treturn object_as_type(the_repository, obj, OBJ_TAG, 0);\n+\t\treturn create_object(r, oid->hash,\n+\t\t\t\t     alloc_tag_node(r));\n+\treturn object_as_type(r, obj, OBJ_TAG, 0);\n }\n \n static timestamp_t parse_tag_date(const char *buf, const char *tail)\ndiff --git a/tag.h b/tag.h\nindex 45b0b08b1f6..6a160c91875 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -11,8 +11,7 @@ struct tag {\n \tchar *tag;\n \ttimestamp_t date;\n };\n-#define lookup_tag(r, o) lookup_tag_##r(o)\n-extern struct tag *lookup_tag_the_repository(const struct object_id *oid);\n+extern struct tag *lookup_tag(struct repository *r, const struct object_id *oid);\n #define parse_tag_buffer(r, i, d, s) parse_tag_buffer_##r(i, d, s)\n extern int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned long size);\n extern int parse_tag(struct tag *item);\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351309","messageId":"20180629012222.167426-24-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 23/32] commit.c: allow parse_commit_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:13Z","receivedAt":"2018-06-29T01:23:31Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 10 +++++-----\n commit.h |  3 +--\n 2 files changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 8749e151451..41d23352098 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -364,7 +364,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n \treturn ret;\n }\n \n-int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size, int check_graph)\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph)\n {\n \tconst char *tail = buffer;\n \tconst char *bufptr = buffer;\n@@ -384,11 +384,11 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,\n \tif (get_oid_hex(bufptr + 5, &parent) < 0)\n \t\treturn error(\"bad tree pointer in commit %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\n-\titem->maybe_tree = lookup_tree(the_repository, &parent);\n+\titem->maybe_tree = lookup_tree(r, &parent);\n \tbufptr += tree_entry_len + 1; /* \"tree \" + \"hex sha1\" + \"\\n\" */\n \tpptr = &item->parents;\n \n-\tgraft = lookup_commit_graft(the_repository, &item->object.oid);\n+\tgraft = lookup_commit_graft(r, &item->object.oid);\n \twhile (bufptr + parent_entry_len < tail && !memcmp(bufptr, \"parent \", 7)) {\n \t\tstruct commit *new_parent;\n \n@@ -403,7 +403,7 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,\n \t\t */\n \t\tif (graft && (graft->nr_parent < 0 || grafts_replace_parents))\n \t\t\tcontinue;\n-\t\tnew_parent = lookup_commit(the_repository, &parent);\n+\t\tnew_parent = lookup_commit(r, &parent);\n \t\tif (new_parent)\n \t\t\tpptr = &commit_list_insert(new_parent, pptr)->next;\n \t}\n@@ -411,7 +411,7 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,\n \t\tint i;\n \t\tstruct commit *new_parent;\n \t\tfor (i = 0; i < graft->nr_parent; i++) {\n-\t\t\tnew_parent = lookup_commit(the_repository,\n+\t\t\tnew_parent = lookup_commit(r,\n \t\t\t\t\t\t   &graft->parent[i]);\n \t\t\tif (!new_parent)\n \t\t\t\tcontinue;\ndiff --git a/commit.h b/commit.h\nindex 27888d82468..e9cb5aaaae9 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -81,8 +81,7 @@ struct commit *lookup_commit_reference_by_name(const char *name);\n  */\n struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);\n \n-#define parse_commit_buffer(r, i, b, s, g) parse_commit_buffer_##r(i, b, s, g)\n-int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size, int check_graph);\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph);\n int parse_commit_gently(struct commit *item, int quiet_on_missing);\n static inline int parse_commit(struct commit *item)\n {\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351310","messageId":"20180629012222.167426-25-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 24/32] commit-slabs: remove realloc counter outside of slab struct","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:14Z","receivedAt":"2018-06-29T01:23:32Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"The realloc counter is declared outside the struct for the given slabname,\nwhich makes it harder for a follow up patch to move the declaration of the\nstruct around as then the counter variable would need special treatment.\n\nAs the reallocation counter is currently unused we can just remove it.\nIf we ever need to count the reallocations again, we can reintroduce\nthe counter as part of 'struct slabname' in commit-slab-decl.h.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit-slab-impl.h | 3 ---\n 1 file changed, 3 deletions(-)\n\ndiff --git a/commit-slab-impl.h b/commit-slab-impl.h\nindex 87a9cadfcca..ac1e6d409ad 100644\n--- a/commit-slab-impl.h\n+++ b/commit-slab-impl.h\n@@ -11,8 +11,6 @@\n \n #define implement_commit_slab(slabname, elemtype, scope)\t\t\\\n \t\t\t\t\t\t\t\t\t\\\n-static int stat_ ##slabname## realloc;\t\t\t\t\t\\\n-\t\t\t\t\t\t\t\t\t\\\n scope void init_ ##slabname## _with_stride(struct slabname *s,\t\t\\\n \t\t\t\t\t\t   unsigned stride)\t\\\n {\t\t\t\t\t\t\t\t\t\\\n@@ -54,7 +52,6 @@ scope elemtype *slabname## _at_peek(struct slabname *s,\t\t\t\\\n \t\tif (!add_if_missing)\t\t\t\t\t\\\n \t\t\treturn NULL;\t\t\t\t\t\\\n \t\tREALLOC_ARRAY(s->slab, nth_slab + 1);\t\t\t\\\n-\t\tstat_ ##slabname## realloc++;\t\t\t\t\\\n \t\tfor (i = s->slab_count; i <= nth_slab; i++)\t\t\\\n \t\t\ts->slab[i] = NULL;\t\t\t\t\\\n \t\ts->slab_count = nth_slab + 1;\t\t\t\t\\\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351311","messageId":"20180629012222.167426-26-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 25/32] commit.c: migrate the commit buffer to the parsed object store","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:15Z","receivedAt":"2018-06-29T01:23:36Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 29 +++++++++++++++++++++++------\n commit.h |  4 ++++\n object.c |  5 +++++\n object.h |  4 ++++\n 4 files changed, 36 insertions(+), 6 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 41d23352098..1baac77861f 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -261,18 +261,32 @@ struct commit_buffer {\n \tunsigned long size;\n };\n define_commit_slab(buffer_slab, struct commit_buffer);\n-static struct buffer_slab buffer_slab = COMMIT_SLAB_INIT(1, buffer_slab);\n+\n+struct buffer_slab *allocate_commit_buffer_slab(void)\n+{\n+\tstruct buffer_slab *bs = xmalloc(sizeof(*bs));\n+\tinit_buffer_slab(bs);\n+\treturn bs;\n+}\n+\n+void free_commit_buffer_slab(struct buffer_slab *bs)\n+{\n+\tclear_buffer_slab(bs);\n+\tfree(bs);\n+}\n \n void set_commit_buffer_the_repository(struct commit *commit, void *buffer, unsigned long size)\n {\n-\tstruct commit_buffer *v = buffer_slab_at(&buffer_slab, commit);\n+\tstruct commit_buffer *v = buffer_slab_at(\n+\t\tthe_repository->parsed_objects->buffer_slab, commit);\n \tv->buffer = buffer;\n \tv->size = size;\n }\n \n const void *get_cached_commit_buffer_the_repository(const struct commit *commit, unsigned long *sizep)\n {\n-\tstruct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit);\n+\tstruct commit_buffer *v = buffer_slab_peek(\n+\t\tthe_repository->parsed_objects->buffer_slab, commit);\n \tif (!v) {\n \t\tif (sizep)\n \t\t\t*sizep = 0;\n@@ -304,14 +318,16 @@ const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)\n \n void unuse_commit_buffer(const struct commit *commit, const void *buffer)\n {\n-\tstruct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit);\n+\tstruct commit_buffer *v = buffer_slab_peek(\n+\t\tthe_repository->parsed_objects->buffer_slab, commit);\n \tif (!(v && v->buffer == buffer))\n \t\tfree((void *)buffer);\n }\n \n void free_commit_buffer(struct commit *commit)\n {\n-\tstruct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit);\n+\tstruct commit_buffer *v = buffer_slab_peek(\n+\t\tthe_repository->parsed_objects->buffer_slab, commit);\n \tif (v) {\n \t\tFREE_AND_NULL(v->buffer);\n \t\tv->size = 0;\n@@ -347,7 +363,8 @@ void release_commit_memory(struct commit *c)\n \n const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n {\n-\tstruct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit);\n+\tstruct commit_buffer *v = buffer_slab_peek(\n+\t\tthe_repository->parsed_objects->buffer_slab, commit);\n \tvoid *ret;\n \n \tif (!v) {\ndiff --git a/commit.h b/commit.h\nindex e9cb5aaaae9..bea5e015b28 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -89,6 +89,10 @@ static inline int parse_commit(struct commit *item)\n }\n void parse_commit_or_die(struct commit *item);\n \n+struct buffer_slab;\n+struct buffer_slab *allocate_commit_buffer_slab(void);\n+void free_commit_buffer_slab(struct buffer_slab *bs);\n+\n /*\n  * Associate an object buffer with the commit. The ownership of the\n  * memory is handed over to the commit, and must be free()-able.\ndiff --git a/object.c b/object.c\nindex 9d74de95f5b..9d588448192 100644\n--- a/object.c\n+++ b/object.c\n@@ -467,6 +467,8 @@ struct parsed_object_pool *parsed_object_pool_new(void)\n \to->is_shallow = -1;\n \to->shallow_stat = xcalloc(1, sizeof(*o->shallow_stat));\n \n+\to->buffer_slab = allocate_commit_buffer_slab();\n+\n \treturn o;\n }\n \n@@ -541,6 +543,9 @@ void parsed_object_pool_clear(struct parsed_object_pool *o)\n \tFREE_AND_NULL(o->obj_hash);\n \to->obj_hash_size = 0;\n \n+\tfree_commit_buffer_slab(o->buffer_slab);\n+\to->buffer_slab = NULL;\n+\n \tclear_alloc_state(o->blob_state);\n \tclear_alloc_state(o->tree_state);\n \tclear_alloc_state(o->commit_state);\ndiff --git a/object.h b/object.h\nindex 0d7d74129b6..f54a892bd10 100644\n--- a/object.h\n+++ b/object.h\n@@ -1,6 +1,8 @@\n #ifndef OBJECT_H\n #define OBJECT_H\n \n+struct buffer_slab;\n+\n struct parsed_object_pool {\n \tstruct object **obj_hash;\n \tint nr_objs, obj_hash_size;\n@@ -22,6 +24,8 @@ struct parsed_object_pool {\n \tchar *alternate_shallow_file;\n \n \tint commit_graft_prepared;\n+\n+\tstruct buffer_slab *buffer_slab;\n };\n \n struct parsed_object_pool *parsed_object_pool_new(void);\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351312","messageId":"20180629012222.167426-27-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 26/32] commit.c: allow set_commit_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:16Z","receivedAt":"2018-06-29T01:23:39Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 4 ++--\n commit.h | 3 +--\n 2 files changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 1baac77861f..dd8c9c15b14 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -275,10 +275,10 @@ void free_commit_buffer_slab(struct buffer_slab *bs)\n \tfree(bs);\n }\n \n-void set_commit_buffer_the_repository(struct commit *commit, void *buffer, unsigned long size)\n+void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer, unsigned long size)\n {\n \tstruct commit_buffer *v = buffer_slab_at(\n-\t\tthe_repository->parsed_objects->buffer_slab, commit);\n+\t\tr->parsed_objects->buffer_slab, commit);\n \tv->buffer = buffer;\n \tv->size = size;\n }\ndiff --git a/commit.h b/commit.h\nindex bea5e015b28..7297af467b9 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -97,8 +97,7 @@ void free_commit_buffer_slab(struct buffer_slab *bs);\n  * Associate an object buffer with the commit. The ownership of the\n  * memory is handed over to the commit, and must be free()-able.\n  */\n-#define set_commit_buffer(r, c, b, s) set_commit_buffer_##r(c, b, s)\n-void set_commit_buffer_the_repository(struct commit *, void *buffer, unsigned long size);\n+void set_commit_buffer(struct repository *r, struct commit *, void *buffer, unsigned long size);\n \n /*\n  * Get any cached object buffer associated with the commit. Returns NULL\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351313","messageId":"20180629012222.167426-29-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 28/32] object.c: allow parse_object_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:18Z","receivedAt":"2018-06-29T01:23:42Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n object.c | 18 +++++++++---------\n object.h |  3 +--\n 2 files changed, 10 insertions(+), 11 deletions(-)\n\ndiff --git a/object.c b/object.c\nindex 9d588448192..cd870fee22b 100644\n--- a/object.c\n+++ b/object.c\n@@ -185,21 +185,21 @@ struct object *lookup_unknown_object(const unsigned char *sha1)\n \treturn obj;\n }\n \n-struct object *parse_object_buffer_the_repository(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)\n+struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)\n {\n \tstruct object *obj;\n \t*eaten_p = 0;\n \n \tobj = NULL;\n \tif (type == OBJ_BLOB) {\n-\t\tstruct blob *blob = lookup_blob(the_repository, oid);\n+\t\tstruct blob *blob = lookup_blob(r, oid);\n \t\tif (blob) {\n \t\t\tif (parse_blob_buffer(blob, buffer, size))\n \t\t\t\treturn NULL;\n \t\t\tobj = &blob->object;\n \t\t}\n \t} else if (type == OBJ_TREE) {\n-\t\tstruct tree *tree = lookup_tree(the_repository, oid);\n+\t\tstruct tree *tree = lookup_tree(r, oid);\n \t\tif (tree) {\n \t\t\tobj = &tree->object;\n \t\t\tif (!tree->buffer)\n@@ -211,20 +211,20 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e\n \t\t\t}\n \t\t}\n \t} else if (type == OBJ_COMMIT) {\n-\t\tstruct commit *commit = lookup_commit(the_repository, oid);\n+\t\tstruct commit *commit = lookup_commit(r, oid);\n \t\tif (commit) {\n-\t\t\tif (parse_commit_buffer(the_repository, commit, buffer, size, 1))\n+\t\t\tif (parse_commit_buffer(r, commit, buffer, size, 1))\n \t\t\t\treturn NULL;\n-\t\t\tif (!get_cached_commit_buffer(the_repository, commit, NULL)) {\n-\t\t\t\tset_commit_buffer(the_repository, commit, buffer, size);\n+\t\t\tif (!get_cached_commit_buffer(r, commit, NULL)) {\n+\t\t\t\tset_commit_buffer(r, commit, buffer, size);\n \t\t\t\t*eaten_p = 1;\n \t\t\t}\n \t\t\tobj = &commit->object;\n \t\t}\n \t} else if (type == OBJ_TAG) {\n-\t\tstruct tag *tag = lookup_tag(the_repository, oid);\n+\t\tstruct tag *tag = lookup_tag(r, oid);\n \t\tif (tag) {\n-\t\t\tif (parse_tag_buffer(the_repository, tag, buffer, size))\n+\t\t\tif (parse_tag_buffer(r, tag, buffer, size))\n \t\t\t       return NULL;\n \t\t\tobj = &tag->object;\n \t\t}\ndiff --git a/object.h b/object.h\nindex f54a892bd10..38198bb73a1 100644\n--- a/object.h\n+++ b/object.h\n@@ -138,8 +138,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name\n  * parsing it.  eaten_p indicates if the object has a borrowed copy\n  * of buffer and the caller should not free() it.\n  */\n-#define parse_object_buffer(r, o, t, s, b, e) parse_object_buffer_##r(o, t, s, b, e)\n-struct object *parse_object_buffer_the_repository(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);\n+struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);\n \n /** Returns the object, with potentially excess memory allocated. **/\n struct object *lookup_unknown_object(const unsigned  char *sha1);\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351314","messageId":"20180629012222.167426-31-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 30/32] tag.c: allow deref_tag to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:20Z","receivedAt":"2018-06-29T01:23:46Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n tag.c | 5 ++---\n tag.h | 3 +--\n 2 files changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/tag.c b/tag.c\nindex 682e7793059..94a89b21cb5 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -64,12 +64,11 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \treturn ret;\n }\n \n-struct object *deref_tag_the_repository(struct object *o, const char *warn, int warnlen)\n+struct object *deref_tag(struct repository *r, struct object *o, const char *warn, int warnlen)\n {\n \twhile (o && o->type == OBJ_TAG)\n \t\tif (((struct tag *)o)->tagged)\n-\t\t\to = parse_object(the_repository,\n-\t\t\t\t\t &((struct tag *)o)->tagged->oid);\n+\t\t\to = parse_object(r, &((struct tag *)o)->tagged->oid);\n \t\telse\n \t\t\to = NULL;\n \tif (!o && warn) {\ndiff --git a/tag.h b/tag.h\nindex efd4c7da67c..e669c3e497a 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -15,8 +15,7 @@ extern struct tag *lookup_tag(struct repository *r, const struct object_id *oid)\n extern int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size);\n extern int parse_tag(struct tag *item);\n extern void release_tag_memory(struct tag *t);\n-#define deref_tag(r, o, w, l) deref_tag_##r(o, w, l)\n-extern struct object *deref_tag_the_repository(struct object *, const char *, int);\n+extern struct object *deref_tag(struct repository *r, struct object *, const char *, int);\n extern struct object *deref_tag_noverify(struct object *);\n extern int gpg_verify_tag(const struct object_id *oid,\n \t\tconst char *name_to_report, unsigned flags);\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351315","messageId":"20180629012222.167426-30-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 29/32] object.c: allow parse_object to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:19Z","receivedAt":"2018-06-29T01:23:49Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n object.c | 14 +++++++-------\n object.h |  3 +--\n 2 files changed, 8 insertions(+), 9 deletions(-)\n\ndiff --git a/object.c b/object.c\nindex cd870fee22b..b0faab85d40 100644\n--- a/object.c\n+++ b/object.c\n@@ -245,28 +245,28 @@ struct object *parse_object_or_die(const struct object_id *oid,\n \tdie(_(\"unable to parse object: %s\"), name ? name : oid_to_hex(oid));\n }\n \n-struct object *parse_object_the_repository(const struct object_id *oid)\n+struct object *parse_object(struct repository *r, const struct object_id *oid)\n {\n \tunsigned long size;\n \tenum object_type type;\n \tint eaten;\n-\tconst struct object_id *repl = lookup_replace_object(the_repository, oid);\n+\tconst struct object_id *repl = lookup_replace_object(r, oid);\n \tvoid *buffer;\n \tstruct object *obj;\n \n-\tobj = lookup_object(the_repository, oid->hash);\n+\tobj = lookup_object(r, oid->hash);\n \tif (obj && obj->parsed)\n \t\treturn obj;\n \n \tif ((obj && obj->type == OBJ_BLOB && has_object_file(oid)) ||\n \t    (!obj && has_object_file(oid) &&\n-\t     oid_object_info(the_repository, oid, NULL) == OBJ_BLOB)) {\n+\t     oid_object_info(r, oid, NULL) == OBJ_BLOB)) {\n \t\tif (check_object_signature(repl, NULL, 0, NULL) < 0) {\n \t\t\terror(\"sha1 mismatch %s\", oid_to_hex(oid));\n \t\t\treturn NULL;\n \t\t}\n-\t\tparse_blob_buffer(lookup_blob(the_repository, oid), NULL, 0);\n-\t\treturn lookup_object(the_repository, oid->hash);\n+\t\tparse_blob_buffer(lookup_blob(r, oid), NULL, 0);\n+\t\treturn lookup_object(r, oid->hash);\n \t}\n \n \tbuffer = read_object_file(oid, &type, &size);\n@@ -277,7 +277,7 @@ struct object *parse_object_the_repository(const struct object_id *oid)\n \t\t\treturn NULL;\n \t\t}\n \n-\t\tobj = parse_object_buffer(the_repository, oid, type, size,\n+\t\tobj = parse_object_buffer(r, oid, type, size,\n \t\t\t\t\t  buffer, &eaten);\n \t\tif (!eaten)\n \t\t\tfree(buffer);\ndiff --git a/object.h b/object.h\nindex 38198bb73a1..fa5ca975678 100644\n--- a/object.h\n+++ b/object.h\n@@ -124,8 +124,7 @@ void *object_as_type(struct repository *r, struct object *obj, enum object_type\n  *\n  * Returns NULL if the object is missing or corrupt.\n  */\n-#define parse_object(r, oid) parse_object_##r(oid)\n-struct object *parse_object_the_repository(const struct object_id *oid);\n+struct object *parse_object(struct repository *r, const struct object_id *oid);\n \n /*\n  * Like parse_object, but will die() instead of returning NULL. If the\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351316","messageId":"20180629012222.167426-32-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 31/32] commit.c: allow lookup_commit_reference_gently to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:21Z","receivedAt":"2018-06-29T01:23:50Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 8 ++++----\n commit.h | 4 +---\n 2 files changed, 5 insertions(+), 7 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 15b044331a1..08b4602f43f 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -24,16 +24,16 @@ int save_commit_buffer = 1;\n \n const char *commit_type = \"commit\";\n \n-struct commit *lookup_commit_reference_gently_the_repository(\n+struct commit *lookup_commit_reference_gently(struct repository *r,\n \t\tconst struct object_id *oid, int quiet)\n {\n-\tstruct object *obj = deref_tag(the_repository,\n-\t\t\t\t       parse_object(the_repository, oid),\n+\tstruct object *obj = deref_tag(r,\n+\t\t\t\t       parse_object(r, oid),\n \t\t\t\t       NULL, 0);\n \n \tif (!obj)\n \t\treturn NULL;\n-\treturn object_as_type(the_repository, obj, OBJ_COMMIT, quiet);\n+\treturn object_as_type(r, obj, OBJ_COMMIT, quiet);\n }\n \n struct commit *lookup_commit_reference_the_repository(const struct object_id *oid)\ndiff --git a/commit.h b/commit.h\nindex d61585df5bc..f1f25957de4 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -67,9 +67,7 @@ struct commit *lookup_commit(struct repository *r, const struct object_id *oid);\n #define lookup_commit_reference(r, o) \\\n \t\tlookup_commit_reference_##r(o)\n struct commit *lookup_commit_reference_the_repository(const struct object_id *oid);\n-#define lookup_commit_reference_gently(r, o, q) \\\n-\t\tlookup_commit_reference_gently_##r(o, q)\n-struct commit *lookup_commit_reference_gently_the_repository(\n+struct commit *lookup_commit_reference_gently(struct repository *r,\n \t\t\t\t\t      const struct object_id *oid,\n \t\t\t\t\t      int quiet);\n struct commit *lookup_commit_reference_by_name(const char *name);\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351317","messageId":"20180629012222.167426-33-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 32/32] commit.c: allow lookup_commit_reference to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:22Z","receivedAt":"2018-06-29T01:23:53Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 4 ++--\n commit.h | 5 ++---\n 2 files changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 08b4602f43f..b88ced5b026 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -36,9 +36,9 @@ struct commit *lookup_commit_reference_gently(struct repository *r,\n \treturn object_as_type(r, obj, OBJ_COMMIT, quiet);\n }\n \n-struct commit *lookup_commit_reference_the_repository(const struct object_id *oid)\n+struct commit *lookup_commit_reference(struct repository *r, const struct object_id *oid)\n {\n-\treturn lookup_commit_reference_gently(the_repository, oid, 0);\n+\treturn lookup_commit_reference_gently(r, oid, 0);\n }\n \n struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name)\ndiff --git a/commit.h b/commit.h\nindex f1f25957de4..8b2cf9692de 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -64,9 +64,8 @@ void add_name_decoration(enum decoration_type type, const char *name, struct obj\n const struct name_decoration *get_name_decoration(const struct object *obj);\n \n struct commit *lookup_commit(struct repository *r, const struct object_id *oid);\n-#define lookup_commit_reference(r, o) \\\n-\t\tlookup_commit_reference_##r(o)\n-struct commit *lookup_commit_reference_the_repository(const struct object_id *oid);\n+struct commit *lookup_commit_reference(struct repository *r,\n+\t\t\t\t       const struct object_id *oid);\n struct commit *lookup_commit_reference_gently(struct repository *r,\n \t\t\t\t\t      const struct object_id *oid,\n \t\t\t\t\t      int quiet);\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351318","messageId":"20180629012222.167426-23-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 22/32] tag: allow parse_tag_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:12Z","receivedAt":"2018-06-29T01:23:59Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n tag.c | 10 +++++-----\n tag.h |  3 +--\n 2 files changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/tag.c b/tag.c\nindex 46b5882ee12..682e7793059 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -126,7 +126,7 @@ void release_tag_memory(struct tag *t)\n \tt->date = 0;\n }\n \n-int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned long size)\n+int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size)\n {\n \tstruct object_id oid;\n \tchar type[20];\n@@ -154,13 +154,13 @@ int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned\n \tbufptr = nl + 1;\n \n \tif (!strcmp(type, blob_type)) {\n-\t\titem->tagged = (struct object *)lookup_blob(the_repository, &oid);\n+\t\titem->tagged = (struct object *)lookup_blob(r, &oid);\n \t} else if (!strcmp(type, tree_type)) {\n-\t\titem->tagged = (struct object *)lookup_tree(the_repository, &oid);\n+\t\titem->tagged = (struct object *)lookup_tree(r, &oid);\n \t} else if (!strcmp(type, commit_type)) {\n-\t\titem->tagged = (struct object *)lookup_commit(the_repository, &oid);\n+\t\titem->tagged = (struct object *)lookup_commit(r, &oid);\n \t} else if (!strcmp(type, tag_type)) {\n-\t\titem->tagged = (struct object *)lookup_tag(the_repository, &oid);\n+\t\titem->tagged = (struct object *)lookup_tag(r, &oid);\n \t} else {\n \t\terror(\"Unknown type %s\", type);\n \t\titem->tagged = NULL;\ndiff --git a/tag.h b/tag.h\nindex 6a160c91875..efd4c7da67c 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -12,8 +12,7 @@ struct tag {\n \ttimestamp_t date;\n };\n extern struct tag *lookup_tag(struct repository *r, const struct object_id *oid);\n-#define parse_tag_buffer(r, i, d, s) parse_tag_buffer_##r(i, d, s)\n-extern int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned long size);\n+extern int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size);\n extern int parse_tag(struct tag *item);\n extern void release_tag_memory(struct tag *t);\n #define deref_tag(r, o, w, l) deref_tag_##r(o, w, l)\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351319","messageId":"20180629012222.167426-28-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 27/32] commit.c: allow get_cached_commit_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:17Z","receivedAt":"2018-06-29T01:24:01Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 4 ++--\n commit.h | 3 +--\n 2 files changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex dd8c9c15b14..15b044331a1 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -283,10 +283,10 @@ void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer\n \tv->size = size;\n }\n \n-const void *get_cached_commit_buffer_the_repository(const struct commit *commit, unsigned long *sizep)\n+const void *get_cached_commit_buffer(struct repository *r, const struct commit *commit, unsigned long *sizep)\n {\n \tstruct commit_buffer *v = buffer_slab_peek(\n-\t\tthe_repository->parsed_objects->buffer_slab, commit);\n+\t\tr->parsed_objects->buffer_slab, commit);\n \tif (!v) {\n \t\tif (sizep)\n \t\t\t*sizep = 0;\ndiff --git a/commit.h b/commit.h\nindex 7297af467b9..d61585df5bc 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -103,8 +103,7 @@ void set_commit_buffer(struct repository *r, struct commit *, void *buffer, unsi\n  * Get any cached object buffer associated with the commit. Returns NULL\n  * if none. The resulting memory should not be freed.\n  */\n-#define get_cached_commit_buffer(r, c, s) get_cached_commit_buffer_##r(c, s)\n-const void *get_cached_commit_buffer_the_repository(const struct commit *, unsigned long *size);\n+const void *get_cached_commit_buffer(struct repository *, const struct commit *, unsigned long *size);\n \n /*\n  * Get the commit's object contents, either from cache or by reading the object\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351320","messageId":"20180629012222.167426-8-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 07/32] commit: add repository argument to lookup_commit_reference_gently","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:21:57Z","receivedAt":"2018-06-29T01:24:08Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow callers of\nlookup_commit_reference_gently to be more specific about which\nrepository to handle. This is a small mechanical change; it doesn't\nchange the implementation to handle repositories other than\nthe_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n archive.c             |  2 +-\n blame.c               |  3 ++-\n builtin/checkout.c    |  6 +++---\n builtin/describe.c    |  5 +++--\n builtin/fetch.c       |  9 ++++++---\n builtin/reflog.c      | 10 ++++++----\n builtin/show-branch.c |  3 ++-\n bundle.c              |  2 +-\n commit-graph.c        |  2 +-\n commit.c              |  6 +++---\n commit.h              |  5 ++++-\n fast-import.c         |  6 ++++--\n notes-cache.c         |  3 ++-\n ref-filter.c          |  6 ++++--\n remote.c              |  9 +++++----\n sequencer.c           |  2 +-\n sha1-name.c           |  4 ++--\n shallow.c             |  9 ++++++---\n walker.c              |  3 ++-\n wt-status.c           |  2 +-\n 20 files changed, 59 insertions(+), 38 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 875dab64b60..78b0a398a0f 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -380,7 +380,7 @@ static void parse_treeish_arg(const char **argv,\n \tif (get_oid(name, &oid))\n \t\tdie(\"Not a valid object name\");\n \n-\tcommit = lookup_commit_reference_gently(&oid, 1);\n+\tcommit = lookup_commit_reference_gently(the_repository, &oid, 1);\n \tif (commit) {\n \t\tcommit_sha1 = commit->object.oid.hash;\n \t\tarchive_time = commit->date;\ndiff --git a/blame.c b/blame.c\nindex 0c4490a35bb..5b022cc2254 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -1712,7 +1712,8 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,\n \t/* Do we have HEAD? */\n \tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, &head_oid, NULL))\n \t\treturn NULL;\n-\thead_commit = lookup_commit_reference_gently(&head_oid, 1);\n+\thead_commit = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t     &head_oid, 1);\n \tif (!head_commit)\n \t\treturn NULL;\n \ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 28627650cd6..40c27bf54d7 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -379,7 +379,7 @@ static int checkout_paths(const struct checkout_opts *opts,\n \t\tdie(_(\"unable to write new index file\"));\n \n \tread_ref_full(\"HEAD\", 0, &rev, NULL);\n-\thead = lookup_commit_reference_gently(&rev, 1);\n+\thead = lookup_commit_reference_gently(the_repository, &rev, 1);\n \n \terrs |= post_checkout_hook(head, head, 0);\n \treturn errs;\n@@ -830,7 +830,7 @@ static int switch_branches(const struct checkout_opts *opts,\n \tmemset(&old_branch_info, 0, sizeof(old_branch_info));\n \told_branch_info.path = path_to_free = resolve_refdup(\"HEAD\", 0, &rev, &flag);\n \tif (old_branch_info.path)\n-\t\told_branch_info.commit = lookup_commit_reference_gently(&rev, 1);\n+\t\told_branch_info.commit = lookup_commit_reference_gently(the_repository, &rev, 1);\n \tif (!(flag & REF_ISSYMREF))\n \t\told_branch_info.path = NULL;\n \n@@ -1004,7 +1004,7 @@ static int parse_branchname_arg(int argc, const char **argv,\n \telse\n \t\tnew_branch_info->path = NULL; /* not an existing branch */\n \n-\tnew_branch_info->commit = lookup_commit_reference_gently(rev, 1);\n+\tnew_branch_info->commit = lookup_commit_reference_gently(the_repository, rev, 1);\n \tif (!new_branch_info->commit) {\n \t\t/* not a commit */\n \t\t*source_tree = parse_tree_indirect(rev);\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 1e87f68d5ee..0b5d8562331 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -331,7 +331,8 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)\n \t\tinit_commit_names(&commit_names);\n \t\tn = hashmap_iter_first(&names, &iter);\n \t\tfor (; n; n = hashmap_iter_next(&iter)) {\n-\t\t\tc = lookup_commit_reference_gently(&n->peeled, 1);\n+\t\t\tc = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t\t   &n->peeled, 1);\n \t\t\tif (c)\n \t\t\t\t*commit_names_at(&commit_names, c) = n;\n \t\t}\n@@ -509,7 +510,7 @@ static void describe(const char *arg, int last_one)\n \n \tif (get_oid(arg, &oid))\n \t\tdie(_(\"Not a valid object name %s\"), arg);\n-\tcmit = lookup_commit_reference_gently(&oid, 1);\n+\tcmit = lookup_commit_reference_gently(the_repository, &oid, 1);\n \n \tif (cmit)\n \t\tdescribe_commit(&oid, &sb);\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 83f36d7cdeb..f5d960baecf 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -684,8 +684,10 @@ static int update_local_ref(struct ref *ref,\n \t\treturn r;\n \t}\n \n-\tcurrent = lookup_commit_reference_gently(&ref->old_oid, 1);\n-\tupdated = lookup_commit_reference_gently(&ref->new_oid, 1);\n+\tcurrent = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t &ref->old_oid, 1);\n+\tupdated = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t &ref->new_oid, 1);\n \tif (!current || !updated) {\n \t\tconst char *msg;\n \t\tconst char *what;\n@@ -818,7 +820,8 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \t\t\t\tcontinue;\n \t\t\t}\n \n-\t\t\tcommit = lookup_commit_reference_gently(&rm->old_oid,\n+\t\t\tcommit = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t\t\t&rm->old_oid,\n \t\t\t\t\t\t\t\t1);\n \t\t\tif (!commit)\n \t\t\t\trm->fetch_head_status = FETCH_HEAD_NOT_FOR_MERGE;\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 5e12c856049..3acef5a0abe 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -196,7 +196,7 @@ static int keep_entry(struct commit **it, struct object_id *oid)\n \n \tif (is_null_oid(oid))\n \t\treturn 1;\n-\tcommit = lookup_commit_reference_gently(oid, 1);\n+\tcommit = lookup_commit_reference_gently(the_repository, oid, 1);\n \tif (!commit)\n \t\treturn 0;\n \n@@ -265,7 +265,8 @@ static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit\n \t\tif (is_null_oid(oid))\n \t\t\treturn 0;\n \n-\t\tcommit = lookup_commit_reference_gently(oid, 1);\n+\t\tcommit = lookup_commit_reference_gently(the_repository, oid,\n+\t\t\t\t\t\t\t1);\n \n \t\t/* Not a commit -- keep it */\n \t\tif (!commit)\n@@ -322,7 +323,7 @@ static int push_tip_to_list(const char *refname, const struct object_id *oid,\n \tstruct commit *tip_commit;\n \tif (flags & REF_ISSYMREF)\n \t\treturn 0;\n-\ttip_commit = lookup_commit_reference_gently(oid, 1);\n+\ttip_commit = lookup_commit_reference_gently(the_repository, oid, 1);\n \tif (!tip_commit)\n \t\treturn 0;\n \tcommit_list_insert(tip_commit, list);\n@@ -339,7 +340,8 @@ static void reflog_expiry_prepare(const char *refname,\n \t\tcb->tip_commit = NULL;\n \t\tcb->unreachable_expire_kind = UE_HEAD;\n \t} else {\n-\t\tcb->tip_commit = lookup_commit_reference_gently(oid, 1);\n+\t\tcb->tip_commit = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t\t\toid, 1);\n \t\tif (!cb->tip_commit)\n \t\t\tcb->unreachable_expire_kind = UE_ALWAYS;\n \t\telse\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex f2e985c00ab..2456b47d344 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -378,7 +378,8 @@ static void sort_ref_range(int bottom, int top)\n static int append_ref(const char *refname, const struct object_id *oid,\n \t\t      int allow_dups)\n {\n-\tstruct commit *commit = lookup_commit_reference_gently(oid, 1);\n+\tstruct commit *commit = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t\t       oid, 1);\n \tint i;\n \n \tif (!commit)\ndiff --git a/bundle.c b/bundle.c\nindex 8283fffd7cc..0a9f4ee76b2 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -180,7 +180,7 @@ int verify_bundle(struct bundle_header *header, int verbose)\n \t/* Clean up objects used, as they will be reused. */\n \tfor (i = 0; i < p->nr; i++) {\n \t\tstruct ref_list_entry *e = p->list + i;\n-\t\tcommit = lookup_commit_reference_gently(&e->oid, 1);\n+\t\tcommit = lookup_commit_reference_gently(the_repository, &e->oid, 1);\n \t\tif (commit)\n \t\t\tclear_commit_marks(commit, ALL_REV_FLAGS);\n \t}\ndiff --git a/commit-graph.c b/commit-graph.c\nindex d1a68f0128f..7801b51c953 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -701,7 +701,7 @@ void write_commit_graph(const char *obj_dir,\n \t\t\tif (commit_hex[i] && parse_oid_hex(commit_hex[i], &oid, &end))\n \t\t\t\tcontinue;\n \n-\t\t\tresult = lookup_commit_reference_gently(&oid, 1);\n+\t\t\tresult = lookup_commit_reference_gently(the_repository, &oid, 1);\n \n \t\t\tif (result) {\n \t\t\t\tALLOC_GROW(oids.list, oids.nr + 1, oids.alloc);\ndiff --git a/commit.c b/commit.c\nindex 2fa4220ac86..756d557b3c9 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -24,8 +24,8 @@ int save_commit_buffer = 1;\n \n const char *commit_type = \"commit\";\n \n-struct commit *lookup_commit_reference_gently(const struct object_id *oid,\n-\t\t\t\t\t      int quiet)\n+struct commit *lookup_commit_reference_gently_the_repository(\n+\t\tconst struct object_id *oid, int quiet)\n {\n \tstruct object *obj = deref_tag(parse_object(the_repository, oid),\n \t\t\t\t       NULL, 0);\n@@ -37,7 +37,7 @@ struct commit *lookup_commit_reference_gently(const struct object_id *oid,\n \n struct commit *lookup_commit_reference(const struct object_id *oid)\n {\n-\treturn lookup_commit_reference_gently(oid, 0);\n+\treturn lookup_commit_reference_gently(the_repository, oid, 0);\n }\n \n struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name)\ndiff --git a/commit.h b/commit.h\nindex 01b8b1d6896..000d194f8aa 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -65,7 +65,10 @@ const struct name_decoration *get_name_decoration(const struct object *obj);\n \n struct commit *lookup_commit(const struct object_id *oid);\n struct commit *lookup_commit_reference(const struct object_id *oid);\n-struct commit *lookup_commit_reference_gently(const struct object_id *oid,\n+#define lookup_commit_reference_gently(r, o, q) \\\n+\t\tlookup_commit_reference_gently_##r(o, q)\n+struct commit *lookup_commit_reference_gently_the_repository(\n+\t\t\t\t\t      const struct object_id *oid,\n \t\t\t\t\t      int quiet);\n struct commit *lookup_commit_reference_by_name(const char *name);\n \ndiff --git a/fast-import.c b/fast-import.c\nindex 4d55910ab9a..3ea5781029d 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1724,8 +1724,10 @@ static int update_branch(struct branch *b)\n \tif (!force_update && !is_null_oid(&old_oid)) {\n \t\tstruct commit *old_cmit, *new_cmit;\n \n-\t\told_cmit = lookup_commit_reference_gently(&old_oid, 0);\n-\t\tnew_cmit = lookup_commit_reference_gently(&b->oid, 0);\n+\t\told_cmit = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t\t  &old_oid, 0);\n+\t\tnew_cmit = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t\t  &b->oid, 0);\n \t\tif (!old_cmit || !new_cmit)\n \t\t\treturn error(\"Branch %s is missing commits.\", b->name);\n \ndiff --git a/notes-cache.c b/notes-cache.c\nindex d5770031776..d87e7ca91cd 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"notes-cache.h\"\n #include \"object-store.h\"\n+#include \"repository.h\"\n #include \"commit.h\"\n #include \"refs.h\"\n \n@@ -15,7 +16,7 @@ static int notes_cache_match_validity(const char *ref, const char *validity)\n \tif (read_ref(ref, &oid) < 0)\n \t\treturn 0;\n \n-\tcommit = lookup_commit_reference_gently(&oid, 1);\n+\tcommit = lookup_commit_reference_gently(the_repository, &oid, 1);\n \tif (!commit)\n \t\treturn 0;\n \ndiff --git a/ref-filter.c b/ref-filter.c\nindex ec9479af1f8..49021ee4467 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -2026,7 +2026,8 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,\n \t * non-commits early. The actual filtering is done later.\n \t */\n \tif (filter->merge_commit || filter->with_commit || filter->no_commit || filter->verbose) {\n-\t\tcommit = lookup_commit_reference_gently(oid, 1);\n+\t\tcommit = lookup_commit_reference_gently(the_repository, oid,\n+\t\t\t\t\t\t\t1);\n \t\tif (!commit)\n \t\t\treturn 0;\n \t\t/* We perform the filtering for the '--contains' option... */\n@@ -2383,7 +2384,8 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)\n \tif (get_oid(arg, &oid))\n \t\tdie(_(\"malformed object name %s\"), arg);\n \n-\trf->merge_commit = lookup_commit_reference_gently(&oid, 0);\n+\trf->merge_commit = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t\t  &oid, 0);\n \tif (!rf->merge_commit)\n \t\treturn opterror(opt, \"must point to a commit\", 0);\n \ndiff --git a/remote.c b/remote.c\nindex a5c04a0a7df..0f1a84d67a3 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1149,7 +1149,7 @@ static void add_to_tips(struct tips *tips, const struct object_id *oid)\n \n \tif (is_null_oid(oid))\n \t\treturn;\n-\tcommit = lookup_commit_reference_gently(oid, 1);\n+\tcommit = lookup_commit_reference_gently(the_repository, oid, 1);\n \tif (!commit || (commit->object.flags & TMP_MARK))\n \t\treturn;\n \tcommit->object.flags |= TMP_MARK;\n@@ -1211,7 +1211,8 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \n \t\t\tif (is_null_oid(&ref->new_oid))\n \t\t\t\tcontinue;\n-\t\t\tcommit = lookup_commit_reference_gently(&ref->new_oid,\n+\t\t\tcommit = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t\t\t&ref->new_oid,\n \t\t\t\t\t\t\t\t1);\n \t\t\tif (!commit)\n \t\t\t\t/* not pushing a commit, which is not an error */\n@@ -1435,8 +1436,8 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n \t\t\t\treject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;\n \t\t\telse if (!has_object_file(&ref->old_oid))\n \t\t\t\treject_reason = REF_STATUS_REJECT_FETCH_FIRST;\n-\t\t\telse if (!lookup_commit_reference_gently(&ref->old_oid, 1) ||\n-\t\t\t\t !lookup_commit_reference_gently(&ref->new_oid, 1))\n+\t\t\telse if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||\n+\t\t\t\t !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))\n \t\t\t\treject_reason = REF_STATUS_REJECT_NEEDS_FORCE;\n \t\t\telse if (!ref_newer(&ref->new_oid, &ref->old_oid))\n \t\t\t\treject_reason = REF_STATUS_REJECT_NONFASTFORWARD;\ndiff --git a/sequencer.c b/sequencer.c\nindex 4cf7afbab6d..b4170b748cc 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -3610,7 +3610,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)\n \t\t\tcontinue;\n \n \t\tif (!get_oid(name, &oid)) {\n-\t\t\tif (!lookup_commit_reference_gently(&oid, 1)) {\n+\t\t\tif (!lookup_commit_reference_gently(the_repository, &oid, 1)) {\n \t\t\t\tenum object_type type = oid_object_info(the_repository,\n \t\t\t\t\t\t\t\t\t&oid,\n \t\t\t\t\t\t\t\t\tNULL);\ndiff --git a/sha1-name.c b/sha1-name.c\nindex dd19abaafd4..473611879bf 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -1251,13 +1251,13 @@ int get_oid_mb(const char *name, struct object_id *oid)\n \t}\n \tif (st)\n \t\treturn st;\n-\tone = lookup_commit_reference_gently(&oid_tmp, 0);\n+\tone = lookup_commit_reference_gently(the_repository, &oid_tmp, 0);\n \tif (!one)\n \t\treturn -1;\n \n \tif (get_oid_committish(dots[3] ? (dots + 3) : \"HEAD\", &oid_tmp))\n \t\treturn -1;\n-\ttwo = lookup_commit_reference_gently(&oid_tmp, 0);\n+\ttwo = lookup_commit_reference_gently(the_repository, &oid_tmp, 0);\n \tif (!two)\n \t\treturn -1;\n \tmbs = get_merge_bases(one, two);\ndiff --git a/shallow.c b/shallow.c\nindex e53067cdede..40054b94852 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -492,7 +492,8 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,\n \tstruct commit_list *head = NULL;\n \tint bitmap_nr = DIV_ROUND_UP(info->nr_bits, 32);\n \tsize_t bitmap_size = st_mult(sizeof(uint32_t), bitmap_nr);\n-\tstruct commit *c = lookup_commit_reference_gently(oid, 1);\n+\tstruct commit *c = lookup_commit_reference_gently(the_repository, oid,\n+\t\t\t\t\t\t\t  1);\n \tuint32_t *tmp; /* to be freed before return */\n \tuint32_t *bitmap;\n \n@@ -554,7 +555,8 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,\n static int mark_uninteresting(const char *refname, const struct object_id *oid,\n \t\t\t      int flags, void *cb_data)\n {\n-\tstruct commit *commit = lookup_commit_reference_gently(oid, 1);\n+\tstruct commit *commit = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t\t       oid, 1);\n \tif (!commit)\n \t\treturn 0;\n \tcommit->object.flags |= UNINTERESTING;\n@@ -664,7 +666,8 @@ static int add_ref(const char *refname, const struct object_id *oid,\n {\n \tstruct commit_array *ca = cb_data;\n \tALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);\n-\tca->commits[ca->nr] = lookup_commit_reference_gently(oid, 1);\n+\tca->commits[ca->nr] = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t\t     oid, 1);\n \tif (ca->commits[ca->nr])\n \t\tca->nr++;\n \treturn 0;\ndiff --git a/walker.c b/walker.c\nindex a3a25667611..96990d84dab 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -207,7 +207,8 @@ static int interpret_target(struct walker *walker, char *target, struct object_i\n static int mark_complete(const char *path, const struct object_id *oid,\n \t\t\t int flag, void *cb_data)\n {\n-\tstruct commit *commit = lookup_commit_reference_gently(oid, 1);\n+\tstruct commit *commit = lookup_commit_reference_gently(the_repository,\n+\t\t\t\t\t\t\t       oid, 1);\n \n \tif (commit) {\n \t\tcommit->object.flags |= COMPLETE;\ndiff --git a/wt-status.c b/wt-status.c\nindex 8827a256d32..6c0e400f813 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1489,7 +1489,7 @@ static void wt_status_get_detached_from(struct wt_status_state *state)\n \t    /* sha1 is a commit? match without further lookup */\n \t    (!oidcmp(&cb.noid, &oid) ||\n \t     /* perhaps sha1 is a tag, try to dereference to a commit */\n-\t     ((commit = lookup_commit_reference_gently(&oid, 1)) != NULL &&\n+\t     ((commit = lookup_commit_reference_gently(the_repository, &oid, 1)) != NULL &&\n \t      !oidcmp(&cb.noid, &commit->object.oid)))) {\n \t\tconst char *from = ref;\n \t\tif (!skip_prefix(from, \"refs/tags/\", &from))\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351321","messageId":"20180629012222.167426-10-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 09/32] commit: add repository argument to lookup_commit","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:21:59Z","receivedAt":"2018-06-29T01:24:10Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow callers of lookup_commit to be more\nspecific about which repository to handle. This is a small mechanical\nchange; it doesn't change the implementation to handle repositories\nother than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/am.c            |  3 ++-\n builtin/commit-tree.c   |  4 +++-\n builtin/diff-tree.c     |  2 +-\n builtin/fast-export.c   |  2 +-\n builtin/fmt-merge-msg.c |  2 +-\n builtin/merge-base.c    |  2 +-\n builtin/verify-commit.c |  4 +++-\n commit-graph.c          | 10 +++++-----\n commit.c                |  7 ++++---\n commit.h                |  3 ++-\n fetch-pack.c            |  5 +++--\n log-tree.c              |  2 +-\n notes-utils.c           |  4 +++-\n object.c                |  2 +-\n sequencer.c             |  4 ++--\n sha1-name.c             |  2 +-\n shallow.c               | 17 ++++++++++-------\n tag.c                   |  2 +-\n tree.c                  |  2 +-\n 19 files changed, 46 insertions(+), 33 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 72e928cee79..b6eeb46c4b6 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1633,7 +1633,8 @@ static void do_commit(const struct am_state *state)\n \n \tif (!get_oid_commit(\"HEAD\", &parent)) {\n \t\told_oid = &parent;\n-\t\tcommit_list_insert(lookup_commit(&parent), &parents);\n+\t\tcommit_list_insert(lookup_commit(the_repository, &parent),\n+\t\t\t\t   &parents);\n \t} else {\n \t\told_oid = NULL;\n \t\tsay(state, stderr, _(\"applying to an empty history\"));\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex 9fbd3529fb1..9ec36a82b63 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -6,6 +6,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"object-store.h\"\n+#include \"repository.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"builtin.h\"\n@@ -60,7 +61,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)\n \t\t\tif (get_oid_commit(argv[i], &oid))\n \t\t\t\tdie(\"Not a valid object name %s\", argv[i]);\n \t\t\tassert_oid_type(&oid, OBJ_COMMIT);\n-\t\t\tnew_parent(lookup_commit(&oid), &parents);\n+\t\t\tnew_parent(lookup_commit(the_repository, &oid),\n+\t\t\t\t\t\t &parents);\n \t\t\tcontinue;\n \t\t}\n \ndiff --git a/builtin/diff-tree.c b/builtin/diff-tree.c\nindex a5718d96ee2..91ba67070e2 100644\n--- a/builtin/diff-tree.c\n+++ b/builtin/diff-tree.c\n@@ -25,7 +25,7 @@ static int stdin_diff_commit(struct commit *commit, const char *p)\n \n \t/* Graft the fake parents locally to the commit */\n \twhile (isspace(*p++) && !parse_oid_hex(p, &oid, &p)) {\n-\t\tstruct commit *parent = lookup_commit(&oid);\n+\t\tstruct commit *parent = lookup_commit(the_repository, &oid);\n \t\tif (!pptr) {\n \t\t\t/* Free the real parent list */\n \t\t\tfree_commit_list(commit->parents);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 7d6b1d8aea2..223499d7ca4 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -963,7 +963,7 @@ static void import_marks(char *input_file)\n \t\t\t/* only commits */\n \t\t\tcontinue;\n \n-\t\tcommit = lookup_commit(&oid);\n+\t\tcommit = lookup_commit(the_repository, &oid);\n \t\tif (!commit)\n \t\t\tdie(\"not a commit? can't happen: %s\", oid_to_hex(&oid));\n \ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 5e44589b545..36318ef46e7 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -572,7 +572,7 @@ static void find_merge_parents(struct merge_parents *result,\n \t\tcommit_list_insert(parent, &parents);\n \t\tadd_merge_parent(result, &obj->oid, &parent->object.oid);\n \t}\n-\thead_commit = lookup_commit(head);\n+\thead_commit = lookup_commit(the_repository, head);\n \tif (head_commit)\n \t\tcommit_list_insert(head_commit, &parents);\n \treduce_heads_replace(&parents);\ndiff --git a/builtin/merge-base.c b/builtin/merge-base.c\nindex bbead6f33e5..08d91b1f0c0 100644\n--- a/builtin/merge-base.c\n+++ b/builtin/merge-base.c\n@@ -124,7 +124,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)\n \tif (is_null_oid(oid))\n \t\treturn;\n \n-\tcommit = lookup_commit(oid);\n+\tcommit = lookup_commit(the_repository, oid);\n \tif (!commit ||\n \t    (commit->object.flags & TMP_MARK) ||\n \t    parse_commit(commit))\ndiff --git a/builtin/verify-commit.c b/builtin/verify-commit.c\nindex f6922da16d6..7772c07ed7a 100644\n--- a/builtin/verify-commit.c\n+++ b/builtin/verify-commit.c\n@@ -9,6 +9,7 @@\n #include \"config.h\"\n #include \"builtin.h\"\n #include \"object-store.h\"\n+#include \"repository.h\"\n #include \"commit.h\"\n #include \"run-command.h\"\n #include <signal.h>\n@@ -27,7 +28,8 @@ static int run_gpg_verify(const struct object_id *oid, const char *buf, unsigned\n \n \tmemset(&signature_check, 0, sizeof(signature_check));\n \n-\tret = check_commit_signature(lookup_commit(oid), &signature_check);\n+\tret = check_commit_signature(lookup_commit(the_repository, oid),\n+\t\t\t\t     &signature_check);\n \tprint_signature_buffer(&signature_check, flags);\n \n \tsignature_check_clear(&signature_check);\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 7801b51c953..7f907b4bfb2 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -242,7 +242,7 @@ static struct commit_list **insert_parent_or_die(struct commit_graph *g,\n \tstruct commit *c;\n \tstruct object_id oid;\n \thashcpy(oid.hash, g->chunk_oid_lookup + g->hash_len * pos);\n-\tc = lookup_commit(&oid);\n+\tc = lookup_commit(the_repository, &oid);\n \tif (!c)\n \t\tdie(\"could not find commit %s\", oid_to_hex(&oid));\n \tc->graph_pos = pos;\n@@ -568,7 +568,7 @@ static void close_reachable(struct packed_oid_list *oids)\n \tstruct commit *commit;\n \n \tfor (i = 0; i < oids->nr; i++) {\n-\t\tcommit = lookup_commit(&oids->list[i]);\n+\t\tcommit = lookup_commit(the_repository, &oids->list[i]);\n \t\tif (commit)\n \t\t\tcommit->object.flags |= UNINTERESTING;\n \t}\n@@ -579,14 +579,14 @@ static void close_reachable(struct packed_oid_list *oids)\n \t * closure.\n \t */\n \tfor (i = 0; i < oids->nr; i++) {\n-\t\tcommit = lookup_commit(&oids->list[i]);\n+\t\tcommit = lookup_commit(the_repository, &oids->list[i]);\n \n \t\tif (commit && !parse_commit(commit))\n \t\t\tadd_missing_parents(oids, commit);\n \t}\n \n \tfor (i = 0; i < oids->nr; i++) {\n-\t\tcommit = lookup_commit(&oids->list[i]);\n+\t\tcommit = lookup_commit(the_repository, &oids->list[i]);\n \n \t\tif (commit)\n \t\t\tcommit->object.flags &= ~UNINTERESTING;\n@@ -737,7 +737,7 @@ void write_commit_graph(const char *obj_dir,\n \t\tif (i > 0 && !oidcmp(&oids.list[i-1], &oids.list[i]))\n \t\t\tcontinue;\n \n-\t\tcommits.list[commits.nr] = lookup_commit(&oids.list[i]);\n+\t\tcommits.list[commits.nr] = lookup_commit(the_repository, &oids.list[i]);\n \t\tparse_commit(commits.list[commits.nr]);\n \n \t\tfor (parent = commits.list[commits.nr]->parents;\ndiff --git a/commit.c b/commit.c\nindex 5e50a079324..4803c8be1df 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -52,7 +52,7 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref\n \treturn c;\n }\n \n-struct commit *lookup_commit(const struct object_id *oid)\n+struct commit *lookup_commit_the_repository(const struct object_id *oid)\n {\n \tstruct object *obj = lookup_object(the_repository, oid->hash);\n \tif (!obj)\n@@ -402,7 +402,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s\n \t\t */\n \t\tif (graft && (graft->nr_parent < 0 || grafts_replace_parents))\n \t\t\tcontinue;\n-\t\tnew_parent = lookup_commit(&parent);\n+\t\tnew_parent = lookup_commit(the_repository, &parent);\n \t\tif (new_parent)\n \t\t\tpptr = &commit_list_insert(new_parent, pptr)->next;\n \t}\n@@ -410,7 +410,8 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s\n \t\tint i;\n \t\tstruct commit *new_parent;\n \t\tfor (i = 0; i < graft->nr_parent; i++) {\n-\t\t\tnew_parent = lookup_commit(&graft->parent[i]);\n+\t\t\tnew_parent = lookup_commit(the_repository,\n+\t\t\t\t\t\t   &graft->parent[i]);\n \t\t\tif (!new_parent)\n \t\t\t\tcontinue;\n \t\t\tpptr = &commit_list_insert(new_parent, pptr)->next;\ndiff --git a/commit.h b/commit.h\nindex 2a411134457..cd80dab59c1 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -63,7 +63,8 @@ enum decoration_type {\n void add_name_decoration(enum decoration_type type, const char *name, struct object *obj);\n const struct name_decoration *get_name_decoration(const struct object *obj);\n \n-struct commit *lookup_commit(const struct object_id *oid);\n+#define lookup_commit(r, o) lookup_commit_##r(o)\n+struct commit *lookup_commit_the_repository(const struct object_id *oid);\n #define lookup_commit_reference(r, o) \\\n \t\tlookup_commit_reference_##r(o)\n struct commit *lookup_commit_reference_the_repository(const struct object_id *oid);\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 771eb8ae471..9f3aa4a88fd 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -498,7 +498,8 @@ static int find_common(struct fetch_pack_args *args,\n \t\t\t\tcase ACK_ready:\n \t\t\t\tcase ACK_continue: {\n \t\t\t\t\tstruct commit *commit =\n-\t\t\t\t\t\tlookup_commit(result_oid);\n+\t\t\t\t\t\tlookup_commit(the_repository,\n+\t\t\t\t\t\t\t      result_oid);\n \t\t\t\t\tif (!commit)\n \t\t\t\t\t\tdie(_(\"invalid commit %s\"), oid_to_hex(result_oid));\n \t\t\t\t\tif (args->stateless_rpc\n@@ -1278,7 +1279,7 @@ static int process_acks(struct packet_reader *reader, struct oidset *common)\n \t\t\tif (!get_oid_hex(arg, &oid)) {\n \t\t\t\tstruct commit *commit;\n \t\t\t\toidset_insert(common, &oid);\n-\t\t\t\tcommit = lookup_commit(&oid);\n+\t\t\t\tcommit = lookup_commit(the_repository, &oid);\n \t\t\t\tmark_common(commit, 0, 1);\n \t\t\t}\n \t\t\tcontinue;\ndiff --git a/log-tree.c b/log-tree.c\nindex 0eb7c6027fa..abe67e8b2e4 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -134,7 +134,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,\n \n static int add_graft_decoration(const struct commit_graft *graft, void *cb_data)\n {\n-\tstruct commit *commit = lookup_commit(&graft->oid);\n+\tstruct commit *commit = lookup_commit(the_repository, &graft->oid);\n \tif (!commit)\n \t\treturn 0;\n \tadd_name_decoration(DECORATION_GRAFTED, \"grafted\", &commit->object);\ndiff --git a/notes-utils.c b/notes-utils.c\nindex 02407fe2a73..14ea03178e9 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -3,6 +3,7 @@\n #include \"commit.h\"\n #include \"refs.h\"\n #include \"notes-utils.h\"\n+#include \"repository.h\"\n \n void create_notes_commit(struct notes_tree *t, struct commit_list *parents,\n \t\t\t const char *msg, size_t msg_len,\n@@ -19,7 +20,8 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,\n \t\t/* Deduce parent commit from t->ref */\n \t\tstruct object_id parent_oid;\n \t\tif (!read_ref(t->ref, &parent_oid)) {\n-\t\t\tstruct commit *parent = lookup_commit(&parent_oid);\n+\t\t\tstruct commit *parent = lookup_commit(the_repository,\n+\t\t\t\t\t\t\t      &parent_oid);\n \t\t\tif (parse_commit(parent))\n \t\t\t\tdie(\"Failed to find/parse commit %s\", t->ref);\n \t\t\tcommit_list_insert(parent, &parents);\ndiff --git a/object.c b/object.c\nindex 2acd3a03e39..530c55e41e4 100644\n--- a/object.c\n+++ b/object.c\n@@ -212,7 +212,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e\n \t\t\t}\n \t\t}\n \t} else if (type == OBJ_COMMIT) {\n-\t\tstruct commit *commit = lookup_commit(oid);\n+\t\tstruct commit *commit = lookup_commit(the_repository, oid);\n \t\tif (commit) {\n \t\t\tif (parse_commit_buffer(commit, buffer, size, 1))\n \t\t\t\treturn NULL;\ndiff --git a/sequencer.c b/sequencer.c\nindex cc7b19199e8..d1d07bed5bb 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -594,7 +594,7 @@ static int is_index_unchanged(void)\n \tif (!resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, &head_oid, NULL))\n \t\treturn error(_(\"could not resolve HEAD commit\"));\n \n-\thead_commit = lookup_commit(&head_oid);\n+\thead_commit = lookup_commit(the_repository, &head_oid);\n \n \t/*\n \t * If head_commit is NULL, check_commit, called from\n@@ -1101,7 +1101,7 @@ void print_commit_summary(const char *prefix, const struct object_id *oid,\n \tstruct strbuf author_ident = STRBUF_INIT;\n \tstruct strbuf committer_ident = STRBUF_INIT;\n \n-\tcommit = lookup_commit(oid);\n+\tcommit = lookup_commit(the_repository, oid);\n \tif (!commit)\n \t\tdie(_(\"couldn't look up newly created commit\"));\n \tif (parse_commit(commit))\ndiff --git a/sha1-name.c b/sha1-name.c\nindex 325915fb276..98480ade12d 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -351,7 +351,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \n \ttype = oid_object_info(the_repository, oid, NULL);\n \tif (type == OBJ_COMMIT) {\n-\t\tstruct commit *commit = lookup_commit(oid);\n+\t\tstruct commit *commit = lookup_commit(the_repository, oid);\n \t\tif (commit) {\n \t\t\tstruct pretty_print_context pp = {0};\n \t\t\tpp.date_mode.type = DATE_SHORT;\ndiff --git a/shallow.c b/shallow.c\nindex 40054b94852..e9ce55bba08 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -31,7 +31,7 @@ int register_shallow(struct repository *r, const struct object_id *oid)\n {\n \tstruct commit_graft *graft =\n \t\txmalloc(sizeof(struct commit_graft));\n-\tstruct commit *commit = lookup_commit(oid);\n+\tstruct commit *commit = lookup_commit(the_repository, oid);\n \n \toidcpy(&graft->oid, oid);\n \tgraft->nr_parent = -1;\n@@ -259,7 +259,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)\n \tif (graft->nr_parent != -1)\n \t\treturn 0;\n \tif (data->flags & SEEN_ONLY) {\n-\t\tstruct commit *c = lookup_commit(&graft->oid);\n+\t\tstruct commit *c = lookup_commit(the_repository, &graft->oid);\n \t\tif (!c || !(c->object.flags & SEEN)) {\n \t\t\tif (data->flags & VERBOSE)\n \t\t\t\tprintf(\"Removing %s from .git/shallow\\n\",\n@@ -624,7 +624,8 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,\n \n \t/* Mark potential bottoms so we won't go out of bound */\n \tfor (i = 0; i < nr_shallow; i++) {\n-\t\tstruct commit *c = lookup_commit(&oid[shallow[i]]);\n+\t\tstruct commit *c = lookup_commit(the_repository,\n+\t\t\t\t\t\t &oid[shallow[i]]);\n \t\tc->object.flags |= BOTTOM;\n \t}\n \n@@ -635,7 +636,8 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,\n \t\tint bitmap_size = DIV_ROUND_UP(pi.nr_bits, 32) * sizeof(uint32_t);\n \t\tmemset(used, 0, sizeof(*used) * info->shallow->nr);\n \t\tfor (i = 0; i < nr_shallow; i++) {\n-\t\t\tconst struct commit *c = lookup_commit(&oid[shallow[i]]);\n+\t\t\tconst struct commit *c = lookup_commit(the_repository,\n+\t\t\t\t\t\t\t       &oid[shallow[i]]);\n \t\t\tuint32_t **map = ref_bitmap_at(&pi.ref_bitmap, c);\n \t\t\tif (*map)\n \t\t\t\tused[shallow[i]] = xmemdupz(*map, bitmap_size);\n@@ -705,7 +707,7 @@ static void post_assign_shallow(struct shallow_info *info,\n \tfor (i = dst = 0; i < info->nr_theirs; i++) {\n \t\tif (i != dst)\n \t\t\tinfo->theirs[dst] = info->theirs[i];\n-\t\tc = lookup_commit(&oid[info->theirs[i]]);\n+\t\tc = lookup_commit(the_repository, &oid[info->theirs[i]]);\n \t\tbitmap = ref_bitmap_at(ref_bitmap, c);\n \t\tif (!*bitmap)\n \t\t\tcontinue;\n@@ -726,7 +728,7 @@ static void post_assign_shallow(struct shallow_info *info,\n \tfor (i = dst = 0; i < info->nr_ours; i++) {\n \t\tif (i != dst)\n \t\t\tinfo->ours[dst] = info->ours[i];\n-\t\tc = lookup_commit(&oid[info->ours[i]]);\n+\t\tc = lookup_commit(the_repository, &oid[info->ours[i]]);\n \t\tbitmap = ref_bitmap_at(ref_bitmap, c);\n \t\tif (!*bitmap)\n \t\t\tcontinue;\n@@ -748,7 +750,8 @@ static void post_assign_shallow(struct shallow_info *info,\n int delayed_reachability_test(struct shallow_info *si, int c)\n {\n \tif (si->need_reachability_test[c]) {\n-\t\tstruct commit *commit = lookup_commit(&si->shallow->oid[c]);\n+\t\tstruct commit *commit = lookup_commit(the_repository,\n+\t\t\t\t\t\t      &si->shallow->oid[c]);\n \n \t\tif (!si->commits) {\n \t\t\tstruct commit_array ca;\ndiff --git a/tag.c b/tag.c\nindex 310102150ab..5dcdf7bf6f9 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -158,7 +158,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n \t} else if (!strcmp(type, tree_type)) {\n \t\titem->tagged = (struct object *)lookup_tree(the_repository, &oid);\n \t} else if (!strcmp(type, commit_type)) {\n-\t\titem->tagged = (struct object *)lookup_commit(&oid);\n+\t\titem->tagged = (struct object *)lookup_commit(the_repository, &oid);\n \t} else if (!strcmp(type, tag_type)) {\n \t\titem->tagged = (struct object *)lookup_tag(&oid);\n \t} else {\ndiff --git a/tree.c b/tree.c\nindex 12b69606ab0..45e89ff08eb 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -101,7 +101,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,\n \t\telse if (S_ISGITLINK(entry.mode)) {\n \t\t\tstruct commit *commit;\n \n-\t\t\tcommit = lookup_commit(entry.oid);\n+\t\t\tcommit = lookup_commit(the_repository, entry.oid);\n \t\t\tif (!commit)\n \t\t\t\tdie(\"Commit %s in submodule path %s%s not found\",\n \t\t\t\t    oid_to_hex(entry.oid),\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351322","messageId":"20180629012222.167426-14-sbeller@google.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"[PATCH v3 13/32] tag: add repository argument to lookup_tag","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T01:22:03Z","receivedAt":"2018-06-29T01:24:13Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of lookup_tag\nto be more specific about which repository to act on. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/describe.c     | 6 +++---\n builtin/pack-objects.c | 2 +-\n builtin/replace.c      | 2 +-\n log-tree.c             | 2 +-\n object.c               | 2 +-\n sha1-name.c            | 2 +-\n tag.c                  | 4 ++--\n tag.h                  | 4 ++--\n 8 files changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex c8ff64766d0..41606c8a900 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -93,13 +93,13 @@ static int replace_name(struct commit_name *e,\n \t\tstruct tag *t;\n \n \t\tif (!e->tag) {\n-\t\t\tt = lookup_tag(&e->oid);\n+\t\t\tt = lookup_tag(the_repository, &e->oid);\n \t\t\tif (!t || parse_tag(t))\n \t\t\t\treturn 1;\n \t\t\te->tag = t;\n \t\t}\n \n-\t\tt = lookup_tag(oid);\n+\t\tt = lookup_tag(the_repository, oid);\n \t\tif (!t || parse_tag(t))\n \t\t\treturn 0;\n \t\t*tag = t;\n@@ -267,7 +267,7 @@ static unsigned long finish_depth_computation(\n static void append_name(struct commit_name *n, struct strbuf *dst)\n {\n \tif (n->prio == 2 && !n->tag) {\n-\t\tn->tag = lookup_tag(&n->oid);\n+\t\tn->tag = lookup_tag(the_repository, &n->oid);\n \t\tif (!n->tag || parse_tag(n->tag))\n \t\t\tdie(_(\"annotated tag %s not available\"), n->path);\n \t}\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 69d3d7b82af..6565c800ac3 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2474,7 +2474,7 @@ static void add_tag_chain(const struct object_id *oid)\n \tif (packlist_find(&to_pack, oid->hash, NULL))\n \t\treturn;\n \n-\ttag = lookup_tag(oid);\n+\ttag = lookup_tag(the_repository, oid);\n \twhile (1) {\n \t\tif (!tag || parse_tag(tag) || !tag->tagged)\n \t\t\tdie(\"unable to pack objects reachable from tag %s\",\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 0232f98f020..0351b7c62cf 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -402,7 +402,7 @@ static int check_one_mergetag(struct commit *commit,\n \tint i;\n \n \thash_object_file(extra->value, extra->len, type_name(OBJ_TAG), &tag_oid);\n-\ttag = lookup_tag(&tag_oid);\n+\ttag = lookup_tag(the_repository, &tag_oid);\n \tif (!tag)\n \t\treturn error(_(\"bad mergetag in commit '%s'\"), ref);\n \tif (parse_tag_buffer(tag, extra->value, extra->len))\ndiff --git a/log-tree.c b/log-tree.c\nindex abe67e8b2e4..840423ca149 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -498,7 +498,7 @@ static int show_one_mergetag(struct commit *commit,\n \tsize_t payload_size, gpg_message_offset;\n \n \thash_object_file(extra->value, extra->len, type_name(OBJ_TAG), &oid);\n-\ttag = lookup_tag(&oid);\n+\ttag = lookup_tag(the_repository, &oid);\n \tif (!tag)\n \t\treturn -1; /* error message already given */\n \ndiff --git a/object.c b/object.c\nindex f08a8874de3..bcfcfd38760 100644\n--- a/object.c\n+++ b/object.c\n@@ -223,7 +223,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e\n \t\t\tobj = &commit->object;\n \t\t}\n \t} else if (type == OBJ_TAG) {\n-\t\tstruct tag *tag = lookup_tag(oid);\n+\t\tstruct tag *tag = lookup_tag(the_repository, oid);\n \t\tif (tag) {\n \t\t\tif (parse_tag_buffer(tag, buffer, size))\n \t\t\t       return NULL;\ndiff --git a/sha1-name.c b/sha1-name.c\nindex 98480ade12d..5854bc75fe2 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -358,7 +358,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \t\t\tformat_commit_message(commit, \" %ad - %s\", &desc, &pp);\n \t\t}\n \t} else if (type == OBJ_TAG) {\n-\t\tstruct tag *tag = lookup_tag(oid);\n+\t\tstruct tag *tag = lookup_tag(the_repository, oid);\n \t\tif (!parse_tag(tag) && tag->tag)\n \t\t\tstrbuf_addf(&desc, \" %s\", tag->tag);\n \t}\ndiff --git a/tag.c b/tag.c\nindex 5dcdf7bf6f9..5b41fc71fad 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -92,7 +92,7 @@ struct object *deref_tag_noverify(struct object *o)\n \treturn o;\n }\n \n-struct tag *lookup_tag(const struct object_id *oid)\n+struct tag *lookup_tag_the_repository(const struct object_id *oid)\n {\n \tstruct object *obj = lookup_object(the_repository, oid->hash);\n \tif (!obj)\n@@ -160,7 +160,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n \t} else if (!strcmp(type, commit_type)) {\n \t\titem->tagged = (struct object *)lookup_commit(the_repository, &oid);\n \t} else if (!strcmp(type, tag_type)) {\n-\t\titem->tagged = (struct object *)lookup_tag(&oid);\n+\t\titem->tagged = (struct object *)lookup_tag(the_repository, &oid);\n \t} else {\n \t\terror(\"Unknown type %s\", type);\n \t\titem->tagged = NULL;\ndiff --git a/tag.h b/tag.h\nindex 9057d76a506..276c448cd55 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -11,8 +11,8 @@ struct tag {\n \tchar *tag;\n \ttimestamp_t date;\n };\n-\n-extern struct tag *lookup_tag(const struct object_id *oid);\n+#define lookup_tag(r, o) lookup_tag_##r(o)\n+extern struct tag *lookup_tag_the_repository(const struct object_id *oid);\n extern int parse_tag_buffer(struct tag *item, const void *data, unsigned long size);\n extern int parse_tag(struct tag *item);\n extern void release_tag_memory(struct tag *t);\n-- \n2.18.0.399.gad0ab374a1-goog\n\n"},{"id":"351336","messageId":"729d08f0-87ac-0a94-97bc-e340d75ae836@gmail.com","threadId":"48799","inReplyTo":"20180629012222.167426-10-sbeller@google.com","subject":"Re: [PATCH v3 09/32] commit: add repository argument to lookup_commit","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-06-29T14:46:47Z","receivedAt":"2018-06-29T14:46:54Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 6/28/2018 9:21 PM, Stefan Beller wrote:\n> Add a repository argument to allow callers of lookup_commit to be more\n> specific about which repository to handle. This is a small mechanical\n> change; it doesn't change the implementation to handle repositories\n> other than the_repository yet.\n>\n> As with the previous commits, use a macro to catch callers passing a\n> repository other than the_repository at compile time.\n\nIn ds/commit-graph-fsck I add a few new callers to lookup_commit(), \nwhich will affect this patch on a reroll.\n\nThanks,\n\n-Stolee\n\n"},{"id":"351337","messageId":"c893b789-ea0b-7c84-c730-b156ecb605be@gmail.com","threadId":"48799","inReplyTo":"20180629012222.167426-11-sbeller@google.com","subject":"Re: [PATCH v3 10/32] commit: add repository argument to parse_commit_buffer","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-06-29T14:49:49Z","receivedAt":"2018-06-29T14:49:55Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 6/28/2018 9:22 PM, Stefan Beller wrote:\n> Add a repository argument to allow the callers of parse_commit_buffer\n> to be more specific about which repository to act on. This is a small\n> mechanical change; it doesn't change the implementation to handle\n> repositories other than the_repository yet.\n>\n> As with the previous commits, use a macro to catch callers passing a\n> repository other than the_repository at compile time.\n>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>   commit.c    | 4 ++--\n>   commit.h    | 3 ++-\n>   object.c    | 2 +-\n>   sha1-file.c | 2 +-\n>   4 files changed, 6 insertions(+), 5 deletions(-)\n>\n> diff --git a/commit.c b/commit.c\n> index 4803c8be1df..75d0bdede84 100644\n> --- a/commit.c\n> +++ b/commit.c\n> @@ -363,7 +363,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n>   \treturn ret;\n>   }\n>   \n> -int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size, int check_graph)\n> +int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size, int check_graph)\n>   {\n>   \tconst char *tail = buffer;\n>   \tconst char *bufptr = buffer;\n> @@ -448,7 +448,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)\n>   \t\treturn error(\"Object %s not a commit\",\n>   \t\t\t     oid_to_hex(&item->object.oid));\n>   \t}\n> -\tret = parse_commit_buffer(item, buffer, size, 0);\n> +\tret = parse_commit_buffer(the_repository, item, buffer, size, 0);\n>   \tif (save_commit_buffer && !ret) {\n>   \t\tset_commit_buffer(item, buffer, size);\n>   \t\treturn 0;\n> diff --git a/commit.h b/commit.h\n> index cd80dab59c1..f326c13622b 100644\n> --- a/commit.h\n> +++ b/commit.h\n> @@ -82,7 +82,8 @@ struct commit *lookup_commit_reference_by_name(const char *name);\n>    */\n>   struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);\n>   \n> -int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size, int check_graph);\n> +#define parse_commit_buffer(r, i, b, s, g) parse_commit_buffer_##r(i, b, s, g)\n> +int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size, int check_graph);\n>   int parse_commit_gently(struct commit *item, int quiet_on_missing);\n>   static inline int parse_commit(struct commit *item)\n>   {\n\nThis part also conflicts with ds/commit-graph-fsck because I added a \n'parse_commit_internal' between parse_commit_buffer() and \nparse_commit_gently(). Likely, you'll want to add a repository struct to \nthat method, too.\n\nThat series also adds new callers to parse_commit_buffer().\n\n> diff --git a/object.c b/object.c\n> index 530c55e41e4..5494c0cbaa1 100644\n> --- a/object.c\n> +++ b/object.c\n> @@ -214,7 +214,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e\n>   \t} else if (type == OBJ_COMMIT) {\n>   \t\tstruct commit *commit = lookup_commit(the_repository, oid);\n>   \t\tif (commit) {\n> -\t\t\tif (parse_commit_buffer(commit, buffer, size, 1))\n> +\t\t\tif (parse_commit_buffer(the_repository, commit, buffer, size, 1))\n>   \t\t\t\treturn NULL;\n>   \t\t\tif (!get_cached_commit_buffer(commit, NULL)) {\n>   \t\t\t\tset_commit_buffer(commit, buffer, size);\n> diff --git a/sha1-file.c b/sha1-file.c\n> index de4839e634c..75ba30b4ab1 100644\n> --- a/sha1-file.c\n> +++ b/sha1-file.c\n> @@ -1801,7 +1801,7 @@ static void check_commit(const void *buf, size_t size)\n>   {\n>   \tstruct commit c;\n>   \tmemset(&c, 0, sizeof(c));\n> -\tif (parse_commit_buffer(&c, buf, size, 0))\n> +\tif (parse_commit_buffer(the_repository, &c, buf, size, 0))\n>   \t\tdie(\"corrupt commit\");\n>   }\n>   \n"},{"id":"351338","messageId":"be744bdb-5a98-8b38-37e1-3d5847e5fbf1@gmail.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"Re: [PATCH v3 00/32] object-store: lookup_commit","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-06-29T14:53:10Z","receivedAt":"2018-06-29T14:53:19Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 6/28/2018 9:21 PM, Stefan Beller wrote:\n> This continues the elimination of global variables in the object store and\n> teaches lookup_commit[_reference] and alike to handle a_repository.\n>\n> This is also available as\n> https://github.com/stefanbeller/git/tree/object-store-lookup-commit\n> or applies on top of 02f70d63027 (Merge branch 'sb/object-store-grafts'\n> into next, 2018-06-28).\n>\n> Picking a base for this one is really hard, as nearly all series currently\n> cooking or in flight collide with it on one or two lines. (lookup_* is used\n> heavily, who would have thought?); I really needed 'sb/object-store-grafts'\n> to build on; and there is only one other series before that in current next,\n> which this series would have conflicted with, if not based on top of it.\n>\n> In \"The state of the object store series\" [1], this was tentatively named\n> \"sb/object-store-lookup\".\n\nAs usual, this series was easy to review. It has a few places where it \nconflicts with ds/commit-graph-fsck, but they are not hard to resolve. I \ncreated a merge commit between that branch and your version of this \nseries [1]. It passes all tests on my machine.\n\nThanks,\n\n-Stolee\n\n[1] \nhttps://github.com/derrickstolee/git/commits/commit-graph-fsck-and-object-store\n\n"},{"id":"351365","messageId":"xmqq8t6xv5kb.fsf@gitster-ct.c.googlers.com","threadId":"48799","inReplyTo":"20180629012222.167426-1-sbeller@google.com","subject":"Re: [PATCH v3 00/32] object-store: lookup_commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-06-29T17:57:40Z","receivedAt":"2018-06-29T17:57:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> This continues the elimination of global variables in the object store and\n> teaches lookup_commit[_reference] and alike to handle a_repository.\n>\n> This is also available as\n> https://github.com/stefanbeller/git/tree/object-store-lookup-commit\n> or applies on top of 02f70d63027 (Merge branch 'sb/object-store-grafts'\n> into next, 2018-06-28).\n>\n> Picking a base for this one is really hard, as nearly all series currently\n> cooking or in flight collide with it on one or two lines. (lookup_* is used\n> heavily, who would have thought?)\n\nOne technique these (not just this) recent efforts seem to be\nforgetting is to introduce \"new\" names that take a_repo and then\nmake the existing one a thin wrapper that calls the new one with\n&the_repo as the argument.\n\nIOW, a new call to lookup_commit_reference(oid) in a function that\nis happy to access the default repo (and notice taht 99% of our code\nis happy with using just the currrent repository the user started\nthe git process for) does not need to be updated to call the\nfunction with the same name with a different function signature\nlookup_commit_reference(the_repo, oid).  If we name the new one\nlookup_commit_reference_in_repo(r, oid) and make the callers that\nalready take a repo pointer call it, while leaving the callers that\ndo not even know or care about multiple in-core repo instances alone\nto keep calling lookup_commit_reference(oid), you do not have to\nworry too much about colliding.  That way, you do not have to step\non each others' toes with avoidable semantic merge conflicts and\nincrementally improve things over time, no?\n\nThanks.\n"},{"id":"351366","messageId":"xmqq4lhlv5a8.fsf@gitster-ct.c.googlers.com","threadId":"48799","inReplyTo":"xmqq8t6xv5kb.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3 00/32] object-store: lookup_commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-06-29T18:03:43Z","receivedAt":"2018-06-29T18:03:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> One technique these (not just this) recent efforts seem to be\n> forgetting is to introduce \"new\" names that take a_repo and then\n> make the existing one a thin wrapper that calls the new one with\n> &the_repo as the argument.\n\nFWIW, here is how I am resolving semantic conflicts that I found so\nfar while merging this topic to 'pu', which is stored in the\nmerge-fix/ mechanism so that I can reuse it while rebuilding 'pu'.\n\n-- >8 --\nSubject: [PATCH] merge-fix/sb/object-store-lookup\n\n---\n builtin/bisect--helper.c | 2 +-\n builtin/branch-diff.c    | 2 +-\n commit-graph.c           | 4 ++--\n negotiator/default.c     | 3 ++-\n 4 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex fc02f889e6..b27f645744 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -231,7 +231,7 @@ static int bisect_write(const char *state, const char *rev,\n \t\tgoto fail;\n \t}\n \n-\tcommit = lookup_commit_reference(&oid);\n+\tcommit = lookup_commit_reference(the_repository, &oid);\n \tlog_commit(fp, \"%s\", state, commit);\n \n \tif (!nolog)\ndiff --git a/builtin/branch-diff.c b/builtin/branch-diff.c\nindex 8a16352e3a..b8604e3fec 100644\n--- a/builtin/branch-diff.c\n+++ b/builtin/branch-diff.c\n@@ -329,7 +329,7 @@ static void output_pair_header(struct diff_options *diffopt, struct strbuf *buf,\n \t\tstrbuf_addf(buf, \" %d:  %s\", j + 1,\n \t\t\t    find_unique_abbrev(&b_util->oid, DEFAULT_ABBREV));\n \n-\tcommit = lookup_commit_reference(oid);\n+\tcommit = lookup_commit_reference(the_repository, oid);\n \tif (commit) {\n \t\tconst char *commit_buffer = get_commit_buffer(commit, NULL);\n \t\tconst char *subject;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex e4dee03679..41a0133ff7 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -924,7 +924,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)\n \t\t\tcur_fanout_pos++;\n \t\t}\n \n-\t\tgraph_commit = lookup_commit(&cur_oid);\n+\t\tgraph_commit = lookup_commit(r, &cur_oid);\n \t\tif (!parse_commit_in_graph_one(g, graph_commit))\n \t\t\tgraph_report(\"failed to parse %s from commit-graph\",\n \t\t\t\t     oid_to_hex(&cur_oid));\n@@ -950,7 +950,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)\n \n \t\thashcpy(cur_oid.hash, g->chunk_oid_lookup + g->hash_len * i);\n \n-\t\tgraph_commit = lookup_commit(&cur_oid);\n+\t\tgraph_commit = lookup_commit(r, &cur_oid);\n \t\todb_commit = (struct commit *)create_object(r, cur_oid.hash, alloc_commit_node(r));\n \t\tif (parse_commit_internal(odb_commit, 0, 0)) {\n \t\t\tgraph_report(\"failed to parse %s from object database\",\ndiff --git a/negotiator/default.c b/negotiator/default.c\nindex 382fc77722..d8c92281bb 100644\n--- a/negotiator/default.c\n+++ b/negotiator/default.c\n@@ -38,7 +38,8 @@ static void rev_list_push(struct negotiation_state *ns,\n static int clear_marks(const char *refname, const struct object_id *oid,\n \t\t       int flag, void *cb_data)\n {\n-\tstruct object *o = deref_tag(parse_object(oid), refname, 0);\n+\tstruct object *o = deref_tag(the_repository,\n+\t\t\t\t     parse_object(the_repository, oid), refname, 0);\n \n \tif (o && o->type == OBJ_COMMIT)\n \t\tclear_commit_marks((struct commit *)o,\n-- \n2.18.0-129-ge3331758f1\n\n\n\n"},{"id":"351368","messageId":"CAGZ79kb=W5_3FB6qSinPpcPzRgAe-qkuOCkXTjs6RLqUTjoboA@mail.gmail.com","threadId":"48799","inReplyTo":"xmqq4lhlv5a8.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3 00/32] object-store: lookup_commit","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-29T18:34:48Z","receivedAt":"2018-06-29T18:35:03Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Fri, Jun 29, 2018 at 11:03 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n> > One technique these (not just this) recent efforts seem to be\n> > forgetting is to introduce \"new\" names that take a_repo and then\n> > make the existing one a thin wrapper that calls the new one with\n> > &the_repo as the argument.\n\nSo you'd rather want to see it less invasive done similar to\nNO_THE_INDEX_COMPATIBILITY_MACROS ? Someone (jrnieder?)\ncalled that a failed experiment, as now we need to carry that baggage\nfor quite some time and never cleaned up the started migration;\nonly recently Duy started to kill off the_index, which would finish\nthat migration?\n\n\n\n> FWIW, here is how I am resolving semantic conflicts that I found so\n> far while merging this topic to 'pu', which is stored in the\n> merge-fix/ mechanism so that I can reuse it while rebuilding 'pu'.\n>\n> -- >8 --\n> Subject: [PATCH] merge-fix/sb/object-store-lookup\n>\n> ---\n>  builtin/bisect--helper.c | 2 +-\n>  builtin/branch-diff.c    | 2 +-\n>  negotiator/default.c     | 3 ++-\n\nThese look as if we can just use the_repository\n(as you did below).\n\n>  commit-graph.c           | 4 ++--\n\nThat is what I want to tackle next, and apparently you already did\nby using the repository *r in there.\n\nThanks,\nStefan\n"},{"id":"351371","messageId":"xmqqvaa1tme8.fsf@gitster-ct.c.googlers.com","threadId":"48799","inReplyTo":"CAGZ79kb=W5_3FB6qSinPpcPzRgAe-qkuOCkXTjs6RLqUTjoboA@mail.gmail.com","subject":"Re: [PATCH v3 00/32] object-store: lookup_commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-06-29T19:37:03Z","receivedAt":"2018-06-29T19:37:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> On Fri, Jun 29, 2018 at 11:03 AM Junio C Hamano <gitster@pobox.com> wrote:\n>>\n>> Junio C Hamano <gitster@pobox.com> writes:\n>>\n>> > One technique these (not just this) recent efforts seem to be\n>> > forgetting is to introduce \"new\" names that take a_repo and then\n>> > make the existing one a thin wrapper that calls the new one with\n>> > &the_repo as the argument.\n>\n> So you'd rather want to see it less invasive done similar to\n> NO_THE_INDEX_COMPATIBILITY_MACROS ? Someone (jrnieder?)\n> called that a failed experiment, as now we need to carry that baggage\n> for quite some time and never cleaned up the started migration;\n> only recently Duy started to kill off the_index, which would finish\n> that migration?\n\nI do not think it was a failed experiment at all.  In fact, most of\nour code is still happy with the single in-core instance of\nthe_index, and I think it is a mistake to trying to use the variant\nthat take an istate instance as parameter just for the sake of it.\n\nIOW, if there is a good concrete reason why it helps to teach the\nset of functions involved in a callchain to operate on an in-core\ninstance of the index_state, passing an istate through the callchain\nis a very welcome change.  If you do not do so, and then just\nreplace $foo_cache(...) with $foo_index(&the_index, ...), that is an\nirritating and useless code churn that harms other topics in flight.\n\n"},{"id":"351390","messageId":"20180629222004.GA197765@google.com","threadId":"48799","inReplyTo":"xmqqvaa1tme8.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3 00/32] object-store: lookup_commit","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2018-06-29T22:20:04Z","receivedAt":"2018-06-29T22:20:10Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 06/29, Junio C Hamano wrote:\n> Stefan Beller <sbeller@google.com> writes:\n> \n> > On Fri, Jun 29, 2018 at 11:03 AM Junio C Hamano <gitster@pobox.com> wrote:\n> >>\n> >> Junio C Hamano <gitster@pobox.com> writes:\n> >>\n> >> > One technique these (not just this) recent efforts seem to be\n> >> > forgetting is to introduce \"new\" names that take a_repo and then\n> >> > make the existing one a thin wrapper that calls the new one with\n> >> > &the_repo as the argument.\n> >\n> > So you'd rather want to see it less invasive done similar to\n> > NO_THE_INDEX_COMPATIBILITY_MACROS ? Someone (jrnieder?)\n> > called that a failed experiment, as now we need to carry that baggage\n> > for quite some time and never cleaned up the started migration;\n> > only recently Duy started to kill off the_index, which would finish\n> > that migration?\n> \n> I do not think it was a failed experiment at all.  In fact, most of\n> our code is still happy with the single in-core instance of\n> the_index, and I think it is a mistake to trying to use the variant\n> that take an istate instance as parameter just for the sake of it.\n> \n> IOW, if there is a good concrete reason why it helps to teach the\n> set of functions involved in a callchain to operate on an in-core\n> instance of the index_state, passing an istate through the callchain\n> is a very welcome change.  If you do not do so, and then just\n> replace $foo_cache(...) with $foo_index(&the_index, ...), that is an\n> irritating and useless code churn that harms other topics in flight.\n\nI 100% think that we need to continue these refactorings with both the\nobject store as well as with the_index (removing the index macros and\nremoving the dependency on global state).  The whole compat macros most\ndefinitely was a failed experiment as we still haven't rid the code\nbase of them yet.  Having two APIs which can be used interchangeably\nfrom different pieces of library code which have very different\nsemantics is _very_ difficult for contributors to reason about and work\naround.  Especially when one API relies on implied global state while\nthe other does not.  (If global state isn't involved, as in the char[20]\n-> OID work, then having two APIs is 'ok' so long as you're working\ntowards converging to one API).\n\nHaving clean APIs makes it incredible easy to reason about sections of\ncode, reason about multi-threading, and implement newer features in a\nsane manner (talking about submodules here).  I implemented submodule\nsupport for grep twice, once using a multi-process paradigm because we\ncould not have two repositories open in a single process and then an\nin-process one once a minimum viable solution for opening multiple\nrepositories in a single process was created.  Being able to open up a\nsubmodule repository in-process made things infinitely simpler to reason\nabout as well as made it much easier to handle errors. This work needs\nto continue if we want to improve the submodule experience in git.\n\nYes this might mean there are a few more conflicts when merging a series\n(because of the scope of these refactorings) but it is well worth it\ngiven what the end-state will look like.\n\n-- \nBrandon Williams\n"},{"id":"351632","messageId":"xmqq8t6srxvq.fsf@gitster-ct.c.googlers.com","threadId":"48799","inReplyTo":"20180629222004.GA197765@google.com","subject":"Re: [PATCH v3 00/32] object-store: lookup_commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-07-03T18:13:13Z","receivedAt":"2018-07-03T18:13:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Williams <bmwill@google.com> writes:\n\n> I 100% think that we need to continue these refactorings with both the\n> object store as well as with the_index (removing the index macros and\n> removing the dependency on global state).  The whole compat macros most\n> definitely was a failed experiment as we still haven't rid the code\n> base of them yet.\n\nThese two are completely different things.  You can call the compat\nmacros a failed experiment only if two things hold true: (1) we want\nto force all callsites to explicitly pass the_index even when they\nalways work on the primary in-core instance of istate and (2) they\nwere invented primarily in the hope that their presense will help us\nachieve (1) sooner.  And neither is true.  The mechanism to allow\nmultiple in-core istate were of course helpful in places like branch\nswitching and merging, but we expected that the majority of\nthen-existing code would be required to work on the primary in-core\nindex, so s/foo_cache(/foo_index(&the_index/ conversion all over the\nplace were noisier than it was worth.  The compat macros were not\nintroduced as an experiment to help wean ourselves off of the\nfoo_cache API.  It was a total opposite---it was a consideration on\nproduction code to help existing code keep working in backward\ncompatible way.  In short, they were neither failed nor experiment.\n\nWhat you _could_ say about them, given that more code than before\nwould benefit by learning to work on istate instances other than the\ndefault &the_index these days, is that they may have outlived their\nusefulness, though.\n"}]}