{"thread":{"id":"48596","subject":"[RFC PATCH 00/35] object-store: lookup_commit","startedAt":"2018-05-30T00:48:27Z","lastAt":"2018-06-14T21:32:01Z","messageCount":92,"participants":["Stefan Beller","Derrick Stolee","Duy Nguyen","Brandon Williams"],"isPatch":true,"patchVersion":1,"patchTotal":35},"messages":[{"id":"348732","messageId":"20180530004810.30076-1-sbeller@google.com","threadId":"48596","inReplyTo":null,"subject":"[RFC PATCH 00/35] object-store: lookup_commit","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:35Z","receivedAt":"2018-05-30T00:48:27Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This 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\nJonathan Nieder (1):\n  object: add repository argument to lookup_unknown_object\n\nStefan Beller (34):\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: add repository argument to parse_commit_gently\n  commit: add repository argument to parse_commit\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                          |  17 +++---\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               |  10 ++--\n builtin/clone.c                  |   3 +-\n builtin/commit-tree.c            |   4 +-\n builtin/commit.c                 |   2 +-\n builtin/describe.c               |  17 +++---\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                   |  22 ++++---\n builtin/grep.c                   |   3 +-\n builtin/index-pack.c             |   5 +-\n builtin/log.c                    |  10 ++--\n builtin/merge-base.c             |   9 +--\n builtin/merge-tree.c             |   3 +-\n builtin/name-rev.c               |  15 +++--\n builtin/notes.c                  |   5 +-\n builtin/pack-objects.c           |   4 +-\n builtin/prune.c                  |   2 +-\n builtin/pull.c                   |  15 +++--\n builtin/receive-pack.c           |   6 +-\n builtin/reflog.c                 |  17 +++---\n builtin/replace.c                |   4 +-\n builtin/reset.c                  |   4 +-\n builtin/rev-list.c               |   2 +-\n builtin/rev-parse.c              |   6 +-\n builtin/show-branch.c            |   9 +--\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                   |  20 +++----\n commit-slab-impl.h               |   3 -\n commit.c                         | 100 ++++++++++++++++++-------------\n commit.h                         |  24 +++++---\n fast-import.c                    |   6 +-\n fetch-pack.c                     |  45 ++++++++------\n fsck.c                           |   9 +--\n http-backend.c                   |   4 +-\n http-push.c                      |  18 +++---\n line-log.c                       |   2 +-\n list-objects.c                   |   4 +-\n log-tree.c                       |  13 ++--\n merge-recursive.c                |  15 +++--\n notes-cache.c                    |   3 +-\n notes-merge.c                    |   5 +-\n notes-utils.c                    |   6 +-\n object.c                         |  63 ++++++++++---------\n object.h                         |  13 ++--\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                           |   4 +-\n refs/files-backend.c             |   2 +-\n remote.c                         |  21 ++++---\n revision.c                       |  37 ++++++------\n sequencer.c                      |  30 +++++-----\n server-info.c                    |   4 +-\n sha1-file.c                      |   4 +-\n sha1-name.c                      |  37 ++++++------\n shallow.c                        |  34 +++++++----\n submodule.c                      |  10 ++--\n t/helper/test-example-decorate.c |   6 +-\n tag.c                            |  28 ++++-----\n tag.h                            |   7 +--\n tree.c                           |  21 +++----\n tree.h                           |   2 +-\n upload-pack.c                    |  19 +++---\n walker.c                         |  16 +++--\n wt-status.c                      |   2 +-\n 83 files changed, 547 insertions(+), 423 deletions(-)\n\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348733","messageId":"20180530004810.30076-2-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 01/35] object: add repository argument to parse_object","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:36Z","receivedAt":"2018-05-30T00:48:31Z","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 16bfb22f738..ed6092ef1a3 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -393,7 +393,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 cb4b1c7f815..0da875b58c9 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -802,7 +802,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 9d59d7d5a21..4b410cba54e 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@@ -616,7 +616,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 cff0d58d698..063057e45de 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 7adb61a37f2..0a74fcc7b0a 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 bee4795a936..3a751fbaa60 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 00ada05f46c..9ef55f6bdb0 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 ddb6c04738b..11db72e9db2 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -26,7 +26,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@@ -1616,7 +1617,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 44e50b57d98..fa39ada77ee 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@@ -1296,7 +1298,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 104c3c0a434..f9476f56e93 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@@ -462,7 +463,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 f308ce0195a..311b6295359 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 9c3053600a4..e8d2857bf06 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@@ -111,13 +112,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@@ -138,7 +139,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 41cf9512d63..8ddedf79c0b 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@@ -2183,7 +2184,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 30b8a721cf6..469e6126286 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 998145de46a..f69095d3dde 100644\n--- a/object.h\n+++ b/object.h\n@@ -121,7 +121,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 1ec86930209..85ef0909087 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1924,7 +1924,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 34fe891fc03..c99f8243faf 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 7b9e44dcaba..6ebb4630f9c 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@@ -1898,7 +1899,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 49d8f67bf13..942f6a0c219 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 db438cfbc56..92a17828d25 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1994,12 +1994,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 a00c43219fb..f051c6c5806 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -187,7 +187,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@@ -199,7 +199,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@@ -236,7 +236,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@@ -1239,7 +1239,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@@ -1567,8 +1567,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@@ -2872,7 +2872,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 83460ec0d6f..368fb547f4b 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 b5406b6eb21..3e1c57e1539 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@@ -857,7 +857,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@@ -930,12 +930,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@@ -1062,7 +1062,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@@ -1108,7 +1108,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 dc20a2693fd..1033e69b590 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 3627e8fafa5..afe997c89ec 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@@ -798,7 +799,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@@ -1168,7 +1169,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@@ -1274,7 +1275,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 a80811f6d5e..3678e344312 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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348734","messageId":"20180530004810.30076-3-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 02/35] object: add repository argument to lookup_object","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:37Z","receivedAt":"2018-05-30T00:48:32Z","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 0da875b58c9..24d42842f9d 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -231,7 +231,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@@ -403,7 +403,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 4b410cba54e..98fdeef5407 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@@ -762,7 +762,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 ded798b72ff..9a4d2708123 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 11db72e9db2..97b4ccde8f0 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -53,7 +53,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 fa39ada77ee..4523e25ff4e 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@@ -1295,7 +1296,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 311b6295359..2615c823d60 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 469e6126286..4de4fa58d59 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 f69095d3dde..fa41d711f44 100644\n--- a/object.h\n+++ b/object.h\n@@ -110,7 +110,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 1033e69b590..47ecc85f90a 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 afe997c89ec..20e61180e48 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -568,7 +568,7 @@ static int get_reachable_list(struct object_array *src,\n \t\tif (namebuf[40] != '\\n' || get_oid_hex(namebuf, &sha1))\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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348735","messageId":"20180530004810.30076-5-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 04/35] object: add repository argument to parse_object_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:39Z","receivedAt":"2018-05-30T00:48:39Z","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\nAdd the cocci patch that converted the callers.\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           | 6 ++++--\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, 17 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 24d42842f9d..a34ab9768f4 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -245,7 +245,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 700739804fc..e6d6eb266eb 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@@ -522,7 +523,8 @@ static struct object *parse_loose_object(const struct object_id *oid,\n \tif (!contents && type != OBJ_BLOB)\n \t\tdie(\"BUG: read_loose_object streamed a non-blob\");\n \n-\tobj = parse_object_buffer(oid, type, size, contents, &eaten);\n+\tobj = parse_object_buffer(the_repository, oid, type, size,\n+\t\t\t\t  contents, &eaten);\n \n \tif (!eaten)\n \t\tfree(contents);\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex e2f670bef9e..0dd10693597 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -848,7 +848,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 9a4d2708123..8e454c48649 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 def3c71cac2..4250ddd3f7f 100644\n--- a/object.c\n+++ b/object.c\n@@ -186,7 +186,7 @@ struct object *lookup_unknown_object_the_repository(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 778f83bf0f7..c6386d7b6b1 100644\n--- a/object.h\n+++ b/object.h\n@@ -136,7 +136,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 #define lookup_unknown_object(r, s) lookup_unknown_object_##r(s)\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 6ebb4630f9c..7e57c07bf54 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -806,7 +806,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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348736","messageId":"20180530004810.30076-4-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 03/35] object: add repository argument to lookup_unknown_object","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:38Z","receivedAt":"2018-05-30T00:48:41Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nAdd a repository argument to allow callers of lookup_unknown_object 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\nThe included coccinelle semantic patch will adapt any new callers in\nthe diff produced by `make coccicheck`.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/fsck.c                   | 2 +-\n builtin/pack-objects.c           | 2 +-\n http-push.c                      | 2 +-\n object.c                         | 2 +-\n object.h                         | 3 ++-\n refs.c                           | 2 +-\n t/helper/test-example-decorate.c | 6 +++---\n upload-pack.c                    | 2 +-\n walker.c                         | 2 +-\n 9 files changed, 12 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 98fdeef5407..700739804fc 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -638,7 +638,7 @@ static int fsck_cache_tree(struct cache_tree *it)\n \n static void mark_object_for_connectivity(const struct object_id *oid)\n {\n-\tstruct object *obj = lookup_unknown_object(oid->hash);\n+\tstruct object *obj = lookup_unknown_object(the_repository, oid->hash);\n \tobj->flags |= HAS_OBJ;\n }\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 8c108109985..6eae39cf858 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2689,7 +2689,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)\n \n \t\tfor (i = 0; i < p->num_objects; i++) {\n \t\t\tnth_packed_object_oid(&oid, p, i);\n-\t\t\to = lookup_unknown_object(oid.hash);\n+\t\t\to = lookup_unknown_object(the_repository, oid.hash);\n \t\t\tif (!(o->flags & OBJECT_ADDED))\n \t\t\t\tmark_in_pack_object(o, p, &in_pack);\n \t\t\to->flags |= OBJECT_ADDED;\ndiff --git a/http-push.c b/http-push.c\nindex 2615c823d60..04d95bd5da8 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1429,7 +1429,7 @@ static void one_remote_ref(const char *refname)\n \t * may be required for updating server info later.\n \t */\n \tif (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {\n-\t\tobj = lookup_unknown_object(ref->old_oid.hash);\n+\t\tobj = lookup_unknown_object(the_repository, ref->old_oid.hash);\n \t\tfprintf(stderr,\t\"  fetch %s for %s\\n\",\n \t\t\toid_to_hex(&ref->old_oid), refname);\n \t\tadd_fetch_request(obj);\ndiff --git a/object.c b/object.c\nindex 4de4fa58d59..def3c71cac2 100644\n--- a/object.c\n+++ b/object.c\n@@ -177,7 +177,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)\n \t}\n }\n \n-struct object *lookup_unknown_object(const unsigned char *sha1)\n+struct object *lookup_unknown_object_the_repository(const unsigned char *sha1)\n {\n \tstruct object *obj = lookup_object(the_repository, sha1);\n \tif (!obj)\ndiff --git a/object.h b/object.h\nindex fa41d711f44..778f83bf0f7 100644\n--- a/object.h\n+++ b/object.h\n@@ -139,7 +139,8 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name\n struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);\n \n /** Returns the object, with potentially excess memory allocated. **/\n-struct object *lookup_unknown_object(const unsigned  char *sha1);\n+#define lookup_unknown_object(r, s) lookup_unknown_object_##r(s)\n+struct object *lookup_unknown_object_the_repository(const unsigned char *sha1);\n \n struct object_list *object_list_insert(struct object *item,\n \t\t\t\t       struct object_list **list_p);\ndiff --git a/refs.c b/refs.c\nindex 23d53957deb..3b9e8463656 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -301,7 +301,7 @@ static int filter_refs(const char *refname, const struct object_id *oid,\n \n enum peel_status peel_object(const struct object_id *name, struct object_id *oid)\n {\n-\tstruct object *o = lookup_unknown_object(name->hash);\n+\tstruct object *o = lookup_unknown_object(the_repository, name->hash);\n \n \tif (o->type == OBJ_NONE) {\n \t\tint type = oid_object_info(the_repository, name, NULL);\ndiff --git a/t/helper/test-example-decorate.c b/t/helper/test-example-decorate.c\nindex 081115bf8eb..33e727f7fc5 100644\n--- a/t/helper/test-example-decorate.c\n+++ b/t/helper/test-example-decorate.c\n@@ -26,8 +26,8 @@ int cmd__example_decorate(int argc, const char **argv)\n \t * Add 2 objects, one with a non-NULL decoration and one with a NULL\n \t * decoration.\n \t */\n-\tone = lookup_unknown_object(one_oid.hash);\n-\ttwo = lookup_unknown_object(two_oid.hash);\n+\tone = lookup_unknown_object(the_repository, one_oid.hash);\n+\ttwo = lookup_unknown_object(the_repository, two_oid.hash);\n \tret = add_decoration(&n, one, &decoration_a);\n \tif (ret)\n \t\tdie(\"BUG: when adding a brand-new object, NULL should be returned\");\n@@ -56,7 +56,7 @@ int cmd__example_decorate(int argc, const char **argv)\n \tret = lookup_decoration(&n, two);\n \tif (ret != &decoration_b)\n \t\tdie(\"BUG: lookup should return added declaration\");\n-\tthree = lookup_unknown_object(three_oid.hash);\n+\tthree = lookup_unknown_object(the_repository, three_oid.hash);\n \tret = lookup_decoration(&n, three);\n \tif (ret)\n \t\tdie(\"BUG: lookup for unknown object should return NULL\");\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 20e61180e48..aebab6f3277 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -971,7 +971,7 @@ static void receive_needs(void)\n static int mark_our_ref(const char *refname, const char *refname_full,\n \t\t\tconst struct object_id *oid)\n {\n-\tstruct object *o = lookup_unknown_object(oid->hash);\n+\tstruct object *o = lookup_unknown_object(the_repository, oid->hash);\n \n \tif (ref_is_hidden(refname, refname_full)) {\n \t\to->flags |= HIDDEN_REF;\ndiff --git a/walker.c b/walker.c\nindex 3678e344312..aea96f0eaff 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -282,7 +282,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,\n \t\t\terror(\"Could not interpret response from server '%s' as something to pull\", target[i]);\n \t\t\tgoto done;\n \t\t}\n-\t\tif (process(walker, lookup_unknown_object(oids[i].hash)))\n+\t\tif (process(walker, lookup_unknown_object(the_repository, oids[i].hash)))\n \t\t\tgoto done;\n \t}\n \n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348737","messageId":"20180530004810.30076-6-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 05/35] object: add repository argument to object_as_type","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:40Z","receivedAt":"2018-05-30T00:48:44Z","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 e6d6eb266eb..82a5acaf76e 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 97b4ccde8f0..d76d64d4dfc 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -31,7 +31,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@@ -57,7 +57,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 4250ddd3f7f..bd5df7d007a 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 c6386d7b6b1..f2afe7cc66f 100644\n--- a/object.h\n+++ b/object.h\n@@ -115,7 +115,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 3b9e8463656..310d5f81dbf 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 47ecc85f90a..bd74ed66e23 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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348738","messageId":"20180530004810.30076-7-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 06/35] blob: add repository argument to lookup_blob","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:41Z","receivedAt":"2018-05-30T00:48: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 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\nAdd the cocci patch that converted the callers.\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                   | 2 +-\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, 22 insertions(+), 17 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 a34ab9768f4..23ca46e6008 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -237,7 +237,7 @@ static void export_blob(const struct object_id *oid)\n \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 82a5acaf76e..6e2b204e938 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -808,7 +808,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 0dd10693597..51c5244a15a 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 8e454c48649..dfea7790fde 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 f9476f56e93..2d372f2a3f3 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -367,7 +367,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);\ndiff --git a/http-push.c b/http-push.c\nindex 04d95bd5da8..730e9cd0667 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 7ae0eb8ebc7..56682c2a441 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 bd5df7d007a..80a8e44832f 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 f051c6c5806..aeccbf5fe24 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -69,7 +69,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@@ -1338,7 +1338,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 aea96f0eaff..a36f53f37be 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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348739","messageId":"20180530004810.30076-11-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 10/35] commit: add repository argument to lookup_commit","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:45Z","receivedAt":"2018-05-30T00:48:52Z","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 f4b510bcc5f..fb7c21f7103 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 23ca46e6008..bc837d2593c 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -964,7 +964,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 5345cc90ed1..6c08fc0a9ba 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -241,7 +241,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@@ -527,7 +527,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@@ -538,14 +538,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@@ -658,7 +658,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 e031a6c3175..5e3f18801a1 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -51,7 +51,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@@ -373,7 +373,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@@ -381,7 +381,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 a5f84466efd..431a7d97a24 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -53,7 +53,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 4523e25ff4e..74ac2977e85 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@@ -1256,7 +1257,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 e8d2857bf06..a47283eca64 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -147,7 +147,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 3fa7722d673..f4207d09e9f 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))\n \t\t\t\treturn NULL;\ndiff --git a/sequencer.c b/sequencer.c\nindex 8931c461f20..da6c9fc5511 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -543,7 +543,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@@ -972,7 +972,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 d153d8c692b..5eef8ddd6d6 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -352,7 +352,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 9bb07a56dca..60fe1fe1e58 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@@ -256,7 +256,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@@ -621,7 +621,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@@ -632,7 +633,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@@ -702,7 +704,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@@ -723,7 +725,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@@ -745,7 +747,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 fbc8d4bc653..33063b8dde0 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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348740","messageId":"20180530004810.30076-10-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 09/35] commit: add repository argument to lookup_commit_reference","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:44Z","receivedAt":"2018-05-30T00:48:56Z","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/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 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           | 10 +++++-----\n 25 files changed, 63 insertions(+), 49 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 726a7a76f20..86d0dd73338 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 9b2742de32a..08d4efc1be6 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -301,7 +301,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 efc9ac1922c..fbbe311e270 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -126,7 +126,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@@ -159,7 +160,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@@ -213,7 +214,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 2f10c468300..5b10ddfc832 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -695,7 +695,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 f3dfd0228be..080b5ce082c 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 063057e45de..c962d22707b 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 6011cd2a074..50963642075 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 324c4ffa1a7..ec3f90545dd 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -760,10 +760,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@@ -937,9 +940,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/reset.c b/builtin/reset.c\nindex a9136a163c0..aeab0c7aea5 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 a8a9b506ff6..cc6a6c9a019 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\texclude = get_merge_bases(a, b);\n \t\t\twhile (exclude) {\n \t\t\t\tstruct commit *commit = pop_commit(&exclude);\n@@ -333,7 +333,7 @@ static int try_parent_shorthands(const char *arg)\n \t\treturn 0;\n \t}\n \n-\tcommit = lookup_commit_reference(&oid);\n+\tcommit = lookup_commit_reference(the_repository, &oid);\n \tif (exclude_parent &&\n \t    exclude_parent > commit_list_count(commit->parents)) {\n \t\t*dotdot = '^';\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 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 14a209ff149..904b59e72a5 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 b039444aa62..e031a6c3175 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -34,14 +34,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@@ -67,7 +67,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 73ccdd8005b..a5f84466efd 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -54,7 +54,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/notes-merge.c b/notes-merge.c\nindex fd96c5ab3d6..2572e435432 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 956fd0fd923..2a6ff7d60c1 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -2058,13 +2058,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 79f228b1586..25df00cc16c 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1581,8 +1581,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 4e89e2b1123..8931c461f20 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1047,7 +1047,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@@ -1370,7 +1370,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@@ -1824,7 +1824,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 412a5257d6f..d153d8c692b 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -810,7 +810,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@@ -838,7 +838,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 8fd8e5d178d..e45150a3f51 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -516,8 +516,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@@ -1800,9 +1800,9 @@ int merge_submodule(struct object_id *result, const char *path,\n \t\treturn 0;\n \t}\n \n-\tif (!(commit_base = lookup_commit_reference(base)) ||\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\tMERGE_WARNING(path, \"commits not present\");\n \t\treturn 0;\n \t}\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348741","messageId":"20180530004810.30076-9-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 08/35] commit: add repository argument to lookup_commit_reference_gently","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:43Z","receivedAt":"2018-05-30T00:48:56Z","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 9da1e3664a6..983a45ba3e7 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 2904b0500d9..726a7a76f20 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 105e07981ff..31a71f75625 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@@ -823,7 +823,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@@ -997,7 +997,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 58341c6f9ed..f3dfd0228be 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 6ce11bfb094..499cf6fcf12 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -690,8 +690,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@@ -824,7 +826,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 93dabd7ce31..6ff3c5abff0 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 9ef55f6bdb0..14a209ff149 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 88a4b0d2a47..5345cc90ed1 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -622,7 +622,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 755b8b9d94f..b039444aa62 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -23,8 +23,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@@ -36,7 +36,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 9019652dbac..73ccdd8005b 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -55,7 +55,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 b2338fa8eb2..fadc2c70021 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 7e57c07bf54..8133871e93d 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -2010,7 +2010,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@@ -2367,7 +2368,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 92a17828d25..956fd0fd923 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1337,7 +1337,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@@ -1399,7 +1399,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@@ -1627,8 +1628,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 bf5620dff0c..4e89e2b1123 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2886,7 +2886,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 3e1c57e1539..412a5257d6f 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -1217,13 +1217,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 7cb893c3d94..9bb07a56dca 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -489,7 +489,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@@ -551,7 +552,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@@ -661,7 +663,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 288006d52d5..c7c9db83df7 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 e35cdfeb4be..40ccf2dccb5 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1481,7 +1481,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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348742","messageId":"20180530004810.30076-8-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 07/35] tree: add repository argument to lookup_tree","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:42Z","receivedAt":"2018-05-30T00:49:00Z","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\nAdd the cocci patch that converted the callers.\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 d834f9e62b6..f4b510bcc5f 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 ed6092ef1a3..0b7d0d612dd 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -379,7 +379,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 3a751fbaa60..93dabd7ce31 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 1c338c41f3a..69b214613dd 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 71125d7cbb6..88a4b0d2a47 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -261,7 +261,7 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin\n \titem->graph_pos = pos;\n \n \thashcpy(oid.hash, commit_data);\n-\titem->tree = lookup_tree(&oid);\n+\titem->tree = lookup_tree(the_repository, &oid);\n \n \tdate_high = get_be32(commit_data + g->hash_len + 8) & 0x3;\n \tdate_low = get_be32(commit_data + g->hash_len + 12);\ndiff --git a/commit.c b/commit.c\nindex d76d64d4dfc..755b8b9d94f 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -354,7 +354,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s\n \tif (get_sha1_hex(bufptr + 5, parent.hash) < 0)\n \t\treturn error(\"bad tree pointer in commit %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\n-\titem->tree = lookup_tree(&parent);\n+\titem->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 2d372f2a3f3..b07abb9796c 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -360,7 +360,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 730e9cd0667..f27026daf8f 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 56682c2a441..b9159c24671 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 8ddedf79c0b..1b06f25b38c 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -96,7 +96,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@@ -335,7 +335,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@@ -2123,7 +2123,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 80a8e44832f..3fa7722d673 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 aeccbf5fe24..79f228b1586 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -66,7 +66,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@@ -1312,7 +1312,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 d715c877501..bf5620dff0c 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -397,7 +397,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 bd74ed66e23..fbc8d4bc653 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 a36f53f37be..288006d52d5 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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348743","messageId":"20180530004810.30076-12-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 11/35] commit: add repository argument to parse_commit_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:46Z","receivedAt":"2018-05-30T00:49: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 5e3f18801a1..dda585025ed 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -334,7 +334,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)\n+int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size)\n {\n \tconst char *tail = buffer;\n \tconst char *bufptr = buffer;\n@@ -416,7 +416,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);\n+\tret = parse_commit_buffer(the_repository, item, buffer, size);\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 431a7d97a24..05b9eccaf66 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -72,7 +72,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);\n+#define parse_commit_buffer(r, i, b, s) parse_commit_buffer_##r(i, b, s)\n+int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size);\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 f4207d09e9f..5b756b5184d 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))\n+\t\t\tif (parse_commit_buffer(the_repository, commit, buffer, size))\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 f66059ed7dd..00b1b2b8660 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -1780,7 +1780,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))\n+\tif (parse_commit_buffer(the_repository, &c, buf, size))\n \t\tdie(\"corrupt commit\");\n }\n \n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348744","messageId":"20180530004810.30076-13-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 12/35] commit: add repository argument to set_commit_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:47Z","receivedAt":"2018-05-30T00:49:06Z","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\nThe included coccinelle semantic patch will adapt any new callers in\nthe diff produced by `make coccicheck`.\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 86d0dd73338..50808c0ff44 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 dda585025ed..667d4dc6cfd 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -249,7 +249,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@@ -418,7 +418,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)\n \t}\n \tret = parse_commit_buffer(the_repository, item, buffer, size);\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 05b9eccaf66..a1ecd067ccc 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -85,7 +85,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 5b756b5184d..71dbd49b675 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))\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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348745","messageId":"20180530004810.30076-26-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 25/35] tag: allow parse_tag_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:48:00Z","receivedAt":"2018-05-30T00:49:11Z","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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348746","messageId":"20180530004810.30076-25-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 24/35] tag: allow lookup_tag to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:59Z","receivedAt":"2018-05-30T00:49:15Z","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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348747","messageId":"20180530004810.30076-24-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 23/35] commit: allow lookup_commit to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:58Z","receivedAt":"2018-05-30T00:49: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 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 8e7dfafe850..492bccf10eb 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -52,13 +52,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 c4d3033dc12..b96a57ad295 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -53,8 +53,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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348748","messageId":"20180530004810.30076-27-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 26/35] commit.c: allow parse_commit_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:48:01Z","receivedAt":"2018-05-30T00:49:19Z","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 492bccf10eb..fd31c453fdc 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -335,7 +335,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)\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size)\n {\n \tconst char *tail = buffer;\n \tconst char *bufptr = buffer;\n@@ -355,11 +355,11 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,\n \tif (get_sha1_hex(bufptr + 5, parent.hash) < 0)\n \t\treturn error(\"bad tree pointer in commit %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\n-\titem->tree = lookup_tree(the_repository, &parent);\n+\titem->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@@ -374,7 +374,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@@ -382,7 +382,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 b96a57ad295..536fa03955f 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -71,8 +71,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) parse_commit_buffer_##r(i, b, s)\n-int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size);\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size);\n #define parse_commit_gently(r, i, q) parse_commit_gently_##r(i, q)\n int parse_commit_gently_the_repository(struct commit *item, int quiet_on_missing);\n #define parse_commit(r, i) parse_commit_##r(i)\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348749","messageId":"20180530004810.30076-23-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 22/35] tree: allow lookup_tree to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:57Z","receivedAt":"2018-05-30T00:49:20Z","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 6b83942e444..58baf29c96f 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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348750","messageId":"20180530004810.30076-22-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 21/35] blob: allow lookup_blob to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:56Z","receivedAt":"2018-05-30T00:49: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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348751","messageId":"20180530004810.30076-21-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 20/35] object: allow lookup_object to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:55Z","receivedAt":"2018-05-30T00:49:26Z","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 fabd3ea2134..03180f84b2a 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 ad5f3b2826a..6adc8323ca4 100644\n--- a/object.h\n+++ b/object.h\n@@ -110,8 +110,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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348752","messageId":"20180530004810.30076-36-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 35/35] commit.c: allow lookup_commit_reference to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:48:10Z","receivedAt":"2018-05-30T00:49:34Z","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 f1bea3d1612..b54aed12170 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -35,9 +35,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 1fc55900fb5..12736c5fbb3 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -54,9 +54,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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348753","messageId":"20180530004810.30076-35-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 34/35] commit.c: allow lookup_commit_reference_gently to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:48:09Z","receivedAt":"2018-05-30T00:49:38Z","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 383997817f0..f1bea3d1612 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -23,16 +23,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 90ab9c403fe..1fc55900fb5 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -57,9 +57,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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348754","messageId":"20180530004810.30076-33-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 32/35] object.c: allow parse_object to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:48:07Z","receivedAt":"2018-05-30T00:49:47Z","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 d3bdee6888f..c2246e21ee4 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 0cd1307b61c..1a01cbf0ca3 100644\n--- a/object.h\n+++ b/object.h\n@@ -123,8 +123,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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348755","messageId":"20180530004810.30076-32-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 31/35] object.c: allow parse_object_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:48:06Z","receivedAt":"2018-05-30T00:49:48Z","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 ce29601c6c2..d3bdee6888f 100644\n--- a/object.c\n+++ b/object.c\n@@ -185,21 +185,21 @@ struct object *lookup_unknown_object_the_repository(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))\n+\t\t\tif (parse_commit_buffer(r, commit, buffer, size))\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 45e22282101..0cd1307b61c 100644\n--- a/object.h\n+++ b/object.h\n@@ -137,8 +137,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 #define lookup_unknown_object(r, s) lookup_unknown_object_##r(s)\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348756","messageId":"20180530004810.30076-34-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 33/35] tag.c: allow deref_tag to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:48:08Z","receivedAt":"2018-05-30T00:49:51Z","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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348757","messageId":"20180530004810.30076-31-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 30/35] commit.c: allow get_cached_commit_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:48:05Z","receivedAt":"2018-05-30T00:49:52Z","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 b824e69186e..383997817f0 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -270,10 +270,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 ec1733ed86d..90ab9c403fe 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -93,8 +93,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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348758","messageId":"20180530004810.30076-30-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 29/35] commit.c: allow set_commit_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:48:04Z","receivedAt":"2018-05-30T00:49:56Z","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 45dbf6f1453..b824e69186e 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -262,10 +262,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 df199498bfb..ec1733ed86d 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -87,8 +87,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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348759","messageId":"20180530004810.30076-29-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 28/35] commit.c: migrate the commit buffer to the parsed object store","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:48:03Z","receivedAt":"2018-05-30T00:49:57Z","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 |  2 ++\n object.c |  5 +++++\n object.h |  2 ++\n 4 files changed, 32 insertions(+), 6 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex fd31c453fdc..45dbf6f1453 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -248,18 +248,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@@ -291,14 +305,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@@ -318,7 +334,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 536fa03955f..df199498bfb 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -81,6 +81,8 @@ static inline int parse_commit_the_repository(struct commit *item)\n }\n void parse_commit_or_die(struct commit *item);\n \n+struct buffer_slab *allocate_commit_buffer_slab(void);\n+void free_commit_buffer_slab(struct buffer_slab *bs);\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 03180f84b2a..ce29601c6c2 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@@ -538,6 +540,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 6adc8323ca4..45e22282101 100644\n--- a/object.h\n+++ b/object.h\n@@ -22,6 +22,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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348760","messageId":"20180530004810.30076-28-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 27/35] commit-slabs: remove realloc counter outside of slab struct","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:48:02Z","receivedAt":"2018-05-30T00:50:00Z","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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348761","messageId":"20180530004810.30076-20-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 19/35] object: allow object_as_type to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:54Z","receivedAt":"2018-05-30T00:50:03Z","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 eb35e82a4a9..fabd3ea2134 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 f2afe7cc66f..ad5f3b2826a 100644\n--- a/object.h\n+++ b/object.h\n@@ -115,8 +115,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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348762","messageId":"20180530004810.30076-18-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 17/35] object: add repository argument to parse_commit_gently","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:52Z","receivedAt":"2018-05-30T00:50:11Z","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 parse_commit_gently 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\nThe included coccinelle semantic patch will adapt any new callers in\nthe diff produced by `make coccicheck`.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c   | 2 +-\n commit.h   | 5 +++--\n revision.c | 4 ++--\n 3 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex ede31c46931..dcb32561275 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -394,7 +394,7 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,\n \treturn 0;\n }\n \n-int parse_commit_gently(struct commit *item, int quiet_on_missing)\n+int parse_commit_gently_the_repository(struct commit *item, int quiet_on_missing)\n {\n \tenum object_type type;\n \tvoid *buffer;\ndiff --git a/commit.h b/commit.h\nindex 66eb576897f..b1198ec2b77 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -74,10 +74,11 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref\n \n #define parse_commit_buffer(r, i, b, s) parse_commit_buffer_##r(i, b, s)\n int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size);\n-int parse_commit_gently(struct commit *item, int quiet_on_missing);\n+#define parse_commit_gently(r, i, q) parse_commit_gently_##r(i, q)\n+int parse_commit_gently_the_repository(struct commit *item, int quiet_on_missing);\n static inline int parse_commit(struct commit *item)\n {\n-\treturn parse_commit_gently(item, 0);\n+\treturn parse_commit_gently(the_repository, item, 0);\n }\n void parse_commit_or_die(struct commit *item);\n \ndiff --git a/revision.c b/revision.c\nindex 25df00cc16c..33506faabda 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -785,7 +785,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,\n \t\t\tparent = parent->next;\n \t\t\tif (p)\n \t\t\t\tp->object.flags |= UNINTERESTING;\n-\t\t\tif (parse_commit_gently(p, 1) < 0)\n+\t\t\tif (parse_commit_gently(the_repository, p, 1) < 0)\n \t\t\t\tcontinue;\n \t\t\tif (p->parents)\n \t\t\t\tmark_parents_uninteresting(p);\n@@ -813,7 +813,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,\n \t\tstruct commit *p = parent->item;\n \t\tint gently = revs->ignore_missing_links ||\n \t\t\t     revs->exclude_promisor_objects;\n-\t\tif (parse_commit_gently(p, gently) < 0) {\n+\t\tif (parse_commit_gently(the_repository, p, gently) < 0) {\n \t\t\tif (revs->exclude_promisor_objects &&\n \t\t\t    is_promisor_object(&p->object.oid)) {\n \t\t\t\tif (revs->first_parent_only)\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348763","messageId":"20180530004810.30076-17-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 16/35] tag: add repository argument to deref_tag","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:51Z","receivedAt":"2018-05-30T00:50: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\nAdd the cocci patch that converted the callers.\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 50808c0ff44..aad53c0f904 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 0b7d0d612dd..1dd7dd4a267 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -395,7 +395,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\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 6e7bc76785a..c93c33cd28f 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -646,7 +646,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 ba06918ba41..ede31c46931 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -26,7 +26,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 74ac2977e85..358d8421a8f 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 f27026daf8f..59447c98166 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 ecdce08c4be..34c4a93c5b2 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 1b06f25b38c..9013aabed9a 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -2184,7 +2184,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 2a6ff7d60c1..0bf5ce3e7ba 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1995,12 +1995,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 368fb547f4b..e83797c3caf 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 98b66c4896c..27cf9cd916e 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@@ -934,7 +936,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@@ -1066,7 +1068,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 60fe1fe1e58..c65cb17195e 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 aebab6f3277..60e05078332 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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348764","messageId":"20180530004810.30076-15-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 14/35] tag: add repository argument to lookup_tag","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:49Z","receivedAt":"2018-05-30T00:50:16Z","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 080b5ce082c..6fb713b6be1 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 6eae39cf858..41192fdf595 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2365,7 +2365,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 14e142d5a80..8c8cec4aae6 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -359,7 +359,7 @@ static void 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\tdie(_(\"bad mergetag in commit '%s'\"), ref);\n \tif (parse_tag_buffer(tag, extra->value, extra->len))\ndiff --git a/log-tree.c b/log-tree.c\nindex a47283eca64..727758eb442 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -506,7 +506,7 @@ static void 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; /* error message already given */\n \ndiff --git a/object.c b/object.c\nindex e859662c63c..b94f8358919 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 5eef8ddd6d6..98b66c4896c 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -359,7 +359,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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348765","messageId":"20180530004810.30076-16-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 15/35] tag: add repository argument to parse_tag_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:50Z","receivedAt":"2018-05-30T00:50:18Z","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 8c8cec4aae6..bff1c3df964 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -362,7 +362,7 @@ static void check_one_mergetag(struct commit *commit,\n \ttag = lookup_tag(the_repository, &tag_oid);\n \tif (!tag)\n \t\tdie(_(\"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\tdie(_(\"malformed mergetag in commit '%s'\"), ref);\n \n \t/* iterate over new parents */\ndiff --git a/log-tree.c b/log-tree.c\nindex 727758eb442..ac42ad42acc 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -511,7 +511,7 @@ static void show_one_mergetag(struct commit *commit,\n \t\treturn; /* 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 b94f8358919..eb35e82a4a9 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 00b1b2b8660..3440b67639e 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -1788,7 +1788,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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348766","messageId":"20180530004810.30076-14-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 13/35] commit: add repository argument to get_cached_commit_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:48Z","receivedAt":"2018-05-30T00:50:22Z","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 667d4dc6cfd..ba06918ba41 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -256,7 +256,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@@ -271,7 +271,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 a1ecd067ccc..66eb576897f 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -92,7 +92,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 71dbd49b675..e859662c63c 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))\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 c99f8243faf..5b139775eac 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.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348767","messageId":"20180530004810.30076-19-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH 18/35] commit: add repository argument to parse_commit","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T00:47:53Z","receivedAt":"2018-05-30T00:50:24Z","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 parse_commit 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               |  4 ++--\n builtin/checkout.c    |  4 ++--\n builtin/commit.c      |  2 +-\n builtin/describe.c    |  4 ++--\n builtin/merge-base.c  |  2 +-\n builtin/name-rev.c    |  2 +-\n builtin/notes.c       |  2 +-\n builtin/reflog.c      |  2 +-\n builtin/show-branch.c |  4 ++--\n commit-graph.c        |  6 +++---\n commit.c              | 18 +++++++++---------\n commit.h              |  3 ++-\n fetch-pack.c          |  6 +++---\n fsck.c                |  2 +-\n merge-recursive.c     |  4 ++--\n notes-utils.c         |  2 +-\n remote.c              |  2 +-\n revision.c            |  7 +++----\n sequencer.c           | 16 ++++++++--------\n sha1-name.c           |  4 ++--\n shallow.c             |  4 ++--\n tree.c                |  2 +-\n walker.c              |  2 +-\n 23 files changed, 52 insertions(+), 52 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex aad53c0f904..c82922506cc 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -1451,7 +1451,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,\n \n \t\t\tif (sg_origin[i])\n \t\t\t\tcontinue;\n-\t\t\tif (parse_commit(p))\n+\t\t\tif (parse_commit(the_repository, p))\n \t\t\t\tcontinue;\n \t\t\tporigin = find(p, origin);\n \t\t\tif (!porigin)\n@@ -1590,7 +1590,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt)\n \t\t * so hold onto it in the meantime.\n \t\t */\n \t\tblame_origin_incref(suspect);\n-\t\tparse_commit(commit);\n+\t\tparse_commit(the_repository, commit);\n \t\tif (sb->reverse ||\n \t\t    (!(commit->object.flags & UNINTERESTING) &&\n \t\t     !(revs->max_age != -1 && commit->date < revs->max_age)))\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 31a71f75625..cf93a6e913d 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -402,7 +402,7 @@ static void describe_detached_head(const char *msg, struct commit *commit)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n \n-\tif (!parse_commit(commit))\n+\tif (!parse_commit(the_repository, commit))\n \t\tpp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);\n \tif (print_sha1_ellipsis()) {\n \t\tfprintf(stderr, \"%s %s... %s\\n\", msg,\n@@ -723,7 +723,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)\n \tstrbuf_addstr(sb, \"  \");\n \tstrbuf_add_unique_abbrev(sb, &commit->object.oid, DEFAULT_ABBREV);\n \tstrbuf_addch(sb, ' ');\n-\tif (!parse_commit(commit))\n+\tif (!parse_commit(the_repository, commit))\n \t\tpp_commit_easy(CMIT_FMT_ONELINE, commit, sb);\n \tstrbuf_addch(sb, '\\n');\n }\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex b6d130b8ff3..4957099080e 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1482,7 +1482,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tcurrent_head = NULL;\n \telse {\n \t\tcurrent_head = lookup_commit_or_die(&oid, \"HEAD\");\n-\t\tif (parse_commit(current_head))\n+\t\tif (parse_commit(the_repository, current_head))\n \t\t\tdie(_(\"could not parse HEAD commit\"));\n \t}\n \tverbose = -1; /* unspecified */\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 6fb713b6be1..7e4481947c1 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -254,7 +254,7 @@ static unsigned long finish_depth_computation(\n \t\t\tbest->depth++;\n \t\twhile (parents) {\n \t\t\tstruct commit *p = parents->item;\n-\t\t\tparse_commit(p);\n+\t\t\tparse_commit(the_repository, p);\n \t\t\tif (!(p->object.flags & SEEN))\n \t\t\t\tcommit_list_insert_by_date(p, list);\n \t\t\tp->object.flags |= c->object.flags;\n@@ -381,7 +381,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)\n \t\t}\n \t\twhile (parents) {\n \t\t\tstruct commit *p = parents->item;\n-\t\t\tparse_commit(p);\n+\t\t\tparse_commit(the_repository, p);\n \t\t\tif (!(p->object.flags & SEEN))\n \t\t\t\tcommit_list_insert_by_date(p, &list);\n \t\t\tp->object.flags |= c->object.flags;\ndiff --git a/builtin/merge-base.c b/builtin/merge-base.c\nindex 08d91b1f0c0..426882818c8 100644\n--- a/builtin/merge-base.c\n+++ b/builtin/merge-base.c\n@@ -127,7 +127,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)\n \tcommit = lookup_commit(the_repository, oid);\n \tif (!commit ||\n \t    (commit->object.flags & TMP_MARK) ||\n-\t    parse_commit(commit))\n+\t    parse_commit(the_repository, commit))\n \t\treturn;\n \n \tALLOC_GROW(revs->commit, revs->nr + 1, revs->alloc);\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex f1cb45c2274..bdeb3027179 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -87,7 +87,7 @@ static void name_rev(struct commit *commit,\n \tint parent_number = 1;\n \tchar *to_free = NULL;\n \n-\tparse_commit(commit);\n+\tparse_commit(the_repository, commit);\n \n \tif (commit->date < cutoff)\n \t\treturn;\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 50963642075..0c558ab0702 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -714,7 +714,7 @@ static int merge_commit(struct notes_merge_options *o)\n \t\tdie(_(\"failed to read ref NOTES_MERGE_PARTIAL\"));\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+\telse if (parse_commit(the_repository, partial))\n \t\tdie(_(\"could not parse commit from NOTES_MERGE_PARTIAL.\"));\n \n \tif (partial->parents)\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 6ff3c5abff0..c4e0ee7caad 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -235,7 +235,7 @@ static void mark_reachable(struct expire_reflog_policy_cb *cb)\n \t\tstruct commit *commit = pop_commit(&pending);\n \t\tif (commit->object.flags & REACHABLE)\n \t\t\tcontinue;\n-\t\tif (parse_commit(commit))\n+\t\tif (parse_commit(the_repository, commit))\n \t\t\tcontinue;\n \t\tcommit->object.flags |= REACHABLE;\n \t\tif (commit->date < expire_limit) {\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 4b9d3c0059b..98fb2cc2da3 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -238,7 +238,7 @@ static void join_revs(struct commit_list **list_p,\n \t\t\tparents = parents->next;\n \t\t\tif ((this_flag & flags) == flags)\n \t\t\t\tcontinue;\n-\t\t\tparse_commit(p);\n+\t\t\tparse_commit(the_repository, p);\n \t\t\tif (mark_seen(p, seen_p) && !still_interesting)\n \t\t\t\textra--;\n \t\t\tp->object.flags |= flags;\n@@ -835,7 +835,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\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));\n-\t\tparse_commit(commit);\n+\t\tparse_commit(the_repository, commit);\n \t\tmark_seen(commit, &seen);\n \n \t\t/* rev#0 uses bit REV_SHIFT, rev#1 uses bit REV_SHIFT+1,\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 6c08fc0a9ba..0e91d8f7139 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -371,7 +371,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,\n \t\tint edge_value;\n \t\tuint32_t packedDate[2];\n \n-\t\tparse_commit(*list);\n+\t\tparse_commit(the_repository, *list);\n \t\thashwrite(f, (*list)->tree->object.oid.hash, hash_len);\n \n \t\tparent = (*list)->parents;\n@@ -540,7 +540,7 @@ static void close_reachable(struct packed_oid_list *oids)\n \tfor (i = 0; i < oids->nr; i++) {\n \t\tcommit = lookup_commit(the_repository, &oids->list[i]);\n \n-\t\tif (commit && !parse_commit(commit))\n+\t\tif (commit && !parse_commit(the_repository, commit))\n \t\t\tadd_missing_parents(oids, commit);\n \t}\n \n@@ -659,7 +659,7 @@ void write_commit_graph(const char *obj_dir,\n \t\t\tcontinue;\n \n \t\tcommits.list[commits.nr] = lookup_commit(the_repository, &oids.list[i]);\n-\t\tparse_commit(commits.list[commits.nr]);\n+\t\tparse_commit(the_repository, commits.list[commits.nr]);\n \n \t\tfor (parent = commits.list[commits.nr]->parents;\n \t\t     parent; parent = parent->next)\ndiff --git a/commit.c b/commit.c\nindex dcb32561275..8e7dfafe850 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -69,7 +69,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)\n \tif (get_oid_committish(name, &oid))\n \t\treturn NULL;\n \tcommit = lookup_commit_reference(the_repository, &oid);\n-\tif (parse_commit(commit))\n+\tif (parse_commit(the_repository, commit))\n \t\treturn NULL;\n \treturn commit;\n }\n@@ -428,7 +428,7 @@ int parse_commit_gently_the_repository(struct commit *item, int quiet_on_missing\n \n void parse_commit_or_die(struct commit *item)\n {\n-\tif (parse_commit(item))\n+\tif (parse_commit(the_repository, item))\n \t\tdie(\"unable to parse commit %s\",\n \t\t    item ? oid_to_hex(&item->object.oid) : \"(null)\");\n }\n@@ -533,7 +533,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,\n \n \twhile (parents) {\n \t\tstruct commit *commit = parents->item;\n-\t\tif (!parse_commit(commit) && !(commit->object.flags & mark)) {\n+\t\tif (!parse_commit(the_repository, commit) && !(commit->object.flags & mark)) {\n \t\t\tcommit->object.flags |= mark;\n \t\t\tcommit_list_insert_by_date(commit, list);\n \t\t}\n@@ -830,7 +830,7 @@ static struct commit_list *paint_down_to_common(struct commit *one, int n, struc\n \t\t\tparents = parents->next;\n \t\t\tif ((p->object.flags & flags) == flags)\n \t\t\t\tcontinue;\n-\t\t\tif (parse_commit(p))\n+\t\t\tif (parse_commit(the_repository, p))\n \t\t\t\treturn NULL;\n \t\t\tp->object.flags |= flags;\n \t\t\tprio_queue_put(&queue, p);\n@@ -856,10 +856,10 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct co\n \t\t\treturn commit_list_insert(one, &result);\n \t}\n \n-\tif (parse_commit(one))\n+\tif (parse_commit(the_repository, one))\n \t\treturn NULL;\n \tfor (i = 0; i < n; i++) {\n-\t\tif (parse_commit(twos[i]))\n+\t\tif (parse_commit(the_repository, twos[i]))\n \t\t\treturn NULL;\n \t}\n \n@@ -918,7 +918,7 @@ static int remove_redundant(struct commit **array, int cnt)\n \tALLOC_ARRAY(filled_index, cnt - 1);\n \n \tfor (i = 0; i < cnt; i++)\n-\t\tparse_commit(array[i]);\n+\t\tparse_commit(the_repository, array[i]);\n \tfor (i = 0; i < cnt; i++) {\n \t\tstruct commit_list *common;\n \n@@ -1041,10 +1041,10 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit *\n \tstruct commit_list *bases;\n \tint ret = 0, i;\n \n-\tif (parse_commit(commit))\n+\tif (parse_commit(the_repository, commit))\n \t\treturn ret;\n \tfor (i = 0; i < nr_reference; i++)\n-\t\tif (parse_commit(reference[i]))\n+\t\tif (parse_commit(the_repository, reference[i]))\n \t\t\treturn ret;\n \n \tbases = paint_down_to_common(commit, nr_reference, reference);\ndiff --git a/commit.h b/commit.h\nindex b1198ec2b77..c4d3033dc12 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -76,7 +76,8 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref\n int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size);\n #define parse_commit_gently(r, i, q) parse_commit_gently_##r(i, q)\n int parse_commit_gently_the_repository(struct commit *item, int quiet_on_missing);\n-static inline int parse_commit(struct commit *item)\n+#define parse_commit(r, i) parse_commit_##r(i)\n+static inline int parse_commit_the_repository(struct commit *item)\n {\n \treturn parse_commit_gently(the_repository, item, 0);\n }\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 358d8421a8f..b551a7d921b 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -114,7 +114,7 @@ static void rev_list_push(struct commit *commit, int mark)\n \tif (!(commit->object.flags & mark)) {\n \t\tcommit->object.flags |= mark;\n \n-\t\tif (parse_commit(commit))\n+\t\tif (parse_commit(the_repository, commit))\n \t\t\treturn;\n \n \t\tprio_queue_put(&rev_list, commit);\n@@ -178,7 +178,7 @@ static void mark_common(struct commit *commit,\n \t\t\tif (!ancestors_only && !(o->flags & POPPED))\n \t\t\t\tnon_common_revs--;\n \t\t\tif (!o->parsed && !dont_parse)\n-\t\t\t\tif (parse_commit(commit))\n+\t\t\t\tif (parse_commit(the_repository, commit))\n \t\t\t\t\treturn;\n \n \t\t\tfor (parents = commit->parents;\n@@ -205,7 +205,7 @@ static const struct object_id *get_rev(void)\n \t\t\treturn NULL;\n \n \t\tcommit = prio_queue_get(&rev_list);\n-\t\tparse_commit(commit);\n+\t\tparse_commit(the_repository, commit);\n \t\tparents = commit->parents;\n \n \t\tcommit->object.flags |= POPPED;\ndiff --git a/fsck.c b/fsck.c\nindex b07abb9796c..e8387e015c8 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -393,7 +393,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio\n \tint result;\n \tconst char *name;\n \n-\tif (parse_commit(commit))\n+\tif (parse_commit(the_repository, commit))\n \t\treturn -1;\n \n \tname = get_object_name(options, &commit->object);\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 9013aabed9a..bdbaff45fcf 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -236,7 +236,7 @@ static void output_commit_title(struct merge_options *o, struct commit *commit)\n \t\tstrbuf_add_unique_abbrev(&o->obuf, &commit->object.oid,\n \t\t\t\t\t DEFAULT_ABBREV);\n \t\tstrbuf_addch(&o->obuf, ' ');\n-\t\tif (parse_commit(commit) != 0)\n+\t\tif (parse_commit(the_repository, commit) != 0)\n \t\t\tstrbuf_addstr(&o->obuf, _(\"(bad commit)\\n\"));\n \t\telse {\n \t\t\tconst char *title;\n@@ -2193,7 +2193,7 @@ static struct commit *get_ref(const struct object_id *oid, const char *name)\n \t\treturn make_virtual_commit((struct tree*)object, name);\n \tif (object->type != OBJ_COMMIT)\n \t\treturn NULL;\n-\tif (parse_commit((struct commit *)object))\n+\tif (parse_commit(the_repository, (struct commit *)object))\n \t\treturn NULL;\n \treturn (struct commit *)object;\n }\ndiff --git a/notes-utils.c b/notes-utils.c\nindex 14ea03178e9..8441ec46199 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -22,7 +22,7 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,\n \t\tif (!read_ref(t->ref, &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\tif (parse_commit(the_repository, parent))\n \t\t\t\tdie(\"Failed to find/parse commit %s\", t->ref);\n \t\t\tcommit_list_insert(parent, &parents);\n \t\t}\ndiff --git a/remote.c b/remote.c\nindex 0bf5ce3e7ba..83a3d3ef649 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -2007,7 +2007,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)\n \t\treturn 0;\n \tnew_commit = (struct commit *) o;\n \n-\tif (parse_commit(new_commit) < 0)\n+\tif (parse_commit(the_repository, new_commit) < 0)\n \t\treturn 0;\n \n \tused = list = NULL;\ndiff --git a/revision.c b/revision.c\nindex 33506faabda..6a3a73cc4ce 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -258,8 +258,7 @@ static struct commit *handle_commit(struct rev_info *revs,\n \t */\n \tif (object->type == OBJ_COMMIT) {\n \t\tstruct commit *commit = (struct commit *)object;\n-\n-\t\tif (parse_commit(commit) < 0)\n+\t\tif (parse_commit(the_repository, commit) < 0)\n \t\t\tdie(\"unable to parse commit %s\", name);\n \t\tif (flags & UNINTERESTING) {\n \t\t\tmark_parents_uninteresting(commit);\n@@ -673,7 +672,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)\n \t\t\t\t\tts->treesame[0] = 1;\n \t\t\t}\n \t\t}\n-\t\tif (parse_commit(p) < 0)\n+\t\tif (parse_commit(the_repository, p) < 0)\n \t\t\tdie(\"cannot simplify commit %s (because of %s)\",\n \t\t\t    oid_to_hex(&commit->object.oid),\n \t\t\t    oid_to_hex(&p->object.oid));\n@@ -706,7 +705,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)\n \t\t\t\t * IOW, we pretend this parent is a\n \t\t\t\t * \"root\" commit.\n \t\t\t\t */\n-\t\t\t\tif (parse_commit(p) < 0)\n+\t\t\t\tif (parse_commit(the_repository, p) < 0)\n \t\t\t\t\tdie(\"cannot simplify commit %s (invalid %s)\",\n \t\t\t\t\t    oid_to_hex(&commit->object.oid),\n \t\t\t\t\t    oid_to_hex(&p->object.oid));\ndiff --git a/sequencer.c b/sequencer.c\nindex da6c9fc5511..d8ba41dc0c8 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -553,7 +553,7 @@ static int is_index_unchanged(void)\n \t * the commit is invalid, parse_commit() will complain.  So\n \t * there is nothing for us to say here.  Just return failure.\n \t */\n-\tif (parse_commit(head_commit))\n+\tif (parse_commit(the_repository, head_commit))\n \t\treturn -1;\n \n \tif (!active_cache_tree)\n@@ -975,7 +975,7 @@ void print_commit_summary(const char *prefix, const struct object_id *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))\n+\tif (parse_commit(the_repository, commit))\n \t\tdie(_(\"could not parse newly created commit\"));\n \n \tstrbuf_addstr(&format, \"format:%h] %s\");\n@@ -1054,7 +1054,7 @@ static int parse_head(struct commit **head)\n \t\t\twarning(_(\"HEAD %s is not a commit!\"),\n \t\t\t\toid_to_hex(&oid));\n \t\t}\n-\t\tif (parse_commit(current_head))\n+\t\tif (parse_commit(the_repository, current_head))\n \t\t\treturn error(_(\"could not parse HEAD commit\"));\n \t}\n \t*head = current_head;\n@@ -1213,12 +1213,12 @@ static int is_original_commit_empty(struct commit *commit)\n {\n \tconst struct object_id *ptree_oid;\n \n-\tif (parse_commit(commit))\n+\tif (parse_commit(the_repository, commit))\n \t\treturn error(_(\"could not parse commit %s\"),\n \t\t\t     oid_to_hex(&commit->object.oid));\n \tif (commit->parents) {\n \t\tstruct commit *parent = commit->parents->item;\n-\t\tif (parse_commit(parent))\n+\t\tif (parse_commit(the_repository, parent))\n \t\t\treturn error(_(\"could not parse parent commit %s\"),\n \t\t\t\toid_to_hex(&parent->object.oid));\n \t\tptree_oid = &parent->tree->object.oid;\n@@ -1533,7 +1533,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\tmsg_file = NULL;\n \t\tgoto fast_forward_edit;\n \t}\n-\tif (parent && parse_commit(parent) < 0)\n+\tif (parent && parse_commit(the_repository, parent) < 0)\n \t\t/* TRANSLATORS: The first %s will be a \"todo\" command like\n \t\t   \"revert\" or \"pick\", the second %s a SHA1. */\n \t\treturn error(_(\"%s: cannot parse parent commit %s\"),\n@@ -3301,7 +3301,7 @@ int skip_unnecessary_picks(void)\n \t\t\tcontinue;\n \t\tif (item->command != TODO_PICK)\n \t\t\tbreak;\n-\t\tif (parse_commit(item->commit)) {\n+\t\tif (parse_commit(the_repository, item->commit)) {\n \t\t\ttodo_list_release(&todo_list);\n \t\t\treturn error(_(\"could not parse commit '%s'\"),\n \t\t\t\toid_to_hex(&item->commit->object.oid));\n@@ -3429,7 +3429,7 @@ int rearrange_squash(void)\n \n \t\t*commit_todo_item_at(&commit_todo, item->commit) = item;\n \n-\t\tparse_commit(item->commit);\n+\t\tparse_commit(the_repository, item->commit);\n \t\tcommit_buffer = get_commit_buffer(item->commit, NULL);\n \t\tfind_commit_subject(commit_buffer, &subject);\n \t\tformat_subject(&buf, subject, \" \");\ndiff --git a/sha1-name.c b/sha1-name.c\nindex 27cf9cd916e..618fd1569f1 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -813,7 +813,7 @@ static int get_parent(const char *name, int len,\n \tif (ret)\n \t\treturn ret;\n \tcommit = lookup_commit_reference(the_repository, &oid);\n-\tif (parse_commit(commit))\n+\tif (parse_commit(the_repository, commit))\n \t\treturn -1;\n \tif (!idx) {\n \t\toidcpy(result, &commit->object.oid);\n@@ -845,7 +845,7 @@ static int get_nth_ancestor(const char *name, int len,\n \t\treturn -1;\n \n \twhile (generation--) {\n-\t\tif (parse_commit(commit) || !commit->parents)\n+\t\tif (parse_commit(the_repository, commit) || !commit->parents)\n \t\t\treturn -1;\n \t\tcommit = commit->parents->item;\n \t}\ndiff --git a/shallow.c b/shallow.c\nindex c65cb17195e..91d8da1917d 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -207,7 +207,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,\n \t\tstruct commit *c = p->item;\n \t\tstruct commit_list *parent;\n \n-\t\tif (parse_commit(c))\n+\t\tif (parse_commit(the_repository, c))\n \t\t\tdie(\"unable to parse commit %s\",\n \t\t\t    oid_to_hex(&c->object.oid));\n \n@@ -530,7 +530,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,\n \t\tif (c->object.flags & BOTTOM)\n \t\t\tcontinue;\n \n-\t\tif (parse_commit(c))\n+\t\tif (parse_commit(the_repository, c))\n \t\t\tdie(\"unable to parse commit %s\",\n \t\t\t    oid_to_hex(&c->object.oid));\n \ndiff --git a/tree.c b/tree.c\nindex 33063b8dde0..6b83942e444 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -107,7 +107,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,\n \t\t\t\t    oid_to_hex(entry.oid),\n \t\t\t\t    base->buf, entry.path);\n \n-\t\t\tif (parse_commit(commit))\n+\t\t\tif (parse_commit(the_repository, commit))\n \t\t\t\tdie(\"Invalid commit %s in submodule path %s%s\",\n \t\t\t\t    oid_to_hex(entry.oid),\n \t\t\t\t    base->buf, entry.path);\ndiff --git a/walker.c b/walker.c\nindex c7c9db83df7..314f56e61ce 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -78,7 +78,7 @@ static int process_commit(struct walker *walker, struct commit *commit)\n {\n \tstruct commit_list *parents;\n \n-\tif (parse_commit(commit))\n+\tif (parse_commit(the_repository, commit))\n \t\treturn -1;\n \n \twhile (complete && complete->item->date >= commit->date) {\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"348769","messageId":"627c65a9-d807-8912-b96d-ef7feecb9ea4@gmail.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"Re: [RFC PATCH 00/35] object-store: lookup_commit","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-05-30T01:05:37Z","receivedAt":"2018-05-30T01:05:42Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/29/2018 8:47 PM, Stefan Beller wrote:\n> This applies on the merge of nd/commit-util-to-slab and sb/object-store-grafts,\n> and is available at http://github.com/stefanbeller/ as branch object-store-lookup-commit\n> as the merge has some merge conflicts as well as syntactical conflicts (upload-pack.c\n> and fetch-pack.c introduce new calls of functions that would want to take a repository struct\n> in the object-store-grafts series)\n>\n> As layed out in https://public-inbox.org/git/20180517225154.9200-1-sbeller@google.com/\n> this is getting close to finishing the set of object store series though the last\n> unfinished 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\nI'll take a look at this series tomorrow. I've been working in \nds/commit-graph-fsck to make many of the methods take a 'struct \ncommit_graph *' parameter, which could easily be 'r->commit_graph' for a \n'struct the_repository *r' instead of the global 'commit_graph'. Those \ngraph-local methods will make the transformation to be repo-local a lot \neasier. (There still may be some need to insert a repository, though.)\n\nSince you are working on the commit-slab stuff in this patch, I'll \n(continue to) delay my patch series on using the commit-slab for \ngeneration numbers to avoid collisions with your work.\n\nThanks,\n\n-Stolee\n\n"},{"id":"348778","messageId":"CAGZ79kaEHhE=suT2-Rzrbu2P7z8KPzRdCOFNCTqsOiV0+HjJ9A@mail.gmail.com","threadId":"48596","inReplyTo":"627c65a9-d807-8912-b96d-ef7feecb9ea4@gmail.com","subject":"Re: [RFC PATCH 00/35] object-store: lookup_commit","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T03:18:45Z","receivedAt":"2018-05-30T03:18:51Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, May 29, 2018 at 6:05 PM, Derrick Stolee <stolee@gmail.com> wrote:\n> On 5/29/2018 8:47 PM, Stefan Beller wrote:\n>>\n>> This applies on the merge of nd/commit-util-to-slab and\n>> sb/object-store-grafts,\n>> and is available at http://github.com/stefanbeller/ as branch\n>> object-store-lookup-commit\n>> as the merge has some merge conflicts as well as syntactical conflicts\n>> (upload-pack.c\n>> and fetch-pack.c introduce new calls of functions that would want to take\n>> a repository struct\n>> in the object-store-grafts series)\n>>\n>> As layed out in\n>> https://public-inbox.org/git/20180517225154.9200-1-sbeller@google.com/\n>> this is getting close to finishing the set of object store series though\n>> the last\n>> unfinished 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,\n>> too.\n>>    But that requires the conversion of the new commit graph. Maybe we need\n>>    to split this series into 2.\n>\n>\n> I'll take a look at this series tomorrow. I've been working in\n> ds/commit-graph-fsck to make many of the methods take a 'struct commit_graph\n> *' parameter, which could easily be 'r->commit_graph' for a 'struct\n> the_repository *r' instead of the global 'commit_graph'. Those graph-local\n> methods will make the transformation to be repo-local a lot easier. (There\n> still may be some need to insert a repository, though.)\n>\n> Since you are working on the commit-slab stuff in this patch, I'll (continue\n> to) delay my patch series on using the commit-slab for generation numbers to\n> avoid collisions with your work.\n\nThis series touches the commit slabs in the last few commits only.\nI don't think there will be huge conflicts, as all I had to do was\nmove the definition from a global to inside the parsed object store.\n"},{"id":"348826","messageId":"e85dbf10-05f3-6968-97c2-8d9010cae73c@gmail.com","threadId":"48596","inReplyTo":"20180530004810.30076-4-sbeller@google.com","subject":"Re: [PATCH 03/35] object: add repository argument to lookup_unknown_object","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-05-30T18:29:57Z","receivedAt":"2018-05-30T18:30:03Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/29/2018 8:47 PM, Stefan Beller wrote:\n> From: Jonathan Nieder <jrnieder@gmail.com>\n>\n> Add a repository argument to allow callers of lookup_unknown_object to\n> be more specific about which repository to handle. 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> repositor other than the_repository at compile time.\n>\n> The included coccinelle semantic patch will adapt any new callers in\n> the diff produced by `make coccicheck`.\n\nI don't see any coccinelle change in this patch.\n\nPerhaps it is in a later commit?\n\nThanks,\n\n-Stolee\n\n>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>   builtin/fsck.c                   | 2 +-\n>   builtin/pack-objects.c           | 2 +-\n>   http-push.c                      | 2 +-\n>   object.c                         | 2 +-\n>   object.h                         | 3 ++-\n>   refs.c                           | 2 +-\n>   t/helper/test-example-decorate.c | 6 +++---\n>   upload-pack.c                    | 2 +-\n>   walker.c                         | 2 +-\n>   9 files changed, 12 insertions(+), 11 deletions(-)\n>\n> diff --git a/builtin/fsck.c b/builtin/fsck.c\n> index 98fdeef5407..700739804fc 100644\n> --- a/builtin/fsck.c\n> +++ b/builtin/fsck.c\n> @@ -638,7 +638,7 @@ static int fsck_cache_tree(struct cache_tree *it)\n>   \n>   static void mark_object_for_connectivity(const struct object_id *oid)\n>   {\n> -\tstruct object *obj = lookup_unknown_object(oid->hash);\n> +\tstruct object *obj = lookup_unknown_object(the_repository, oid->hash);\n>   \tobj->flags |= HAS_OBJ;\n>   }\n>   \n> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\n> index 8c108109985..6eae39cf858 100644\n> --- a/builtin/pack-objects.c\n> +++ b/builtin/pack-objects.c\n> @@ -2689,7 +2689,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)\n>   \n>   \t\tfor (i = 0; i < p->num_objects; i++) {\n>   \t\t\tnth_packed_object_oid(&oid, p, i);\n> -\t\t\to = lookup_unknown_object(oid.hash);\n> +\t\t\to = lookup_unknown_object(the_repository, oid.hash);\n>   \t\t\tif (!(o->flags & OBJECT_ADDED))\n>   \t\t\t\tmark_in_pack_object(o, p, &in_pack);\n>   \t\t\to->flags |= OBJECT_ADDED;\n> diff --git a/http-push.c b/http-push.c\n> index 2615c823d60..04d95bd5da8 100644\n> --- a/http-push.c\n> +++ b/http-push.c\n> @@ -1429,7 +1429,7 @@ static void one_remote_ref(const char *refname)\n>   \t * may be required for updating server info later.\n>   \t */\n>   \tif (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {\n> -\t\tobj = lookup_unknown_object(ref->old_oid.hash);\n> +\t\tobj = lookup_unknown_object(the_repository, ref->old_oid.hash);\n>   \t\tfprintf(stderr,\t\"  fetch %s for %s\\n\",\n>   \t\t\toid_to_hex(&ref->old_oid), refname);\n>   \t\tadd_fetch_request(obj);\n> diff --git a/object.c b/object.c\n> index 4de4fa58d59..def3c71cac2 100644\n> --- a/object.c\n> +++ b/object.c\n> @@ -177,7 +177,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)\n>   \t}\n>   }\n>   \n> -struct object *lookup_unknown_object(const unsigned char *sha1)\n> +struct object *lookup_unknown_object_the_repository(const unsigned char *sha1)\n>   {\n>   \tstruct object *obj = lookup_object(the_repository, sha1);\n>   \tif (!obj)\n> diff --git a/object.h b/object.h\n> index fa41d711f44..778f83bf0f7 100644\n> --- a/object.h\n> +++ b/object.h\n> @@ -139,7 +139,8 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name\n>   struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);\n>   \n>   /** Returns the object, with potentially excess memory allocated. **/\n> -struct object *lookup_unknown_object(const unsigned  char *sha1);\n> +#define lookup_unknown_object(r, s) lookup_unknown_object_##r(s)\n> +struct object *lookup_unknown_object_the_repository(const unsigned char *sha1);\n>   \n>   struct object_list *object_list_insert(struct object *item,\n>   \t\t\t\t       struct object_list **list_p);\n> diff --git a/refs.c b/refs.c\n> index 23d53957deb..3b9e8463656 100644\n> --- a/refs.c\n> +++ b/refs.c\n> @@ -301,7 +301,7 @@ static int filter_refs(const char *refname, const struct object_id *oid,\n>   \n>   enum peel_status peel_object(const struct object_id *name, struct object_id *oid)\n>   {\n> -\tstruct object *o = lookup_unknown_object(name->hash);\n> +\tstruct object *o = lookup_unknown_object(the_repository, name->hash);\n>   \n>   \tif (o->type == OBJ_NONE) {\n>   \t\tint type = oid_object_info(the_repository, name, NULL);\n> diff --git a/t/helper/test-example-decorate.c b/t/helper/test-example-decorate.c\n> index 081115bf8eb..33e727f7fc5 100644\n> --- a/t/helper/test-example-decorate.c\n> +++ b/t/helper/test-example-decorate.c\n> @@ -26,8 +26,8 @@ int cmd__example_decorate(int argc, const char **argv)\n>   \t * Add 2 objects, one with a non-NULL decoration and one with a NULL\n>   \t * decoration.\n>   \t */\n> -\tone = lookup_unknown_object(one_oid.hash);\n> -\ttwo = lookup_unknown_object(two_oid.hash);\n> +\tone = lookup_unknown_object(the_repository, one_oid.hash);\n> +\ttwo = lookup_unknown_object(the_repository, two_oid.hash);\n>   \tret = add_decoration(&n, one, &decoration_a);\n>   \tif (ret)\n>   \t\tdie(\"BUG: when adding a brand-new object, NULL should be returned\");\n> @@ -56,7 +56,7 @@ int cmd__example_decorate(int argc, const char **argv)\n>   \tret = lookup_decoration(&n, two);\n>   \tif (ret != &decoration_b)\n>   \t\tdie(\"BUG: lookup should return added declaration\");\n> -\tthree = lookup_unknown_object(three_oid.hash);\n> +\tthree = lookup_unknown_object(the_repository, three_oid.hash);\n>   \tret = lookup_decoration(&n, three);\n>   \tif (ret)\n>   \t\tdie(\"BUG: lookup for unknown object should return NULL\");\n> diff --git a/upload-pack.c b/upload-pack.c\n> index 20e61180e48..aebab6f3277 100644\n> --- a/upload-pack.c\n> +++ b/upload-pack.c\n> @@ -971,7 +971,7 @@ static void receive_needs(void)\n>   static int mark_our_ref(const char *refname, const char *refname_full,\n>   \t\t\tconst struct object_id *oid)\n>   {\n> -\tstruct object *o = lookup_unknown_object(oid->hash);\n> +\tstruct object *o = lookup_unknown_object(the_repository, oid->hash);\n>   \n>   \tif (ref_is_hidden(refname, refname_full)) {\n>   \t\to->flags |= HIDDEN_REF;\n> diff --git a/walker.c b/walker.c\n> index 3678e344312..aea96f0eaff 100644\n> --- a/walker.c\n> +++ b/walker.c\n> @@ -282,7 +282,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,\n>   \t\t\terror(\"Could not interpret response from server '%s' as something to pull\", target[i]);\n>   \t\t\tgoto done;\n>   \t\t}\n> -\t\tif (process(walker, lookup_unknown_object(oids[i].hash)))\n> +\t\tif (process(walker, lookup_unknown_object(the_repository, oids[i].hash)))\n>   \t\t\tgoto done;\n>   \t}\n>   \n"},{"id":"348827","messageId":"e6651365-dd04-98dd-10b7-867bebcc4e27@gmail.com","threadId":"48596","inReplyTo":"20180530004810.30076-5-sbeller@google.com","subject":"Re: [PATCH 04/35] object: add repository argument to parse_object_buffer","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-05-30T18:34:17Z","receivedAt":"2018-05-30T18:34:25Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/29/2018 8:47 PM, Stefan Beller wrote:\n> Add a repository argument to allow the callers of parse_object_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> Add the cocci patch that converted the callers.\n\nAgain, I'm missing the cocci patch here.\n\n\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>   builtin/fast-export.c    | 3 ++-\n>   builtin/fsck.c           | 6 ++++--\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, 17 insertions(+), 9 deletions(-)\n>\n> diff --git a/builtin/fast-export.c b/builtin/fast-export.c\n> index 24d42842f9d..a34ab9768f4 100644\n> --- a/builtin/fast-export.c\n> +++ b/builtin/fast-export.c\n> @@ -245,7 +245,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)\n> diff --git a/builtin/fsck.c b/builtin/fsck.c\n> index 700739804fc..e6d6eb266eb 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> @@ -522,7 +523,8 @@ static struct object *parse_loose_object(const struct object_id *oid,\n>   \tif (!contents && type != OBJ_BLOB)\n>   \t\tdie(\"BUG: read_loose_object streamed a non-blob\");\n>   \n> -\tobj = parse_object_buffer(oid, type, size, contents, &eaten);\n> +\tobj = parse_object_buffer(the_repository, oid, type, size,\n> +\t\t\t\t  contents, &eaten);\n>   \n>   \tif (!eaten)\n>   \t\tfree(contents);\n> diff --git a/builtin/index-pack.c b/builtin/index-pack.c\n> index e2f670bef9e..0dd10693597 100644\n> --- a/builtin/index-pack.c\n> +++ b/builtin/index-pack.c\n> @@ -848,7 +848,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));\n> diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\n> index 9a4d2708123..8e454c48649 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));\n> diff --git a/object.c b/object.c\n> index def3c71cac2..4250ddd3f7f 100644\n> --- a/object.c\n> +++ b/object.c\n> @@ -186,7 +186,7 @@ struct object *lookup_unknown_object_the_repository(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;\n> diff --git a/object.h b/object.h\n> index 778f83bf0f7..c6386d7b6b1 100644\n> --- a/object.h\n> +++ b/object.h\n> @@ -136,7 +136,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>   #define lookup_unknown_object(r, s) lookup_unknown_object_##r(s)\n> diff --git a/ref-filter.c b/ref-filter.c\n> index 6ebb4630f9c..7e57c07bf54 100644\n> --- a/ref-filter.c\n> +++ b/ref-filter.c\n> @@ -806,7 +806,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"},{"id":"348828","messageId":"defafdc6-e3e2-381e-3239-926a7df43146@gmail.com","threadId":"48596","inReplyTo":"20180530004810.30076-7-sbeller@google.com","subject":"Re: [PATCH 06/35] blob: add repository argument to lookup_blob","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-05-30T18:36:59Z","receivedAt":"2018-05-30T18:37:07Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/29/2018 8:47 PM, Stefan Beller wrote:\n> Add a repository argument to allow the callers of lookup_blob\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> Add the cocci patch that converted the callers.\n(this is the last time I'll point this out. I'll wait until I read to \nthe end to see if the coccinelle patch is included in the series.)\n>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> Signed-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                   | 2 +-\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, 22 insertions(+), 17 deletions(-)\n>\n> diff --git a/blob.c b/blob.c\n> index 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)\n> diff --git a/blob.h b/blob.h\n> index 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>   \n> diff --git a/builtin/fast-export.c b/builtin/fast-export.c\n> index a34ab9768f4..23ca46e6008 100644\n> --- a/builtin/fast-export.c\n> +++ b/builtin/fast-export.c\n> @@ -237,7 +237,7 @@ static void export_blob(const struct object_id *oid)\n>   \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);\n> diff --git a/builtin/fsck.c b/builtin/fsck.c\n> index 82a5acaf76e..6e2b204e938 100644\n> --- a/builtin/fsck.c\n> +++ b/builtin/fsck.c\n> @@ -808,7 +808,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;\n> diff --git a/builtin/index-pack.c b/builtin/index-pack.c\n> index 0dd10693597..51c5244a15a 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\n> diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\n> index 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>   \n> diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\n> index 8e454c48649..dfea7790fde 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\n> diff --git a/fsck.c b/fsck.c\n> index f9476f56e93..2d372f2a3f3 100644\n> --- a/fsck.c\n> +++ b/fsck.c\n> @@ -367,7 +367,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> diff --git a/http-push.c b/http-push.c\n> index 04d95bd5da8..730e9cd0667 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 */\n> diff --git a/list-objects.c b/list-objects.c\n> index 7ae0eb8ebc7..56682c2a441 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}\n> diff --git a/object.c b/object.c\n> index bd5df7d007a..80a8e44832f 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>   \n> diff --git a/reachable.c b/reachable.c\n> index 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\",\n> diff --git a/revision.c b/revision.c\n> index f051c6c5806..aeccbf5fe24 100644\n> --- a/revision.c\n> +++ b/revision.c\n> @@ -69,7 +69,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> @@ -1338,7 +1338,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, \"\",\n> diff --git a/tag.c b/tag.c\n> index 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)) {\n> diff --git a/walker.c b/walker.c\n> index aea96f0eaff..a36f53f37be 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"},{"id":"348831","messageId":"45386849-9a42-a639-06de-78d7e127407b@gmail.com","threadId":"48596","inReplyTo":"20180530004810.30076-28-sbeller@google.com","subject":"Re: [PATCH 27/35] commit-slabs: remove realloc counter outside of slab struct","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-05-30T19:00:32Z","receivedAt":"2018-05-30T19:00:37Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/29/2018 8:48 PM, Stefan Beller wrote:\n> The realloc counter is declared outside the struct for the given slabname,\n> which makes it harder for a follow up patch to move the declaration of the\n> struct around as then the counter variable would need special treatment.\n>\n> As the reallocation counter is currently unused we can just remove it.\n> If we ever need to count the reallocations again, we can reintroduce\n> the counter as part of 'struct slabname' in commit-slab-decl.h.\n\nIt's worth noting that this patch is different from the other mechanical \npatches. I do agree that we should remove this unused portion of the \nslab API. Likely this was built for testing purposes.\n\nCC'ing Junio, who I found introduced this in a84b794ad \"commit-slab: \nintroduce a macro to define a slab for new type\". Looking at that diff, \nthe realloc portion did not appear to exist in the previous \nin-degree-specific version of slabs.\n\n>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>   commit-slab-impl.h | 3 ---\n>   1 file changed, 3 deletions(-)\n>\n> diff --git a/commit-slab-impl.h b/commit-slab-impl.h\n> index 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"},{"id":"348833","messageId":"6e18e6bb-cc11-a1b4-becb-4115df124284@gmail.com","threadId":"48596","inReplyTo":"CAGZ79kaEHhE=suT2-Rzrbu2P7z8KPzRdCOFNCTqsOiV0+HjJ9A@mail.gmail.com","subject":"Re: [RFC PATCH 00/35] object-store: lookup_commit","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-05-30T19:18:24Z","receivedAt":"2018-05-30T19:18:30Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 5/29/2018 11:18 PM, Stefan Beller wrote:\n> On Tue, May 29, 2018 at 6:05 PM, Derrick Stolee <stolee@gmail.com> wrote:\n>> On 5/29/2018 8:47 PM, Stefan Beller wrote:\n>>> This applies on the merge of nd/commit-util-to-slab and\n>>> sb/object-store-grafts,\n>>> and is available at http://github.com/stefanbeller/ as branch\n>>> object-store-lookup-commit\n>>> as the merge has some merge conflicts as well as syntactical conflicts\n>>> (upload-pack.c\n>>> and fetch-pack.c introduce new calls of functions that would want to take\n>>> a repository struct\n>>> in the object-store-grafts series)\n>>>\n>>> As layed out in\n>>> https://public-inbox.org/git/20180517225154.9200-1-sbeller@google.com/\n>>> this is getting close to finishing the set of object store series though\n>>> the last\n>>> unfinished 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,\n>>> too.\n>>>     But that requires the conversion of the new commit graph. Maybe we need\n>>>     to split this series into 2.\n>>\n>> I'll take a look at this series tomorrow. I've been working in\n>> ds/commit-graph-fsck to make many of the methods take a 'struct commit_graph\n>> *' parameter, which could easily be 'r->commit_graph' for a 'struct\n>> the_repository *r' instead of the global 'commit_graph'. Those graph-local\n>> methods will make the transformation to be repo-local a lot easier. (There\n>> still may be some need to insert a repository, though.)\n>>\n>> Since you are working on the commit-slab stuff in this patch, I'll (continue\n>> to) delay my patch series on using the commit-slab for generation numbers to\n>> avoid collisions with your work.\n> This series touches the commit slabs in the last few commits only.\n> I don't think there will be huge conflicts, as all I had to do was\n> move the definition from a global to inside the parsed object store.\n\nI went through the whole series and didn't find any issue with the code. \nThe commit messages reference coccinelle scripts that I never saw, so \nthose should be struck from the messages.\n\nIf anyone else plans to review, these two commits are worth special \nattention compared to the others:\n\n[PATCH 27/35] commit-slabs: remove realloc counter outside of slab struct\n[PATCH 28/35] commit.c: migrate the commit buffer to the parsed object store\n\nI found no issue with them, but they do actually change behavior slightly as opposed to the other commits which have no change other than to relax the dependence on the_repository as a global. I also like the pattern of storing the slabs inside the parsed object structure in the_repository. I'll use a similar pattern when looking into using slabs for generation number.\n\nFor Junio: I know this will conflict with ds/commit-graph-fsck (specifically, I add new references to lookup_commit() and manipulate parse_commit_gently()). If this series is ready to be queued quickly, I can rebase my v4 onto these commits as they are placed into 'pu' (and please eject ds/commit-graph-fsck at that time).\n\nThanks,\n-Stolee\n\n"},{"id":"348848","messageId":"CAGZ79kaaObh50ff1fT3no=jsHde+ZyacKtgbFa8ht__Hg4SDsg@mail.gmail.com","threadId":"48596","inReplyTo":"6e18e6bb-cc11-a1b4-becb-4115df124284@gmail.com","subject":"Re: [RFC PATCH 00/35] object-store: lookup_commit","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-30T22:19:33Z","receivedAt":"2018-05-30T22:19:37Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Hi Derrick,\n\n> I went through the whole series and didn't find any issue with the code. The\n> commit messages reference coccinelle scripts that I never saw, so those\n> should be struck from the messages.\n\nI fixed this locally. I'll wait for more reviews to resend though.\n\n>\n> If anyone else plans to review, these two commits are worth special\n> attention compared to the others:\n>\n> [PATCH 27/35] commit-slabs: remove realloc counter outside of slab struct\n> [PATCH 28/35] commit.c: migrate the commit buffer to the parsed object store\n\nThanks for pointing these out! patch 27 might even go on top of\nnd/commit-slab-to-util.\n"},{"id":"349544","messageId":"CACsJy8Daj2yvZ6FHJJSrjMuYsy7sUqW2o4XtUqEh0r=o6cjJew@mail.gmail.com","threadId":"48596","inReplyTo":"20180530004810.30076-8-sbeller@google.com","subject":"Re: [PATCH 07/35] tree: add repository argument to lookup_tree","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-06-06T19:26:24Z","receivedAt":"2018-06-06T19:26:58Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, May 30, 2018 at 2:47 AM, Stefan Beller <sbeller@google.com> wrote:\n> Add a repository argument to allow the callers of lookup_tree\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> Add the cocci patch that converted the callers.\n\nI don't see the cocci patch in diffstat. I don't need to see it, but\nthis sentence probably should be dropped.\n\n>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> Signed-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-- \nDuy\n"},{"id":"349545","messageId":"CACsJy8BQGqNDkoL0ykNdbgAx75MjPzW3Ki5+rbHxxJ8TNWDZcw@mail.gmail.com","threadId":"48596","inReplyTo":"20180530004810.30076-29-sbeller@google.com","subject":"Re: [PATCH 28/35] commit.c: migrate the commit buffer to the parsed object store","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-06-06T19:31:56Z","receivedAt":"2018-06-06T19:32:30Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, May 30, 2018 at 2:48 AM, Stefan Beller <sbeller@google.com> wrote:\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>  commit.c | 29 +++++++++++++++++++++++------\n>  commit.h |  2 ++\n>  object.c |  5 +++++\n>  object.h |  2 ++\n>  4 files changed, 32 insertions(+), 6 deletions(-)\n>\n> diff --git a/commit.c b/commit.c\n> index fd31c453fdc..45dbf6f1453 100644\n> --- a/commit.c\n> +++ b/commit.c\n> @@ -248,18 +248,32 @@ struct commit_buffer {\n>         unsigned long size;\n>  };\n>  define_commit_slab(buffer_slab, struct commit_buffer);\n\nstruct buffer_slab is defined locally here...\n\n> diff --git a/commit.h b/commit.h\n> index 536fa03955f..df199498bfb 100644\n> --- a/commit.h\n> +++ b/commit.h\n> @@ -81,6 +81,8 @@ static inline int parse_commit_the_repository(struct commit *item)\n>  }\n>  void parse_commit_or_die(struct commit *item);\n>\n> +struct buffer_slab *allocate_commit_buffer_slab(void);\n\nSo you would need a forward declaration of struct buffer_slab in\ncommit.h before it's referenced here?\n\n> diff --git a/object.h b/object.h\n> index 6adc8323ca4..45e22282101 100644\n> --- a/object.h\n> +++ b/object.h\n> @@ -22,6 +22,8 @@ struct parsed_object_pool {\n>         char *alternate_shallow_file;\n>\n>         int commit_graft_prepared;\n> +\n> +       struct buffer_slab *buffer_slab;\n\nand maybe here as well\n\n>  };\n>\n>  struct parsed_object_pool *parsed_object_pool_new(void);\n> --\n> 2.17.0.582.gccdcbd54c44.dirty\n>\n\n\n\n-- \nDuy\n"},{"id":"349548","messageId":"CACsJy8C=YNRmawuR3SZDMpmkKHMp=kPJsDjffCrcONe+CDpJ_g@mail.gmail.com","threadId":"48596","inReplyTo":"20180530004810.30076-4-sbeller@google.com","subject":"Re: [PATCH 03/35] object: add repository argument to lookup_unknown_object","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-06-06T19:38:26Z","receivedAt":"2018-06-06T19:39:03Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, May 30, 2018 at 2:47 AM, Stefan Beller <sbeller@google.com> wrote:\n> diff --git a/object.c b/object.c\n> index 4de4fa58d59..def3c71cac2 100644\n> --- a/object.c\n> +++ b/object.c\n> @@ -177,7 +177,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)\n>         }\n>  }\n>\n> -struct object *lookup_unknown_object(const unsigned char *sha1)\n> +struct object *lookup_unknown_object_the_repository(const unsigned char *sha1)\n\nI'm looking at your branch and this function (with the _the_repository\nsuffix) is still there. Did you forget to send a patch to convert this\nfunction?\n\n>  {\n>         struct object *obj = lookup_object(the_repository, sha1);\n>         if (!obj)\n-- \nDuy\n"},{"id":"350081","messageId":"CAGZ79kY97np6ZJv1_CBx_ZqPF-AQJh2U8uW8sFxJZMAHnhPrpg@mail.gmail.com","threadId":"48596","inReplyTo":"CACsJy8C=YNRmawuR3SZDMpmkKHMp=kPJsDjffCrcONe+CDpJ_g@mail.gmail.com","subject":"Re: [PATCH 03/35] object: add repository argument to lookup_unknown_object","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T19:30:15Z","receivedAt":"2018-06-13T19:30:33Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Jun 6, 2018 at 12:38 PM Duy Nguyen <pclouds@gmail.com> wrote:\n>\n> On Wed, May 30, 2018 at 2:47 AM, Stefan Beller <sbeller@google.com> wrote:\n> > diff --git a/object.c b/object.c\n> > index 4de4fa58d59..def3c71cac2 100644\n> > --- a/object.c\n> > +++ b/object.c\n> > @@ -177,7 +177,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)\n> >         }\n> >  }\n> >\n> > -struct object *lookup_unknown_object(const unsigned char *sha1)\n> > +struct object *lookup_unknown_object_the_repository(const unsigned char *sha1)\n>\n> I'm looking at your branch and this function (with the _the_repository\n> suffix) is still there. Did you forget to send a patch to convert this\n> function?\n\nThis and parse_commit and parse_commit_gently have not been converted.\n\nI stopped with this series as soon as I hit the commit-graph code, which needs\nto be updated, too. I'll start redoing this series soon and will fix\nthose conversions.\n"},{"id":"350082","messageId":"CAGZ79kYxttQvoyg-QuMw3Wwm_j=MSw_ut2bY6vHHfDv4qgB7jA@mail.gmail.com","threadId":"48596","inReplyTo":"CACsJy8BQGqNDkoL0ykNdbgAx75MjPzW3Ki5+rbHxxJ8TNWDZcw@mail.gmail.com","subject":"Re: [PATCH 28/35] commit.c: migrate the commit buffer to the parsed object store","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T20:55:11Z","receivedAt":"2018-06-13T20:55:26Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Jun 6, 2018 at 12:32 PM Duy Nguyen <pclouds@gmail.com> wrote:\n> >  define_commit_slab(buffer_slab, struct commit_buffer);\n>\n> struct buffer_slab is defined locally here...\n>\n...\n> > +struct buffer_slab *allocate_commit_buffer_slab(void);\n>\n> So you would need a forward declaration of struct buffer_slab in\n> commit.h before it's referenced here?\n\nWill do so in a resend; as well as in object.h\n"},{"id":"350101","messageId":"20180613230522.55335-1-sbeller@google.com","threadId":"48596","inReplyTo":"20180530004810.30076-1-sbeller@google.com","subject":"[PATCH v2 00/31] object-store: lookup_commit","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:04:51Z","receivedAt":"2018-06-13T23:05:38Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"* 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\nStefan Beller (31):\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      |  6 ++--\n builtin/diff.c           |  5 +--\n builtin/fast-export.c    | 12 ++++---\n builtin/fetch.c          |  9 +++--\n builtin/fmt-merge-msg.c  |  5 +--\n builtin/fsck.c           | 16 +++++----\n builtin/grep.c           |  3 +-\n builtin/index-pack.c     |  5 +--\n builtin/log.c            |  7 ++--\n builtin/merge-base.c     |  7 ++--\n builtin/merge-tree.c     |  3 +-\n builtin/name-rev.c       |  6 ++--\n builtin/notes.c          |  3 +-\n builtin/pack-objects.c   |  2 +-\n builtin/prune.c          |  2 +-\n builtin/pull.c           | 15 +++++---\n builtin/reflog.c         | 12 ++++---\n builtin/replace.c        |  4 +--\n builtin/reset.c          |  4 +--\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                 |  5 +--\n cache-tree.c             |  3 +-\n commit-graph.c           | 14 ++++----\n commit-slab-impl.h       |  3 --\n commit.c                 | 77 +++++++++++++++++++++++++---------------\n commit.h                 | 18 ++++++----\n fast-import.c            |  6 ++--\n fetch-pack.c             | 25 +++++++------\n fsck.c                   |  4 +--\n http-backend.c           |  2 +-\n http-push.c              | 10 +++---\n line-log.c               |  2 +-\n list-objects.c           |  4 +--\n log-tree.c               |  6 ++--\n merge-recursive.c        |  9 ++---\n notes-cache.c            |  3 +-\n notes-merge.c            |  5 +--\n notes-utils.c            |  4 ++-\n object.c                 | 59 ++++++++++++++++--------------\n object.h                 | 13 ++++---\n parse-options-cb.c       |  2 +-\n pretty.c                 |  2 +-\n reachable.c              |  8 ++---\n ref-filter.c             |  9 +++--\n refs.c                   |  2 +-\n remote.c                 | 19 +++++-----\n revision.c               | 12 +++----\n sequencer.c              | 14 ++++----\n server-info.c            |  2 +-\n sha1-file.c              |  4 +--\n sha1-name.c              | 23 ++++++------\n shallow.c                | 30 ++++++++++------\n submodule.c              | 10 +++---\n tag.c                    | 27 +++++++-------\n tag.h                    |  7 ++--\n tree.c                   | 14 ++++----\n tree.h                   |  2 +-\n upload-pack.c            |  4 +--\n walker.c                 |  9 +++--\n wt-status.c              |  2 +-\n 76 files changed, 400 insertions(+), 297 deletions(-)\n\n-- \n2.18.0.rc1.244.gcf134e6275-goog\n\n"},{"id":"350102","messageId":"20180613230522.55335-2-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 01/31] object: add repository argument to lookup_object","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:04:52Z","receivedAt":"2018-06-13T23:05:42Z","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 0da875b58c9..24d42842f9d 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -231,7 +231,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@@ -403,7 +403,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 4b410cba54e..98fdeef5407 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@@ -762,7 +762,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 ded798b72ff..9a4d2708123 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 11db72e9db2..97b4ccde8f0 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -53,7 +53,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 fa39ada77ee..4523e25ff4e 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@@ -1295,7 +1296,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 311b6295359..2615c823d60 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 469e6126286..4de4fa58d59 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 f69095d3dde..fa41d711f44 100644\n--- a/object.h\n+++ b/object.h\n@@ -110,7 +110,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 1033e69b590..47ecc85f90a 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 afe997c89ec..20e61180e48 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -568,7 +568,7 @@ static int get_reachable_list(struct object_array *src,\n \t\tif (namebuf[40] != '\\n' || get_oid_hex(namebuf, &sha1))\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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350103","messageId":"20180613230522.55335-3-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 02/31] object: add repository argument to parse_object_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:04:53Z","receivedAt":"2018-06-13T23:05: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_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           | 6 ++++--\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, 17 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 24d42842f9d..a34ab9768f4 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -245,7 +245,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 98fdeef5407..6b8c9074920 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@@ -522,7 +523,8 @@ static struct object *parse_loose_object(const struct object_id *oid,\n \tif (!contents && type != OBJ_BLOB)\n \t\tdie(\"BUG: read_loose_object streamed a non-blob\");\n \n-\tobj = parse_object_buffer(oid, type, size, contents, &eaten);\n+\tobj = parse_object_buffer(the_repository, oid, type, size,\n+\t\t\t\t  contents, &eaten);\n \n \tif (!eaten)\n \t\tfree(contents);\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex e2f670bef9e..0dd10693597 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -848,7 +848,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 9a4d2708123..8e454c48649 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 4de4fa58d59..0ffcf619cef 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 fa41d711f44..7526ee151f5 100644\n--- a/object.h\n+++ b/object.h\n@@ -136,7 +136,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 6ebb4630f9c..7e57c07bf54 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -806,7 +806,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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350104","messageId":"20180613230522.55335-4-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 03/31] object: add repository argument to object_as_type","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:04:54Z","receivedAt":"2018-06-13T23:05: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 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 6b8c9074920..72d7a9cbd8c 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 97b4ccde8f0..d76d64d4dfc 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -31,7 +31,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@@ -57,7 +57,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 0ffcf619cef..b221ba714a7 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 7526ee151f5..5425d8e647c 100644\n--- a/object.h\n+++ b/object.h\n@@ -115,7 +115,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 23d53957deb..0304e2b866f 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 47ecc85f90a..bd74ed66e23 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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350105","messageId":"20180613230522.55335-5-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 04/31] blob: add repository argument to lookup_blob","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:04:55Z","receivedAt":"2018-06-13T23:05:49Z","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                   | 2 +-\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, 22 insertions(+), 17 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 a34ab9768f4..23ca46e6008 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -237,7 +237,7 @@ static void export_blob(const struct object_id *oid)\n \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 72d7a9cbd8c..0c61249282a 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -808,7 +808,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 0dd10693597..51c5244a15a 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 8e454c48649..dfea7790fde 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 f9476f56e93..2d372f2a3f3 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -367,7 +367,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);\ndiff --git a/http-push.c b/http-push.c\nindex 2615c823d60..8c9d285c914 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 7ae0eb8ebc7..56682c2a441 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 b221ba714a7..8d790ac920a 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 f051c6c5806..aeccbf5fe24 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -69,7 +69,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@@ -1338,7 +1338,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 3678e344312..ea0c41f47a2 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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350106","messageId":"20180613230522.55335-7-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 06/31] commit: add repository argument to lookup_commit_reference_gently","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:04:57Z","receivedAt":"2018-06-13T23:05:53Z","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 9da1e3664a6..983a45ba3e7 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 2904b0500d9..726a7a76f20 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 105e07981ff..31a71f75625 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@@ -823,7 +823,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@@ -997,7 +997,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 58341c6f9ed..f3dfd0228be 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 6ce11bfb094..499cf6fcf12 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -690,8 +690,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@@ -824,7 +826,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 93dabd7ce31..6ff3c5abff0 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 9ef55f6bdb0..14a209ff149 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 88a4b0d2a47..5345cc90ed1 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -622,7 +622,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 755b8b9d94f..b039444aa62 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -23,8 +23,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@@ -36,7 +36,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 9019652dbac..73ccdd8005b 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -55,7 +55,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 b2338fa8eb2..fadc2c70021 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 7e57c07bf54..8133871e93d 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -2010,7 +2010,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@@ -2367,7 +2368,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 92a17828d25..956fd0fd923 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1337,7 +1337,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@@ -1399,7 +1399,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@@ -1627,8 +1628,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 bf5620dff0c..4e89e2b1123 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2886,7 +2886,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 3e1c57e1539..412a5257d6f 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -1217,13 +1217,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 7cb893c3d94..9bb07a56dca 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -489,7 +489,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@@ -551,7 +552,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@@ -661,7 +663,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 07cecfda693..d3721349254 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 e35cdfeb4be..40ccf2dccb5 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1481,7 +1481,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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350107","messageId":"20180613230522.55335-6-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 05/31] tree: add repository argument to lookup_tree","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:04:56Z","receivedAt":"2018-06-13T23:05:57Z","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 d834f9e62b6..f4b510bcc5f 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 ed6092ef1a3..0b7d0d612dd 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -379,7 +379,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 3a751fbaa60..93dabd7ce31 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 1c338c41f3a..69b214613dd 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 71125d7cbb6..88a4b0d2a47 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -261,7 +261,7 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin\n \titem->graph_pos = pos;\n \n \thashcpy(oid.hash, commit_data);\n-\titem->tree = lookup_tree(&oid);\n+\titem->tree = lookup_tree(the_repository, &oid);\n \n \tdate_high = get_be32(commit_data + g->hash_len + 8) & 0x3;\n \tdate_low = get_be32(commit_data + g->hash_len + 12);\ndiff --git a/commit.c b/commit.c\nindex d76d64d4dfc..755b8b9d94f 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -354,7 +354,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s\n \tif (get_sha1_hex(bufptr + 5, parent.hash) < 0)\n \t\treturn error(\"bad tree pointer in commit %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\n-\titem->tree = lookup_tree(&parent);\n+\titem->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 2d372f2a3f3..b07abb9796c 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -360,7 +360,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 8c9d285c914..94ae9671def 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 56682c2a441..b9159c24671 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 8ddedf79c0b..1b06f25b38c 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -96,7 +96,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@@ -335,7 +335,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@@ -2123,7 +2123,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 8d790ac920a..1a67d6e341f 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 aeccbf5fe24..79f228b1586 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -66,7 +66,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@@ -1312,7 +1312,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 d715c877501..bf5620dff0c 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -397,7 +397,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 bd74ed66e23..fbc8d4bc653 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 ea0c41f47a2..07cecfda693 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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350108","messageId":"20180613230522.55335-9-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 08/31] commit: add repository argument to lookup_commit","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:04:59Z","receivedAt":"2018-06-13T23:05:59Z","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 f4b510bcc5f..fb7c21f7103 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 23ca46e6008..bc837d2593c 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -964,7 +964,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 5345cc90ed1..6c08fc0a9ba 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -241,7 +241,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@@ -527,7 +527,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@@ -538,14 +538,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@@ -658,7 +658,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 e031a6c3175..5e3f18801a1 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -51,7 +51,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@@ -373,7 +373,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@@ -381,7 +381,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 a5f84466efd..431a7d97a24 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -53,7 +53,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 4523e25ff4e..74ac2977e85 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@@ -1256,7 +1257,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 e8d2857bf06..a47283eca64 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -147,7 +147,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 1a67d6e341f..4eca16f4adb 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))\n \t\t\t\treturn NULL;\ndiff --git a/sequencer.c b/sequencer.c\nindex 8931c461f20..da6c9fc5511 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -543,7 +543,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@@ -972,7 +972,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 d153d8c692b..5eef8ddd6d6 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -352,7 +352,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 9bb07a56dca..60fe1fe1e58 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@@ -256,7 +256,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@@ -621,7 +621,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@@ -632,7 +633,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@@ -702,7 +704,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@@ -723,7 +725,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@@ -745,7 +747,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 fbc8d4bc653..33063b8dde0 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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350109","messageId":"20180613230522.55335-8-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 07/31] commit: add repository argument to lookup_commit_reference","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:04:58Z","receivedAt":"2018-06-13T23:06:01Z","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/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 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           | 10 +++++-----\n 25 files changed, 63 insertions(+), 49 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 726a7a76f20..86d0dd73338 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 9b2742de32a..08d4efc1be6 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -301,7 +301,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 efc9ac1922c..fbbe311e270 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -126,7 +126,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@@ -159,7 +160,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@@ -213,7 +214,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 2f10c468300..5b10ddfc832 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -695,7 +695,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 f3dfd0228be..080b5ce082c 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 063057e45de..c962d22707b 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 6011cd2a074..50963642075 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 324c4ffa1a7..ec3f90545dd 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -760,10 +760,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@@ -937,9 +940,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/reset.c b/builtin/reset.c\nindex a9136a163c0..aeab0c7aea5 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 a8a9b506ff6..cc6a6c9a019 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\texclude = get_merge_bases(a, b);\n \t\t\twhile (exclude) {\n \t\t\t\tstruct commit *commit = pop_commit(&exclude);\n@@ -333,7 +333,7 @@ static int try_parent_shorthands(const char *arg)\n \t\treturn 0;\n \t}\n \n-\tcommit = lookup_commit_reference(&oid);\n+\tcommit = lookup_commit_reference(the_repository, &oid);\n \tif (exclude_parent &&\n \t    exclude_parent > commit_list_count(commit->parents)) {\n \t\t*dotdot = '^';\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 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 14a209ff149..904b59e72a5 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 b039444aa62..e031a6c3175 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -34,14 +34,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@@ -67,7 +67,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 73ccdd8005b..a5f84466efd 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -54,7 +54,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/notes-merge.c b/notes-merge.c\nindex fd96c5ab3d6..2572e435432 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 956fd0fd923..2a6ff7d60c1 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -2058,13 +2058,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 79f228b1586..25df00cc16c 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1581,8 +1581,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 4e89e2b1123..8931c461f20 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1047,7 +1047,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@@ -1370,7 +1370,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@@ -1824,7 +1824,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 412a5257d6f..d153d8c692b 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -810,7 +810,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@@ -838,7 +838,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 8fd8e5d178d..e45150a3f51 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -516,8 +516,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@@ -1800,9 +1800,9 @@ int merge_submodule(struct object_id *result, const char *path,\n \t\treturn 0;\n \t}\n \n-\tif (!(commit_base = lookup_commit_reference(base)) ||\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\tMERGE_WARNING(path, \"commits not present\");\n \t\treturn 0;\n \t}\n-- \n2.18.0.rc1.244.gcf134e6275-goog\n\n"},{"id":"350110","messageId":"20180613230522.55335-11-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 10/31] commit: add repository argument to set_commit_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:01Z","receivedAt":"2018-06-13T23:06:05Z","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 86d0dd73338..50808c0ff44 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 dda585025ed..667d4dc6cfd 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -249,7 +249,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@@ -418,7 +418,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)\n \t}\n \tret = parse_commit_buffer(the_repository, item, buffer, size);\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 05b9eccaf66..a1ecd067ccc 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -85,7 +85,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 fe1f84f7c6c..ff0ba98675e 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))\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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350111","messageId":"20180613230522.55335-13-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 12/31] tag: add repository argument to lookup_tag","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:03Z","receivedAt":"2018-06-13T23:06:08Z","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 080b5ce082c..6fb713b6be1 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 8c108109985..eb11ef4a5dd 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2365,7 +2365,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 14e142d5a80..8c8cec4aae6 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -359,7 +359,7 @@ static void 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\tdie(_(\"bad mergetag in commit '%s'\"), ref);\n \tif (parse_tag_buffer(tag, extra->value, extra->len))\ndiff --git a/log-tree.c b/log-tree.c\nindex a47283eca64..727758eb442 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -506,7 +506,7 @@ static void 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; /* error message already given */\n \ndiff --git a/object.c b/object.c\nindex ecaac5c2990..080e9b36eaf 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 5eef8ddd6d6..98b66c4896c 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -359,7 +359,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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350112","messageId":"20180613230522.55335-14-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 13/31] tag: add repository argument to parse_tag_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:04Z","receivedAt":"2018-06-13T23:06:10Z","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 8c8cec4aae6..bff1c3df964 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -362,7 +362,7 @@ static void check_one_mergetag(struct commit *commit,\n \ttag = lookup_tag(the_repository, &tag_oid);\n \tif (!tag)\n \t\tdie(_(\"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\tdie(_(\"malformed mergetag in commit '%s'\"), ref);\n \n \t/* iterate over new parents */\ndiff --git a/log-tree.c b/log-tree.c\nindex 727758eb442..ac42ad42acc 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -511,7 +511,7 @@ static void show_one_mergetag(struct commit *commit,\n \t\treturn; /* 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 080e9b36eaf..c6779ee596f 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 00b1b2b8660..3440b67639e 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -1788,7 +1788,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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350113","messageId":"20180613230522.55335-15-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 14/31] tag: add repository argument to deref_tag","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:05Z","receivedAt":"2018-06-13T23:06: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 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 50808c0ff44..aad53c0f904 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 0b7d0d612dd..1dd7dd4a267 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -395,7 +395,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\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 6e7bc76785a..c93c33cd28f 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -646,7 +646,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 ba06918ba41..ede31c46931 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -26,7 +26,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 74ac2977e85..358d8421a8f 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 94ae9671def..61cdd40822a 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 ecdce08c4be..34c4a93c5b2 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 1b06f25b38c..9013aabed9a 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -2184,7 +2184,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 2a6ff7d60c1..0bf5ce3e7ba 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1995,12 +1995,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 368fb547f4b..e83797c3caf 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 98b66c4896c..27cf9cd916e 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@@ -934,7 +936,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@@ -1066,7 +1068,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 60fe1fe1e58..c65cb17195e 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 20e61180e48..1d7d6917f24 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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350114","messageId":"20180613230522.55335-16-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 15/31] object: allow object_as_type to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:06Z","receivedAt":"2018-06-13T23:06:17Z","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 c6779ee596f..876ca4977e2 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 5425d8e647c..bd25155480f 100644\n--- a/object.h\n+++ b/object.h\n@@ -115,8 +115,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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350115","messageId":"20180613230522.55335-18-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 17/31] blob: allow lookup_blob to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:08Z","receivedAt":"2018-06-13T23:06:18Z","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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350116","messageId":"20180613230522.55335-19-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 18/31] tree: allow lookup_tree to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:09Z","receivedAt":"2018-06-13T23:06: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 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 33063b8dde0..2bffc0714a8 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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350117","messageId":"20180613230522.55335-17-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 16/31] object: allow lookup_object to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:07Z","receivedAt":"2018-06-13T23:06:29Z","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 876ca4977e2..c1c1cbc1f53 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 bd25155480f..66e0b7b93dc 100644\n--- a/object.h\n+++ b/object.h\n@@ -110,8 +110,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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350118","messageId":"20180613230522.55335-10-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 09/31] commit: add repository argument to parse_commit_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:00Z","receivedAt":"2018-06-13T23:06:30Z","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 5e3f18801a1..dda585025ed 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -334,7 +334,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)\n+int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size)\n {\n \tconst char *tail = buffer;\n \tconst char *bufptr = buffer;\n@@ -416,7 +416,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);\n+\tret = parse_commit_buffer(the_repository, item, buffer, size);\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 431a7d97a24..05b9eccaf66 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -72,7 +72,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);\n+#define parse_commit_buffer(r, i, b, s) parse_commit_buffer_##r(i, b, s)\n+int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size);\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 4eca16f4adb..fe1f84f7c6c 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))\n+\t\t\tif (parse_commit_buffer(the_repository, commit, buffer, size))\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 f66059ed7dd..00b1b2b8660 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -1780,7 +1780,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))\n+\tif (parse_commit_buffer(the_repository, &c, buf, size))\n \t\tdie(\"corrupt commit\");\n }\n \n-- \n2.18.0.rc1.244.gcf134e6275-goog\n\n"},{"id":"350119","messageId":"20180613230522.55335-23-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 22/31] commit.c: allow parse_commit_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:13Z","receivedAt":"2018-06-13T23:06:33Z","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 4b10e7173b5..fe3b6ff216f 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -335,7 +335,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)\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size)\n {\n \tconst char *tail = buffer;\n \tconst char *bufptr = buffer;\n@@ -355,11 +355,11 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,\n \tif (get_sha1_hex(bufptr + 5, parent.hash) < 0)\n \t\treturn error(\"bad tree pointer in commit %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\n-\titem->tree = lookup_tree(the_repository, &parent);\n+\titem->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@@ -374,7 +374,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@@ -382,7 +382,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 d4561587851..66aabb80068 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -71,8 +71,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) parse_commit_buffer_##r(i, b, s)\n-int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size);\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size);\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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350120","messageId":"20180613230522.55335-24-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 23/31] commit-slabs: remove realloc counter outside of slab struct","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:14Z","receivedAt":"2018-06-13T23:06:34Z","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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350121","messageId":"20180613230522.55335-26-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 25/31] commit.c: allow set_commit_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:16Z","receivedAt":"2018-06-13T23:06:38Z","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 e9b22268997..44d1a38187a 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -262,10 +262,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 a417f99ad4f..3e883787855 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -87,8 +87,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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350122","messageId":"20180613230522.55335-27-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 26/31] commit.c: allow get_cached_commit_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:17Z","receivedAt":"2018-06-13T23:06:41Z","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 44d1a38187a..7ee55f6b8f0 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -270,10 +270,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 3e883787855..c7bb01ffe4b 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -93,8 +93,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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350123","messageId":"20180613230522.55335-28-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 27/31] object.c: allow parse_object_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:18Z","receivedAt":"2018-06-13T23:06:43Z","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 7a7b078e4d0..b63a51febd4 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))\n+\t\t\tif (parse_commit_buffer(r, commit, buffer, size))\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 876480c933c..9a667fbe795 100644\n--- a/object.h\n+++ b/object.h\n@@ -139,8 +139,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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350124","messageId":"20180613230522.55335-30-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 29/31] tag.c: allow deref_tag to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:20Z","receivedAt":"2018-06-13T23:06:47Z","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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350125","messageId":"20180613230522.55335-25-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 24/31] commit.c: migrate the commit buffer to the parsed object store","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:15Z","receivedAt":"2018-06-13T23:06:48Z","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 fe3b6ff216f..e9b22268997 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -248,18 +248,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@@ -291,14 +305,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@@ -318,7 +334,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 66aabb80068..a417f99ad4f 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -79,6 +79,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 c1c1cbc1f53..7a7b078e4d0 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@@ -538,6 +540,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 66e0b7b93dc..876480c933c 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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350126","messageId":"20180613230522.55335-32-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 31/31] commit.c: allow lookup_commit_reference to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:22Z","receivedAt":"2018-06-13T23:06:51Z","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 009e1d33e08..7b60e0cb030 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -35,9 +35,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 717403d6431..e1eb48afde2 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -54,9 +54,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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350127","messageId":"20180613230522.55335-29-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 28/31] object.c: allow parse_object to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:19Z","receivedAt":"2018-06-13T23:06:54Z","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 b63a51febd4..62df8e11b63 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 9a667fbe795..a7892b04455 100644\n--- a/object.h\n+++ b/object.h\n@@ -125,8 +125,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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350128","messageId":"20180613230522.55335-31-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 30/31] commit.c: allow lookup_commit_reference_gently to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:21Z","receivedAt":"2018-06-13T23:06:56Z","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 7ee55f6b8f0..009e1d33e08 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -23,16 +23,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 c7bb01ffe4b..717403d6431 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -57,9 +57,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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350129","messageId":"20180613230522.55335-12-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 11/31] commit: add repository argument to get_cached_commit_buffer","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:02Z","receivedAt":"2018-06-13T23:07:01Z","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 667d4dc6cfd..ba06918ba41 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -256,7 +256,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@@ -271,7 +271,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 a1ecd067ccc..66eb576897f 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -92,7 +92,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 ff0ba98675e..ecaac5c2990 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))\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 c99f8243faf..5b139775eac 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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350130","messageId":"20180613230522.55335-20-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 19/31] commit: allow lookup_commit to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:10Z","receivedAt":"2018-06-13T23:07:05Z","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 ede31c46931..4b10e7173b5 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -52,13 +52,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 66eb576897f..d4561587851 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -53,8 +53,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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350131","messageId":"20180613230522.55335-21-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 20/31] tag: allow lookup_tag to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:11Z","receivedAt":"2018-06-13T23:07:08Z","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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350132","messageId":"20180613230522.55335-22-sbeller@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"[PATCH v2 21/31] tag: allow parse_tag_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-13T23:05:12Z","receivedAt":"2018-06-13T23:07:09Z","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.rc1.244.gcf134e6275-goog\n\n"},{"id":"350136","messageId":"fbb5b88e-dbd3-1088-ef32-21f1ef9b0589@gmail.com","threadId":"48596","inReplyTo":"CAGZ79kY97np6ZJv1_CBx_ZqPF-AQJh2U8uW8sFxJZMAHnhPrpg@mail.gmail.com","subject":"Re: [PATCH 03/35] object: add repository argument to lookup_unknown_object","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-06-14T01:17:43Z","receivedAt":"2018-06-14T01:17:48Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 6/13/2018 3:30 PM, Stefan Beller wrote:\n> On Wed, Jun 6, 2018 at 12:38 PM Duy Nguyen <pclouds@gmail.com> wrote:\n>> On Wed, May 30, 2018 at 2:47 AM, Stefan Beller <sbeller@google.com> wrote:\n>>> diff --git a/object.c b/object.c\n>>> index 4de4fa58d59..def3c71cac2 100644\n>>> --- a/object.c\n>>> +++ b/object.c\n>>> @@ -177,7 +177,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)\n>>>          }\n>>>   }\n>>>\n>>> -struct object *lookup_unknown_object(const unsigned char *sha1)\n>>> +struct object *lookup_unknown_object_the_repository(const unsigned char *sha1)\n>> I'm looking at your branch and this function (with the _the_repository\n>> suffix) is still there. Did you forget to send a patch to convert this\n>> function?\n> This and parse_commit and parse_commit_gently have not been converted.\n>\n> I stopped with this series as soon as I hit the commit-graph code, which needs\n> to be updated, too. I'll start redoing this series soon and will fix\n> those conversions.\n\nYes, we are colliding a bit at the moment.\n\n  I'm planning to delay rerolling my patches until your last few series \nget merged.\n\nThanks,\n\n-Stolee\n\n"},{"id":"350137","messageId":"d5d95334-b0fc-bb8a-67ff-75b03ad7877a@gmail.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"Re: [PATCH v2 00/31] object-store: lookup_commit","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-06-14T01:23:26Z","receivedAt":"2018-06-14T01:23:31Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 6/13/2018 7:04 PM, Stefan Beller wrote\n> * Once this is in good shape we can talk about converting parts of the revision\n>    walking code,\n\nThis is another reason why I'll be waiting for this series of series. I \nplan to rework the revision walking code around \nsort_in_topological_order(), but I'll wait for your changes to land \nbefore submitting a patch. I'm itching to play with it, so I may start \ntesting things out before then.\n\nIn the meantime, I'll do my part by reviewing the current series.\n\nThanks,\n\n-Stolee\n\n"},{"id":"350139","messageId":"a55e0dae-9cb1-62d8-be82-46b5f823fd58@gmail.com","threadId":"48596","inReplyTo":"d5d95334-b0fc-bb8a-67ff-75b03ad7877a@gmail.com","subject":"Re: [PATCH v2 00/31] object-store: lookup_commit","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-06-14T01:42:17Z","receivedAt":"2018-06-14T01:42:21Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"\nOn 6/13/2018 9:23 PM, Derrick Stolee wrote:\n> On 6/13/2018 7:04 PM, Stefan Beller wrote\n>> * Once this is in good shape we can talk about converting parts of \n>> the revision\n>>    walking code,\n>\n> This is another reason why I'll be waiting for this series of series. \n> I plan to rework the revision walking code around \n> sort_in_topological_order(), but I'll wait for your changes to land \n> before submitting a patch. I'm itching to play with it, so I may start \n> testing things out before then.\n>\n> In the meantime, I'll do my part by reviewing the current series.\n\nLooks good to me.\n\nReviewed-by: Derrick Stolee <dstolee@microsoft.com>\n\n"},{"id":"350159","messageId":"CACsJy8D2JbeWvBg9F69tAJgq1874=ROFBG-QKfCHeUMZwcY-VQ@mail.gmail.com","threadId":"48596","inReplyTo":"20180530004810.30076-11-sbeller@google.com","subject":"Re: [PATCH 10/35] commit: add repository argument to lookup_commit","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-06-14T16:22:04Z","receivedAt":"2018-06-14T16:22:35Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, May 30, 2018 at 2:51 AM Stefan Beller <sbeller@google.com> wrote:\n> diff --git a/shallow.c b/shallow.c\n> index 9bb07a56dca..60fe1fe1e58 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>         struct commit_graft *graft =\n>                 xmalloc(sizeof(struct commit_graft));\n> -       struct commit *commit = lookup_commit(oid);\n> +       struct commit *commit = lookup_commit(the_repository, oid);\n\nThis looks wrong. register_shallow() has struct repository argument\n'r' and it should be used here instead.\n\nIf this is a mechanical conversion, I will also be happy that the\nswitch from the_repo to r is done in a separate patch.\n\nFYI I noticed this because I'm in a quest to kill the_index by passing\n'struct index_state *' throughout library code, and sometimes I pass\n'struct repository *' instead when I see that code uses more things\nthat just the index.  And I have started to replace the_repository in\nsome places with a function argument.\n\nIf some of my patches come first while you have not finished\nrepository conversion (very likely), you and I will have to pay\nattention to this more often.\n-- \nDuy\n"},{"id":"350160","messageId":"CACsJy8BvsfPoBZg69u8MvGQUxp3eQQu4=w-0FPmZ9EKQqA55Zw@mail.gmail.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"Re: [PATCH v2 00/31] object-store: lookup_commit","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-06-14T16:26:01Z","receivedAt":"2018-06-14T16:26:31Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Jun 14, 2018 at 1:08 AM Stefan Beller <sbeller@google.com> wrote:\n>\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>\n> v1, https://public-inbox.org/git/20180530004810.30076-1-sbeller@google.com/\n>\n> This applies on the merge of nd/commit-util-to-slab and sb/object-store-grafts,\n> and is available at http://github.com/stefanbeller/ as branch object-store-lookup-commit\n\nI only looked at whole-series diff, not individual patches (sorry).\nBesides the one comment I made elsewhere, it looks good.\n\nYou don't even need to reroll this series to address that one. A\nfollow up patch whenever you feel like it is fine, or I'll get to it\neventually (after the_index is gone, I plan to kill the_repository\noutside builtin/ too, for the same reason).\n-- \nDuy\n"},{"id":"350176","messageId":"fcb052e0-2308-31bd-aa90-d6d3327642c0@gmail.com","threadId":"48596","inReplyTo":"20180613230522.55335-6-sbeller@google.com","subject":"Re: [PATCH v2 05/31] tree: add repository argument to lookup_tree","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-06-14T17:55:08Z","receivedAt":"2018-06-14T17:55:15Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 6/13/2018 7:04 PM, Stefan Beller wrote:\n> diff --git a/commit-graph.c b/commit-graph.c\n> index 71125d7cbb6..88a4b0d2a47 100644\n> --- a/commit-graph.c\n> +++ b/commit-graph.c\n> @@ -261,7 +261,7 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin\n>   \titem->graph_pos = pos;\n>   \n>   \thashcpy(oid.hash, commit_data);\n> -\titem->tree = lookup_tree(&oid);\n> +\titem->tree = lookup_tree(the_repository, &oid);\n>   \n>   \tdate_high = get_be32(commit_data + g->hash_len + 8) & 0x3;\n>   \tdate_low = get_be32(commit_data + g->hash_len + 12);\n> diff --git a/commit.c b/commit.c\n> index d76d64d4dfc..755b8b9d94f 100644\n> --- a/commit.c\n> +++ b/commit.c\n> @@ -354,7 +354,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s\n>   \tif (get_sha1_hex(bufptr + 5, parent.hash) < 0)\n>   \t\treturn error(\"bad tree pointer in commit %s\",\n>   \t\t\t     oid_to_hex(&item->object.oid));\n> -\titem->tree = lookup_tree(&parent);\n> +\titem->tree = lookup_tree(the_repository, &parent);\n>   \tbufptr += tree_entry_len + 1; /* \"tree \" + \"hex sha1\" + \"\\n\" */\n>   \tpptr = &item->parents;\n>   \n> diff --git a/fsck.c b/fsck.c\n> index 2d372f2a3f3..b07abb9796c 100644\n\nI'm a bit late here, but you don't have ds/lazy-load-trees merged in \nyour history, so this will conflict with 'master'. I caught this as I \nwas trying to merge ds/generation-numbers with your branch.\n\nThe 'tree' member of 'struct commit' was renamed to 'maybe_tree'.\n\nThanks,\n-Stolee\n"},{"id":"350182","messageId":"20180614182725.GG220741@google.com","threadId":"48596","inReplyTo":"20180613230522.55335-1-sbeller@google.com","subject":"Re: [PATCH v2 00/31] object-store: lookup_commit","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2018-06-14T18:27:25Z","receivedAt":"2018-06-14T18:27:31Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 06/13, Stefan Beller wrote:\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> \n> v1, https://public-inbox.org/git/20180530004810.30076-1-sbeller@google.com/\n> \n> This applies on the merge of nd/commit-util-to-slab and sb/object-store-grafts,\n> and is available at http://github.com/stefanbeller/ as branch object-store-lookup-commit\n> as the merge has some merge conflicts as well as syntactical conflicts (upload-pack.c\n> and fetch-pack.c introduce new calls of functions that would want to take a repository struct\n> in the object-store-grafts series)\n> \n> As layed out in https://public-inbox.org/git/20180517225154.9200-1-sbeller@google.com/\n> this is getting close to finishing the set of object store series though the last\n> unfinished 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\nI've taken a look at the series and it looks good.  I'm glad we're\ngetting closer to this set of series being completed.  Thanks for\npushing this through :)\n\n-- \nBrandon Williams\n"},{"id":"350191","messageId":"709bd61c-70fc-a925-efba-58ab9be265c9@gmail.com","threadId":"48596","inReplyTo":"fcb052e0-2308-31bd-aa90-d6d3327642c0@gmail.com","subject":"Re: [PATCH v2 05/31] tree: add repository argument to lookup_tree","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-06-14T19:33:32Z","receivedAt":"2018-06-14T19:33:37Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 6/14/2018 1:55 PM, Derrick Stolee wrote:\n> On 6/13/2018 7:04 PM, Stefan Beller wrote:\n>> diff --git a/commit-graph.c b/commit-graph.c\n>> index 71125d7cbb6..88a4b0d2a47 100644\n>> --- a/commit-graph.c\n>> +++ b/commit-graph.c\n>> @@ -261,7 +261,7 @@ static int fill_commit_in_graph(struct commit \n>> *item, struct commit_graph *g, uin\n>>       item->graph_pos = pos;\n>>         hashcpy(oid.hash, commit_data);\n>> -    item->tree = lookup_tree(&oid);\n>> +    item->tree = lookup_tree(the_repository, &oid);\n>>         date_high = get_be32(commit_data + g->hash_len + 8) & 0x3;\n>>       date_low = get_be32(commit_data + g->hash_len + 12);\n>> diff --git a/commit.c b/commit.c\n>> index d76d64d4dfc..755b8b9d94f 100644\n>> --- a/commit.c\n>> +++ b/commit.c\n>> @@ -354,7 +354,7 @@ int parse_commit_buffer(struct commit *item, \n>> const void *buffer, unsigned long s\n>>       if (get_sha1_hex(bufptr + 5, parent.hash) < 0)\n>>           return error(\"bad tree pointer in commit %s\",\n>>                    oid_to_hex(&item->object.oid));\n>> -    item->tree = lookup_tree(&parent);\n>> +    item->tree = lookup_tree(the_repository, &parent);\n>>       bufptr += tree_entry_len + 1; /* \"tree \" + \"hex sha1\" + \"\\n\" */\n>>       pptr = &item->parents;\n>>   diff --git a/fsck.c b/fsck.c\n>> index 2d372f2a3f3..b07abb9796c 100644\n>\n> I'm a bit late here, but you don't have ds/lazy-load-trees merged in \n> your history, so this will conflict with 'master'. I caught this as I \n> was trying to merge ds/generation-numbers with your branch.\n>\n> The 'tree' member of 'struct commit' was renamed to 'maybe_tree'.\n\nResolving the merge was not very simple. I have a working merge \navailable on GitHub [1] as commit 99a899f7c12ef73840dbe79c71acb11034d707dd.\n\nThanks,\n-Stolee\n\n[1] \nhttps://github.com/derrickstolee/git/commits/generation-numbers-object-store\n"},{"id":"350205","messageId":"CAGZ79kapzeBc1KJFCS2Q4UsZDssaFpf6xamva68LAp+gQcTCCw@mail.gmail.com","threadId":"48596","inReplyTo":"CACsJy8D2JbeWvBg9F69tAJgq1874=ROFBG-QKfCHeUMZwcY-VQ@mail.gmail.com","subject":"Re: [PATCH 10/35] commit: add repository argument to lookup_commit","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-14T21:15:15Z","receivedAt":"2018-06-14T21:16:49Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Jun 14, 2018 at 9:22 AM Duy Nguyen <pclouds@gmail.com> wrote:\n>\n> On Wed, May 30, 2018 at 2:51 AM Stefan Beller <sbeller@google.com> wrote:\n> > diff --git a/shallow.c b/shallow.c\n> > index 9bb07a56dca..60fe1fe1e58 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> >         struct commit_graft *graft =\n> >                 xmalloc(sizeof(struct commit_graft));\n> > -       struct commit *commit = lookup_commit(oid);\n> > +       struct commit *commit = lookup_commit(the_repository, oid);\n>\n> This looks wrong. register_shallow() has struct repository argument\n> 'r' and it should be used here instead.\n\nRight.\n\n> If this is a mechanical conversion, I will also be happy that the\n> switch from the_repo to r is done in a separate patch.\n\nThis part of the code is not touched later in this series,\nso I'll fix it if a reroll is needed.\n\n> FYI I noticed this because I'm in a quest to kill the_index by passing\n> 'struct index_state *' throughout library code, and sometimes I pass\n> 'struct repository *' instead when I see that code uses more things\n> that just the index.  And I have started to replace the_repository in\n> some places with a function argument.\n>\n> If some of my patches come first while you have not finished\n> repository conversion (very likely), you and I will have to pay\n> attention to this more often.\n"},{"id":"350207","messageId":"20180614212457.GB68349@google.com","threadId":"48596","inReplyTo":"CAGZ79kapzeBc1KJFCS2Q4UsZDssaFpf6xamva68LAp+gQcTCCw@mail.gmail.com","subject":"Re: [PATCH 10/35] commit: add repository argument to lookup_commit","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2018-06-14T21:24:57Z","receivedAt":"2018-06-14T21:25:07Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 06/14, Stefan Beller wrote:\n> On Thu, Jun 14, 2018 at 9:22 AM Duy Nguyen <pclouds@gmail.com> wrote:\n> >\n> > On Wed, May 30, 2018 at 2:51 AM Stefan Beller <sbeller@google.com> wrote:\n> > > diff --git a/shallow.c b/shallow.c\n> > > index 9bb07a56dca..60fe1fe1e58 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> > >         struct commit_graft *graft =\n> > >                 xmalloc(sizeof(struct commit_graft));\n> > > -       struct commit *commit = lookup_commit(oid);\n> > > +       struct commit *commit = lookup_commit(the_repository, oid);\n> >\n> > This looks wrong. register_shallow() has struct repository argument\n> > 'r' and it should be used here instead.\n> \n> Right.\n> \n> > If this is a mechanical conversion, I will also be happy that the\n> > switch from the_repo to r is done in a separate patch.\n> \n> This part of the code is not touched later in this series,\n> so I'll fix it if a reroll is needed.\n\nYeah maybe at some point when lookup_commit can understand arbitrary\nrepositories we can change this from the_repository to r.  This patch is\npart of that mechanical change and has to be the_repository till\nlookup_commit has been fully converted.\n\n> \n> > FYI I noticed this because I'm in a quest to kill the_index by passing\n> > 'struct index_state *' throughout library code, and sometimes I pass\n> > 'struct repository *' instead when I see that code uses more things\n> > that just the index.  And I have started to replace the_repository in\n> > some places with a function argument.\n> >\n> > If some of my patches come first while you have not finished\n> > repository conversion (very likely), you and I will have to pay\n> > attention to this more often.\n\n-- \nBrandon Williams\n"},{"id":"350208","messageId":"CAGZ79kaQ-smyCz6WmzybgLoS_NFxw5d2q_oxeWVHYnJxEn=mAQ@mail.gmail.com","threadId":"48596","inReplyTo":"709bd61c-70fc-a925-efba-58ab9be265c9@gmail.com","subject":"Re: [PATCH v2 05/31] tree: add repository argument to lookup_tree","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-14T21:31:46Z","receivedAt":"2018-06-14T21:32:01Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Jun 14, 2018 at 12:33 PM Derrick Stolee <stolee@gmail.com> wrote:\n> > The 'tree' member of 'struct commit' was renamed to 'maybe_tree'.\n>\n> Resolving the merge was not very simple. I have a working merge\n> available on GitHub [1] as commit 99a899f7c12ef73840dbe79c71acb11034d707dd.\n\nThanks for pointing this out and resolving the merge.\nds/generation-numbers seems to be cooking in next for longer already, so\nI might just rebase this series on top of that as well.\n\nThanks for the heads up!\nStefan\n"}]}