{"thread":{"id":"48355","subject":"[PATCHv2 0/9] object store: oid_object_info is the next contender","startedAt":"2018-04-24T21:59:18Z","lastAt":"2018-04-26T16:30:33Z","messageCount":24,"participants":["Stefan Beller","Jonathan Tan","Brandon Williams"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"345693","messageId":"20180424215910.22201-1-sbeller@google.com","threadId":"48355","inReplyTo":null,"subject":"[PATCHv2 0/9] object store: oid_object_info is the next contender","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-24T21:59:00Z","receivedAt":"2018-04-24T21:59:18Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"v2:\n\n* fixed the sha1/oid typo\n* removed spurious new line\n* Brandon and Jonthan discovered another dependency that I missed due\n  to cherrypicking that commit from a tree before partial clone was a thing.\n  We error out when attempting to use fetch_object for repos that are not\n  the_repository.\n  \nThanks,\nStefan\n\nv1:\nThis applies on top of origin/sb/object-store-replace and is available as\nhttps://github.com/stefanbeller/git/tree/oid_object_info\n\nThis continues the work of sb/packfiles-in-repository,\nextending the layer at which we have to pass in an explicit\nrepository object to oid_object_info.\n\nA test merge to next shows only a minor merge conflicit (adding\ndifferent #include lines in one c file), so this might be a good next\nstep for the object store series.\n\nNotes on further object store series:\nI plan on converting the \"parsed object store\" next,\nwhich would be {alloc, object, tree, commit, tag}.c as that is a prerequisite\nfor migrating shallow (which is intermingled with grafts) information to the\nobject store.\n\nThere is currently work going on in allocation (mempool - Jameson Miller)\nand grafts (deprecate grafts - DScho), which is why I am sending this\nseries first. I think it can go in parallel to the \"parsed object store\"\nthat is coming next.\n\nThanks,\nStefan\n\nJonathan Nieder (1):\n  packfile: add repository argument to packed_object_info\n\nStefan Beller (8):\n  cache.h: add repository argument to oid_object_info_extended\n  cache.h: add repository argument to oid_object_info\n  packfile: add repository argument to retry_bad_packed_offset\n  packfile: add repository argument to packed_to_object_type\n  packfile: add repository argument to read_object\n  packfile: add repository argument to unpack_entry\n  packfile: add repository argument to cache_or_unpack_entry\n  cache.h: allow oid_object_info to handle arbitrary repositories\n\n archive-tar.c            |  2 +-\n archive-zip.c            |  3 ++-\n blame.c                  |  4 ++--\n builtin/blame.c          |  2 +-\n builtin/cat-file.c       | 12 ++++++------\n builtin/describe.c       |  2 +-\n builtin/fast-export.c    |  2 +-\n builtin/fetch.c          |  2 +-\n builtin/fsck.c           |  3 ++-\n builtin/index-pack.c     |  4 ++--\n builtin/ls-tree.c        |  2 +-\n builtin/mktree.c         |  2 +-\n builtin/pack-objects.c   | 11 +++++++----\n builtin/prune.c          |  3 ++-\n builtin/replace.c        | 11 ++++++-----\n builtin/tag.c            |  4 ++--\n builtin/unpack-objects.c |  2 +-\n cache.h                  |  7 +++++--\n diff.c                   |  3 ++-\n fast-import.c            | 16 ++++++++++------\n list-objects-filter.c    |  2 +-\n object.c                 |  2 +-\n pack-bitmap-write.c      |  3 ++-\n pack-check.c             |  3 ++-\n packfile.c               | 40 +++++++++++++++++++++++-----------------\n packfile.h               |  6 ++++--\n reachable.c              |  2 +-\n refs.c                   |  2 +-\n remote.c                 |  2 +-\n sequencer.c              |  3 ++-\n sha1_file.c              | 36 +++++++++++++++++++++---------------\n sha1_name.c              | 12 ++++++------\n streaming.c              |  2 +-\n submodule.c              |  2 +-\n tag.c                    |  2 +-\n 35 files changed, 124 insertions(+), 92 deletions(-)\n\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345694","messageId":"20180424215910.22201-2-sbeller@google.com","threadId":"48355","inReplyTo":"20180424215910.22201-1-sbeller@google.com","subject":"[PATCHv2 1/9] cache.h: add repository argument to oid_object_info_extended","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-24T21:59:01Z","receivedAt":"2018-04-24T21:59:21Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow oid_object_info_extended callers\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\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/cat-file.c |  6 +++---\n cache.h            |  5 ++++-\n packfile.c         |  2 +-\n sha1_file.c        | 10 +++++-----\n streaming.c        |  2 +-\n 5 files changed, 14 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 2c46d257cd..4ecdb9ff54 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -77,7 +77,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tswitch (opt) {\n \tcase 't':\n \t\toi.type_name = &sb;\n-\t\tif (oid_object_info_extended(&oid, &oi, flags) < 0)\n+\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \t\tif (sb.len) {\n \t\t\tprintf(\"%s\\n\", sb.buf);\n@@ -88,7 +88,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \n \tcase 's':\n \t\toi.sizep = &size;\n-\t\tif (oid_object_info_extended(&oid, &oi, flags) < 0)\n+\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \t\tprintf(\"%lu\\n\", size);\n \t\treturn 0;\n@@ -342,7 +342,7 @@ static void batch_object_write(const char *obj_name, struct batch_options *opt,\n \tstruct strbuf buf = STRBUF_INIT;\n \n \tif (!data->skip_object_info &&\n-\t    oid_object_info_extended(&data->oid, &data->info,\n+\t    oid_object_info_extended(the_repository, &data->oid, &data->info,\n \t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n \t\tprintf(\"%s missing\\n\",\n \t\t       obj_name ? obj_name : oid_to_hex(&data->oid));\ndiff --git a/cache.h b/cache.h\nindex 027bd7ffc8..588c4fff9a 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1673,7 +1673,10 @@ struct object_info {\n #define OBJECT_INFO_QUICK 8\n /* Do not check loose object */\n #define OBJECT_INFO_IGNORE_LOOSE 16\n-extern int oid_object_info_extended(const struct object_id *, struct object_info *, unsigned flags);\n+\n+#define oid_object_info_extended(r, oid, oi, flags) \\\n+\toid_object_info_extended_##r(oid, oi, flags)\n+int oid_object_info_extended_the_repository(const struct object_id *, struct object_info *, unsigned flags);\n \n /*\n  * Set this to 0 to prevent sha1_object_info_extended() from fetching missing\ndiff --git a/packfile.c b/packfile.c\nindex 0bc67d0e00..d9914ba723 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1474,7 +1474,7 @@ static void *read_object(const struct object_id *oid, enum object_type *type,\n \toi.sizep = size;\n \toi.contentp = &content;\n \n-\tif (oid_object_info_extended(oid, &oi, 0) < 0)\n+\tif (oid_object_info_extended(the_repository, oid, &oi, 0) < 0)\n \t\treturn NULL;\n \treturn content;\n }\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 64a5bd7d87..50a2dc5f0a 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1231,7 +1231,7 @@ static int sha1_loose_object_info(struct repository *r,\n \n int fetch_if_missing = 1;\n \n-int oid_object_info_extended(const struct object_id *oid, struct object_info *oi, unsigned flags)\n+int oid_object_info_extended_the_repository(const struct object_id *oid, struct object_info *oi, unsigned flags)\n {\n \tstatic struct object_info blank_oi = OBJECT_INFO_INIT;\n \tstruct pack_entry e;\n@@ -1310,7 +1310,7 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi\n \trtype = packed_object_info(e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real->hash);\n-\t\treturn oid_object_info_extended(real, oi, 0);\n+\t\treturn oid_object_info_extended(the_repository, real, oi, 0);\n \t} else if (oi->whence == OI_PACKED) {\n \t\toi->u.packed.offset = e.offset;\n \t\toi->u.packed.pack = e.p;\n@@ -1329,7 +1329,7 @@ int oid_object_info(const struct object_id *oid, unsigned long *sizep)\n \n \toi.typep = &type;\n \toi.sizep = sizep;\n-\tif (oid_object_info_extended(oid, &oi,\n+\tif (oid_object_info_extended(the_repository, oid, &oi,\n \t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\treturn -1;\n \treturn type;\n@@ -1347,7 +1347,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,\n \n \thashcpy(oid.hash, sha1);\n \n-\tif (oid_object_info_extended(&oid, &oi, 0) < 0)\n+\tif (oid_object_info_extended(the_repository, &oid, &oi, 0) < 0)\n \t\treturn NULL;\n \treturn content;\n }\n@@ -1745,7 +1745,7 @@ int has_sha1_file_with_flags(const unsigned char *sha1, int flags)\n \tif (!startup_info->have_repository)\n \t\treturn 0;\n \thashcpy(oid.hash, sha1);\n-\treturn oid_object_info_extended(&oid, NULL,\n+\treturn oid_object_info_extended(the_repository, &oid, NULL,\n \t\t\t\t\tflags | OBJECT_INFO_SKIP_CACHED) >= 0;\n }\n \ndiff --git a/streaming.c b/streaming.c\nindex cce7b17ea7..d1e6b2dce6 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -117,7 +117,7 @@ static enum input_source istream_source(const struct object_id *oid,\n \n \toi->typep = type;\n \toi->sizep = &size;\n-\tstatus = oid_object_info_extended(oid, oi, 0);\n+\tstatus = oid_object_info_extended(the_repository, oid, oi, 0);\n \tif (status < 0)\n \t\treturn stream_error;\n \n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345695","messageId":"20180424215910.22201-3-sbeller@google.com","threadId":"48355","inReplyTo":"20180424215910.22201-1-sbeller@google.com","subject":"[PATCHv2 2/9] cache.h: add repository argument to oid_object_info","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-24T21:59:02Z","receivedAt":"2018-04-24T21:59:25Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of oid_object_info\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 archive-tar.c            |  2 +-\n archive-zip.c            |  3 ++-\n blame.c                  |  4 ++--\n builtin/blame.c          |  2 +-\n builtin/cat-file.c       |  6 +++---\n builtin/describe.c       |  2 +-\n builtin/fast-export.c    |  2 +-\n builtin/fetch.c          |  2 +-\n builtin/fsck.c           |  3 ++-\n builtin/index-pack.c     |  4 ++--\n builtin/ls-tree.c        |  2 +-\n builtin/mktree.c         |  2 +-\n builtin/pack-objects.c   |  8 +++++---\n builtin/prune.c          |  3 ++-\n builtin/replace.c        | 11 ++++++-----\n builtin/tag.c            |  4 ++--\n builtin/unpack-objects.c |  2 +-\n cache.h                  |  3 ++-\n diff.c                   |  3 ++-\n fast-import.c            | 14 +++++++++-----\n list-objects-filter.c    |  2 +-\n object.c                 |  2 +-\n pack-bitmap-write.c      |  3 ++-\n packfile.c               |  2 +-\n reachable.c              |  2 +-\n refs.c                   |  2 +-\n remote.c                 |  2 +-\n sequencer.c              |  3 ++-\n sha1_file.c              |  4 ++--\n sha1_name.c              | 12 ++++++------\n submodule.c              |  2 +-\n tag.c                    |  2 +-\n 32 files changed, 67 insertions(+), 53 deletions(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 3563bcb9f2..f93409324f 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -276,7 +276,7 @@ static int write_tar_entry(struct archiver_args *args,\n \t\tmemcpy(header.name, path, pathlen);\n \n \tif (S_ISREG(mode) && !args->convert &&\n-\t    oid_object_info(oid, &size) == OBJ_BLOB &&\n+\t    oid_object_info(the_repository, oid, &size) == OBJ_BLOB &&\n \t    size > big_file_threshold)\n \t\tbuffer = NULL;\n \telse if (S_ISLNK(mode) || S_ISREG(mode)) {\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 6b20bce4d1..74f3fe9103 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -325,7 +325,8 @@ static int write_zip_entry(struct archiver_args *args,\n \t\tcompressed_size = 0;\n \t\tbuffer = NULL;\n \t} else if (S_ISREG(mode) || S_ISLNK(mode)) {\n-\t\tenum object_type type = oid_object_info(oid, &size);\n+\t\tenum object_type type = oid_object_info(the_repository, oid,\n+\t\t\t\t\t\t\t&size);\n \n \t\tmethod = 0;\n \t\tattr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :\ndiff --git a/blame.c b/blame.c\nindex 78c9808bd1..dfa24473dc 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -81,7 +81,7 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)\n \t\tunsigned mode;\n \n \t\tif (!get_tree_entry(commit_oid, path, &blob_oid, &mode) &&\n-\t\t    oid_object_info(&blob_oid, NULL) == OBJ_BLOB)\n+\t\t    oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB)\n \t\t\treturn;\n \t}\n \n@@ -504,7 +504,7 @@ static int fill_blob_sha1_and_mode(struct blame_origin *origin)\n \t\treturn 0;\n \tif (get_tree_entry(&origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))\n \t\tgoto error_out;\n-\tif (oid_object_info(&origin->blob_oid, NULL) != OBJ_BLOB)\n+\tif (oid_object_info(the_repository, &origin->blob_oid, NULL) != OBJ_BLOB)\n \t\tgoto error_out;\n \treturn 0;\n  error_out:\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex db38c0b307..bfdf7cc132 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -655,7 +655,7 @@ static int is_a_rev(const char *name)\n \n \tif (get_oid(name, &oid))\n \t\treturn 0;\n-\treturn OBJ_NONE < oid_object_info(&oid, NULL);\n+\treturn OBJ_NONE < oid_object_info(the_repository, &oid, NULL);\n }\n \n int cmd_blame(int argc, const char **argv, const char *prefix)\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 4ecdb9ff54..b8ecbea98e 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -116,7 +116,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t/* else fallthrough */\n \n \tcase 'p':\n-\t\ttype = oid_object_info(&oid, NULL);\n+\t\ttype = oid_object_info(the_repository, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Not a valid object name %s\", obj_name);\n \n@@ -140,7 +140,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tcase 0:\n \t\tif (type_from_string(exp_type) == OBJ_BLOB) {\n \t\t\tstruct object_id blob_oid;\n-\t\t\tif (oid_object_info(&oid, NULL) == OBJ_TAG) {\n+\t\t\tif (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {\n \t\t\t\tchar *buffer = read_object_file(&oid, &type,\n \t\t\t\t\t\t\t\t&size);\n \t\t\t\tconst char *target;\n@@ -151,7 +151,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\t} else\n \t\t\t\toidcpy(&blob_oid, &oid);\n \n-\t\t\tif (oid_object_info(&blob_oid, NULL) == OBJ_BLOB)\n+\t\t\tif (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB)\n \t\t\t\treturn stream_blob_to_fd(1, &blob_oid, NULL, 0);\n \t\t\t/*\n \t\t\t * we attempted to dereference a tag to a blob\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex de840f96a4..66c497f789 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -502,7 +502,7 @@ static void describe(const char *arg, int last_one)\n \n \tif (cmit)\n \t\tdescribe_commit(&oid, &sb);\n-\telse if (oid_object_info(&oid, NULL) == OBJ_BLOB)\n+\telse if (oid_object_info(the_repository, &oid, NULL) == OBJ_BLOB)\n \t\tdescribe_blob(oid, &sb);\n \telse\n \t\tdie(_(\"%s is neither a commit nor blob\"), arg);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex a15898d641..373c794873 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -947,7 +947,7 @@ static void import_marks(char *input_file)\n \t\tif (last_idnum < mark)\n \t\t\tlast_idnum = mark;\n \n-\t\ttype = oid_object_info(&oid, NULL);\n+\t\ttype = oid_object_info(the_repository, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(&oid));\n \ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex dcdfc66f09..73be393b2e 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -637,7 +637,7 @@ static int update_local_ref(struct ref *ref,\n \tstruct branch *current_branch = branch_get(NULL);\n \tconst char *pretty_ref = prettify_refname(ref->name);\n \n-\ttype = oid_object_info(&ref->new_oid, NULL);\n+\ttype = oid_object_info(the_repository, &ref->new_oid, NULL);\n \tif (type < 0)\n \t\tdie(_(\"object %s not found\"), oid_to_hex(&ref->new_oid));\n \ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 087360a675..9d59d7d5a2 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -67,7 +67,8 @@ static const char *printable_type(struct object *obj)\n \tconst char *ret;\n \n \tif (obj->type == OBJ_NONE) {\n-\t\tenum object_type type = oid_object_info(&obj->oid, NULL);\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}\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex d81473e722..2d04a596f5 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -223,7 +223,7 @@ static unsigned check_object(struct object *obj)\n \n \tif (!(obj->flags & FLAG_CHECKED)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(&obj->oid, &size);\n+\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n \t\t\t      oid_to_hex(&obj->oid));\n@@ -812,7 +812,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\tenum object_type has_type;\n \t\tunsigned long has_size;\n \t\tread_lock();\n-\t\thas_type = oid_object_info(oid, &has_size);\n+\t\thas_type = oid_object_info(the_repository, oid, &has_size);\n \t\tif (has_type < 0)\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex d44b4f9c27..409da4e835 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -94,7 +94,7 @@ static int show_tree(const struct object_id *oid, struct strbuf *base,\n \t\t\tchar size_text[24];\n \t\t\tif (!strcmp(type, blob_type)) {\n \t\t\t\tunsigned long size;\n-\t\t\t\tif (oid_object_info(oid, &size) == OBJ_BAD)\n+\t\t\t\tif (oid_object_info(the_repository, oid, &size) == OBJ_BAD)\n \t\t\t\t\txsnprintf(size_text, sizeof(size_text),\n \t\t\t\t\t\t  \"BAD\");\n \t\t\t\telse\ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 263c530315..bb76b469fd 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -116,7 +116,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss\n \t}\n \n \t/* Check the type of object identified by sha1 */\n-\tobj_type = oid_object_info(&oid, NULL);\n+\tobj_type = oid_object_info(the_repository, &oid, NULL);\n \tif (obj_type < 0) {\n \t\tif (allow_missing) {\n \t\t\t; /* no problem - missing objects are presumed to be of the right type */\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 4bdae5a1d8..8d4111f748 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1516,7 +1516,8 @@ static void check_object(struct object_entry *entry)\n \t\tunuse_pack(&w_curs);\n \t}\n \n-\tentry->type = oid_object_info(&entry->idx.oid, &entry->size);\n+\tentry->type = oid_object_info(the_repository, &entry->idx.oid,\n+\t\t\t\t      &entry->size);\n \t/*\n \t * The error condition is checked in prepare_pack().  This is\n \t * to permit a missing preferred base object to be ignored\n@@ -1578,7 +1579,8 @@ static void drop_reused_delta(struct object_entry *entry)\n \t\t * And if that fails, the error will be recorded in entry->type\n \t\t * and dealt with in prepare_pack().\n \t\t */\n-\t\tentry->type = oid_object_info(&entry->idx.oid, &entry->size);\n+\t\tentry->type = oid_object_info(the_repository, &entry->idx.oid,\n+\t\t\t\t\t      &entry->size);\n \t}\n }\n \n@@ -2706,7 +2708,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)\n static int add_loose_object(const struct object_id *oid, const char *path,\n \t\t\t    void *data)\n {\n-\tenum object_type type = oid_object_info(oid, NULL);\n+\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n \n \tif (type < 0) {\n \t\twarning(\"loose object at %s could not be examined\", path);\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 38ced18dad..518ffbea13 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -50,7 +50,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath,\n \tif (st.st_mtime > expire)\n \t\treturn 0;\n \tif (show_only || verbose) {\n-\t\tenum object_type type = oid_object_info(oid, NULL);\n+\t\tenum object_type type = oid_object_info(the_repository, oid,\n+\t\t\t\t\t\t\tNULL);\n \t\tprintf(\"%s %s\\n\", oid_to_hex(oid),\n \t\t       (type > 0) ? type_name(type) : \"unknown\");\n \t}\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 237ea656cf..14e142d5a8 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -55,8 +55,9 @@ static int show_reference(const char *refname, const struct object_id *oid,\n \t\t\tif (get_oid(refname, &object))\n \t\t\t\treturn error(\"Failed to resolve '%s' as a valid ref.\", refname);\n \n-\t\t\tobj_type = oid_object_info(&object, NULL);\n-\t\t\trepl_type = oid_object_info(oid, NULL);\n+\t\t\tobj_type = oid_object_info(the_repository, &object,\n+\t\t\t\t\t\t   NULL);\n+\t\t\trepl_type = oid_object_info(the_repository, oid, NULL);\n \n \t\t\tprintf(\"%s (%s) -> %s (%s)\\n\", refname, type_name(obj_type),\n \t\t\t       oid_to_hex(oid), type_name(repl_type));\n@@ -164,8 +165,8 @@ static int replace_object_oid(const char *object_ref,\n \tstruct ref_transaction *transaction;\n \tstruct strbuf err = STRBUF_INIT;\n \n-\tobj_type = oid_object_info(object, NULL);\n-\trepl_type = oid_object_info(repl, NULL);\n+\tobj_type = oid_object_info(the_repository, object, NULL);\n+\trepl_type = oid_object_info(the_repository, repl, NULL);\n \tif (!force && obj_type != repl_type)\n \t\tdie(\"Objects must be of the same type.\\n\"\n \t\t    \"'%s' points to a replaced object of type '%s'\\n\"\n@@ -292,7 +293,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)\n \tif (get_oid(object_ref, &old_oid) < 0)\n \t\tdie(\"Not a valid object name: '%s'\", object_ref);\n \n-\ttype = oid_object_info(&old_oid, NULL);\n+\ttype = oid_object_info(the_repository, &old_oid, NULL);\n \tif (type < 0)\n \t\tdie(\"unable to get object type for %s\", oid_to_hex(&old_oid));\n \ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 8cff6d0b72..26d7729f57 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -212,7 +212,7 @@ static void create_tag(const struct object_id *object, const char *tag,\n \tstruct strbuf header = STRBUF_INIT;\n \tchar *path = NULL;\n \n-\ttype = oid_object_info(object, NULL);\n+\ttype = oid_object_info(the_repository, object, NULL);\n \tif (type <= OBJ_NONE)\n \t    die(_(\"bad object type.\"));\n \n@@ -298,7 +298,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t}\n \n \tstrbuf_addstr(sb, \" (\");\n-\ttype = oid_object_info(oid, NULL);\n+\ttype = oid_object_info(the_repository, oid, NULL);\n \tswitch (type) {\n \tdefault:\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex b7755c6cc5..cfe9019f80 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -199,7 +199,7 @@ static int check_object(struct object *obj, int type, void *data, struct fsck_op\n \n \tif (!(obj->flags & FLAG_OPEN)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(&obj->oid, &size);\n+\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n \t\tobj->flags |= FLAG_WRITTEN;\ndiff --git a/cache.h b/cache.h\nindex 588c4fff9a..6340b2c572 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1192,7 +1192,8 @@ static inline void *read_object_file(const struct object_id *oid, enum object_ty\n }\n \n /* Read and unpack an object file into memory, write memory to an object file */\n-extern int oid_object_info(const struct object_id *, unsigned long *);\n+#define oid_object_info(r, o, f) oid_object_info_##r(o, f)\n+int oid_object_info_the_repository(const struct object_id *, unsigned long *);\n \n extern int hash_object_file(const void *buf, unsigned long len,\n \t\t\t    const char *type, struct object_id *oid);\ndiff --git a/diff.c b/diff.c\nindex 1289df4b1f..4753170fe1 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3638,7 +3638,8 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)\n \telse {\n \t\tenum object_type type;\n \t\tif (size_only || (flags & CHECK_BINARY)) {\n-\t\t\ttype = oid_object_info(&s->oid, &s->size);\n+\t\t\ttype = oid_object_info(the_repository, &s->oid,\n+\t\t\t\t\t       &s->size);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"unable to read %s\",\n \t\t\t\t    oid_to_hex(&s->oid));\ndiff --git a/fast-import.c b/fast-import.c\nindex 99f8f56e8c..afe06bd7c1 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1917,7 +1917,8 @@ static void read_marks(void)\n \t\t\tdie(\"corrupt mark line: %s\", line);\n \t\te = find_object(&oid);\n \t\tif (!e) {\n-\t\t\tenum object_type type = oid_object_info(&oid, NULL);\n+\t\t\tenum object_type type = oid_object_info(the_repository,\n+\t\t\t\t\t\t\t\t&oid, NULL);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"object not found: %s\", oid_to_hex(&oid));\n \t\t\te = insert_object(&oid);\n@@ -2447,7 +2448,8 @@ static void file_change_m(const char *p, struct branch *b)\n \t\tenum object_type expected = S_ISDIR(mode) ?\n \t\t\t\t\t\tOBJ_TREE: OBJ_BLOB;\n \t\tenum object_type type = oe ? oe->type :\n-\t\t\t\t\toid_object_info(&oid, NULL);\n+\t\t\t\t\toid_object_info(the_repository, &oid,\n+\t\t\t\t\t\t\tNULL);\n \t\tif (type < 0)\n \t\t\tdie(\"%s not found: %s\",\n \t\t\t\t\tS_ISDIR(mode) ?  \"Tree\" : \"Blob\",\n@@ -2608,7 +2610,8 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tdie(\"Not a blob (actually a %s): %s\",\n \t\t\t\ttype_name(oe->type), command_buf.buf);\n \t} else if (!is_null_oid(&oid)) {\n-\t\tenum object_type type = oid_object_info(&oid, NULL);\n+\t\tenum object_type type = oid_object_info(the_repository, &oid,\n+\t\t\t\t\t\t\tNULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Blob not found: %s\", command_buf.buf);\n \t\tif (type != OBJ_BLOB)\n@@ -2895,7 +2898,7 @@ static void parse_new_tag(const char *arg)\n \t} else if (!get_oid(from, &oid)) {\n \t\tstruct object_entry *oe = find_object(&oid);\n \t\tif (!oe) {\n-\t\t\ttype = oid_object_info(&oid, NULL);\n+\t\t\ttype = oid_object_info(the_repository, &oid, NULL);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"Not a valid object: %s\", from);\n \t\t} else\n@@ -3053,7 +3056,8 @@ static struct object_entry *dereference(struct object_entry *oe,\n \tunsigned long size;\n \tchar *buf = NULL;\n \tif (!oe) {\n-\t\tenum object_type type = oid_object_info(oid, NULL);\n+\t\tenum object_type type = oid_object_info(the_repository, oid,\n+\t\t\t\t\t\t\tNULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\t/* cache it! */\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex 0ec83aaf18..ea94fe8af2 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -117,7 +117,7 @@ static enum list_objects_filter_result filter_blobs_limit(\n \t\tassert(obj->type == OBJ_BLOB);\n \t\tassert((obj->flags & SEEN) == 0);\n \n-\t\tt = oid_object_info(&obj->oid, &object_length);\n+\t\tt = oid_object_info(the_repository, &obj->oid, &object_length);\n \t\tif (t != OBJ_BLOB) { /* probably OBJ_NONE */\n \t\t\t/*\n \t\t\t * We DO NOT have the blob locally, so we cannot\ndiff --git a/object.c b/object.c\nindex 66cffaf6e5..5044d08e96 100644\n--- a/object.c\n+++ b/object.c\n@@ -257,7 +257,7 @@ struct object *parse_object(const struct object_id *oid)\n \n \tif ((obj && obj->type == OBJ_BLOB && has_object_file(oid)) ||\n \t    (!obj && has_object_file(oid) &&\n-\t     oid_object_info(oid, NULL) == OBJ_BLOB)) {\n+\t     oid_object_info(the_repository, 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;\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 41ae27fb19..cd1903e717 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -73,7 +73,8 @@ void bitmap_writer_build_type_index(struct pack_idx_entry **index,\n \t\t\tbreak;\n \n \t\tdefault:\n-\t\t\treal_type = oid_object_info(&entry->idx.oid, NULL);\n+\t\t\treal_type = oid_object_info(the_repository,\n+\t\t\t\t\t\t    &entry->idx.oid, NULL);\n \t\t\tbreak;\n \t\t}\n \ndiff --git a/packfile.c b/packfile.c\nindex d9914ba723..80c7fa734f 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1114,7 +1114,7 @@ static int retry_bad_packed_offset(struct packed_git *p, off_t obj_offset)\n \t\treturn OBJ_BAD;\n \tnth_packed_object_oid(&oid, p, revidx->nr);\n \tmark_bad_packed_object(p, oid.hash);\n-\ttype = oid_object_info(&oid, NULL);\n+\ttype = oid_object_info(the_repository, &oid, NULL);\n \tif (type <= OBJ_NONE)\n \t\treturn OBJ_BAD;\n \treturn type;\ndiff --git a/reachable.c b/reachable.c\nindex a6ea33a5db..ffb976c33c 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -78,7 +78,7 @@ static void add_recent_object(const struct object_id *oid,\n \t * later processing, and the revision machinery expects\n \t * commits and tags to have been parsed.\n \t */\n-\ttype = oid_object_info(oid, NULL);\n+\ttype = oid_object_info(the_repository, oid, NULL);\n \tif (type < 0)\n \t\tdie(\"unable to get object info for %s\", oid_to_hex(oid));\n \ndiff --git a/refs.c b/refs.c\nindex 9b56fa9b81..27c88ba768 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -302,7 +302,7 @@ enum peel_status peel_object(const struct object_id *name, struct object_id *oid\n \tstruct object *o = lookup_unknown_object(name->hash);\n \n \tif (o->type == OBJ_NONE) {\n-\t\tint type = oid_object_info(name, NULL);\n+\t\tint type = oid_object_info(the_repository, name, NULL);\n \t\tif (type < 0 || !object_as_type(o, type, 0))\n \t\t\treturn PEEL_INVALID;\n \t}\ndiff --git a/remote.c b/remote.c\nindex 91eb010ca9..481bf933f3 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1376,7 +1376,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \t\t\tcontinue; /* not a tag */\n \t\tif (string_list_has_string(&dst_tag, ref->name))\n \t\t\tcontinue; /* they already have it */\n-\t\tif (oid_object_info(&ref->new_oid, NULL) != OBJ_TAG)\n+\t\tif (oid_object_info(the_repository, &ref->new_oid, NULL) != OBJ_TAG)\n \t\t\tcontinue; /* be conservative */\n \t\titem = string_list_append(&src_tag, ref->name);\n \t\titem->util = ref;\ndiff --git a/sequencer.c b/sequencer.c\nindex 667f35ebdf..44f0518b9c 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2876,7 +2876,8 @@ int sequencer_pick_revisions(struct replay_opts *opts)\n \n \t\tif (!get_oid(name, &oid)) {\n \t\t\tif (!lookup_commit_reference_gently(&oid, 1)) {\n-\t\t\t\tenum object_type type = oid_object_info(&oid,\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);\n \t\t\t\treturn error(_(\"%s: can't cherry-pick a %s\"),\n \t\t\t\t\tname, type_name(type));\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 50a2dc5f0a..93f25c6c6a 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1322,7 +1322,7 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n }\n \n /* returns enum object_type or negative */\n-int oid_object_info(const struct object_id *oid, unsigned long *sizep)\n+int oid_object_info_the_repository(const struct object_id *oid, unsigned long *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n@@ -1988,7 +1988,7 @@ int read_pack_header(int fd, struct pack_header *header)\n \n void assert_oid_type(const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = oid_object_info(oid, NULL);\n+\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n \tif (type < 0)\n \t\tdie(\"%s is not a valid object\", oid_to_hex(oid));\n \tif (type != expect)\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 5b93bf8da3..b5406b6eb2 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -223,7 +223,7 @@ static int finish_object_disambiguation(struct disambiguate_state *ds,\n \n static int disambiguate_commit_only(const struct object_id *oid, void *cb_data_unused)\n {\n-\tint kind = oid_object_info(oid, NULL);\n+\tint kind = oid_object_info(the_repository, oid, NULL);\n \treturn kind == OBJ_COMMIT;\n }\n \n@@ -232,7 +232,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(oid, NULL);\n+\tkind = oid_object_info(the_repository, oid, NULL);\n \tif (kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -247,7 +247,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da\n \n static int disambiguate_tree_only(const struct object_id *oid, void *cb_data_unused)\n {\n-\tint kind = oid_object_info(oid, NULL);\n+\tint kind = oid_object_info(the_repository, oid, NULL);\n \treturn kind == OBJ_TREE;\n }\n \n@@ -256,7 +256,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(oid, NULL);\n+\tkind = oid_object_info(the_repository, oid, NULL);\n \tif (kind == OBJ_TREE || kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -271,7 +271,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_\n \n static int disambiguate_blob_only(const struct object_id *oid, void *cb_data_unused)\n {\n-\tint kind = oid_object_info(oid, NULL);\n+\tint kind = oid_object_info(the_repository, oid, NULL);\n \treturn kind == OBJ_BLOB;\n }\n \n@@ -350,7 +350,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \tif (ds->fn && !ds->fn(oid, ds->cb_data))\n \t\treturn 0;\n \n-\ttype = oid_object_info(oid, NULL);\n+\ttype = oid_object_info(the_repository, oid, NULL);\n \tif (type == OBJ_COMMIT) {\n \t\tstruct commit *commit = lookup_commit(oid);\n \t\tif (commit) {\ndiff --git a/submodule.c b/submodule.c\nindex 9a50168b23..bb133e9b93 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -818,7 +818,7 @@ static int check_has_commit(const struct object_id *oid, void *data)\n {\n \tstruct has_commit_data *cb = data;\n \n-\tenum object_type type = oid_object_info(oid, NULL);\n+\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n \n \tswitch (type) {\n \tcase OBJ_COMMIT:\ndiff --git a/tag.c b/tag.c\nindex 86b1dcbb82..3d37c1bd25 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -41,7 +41,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \tunsigned long size;\n \tint ret;\n \n-\ttype = oid_object_info(oid, NULL);\n+\ttype = oid_object_info(the_repository, oid, NULL);\n \tif (type != OBJ_TAG)\n \t\treturn error(\"%s: cannot verify a non-tag object of type %s.\",\n \t\t\t\tname_to_report ?\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345696","messageId":"20180424215910.22201-4-sbeller@google.com","threadId":"48355","inReplyTo":"20180424215910.22201-1-sbeller@google.com","subject":"[PATCHv2 3/9] packfile: add repository argument to retry_bad_packed_offset","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-24T21:59:03Z","receivedAt":"2018-04-24T21:59:28Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of retry_bad_packed_offset\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: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n packfile.c | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/packfile.c b/packfile.c\nindex 80c7fa734f..d2b3f3503b 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1104,7 +1104,9 @@ static const unsigned char *get_delta_base_sha1(struct packed_git *p,\n \t\treturn NULL;\n }\n \n-static int retry_bad_packed_offset(struct packed_git *p, off_t obj_offset)\n+#define retry_bad_packed_offset(r, p, o) \\\n+\tretry_bad_packed_offset_##r(p, o)\n+static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t obj_offset)\n {\n \tint type;\n \tstruct revindex_entry *revidx;\n@@ -1153,7 +1155,7 @@ static enum object_type packed_to_object_type(struct packed_git *p,\n \t\tif (type <= OBJ_NONE) {\n \t\t\t/* If getting the base itself fails, we first\n \t\t\t * retry the base, otherwise unwind */\n-\t\t\ttype = retry_bad_packed_offset(p, base_offset);\n+\t\t\ttype = retry_bad_packed_offset(the_repository, p, base_offset);\n \t\t\tif (type > OBJ_NONE)\n \t\t\t\tgoto out;\n \t\t\tgoto unwind;\n@@ -1181,7 +1183,7 @@ static enum object_type packed_to_object_type(struct packed_git *p,\n unwind:\n \twhile (poi_stack_nr) {\n \t\tobj_offset = poi_stack[--poi_stack_nr];\n-\t\ttype = retry_bad_packed_offset(p, obj_offset);\n+\t\ttype = retry_bad_packed_offset(the_repository, p, obj_offset);\n \t\tif (type > OBJ_NONE)\n \t\t\tgoto out;\n \t}\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345697","messageId":"20180424215910.22201-5-sbeller@google.com","threadId":"48355","inReplyTo":"20180424215910.22201-1-sbeller@google.com","subject":"[PATCHv2 4/9] packfile: add repository argument to packed_to_object_type","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-24T21:59:04Z","receivedAt":"2018-04-24T21:59:30Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of packed_to_object_type\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: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n packfile.c | 16 +++++++++-------\n 1 file changed, 9 insertions(+), 7 deletions(-)\n\ndiff --git a/packfile.c b/packfile.c\nindex d2b3f3503b..3ecfba66af 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1124,11 +1124,13 @@ static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t ob\n \n #define POI_STACK_PREALLOC 64\n \n-static enum object_type packed_to_object_type(struct packed_git *p,\n-\t\t\t\t\t      off_t obj_offset,\n-\t\t\t\t\t      enum object_type type,\n-\t\t\t\t\t      struct pack_window **w_curs,\n-\t\t\t\t\t      off_t curpos)\n+#define packed_to_object_type(r, p, o, t, w, c) \\\n+\tpacked_to_object_type_##r(p, o, t, w, c)\n+static enum object_type packed_to_object_type_the_repository(struct packed_git *p,\n+\t\t\t\t\t\t\t     off_t obj_offset,\n+\t\t\t\t\t\t\t     enum object_type type,\n+\t\t\t\t\t\t\t     struct pack_window **w_curs,\n+\t\t\t\t\t\t\t     off_t curpos)\n {\n \toff_t small_poi_stack[POI_STACK_PREALLOC];\n \toff_t *poi_stack = small_poi_stack;\n@@ -1378,8 +1380,8 @@ int packed_object_info(struct packed_git *p, off_t obj_offset,\n \n \tif (oi->typep || oi->type_name) {\n \t\tenum object_type ptot;\n-\t\tptot = packed_to_object_type(p, obj_offset, type, &w_curs,\n-\t\t\t\t\t     curpos);\n+\t\tptot = packed_to_object_type(the_repository, p, obj_offset,\n+\t\t\t\t\t     type, &w_curs, curpos);\n \t\tif (oi->typep)\n \t\t\t*oi->typep = ptot;\n \t\tif (oi->type_name) {\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345698","messageId":"20180424215910.22201-6-sbeller@google.com","threadId":"48355","inReplyTo":"20180424215910.22201-1-sbeller@google.com","subject":"[PATCHv2 5/9] packfile: add repository argument to packed_object_info","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-24T21:59:05Z","receivedAt":"2018-04-24T21:59:33Z","isPatch":false,"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 packed_object_info to be\nmore 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: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/pack-objects.c | 3 ++-\n packfile.c             | 4 ++--\n packfile.h             | 3 ++-\n sha1_file.c            | 2 +-\n 4 files changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 8d4111f748..d65eb4a947 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1572,7 +1572,8 @@ static void drop_reused_delta(struct object_entry *entry)\n \n \toi.sizep = &entry->size;\n \toi.typep = &entry->type;\n-\tif (packed_object_info(entry->in_pack, entry->in_pack_offset, &oi) < 0) {\n+\tif (packed_object_info(the_repository, entry->in_pack,\n+\t\t\t       entry->in_pack_offset, &oi) < 0) {\n \t\t/*\n \t\t * We failed to get the info from this pack for some reason;\n \t\t * fall back to sha1_object_info, which may find another copy.\ndiff --git a/packfile.c b/packfile.c\nindex 3ecfba66af..5fa7d27d3b 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1333,8 +1333,8 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,\n \thashmap_add(&delta_base_cache, ent);\n }\n \n-int packed_object_info(struct packed_git *p, off_t obj_offset,\n-\t\t       struct object_info *oi)\n+int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,\n+\t\t\t\t      struct object_info *oi)\n {\n \tstruct pack_window *w_curs = NULL;\n \tunsigned long size;\ndiff --git a/packfile.h b/packfile.h\nindex a92c0b241c..bc8d840b1b 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -125,7 +125,8 @@ extern void release_pack_memory(size_t);\n /* global flag to enable extra checks when accessing packed objects */\n extern int do_check_packed_object_crc;\n \n-extern int packed_object_info(struct packed_git *pack, off_t offset, struct object_info *);\n+#define packed_object_info(r, p, o, oi) packed_object_info_##r(p, o, oi)\n+extern int packed_object_info_the_repository(struct packed_git *pack, off_t offset, struct object_info *);\n \n extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1);\n extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 93f25c6c6a..746ff8297a 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1307,7 +1307,7 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \t\t * information below, so return early.\n \t\t */\n \t\treturn 0;\n-\trtype = packed_object_info(e.p, e.offset, oi);\n+\trtype = packed_object_info(the_repository, e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real->hash);\n \t\treturn oid_object_info_extended(the_repository, real, oi, 0);\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345699","messageId":"20180424215910.22201-10-sbeller@google.com","threadId":"48355","inReplyTo":"20180424215910.22201-1-sbeller@google.com","subject":"[PATCHv2 9/9] cache.h: allow oid_object_info to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-24T21:59:09Z","receivedAt":"2018-04-24T21:59:35Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This involves also adapting oid_object_info_extended and a some\ninternal functions that are used to implement these. It all has to\nhappen in one patch, because of a single recursive chain of calls visits\nall these functions.\n\nsha1_object_info_extended is also used in partial clones, which allow\nfetching missing objects. As this series will not add the repository\nstruct to the transport code and fetch_object(), add a TODO note and\nbug out if a user tries to use a partial clone in a repository other than\nthe_repository.\n\nHelped-by: Brandon Williams <bmwill@google.com>\nHelped-by: Jonathan Tan <jonathantanmy@google.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n cache.h     |  9 ++++-----\n packfile.c  | 58 ++++++++++++++++++++++++++---------------------------\n packfile.h  |  8 ++++----\n sha1_file.c | 30 ++++++++++++++++-----------\n 4 files changed, 54 insertions(+), 51 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 6340b2c572..3a4d80e92b 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1192,8 +1192,7 @@ static inline void *read_object_file(const struct object_id *oid, enum object_ty\n }\n \n /* Read and unpack an object file into memory, write memory to an object file */\n-#define oid_object_info(r, o, f) oid_object_info_##r(o, f)\n-int oid_object_info_the_repository(const struct object_id *, unsigned long *);\n+int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);\n \n extern int hash_object_file(const void *buf, unsigned long len,\n \t\t\t    const char *type, struct object_id *oid);\n@@ -1675,9 +1674,9 @@ struct object_info {\n /* Do not check loose object */\n #define OBJECT_INFO_IGNORE_LOOSE 16\n \n-#define oid_object_info_extended(r, oid, oi, flags) \\\n-\toid_object_info_extended_##r(oid, oi, flags)\n-int oid_object_info_extended_the_repository(const struct object_id *, struct object_info *, unsigned flags);\n+int oid_object_info_extended(struct repository *r,\n+\t\t\t     const struct object_id *,\n+\t\t\t     struct object_info *, unsigned flags);\n \n /*\n  * Set this to 0 to prevent sha1_object_info_extended() from fetching missing\ndiff --git a/packfile.c b/packfile.c\nindex 8de87f904b..55d383ed0a 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1104,9 +1104,9 @@ static const unsigned char *get_delta_base_sha1(struct packed_git *p,\n \t\treturn NULL;\n }\n \n-#define retry_bad_packed_offset(r, p, o) \\\n-\tretry_bad_packed_offset_##r(p, o)\n-static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t obj_offset)\n+static int retry_bad_packed_offset(struct repository *r,\n+\t\t\t\t   struct packed_git *p,\n+\t\t\t\t   off_t obj_offset)\n {\n \tint type;\n \tstruct revindex_entry *revidx;\n@@ -1116,7 +1116,7 @@ static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t ob\n \t\treturn OBJ_BAD;\n \tnth_packed_object_oid(&oid, p, revidx->nr);\n \tmark_bad_packed_object(p, oid.hash);\n-\ttype = oid_object_info(the_repository, &oid, NULL);\n+\ttype = oid_object_info(r, &oid, NULL);\n \tif (type <= OBJ_NONE)\n \t\treturn OBJ_BAD;\n \treturn type;\n@@ -1124,13 +1124,12 @@ static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t ob\n \n #define POI_STACK_PREALLOC 64\n \n-#define packed_to_object_type(r, p, o, t, w, c) \\\n-\tpacked_to_object_type_##r(p, o, t, w, c)\n-static enum object_type packed_to_object_type_the_repository(struct packed_git *p,\n-\t\t\t\t\t\t\t     off_t obj_offset,\n-\t\t\t\t\t\t\t     enum object_type type,\n-\t\t\t\t\t\t\t     struct pack_window **w_curs,\n-\t\t\t\t\t\t\t     off_t curpos)\n+static enum object_type packed_to_object_type(struct repository *r,\n+\t\t\t\t\t      struct packed_git *p,\n+\t\t\t\t\t      off_t obj_offset,\n+\t\t\t\t\t      enum object_type type,\n+\t\t\t\t\t      struct pack_window **w_curs,\n+\t\t\t\t\t      off_t curpos)\n {\n \toff_t small_poi_stack[POI_STACK_PREALLOC];\n \toff_t *poi_stack = small_poi_stack;\n@@ -1157,7 +1156,7 @@ static enum object_type packed_to_object_type_the_repository(struct packed_git *\n \t\tif (type <= OBJ_NONE) {\n \t\t\t/* If getting the base itself fails, we first\n \t\t\t * retry the base, otherwise unwind */\n-\t\t\ttype = retry_bad_packed_offset(the_repository, p, base_offset);\n+\t\t\ttype = retry_bad_packed_offset(r, p, base_offset);\n \t\t\tif (type > OBJ_NONE)\n \t\t\t\tgoto out;\n \t\t\tgoto unwind;\n@@ -1185,7 +1184,7 @@ static enum object_type packed_to_object_type_the_repository(struct packed_git *\n unwind:\n \twhile (poi_stack_nr) {\n \t\tobj_offset = poi_stack[--poi_stack_nr];\n-\t\ttype = retry_bad_packed_offset(the_repository, p, obj_offset);\n+\t\ttype = retry_bad_packed_offset(r, p, obj_offset);\n \t\tif (type > OBJ_NONE)\n \t\t\tgoto out;\n \t}\n@@ -1272,15 +1271,15 @@ static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)\n \tfree(ent);\n }\n \n-#define cache_or_unpack_entry(r, p, bo, bs, t) cache_or_unpack_entry_##r(p, bo, bs, t)\n-static void *cache_or_unpack_entry_the_repository(struct packed_git *p, off_t base_offset,\n-\tunsigned long *base_size, enum object_type *type)\n+static void *cache_or_unpack_entry(struct repository *r, struct packed_git *p,\n+\t\t\t\t   off_t base_offset, unsigned long *base_size,\n+\t\t\t\t   enum object_type *type)\n {\n \tstruct delta_base_cache_entry *ent;\n \n \tent = get_delta_base_cache_entry(p, base_offset);\n \tif (!ent)\n-\t\treturn unpack_entry(the_repository, p, base_offset, type, base_size);\n+\t\treturn unpack_entry(r, p, base_offset, type, base_size);\n \n \tif (type)\n \t\t*type = ent->type;\n@@ -1334,8 +1333,8 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,\n \thashmap_add(&delta_base_cache, ent);\n }\n \n-int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,\n-\t\t\t\t      struct object_info *oi)\n+int packed_object_info(struct repository *r, struct packed_git *p,\n+\t\t       off_t obj_offset, struct object_info *oi)\n {\n \tstruct pack_window *w_curs = NULL;\n \tunsigned long size;\n@@ -1347,7 +1346,7 @@ int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,\n \t * a \"real\" type later if the caller is interested.\n \t */\n \tif (oi->contentp) {\n-\t\t*oi->contentp = cache_or_unpack_entry(the_repository, p, obj_offset, oi->sizep,\n+\t\t*oi->contentp = cache_or_unpack_entry(r, p, obj_offset, oi->sizep,\n \t\t\t\t\t\t      &type);\n \t\tif (!*oi->contentp)\n \t\t\ttype = OBJ_BAD;\n@@ -1381,7 +1380,7 @@ int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,\n \n \tif (oi->typep || oi->type_name) {\n \t\tenum object_type ptot;\n-\t\tptot = packed_to_object_type(the_repository, p, obj_offset,\n+\t\tptot = packed_to_object_type(r, p, obj_offset,\n \t\t\t\t\t     type, &w_curs, curpos);\n \t\tif (oi->typep)\n \t\t\t*oi->typep = ptot;\n@@ -1470,10 +1469,10 @@ struct unpack_entry_stack_ent {\n \tunsigned long size;\n };\n \n-#define read_object(r, o, t, s) read_object_##r(o, t, s)\n-static void *read_object_the_repository(const struct object_id *oid,\n-\t\t\t\t\tenum object_type *type,\n-\t\t\t\t\tunsigned long *size)\n+static void *read_object(struct repository *r,\n+\t\t\t const struct object_id *oid,\n+\t\t\t enum object_type *type,\n+\t\t\t unsigned long *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tvoid *content;\n@@ -1481,14 +1480,13 @@ static void *read_object_the_repository(const struct object_id *oid,\n \toi.sizep = size;\n \toi.contentp = &content;\n \n-\tif (oid_object_info_extended(the_repository, oid, &oi, 0) < 0)\n+\tif (oid_object_info_extended(r, oid, &oi, 0) < 0)\n \t\treturn NULL;\n \treturn content;\n }\n \n-void *unpack_entry_the_repository(struct packed_git *p, off_t obj_offset,\n-\t\t\t\t  enum object_type *final_type,\n-\t\t\t\t  unsigned long *final_size)\n+void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n+\t\t   enum object_type *final_type, unsigned long *final_size)\n {\n \tstruct pack_window *w_curs = NULL;\n \toff_t curpos = obj_offset;\n@@ -1618,7 +1616,7 @@ void *unpack_entry_the_repository(struct packed_git *p, off_t obj_offset,\n \t\t\t\t      oid_to_hex(&base_oid), (uintmax_t)obj_offset,\n \t\t\t\t      p->pack_name);\n \t\t\t\tmark_bad_packed_object(p, base_oid.hash);\n-\t\t\t\tbase = read_object(the_repository, &base_oid, &type, &base_size);\n+\t\t\t\tbase = read_object(r, &base_oid, &type, &base_size);\n \t\t\t\texternal_base = base;\n \t\t\t}\n \t\t}\ndiff --git a/packfile.h b/packfile.h\nindex 1efa57a90e..fdfddb89b5 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -115,8 +115,7 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);\n extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);\n \n extern int is_pack_valid(struct packed_git *);\n-#define unpack_entry(r, p, of, ot, s) unpack_entry_##r(p, of, ot, s)\n-extern void *unpack_entry_the_repository(struct packed_git *, off_t, enum object_type *, unsigned long *);\n+extern void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object_type *, unsigned long *);\n extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);\n extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);\n@@ -126,8 +125,9 @@ extern void release_pack_memory(size_t);\n /* global flag to enable extra checks when accessing packed objects */\n extern int do_check_packed_object_crc;\n \n-#define packed_object_info(r, p, o, oi) packed_object_info_##r(p, o, oi)\n-extern int packed_object_info_the_repository(struct packed_git *pack, off_t offset, struct object_info *);\n+extern int packed_object_info(struct repository *r,\n+\t\t\t      struct packed_git *pack,\n+\t\t\t      off_t offset, struct object_info *);\n \n extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1);\n extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 746ff8297a..94123e0299 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1231,7 +1231,8 @@ static int sha1_loose_object_info(struct repository *r,\n \n int fetch_if_missing = 1;\n \n-int oid_object_info_extended_the_repository(const struct object_id *oid, struct object_info *oi, unsigned flags)\n+int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n+\t\t\t     struct object_info *oi, unsigned flags)\n {\n \tstatic struct object_info blank_oi = OBJECT_INFO_INIT;\n \tstruct pack_entry e;\n@@ -1240,7 +1241,7 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \tint already_retried = 0;\n \n \tif (flags & OBJECT_INFO_LOOKUP_REPLACE)\n-\t\treal = lookup_replace_object(the_repository, oid);\n+\t\treal = lookup_replace_object(r, oid);\n \n \tif (is_null_oid(real))\n \t\treturn -1;\n@@ -1269,20 +1270,20 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \t}\n \n \twhile (1) {\n-\t\tif (find_pack_entry(the_repository, real->hash, &e))\n+\t\tif (find_pack_entry(r, real->hash, &e))\n \t\t\tbreak;\n \n \t\tif (flags & OBJECT_INFO_IGNORE_LOOSE)\n \t\t\treturn -1;\n \n \t\t/* Most likely it's a loose object. */\n-\t\tif (!sha1_loose_object_info(the_repository, real->hash, oi, flags))\n+\t\tif (!sha1_loose_object_info(r, real->hash, oi, flags))\n \t\t\treturn 0;\n \n \t\t/* Not a loose object; someone else may have just packed it. */\n \t\tif (!(flags & OBJECT_INFO_QUICK)) {\n-\t\t\treprepare_packed_git(the_repository);\n-\t\t\tif (find_pack_entry(the_repository, real->hash, &e))\n+\t\t\treprepare_packed_git(r);\n+\t\t\tif (find_pack_entry(r, real->hash, &e))\n \t\t\t\tbreak;\n \t\t}\n \n@@ -1290,9 +1291,12 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \t\tif (fetch_if_missing && repository_format_partial_clone &&\n \t\t    !already_retried) {\n \t\t\t/*\n-\t\t\t * TODO Investigate haveing fetch_object() return\n+\t\t\t * TODO Investigate having fetch_object() return\n \t\t\t * TODO error/success and stopping the music here.\n+\t\t\t * TODO Pass a repository struct through fetch_object.\n \t\t\t */\n+\t\t\tif (r != the_repository)\n+\t\t\t\tdie(_(\"partial clones only supported in the_repository\"));\n \t\t\tfetch_object(repository_format_partial_clone, real->hash);\n \t\t\talready_retried = 1;\n \t\t\tcontinue;\n@@ -1307,10 +1311,10 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \t\t * information below, so return early.\n \t\t */\n \t\treturn 0;\n-\trtype = packed_object_info(the_repository, e.p, e.offset, oi);\n+\trtype = packed_object_info(r, e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real->hash);\n-\t\treturn oid_object_info_extended(the_repository, real, oi, 0);\n+\t\treturn oid_object_info_extended(r, real, oi, 0);\n \t} else if (oi->whence == OI_PACKED) {\n \t\toi->u.packed.offset = e.offset;\n \t\toi->u.packed.pack = e.p;\n@@ -1322,15 +1326,17 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n }\n \n /* returns enum object_type or negative */\n-int oid_object_info_the_repository(const struct object_id *oid, unsigned long *sizep)\n+int oid_object_info(struct repository *r,\n+\t\t    const struct object_id *oid,\n+\t\t    unsigned long *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \n \toi.typep = &type;\n \toi.sizep = sizep;\n-\tif (oid_object_info_extended(the_repository, oid, &oi,\n-\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\tif (oid_object_info_extended(r, oid, &oi,\n+\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\treturn -1;\n \treturn type;\n }\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345700","messageId":"20180424215910.22201-9-sbeller@google.com","threadId":"48355","inReplyTo":"20180424215910.22201-1-sbeller@google.com","subject":"[PATCHv2 8/9] packfile: add repository argument to cache_or_unpack_entry","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-24T21:59:08Z","receivedAt":"2018-04-24T21:59:36Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of cache_or_unpack_entry\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 packfile.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/packfile.c b/packfile.c\nindex d5ac48ef18..8de87f904b 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1272,7 +1272,8 @@ static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)\n \tfree(ent);\n }\n \n-static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,\n+#define cache_or_unpack_entry(r, p, bo, bs, t) cache_or_unpack_entry_##r(p, bo, bs, t)\n+static void *cache_or_unpack_entry_the_repository(struct packed_git *p, off_t base_offset,\n \tunsigned long *base_size, enum object_type *type)\n {\n \tstruct delta_base_cache_entry *ent;\n@@ -1346,7 +1347,7 @@ int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,\n \t * a \"real\" type later if the caller is interested.\n \t */\n \tif (oi->contentp) {\n-\t\t*oi->contentp = cache_or_unpack_entry(p, obj_offset, oi->sizep,\n+\t\t*oi->contentp = cache_or_unpack_entry(the_repository, p, obj_offset, oi->sizep,\n \t\t\t\t\t\t      &type);\n \t\tif (!*oi->contentp)\n \t\t\ttype = OBJ_BAD;\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345701","messageId":"20180424215910.22201-8-sbeller@google.com","threadId":"48355","inReplyTo":"20180424215910.22201-1-sbeller@google.com","subject":"[PATCHv2 7/9] packfile: add repository argument to unpack_entry","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-24T21:59:07Z","receivedAt":"2018-04-24T21:59:43Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of unpack_entry\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 fast-import.c | 2 +-\n pack-check.c  | 3 ++-\n packfile.c    | 7 ++++---\n packfile.h    | 3 ++-\n 4 files changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex afe06bd7c1..b009353e93 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1376,7 +1376,7 @@ static void *gfi_unpack_entry(\n \t\t */\n \t\tp->pack_size = pack_size + the_hash_algo->rawsz;\n \t}\n-\treturn unpack_entry(p, oe->idx.offset, &type, sizep);\n+\treturn unpack_entry(the_repository, p, oe->idx.offset, &type, sizep);\n }\n \n static const char *get_mode(const char *str, uint16_t *modep)\ndiff --git a/pack-check.c b/pack-check.c\nindex 385d964bdd..d3a57df34f 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"repository.h\"\n #include \"pack.h\"\n #include \"pack-revindex.h\"\n #include \"progress.h\"\n@@ -134,7 +135,7 @@ static int verify_packfile(struct packed_git *p,\n \t\t\tdata = NULL;\n \t\t\tdata_valid = 0;\n \t\t} else {\n-\t\t\tdata = unpack_entry(p, entries[i].offset, &type, &size);\n+\t\t\tdata = unpack_entry(the_repository, p, entries[i].offset, &type, &size);\n \t\t\tdata_valid = 1;\n \t\t}\n \ndiff --git a/packfile.c b/packfile.c\nindex 2876e04bb1..d5ac48ef18 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1279,7 +1279,7 @@ static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,\n \n \tent = get_delta_base_cache_entry(p, base_offset);\n \tif (!ent)\n-\t\treturn unpack_entry(p, base_offset, type, base_size);\n+\t\treturn unpack_entry(the_repository, p, base_offset, type, base_size);\n \n \tif (type)\n \t\t*type = ent->type;\n@@ -1485,8 +1485,9 @@ static void *read_object_the_repository(const struct object_id *oid,\n \treturn content;\n }\n \n-void *unpack_entry(struct packed_git *p, off_t obj_offset,\n-\t\t   enum object_type *final_type, unsigned long *final_size)\n+void *unpack_entry_the_repository(struct packed_git *p, off_t obj_offset,\n+\t\t\t\t  enum object_type *final_type,\n+\t\t\t\t  unsigned long *final_size)\n {\n \tstruct pack_window *w_curs = NULL;\n \toff_t curpos = obj_offset;\ndiff --git a/packfile.h b/packfile.h\nindex bc8d840b1b..1efa57a90e 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -115,7 +115,8 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);\n extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);\n \n extern int is_pack_valid(struct packed_git *);\n-extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);\n+#define unpack_entry(r, p, of, ot, s) unpack_entry_##r(p, of, ot, s)\n+extern void *unpack_entry_the_repository(struct packed_git *, off_t, enum object_type *, unsigned long *);\n extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);\n extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345702","messageId":"20180424215910.22201-7-sbeller@google.com","threadId":"48355","inReplyTo":"20180424215910.22201-1-sbeller@google.com","subject":"[PATCHv2 6/9] packfile: add repository argument to read_object","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-24T21:59:06Z","receivedAt":"2018-04-24T21:59:44Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of read_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: Stefan Beller <sbeller@google.com>\n---\n packfile.c | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/packfile.c b/packfile.c\nindex 5fa7d27d3b..2876e04bb1 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1469,8 +1469,10 @@ struct unpack_entry_stack_ent {\n \tunsigned long size;\n };\n \n-static void *read_object(const struct object_id *oid, enum object_type *type,\n-\t\t\t unsigned long *size)\n+#define read_object(r, o, t, s) read_object_##r(o, t, s)\n+static void *read_object_the_repository(const struct object_id *oid,\n+\t\t\t\t\tenum object_type *type,\n+\t\t\t\t\tunsigned long *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tvoid *content;\n@@ -1614,7 +1616,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,\n \t\t\t\t      oid_to_hex(&base_oid), (uintmax_t)obj_offset,\n \t\t\t\t      p->pack_name);\n \t\t\t\tmark_bad_packed_object(p, base_oid.hash);\n-\t\t\t\tbase = read_object(&base_oid, &type, &base_size);\n+\t\t\t\tbase = read_object(the_repository, &base_oid, &type, &base_size);\n \t\t\t\texternal_base = base;\n \t\t\t}\n \t\t}\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345703","messageId":"20180424215910.22201-11-sbeller@google.com","threadId":"48355","inReplyTo":"20180424215910.22201-1-sbeller@google.com","subject":"[PATCHv2 9/9] cache.h: allow sha1_object_info to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-24T21:59:10Z","receivedAt":"2018-04-24T21:59:48Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This involves also adapting sha1_object_info_extended and a some\ninternal functions that are used to implement these. It all has to\nhappen in one patch, because of a single recursive chain of calls visits\nall these functions.\n\nsha1_object_info_extended is also used in partial clones, which allow\nfetching missing objects. As this series will not add the repository\nstruct to the transport code and fetch_object(), add a TODO note and\nbug out if a user tries to use a partial clone in a repository other than\nthe_repository.\n\nHelped-by: Brandon Williams <bmwill@google.com>\nHelped-by: Jonathan Tan <jonathantanmy@google.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n cache.h     |  9 ++++-----\n packfile.c  | 58 ++++++++++++++++++++++++++---------------------------\n packfile.h  |  8 ++++----\n sha1_file.c | 30 ++++++++++++++++-----------\n 4 files changed, 54 insertions(+), 51 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 6340b2c572..3a4d80e92b 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1192,8 +1192,7 @@ static inline void *read_object_file(const struct object_id *oid, enum object_ty\n }\n \n /* Read and unpack an object file into memory, write memory to an object file */\n-#define oid_object_info(r, o, f) oid_object_info_##r(o, f)\n-int oid_object_info_the_repository(const struct object_id *, unsigned long *);\n+int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);\n \n extern int hash_object_file(const void *buf, unsigned long len,\n \t\t\t    const char *type, struct object_id *oid);\n@@ -1675,9 +1674,9 @@ struct object_info {\n /* Do not check loose object */\n #define OBJECT_INFO_IGNORE_LOOSE 16\n \n-#define oid_object_info_extended(r, oid, oi, flags) \\\n-\toid_object_info_extended_##r(oid, oi, flags)\n-int oid_object_info_extended_the_repository(const struct object_id *, struct object_info *, unsigned flags);\n+int oid_object_info_extended(struct repository *r,\n+\t\t\t     const struct object_id *,\n+\t\t\t     struct object_info *, unsigned flags);\n \n /*\n  * Set this to 0 to prevent sha1_object_info_extended() from fetching missing\ndiff --git a/packfile.c b/packfile.c\nindex 8de87f904b..55d383ed0a 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1104,9 +1104,9 @@ static const unsigned char *get_delta_base_sha1(struct packed_git *p,\n \t\treturn NULL;\n }\n \n-#define retry_bad_packed_offset(r, p, o) \\\n-\tretry_bad_packed_offset_##r(p, o)\n-static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t obj_offset)\n+static int retry_bad_packed_offset(struct repository *r,\n+\t\t\t\t   struct packed_git *p,\n+\t\t\t\t   off_t obj_offset)\n {\n \tint type;\n \tstruct revindex_entry *revidx;\n@@ -1116,7 +1116,7 @@ static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t ob\n \t\treturn OBJ_BAD;\n \tnth_packed_object_oid(&oid, p, revidx->nr);\n \tmark_bad_packed_object(p, oid.hash);\n-\ttype = oid_object_info(the_repository, &oid, NULL);\n+\ttype = oid_object_info(r, &oid, NULL);\n \tif (type <= OBJ_NONE)\n \t\treturn OBJ_BAD;\n \treturn type;\n@@ -1124,13 +1124,12 @@ static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t ob\n \n #define POI_STACK_PREALLOC 64\n \n-#define packed_to_object_type(r, p, o, t, w, c) \\\n-\tpacked_to_object_type_##r(p, o, t, w, c)\n-static enum object_type packed_to_object_type_the_repository(struct packed_git *p,\n-\t\t\t\t\t\t\t     off_t obj_offset,\n-\t\t\t\t\t\t\t     enum object_type type,\n-\t\t\t\t\t\t\t     struct pack_window **w_curs,\n-\t\t\t\t\t\t\t     off_t curpos)\n+static enum object_type packed_to_object_type(struct repository *r,\n+\t\t\t\t\t      struct packed_git *p,\n+\t\t\t\t\t      off_t obj_offset,\n+\t\t\t\t\t      enum object_type type,\n+\t\t\t\t\t      struct pack_window **w_curs,\n+\t\t\t\t\t      off_t curpos)\n {\n \toff_t small_poi_stack[POI_STACK_PREALLOC];\n \toff_t *poi_stack = small_poi_stack;\n@@ -1157,7 +1156,7 @@ static enum object_type packed_to_object_type_the_repository(struct packed_git *\n \t\tif (type <= OBJ_NONE) {\n \t\t\t/* If getting the base itself fails, we first\n \t\t\t * retry the base, otherwise unwind */\n-\t\t\ttype = retry_bad_packed_offset(the_repository, p, base_offset);\n+\t\t\ttype = retry_bad_packed_offset(r, p, base_offset);\n \t\t\tif (type > OBJ_NONE)\n \t\t\t\tgoto out;\n \t\t\tgoto unwind;\n@@ -1185,7 +1184,7 @@ static enum object_type packed_to_object_type_the_repository(struct packed_git *\n unwind:\n \twhile (poi_stack_nr) {\n \t\tobj_offset = poi_stack[--poi_stack_nr];\n-\t\ttype = retry_bad_packed_offset(the_repository, p, obj_offset);\n+\t\ttype = retry_bad_packed_offset(r, p, obj_offset);\n \t\tif (type > OBJ_NONE)\n \t\t\tgoto out;\n \t}\n@@ -1272,15 +1271,15 @@ static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)\n \tfree(ent);\n }\n \n-#define cache_or_unpack_entry(r, p, bo, bs, t) cache_or_unpack_entry_##r(p, bo, bs, t)\n-static void *cache_or_unpack_entry_the_repository(struct packed_git *p, off_t base_offset,\n-\tunsigned long *base_size, enum object_type *type)\n+static void *cache_or_unpack_entry(struct repository *r, struct packed_git *p,\n+\t\t\t\t   off_t base_offset, unsigned long *base_size,\n+\t\t\t\t   enum object_type *type)\n {\n \tstruct delta_base_cache_entry *ent;\n \n \tent = get_delta_base_cache_entry(p, base_offset);\n \tif (!ent)\n-\t\treturn unpack_entry(the_repository, p, base_offset, type, base_size);\n+\t\treturn unpack_entry(r, p, base_offset, type, base_size);\n \n \tif (type)\n \t\t*type = ent->type;\n@@ -1334,8 +1333,8 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,\n \thashmap_add(&delta_base_cache, ent);\n }\n \n-int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,\n-\t\t\t\t      struct object_info *oi)\n+int packed_object_info(struct repository *r, struct packed_git *p,\n+\t\t       off_t obj_offset, struct object_info *oi)\n {\n \tstruct pack_window *w_curs = NULL;\n \tunsigned long size;\n@@ -1347,7 +1346,7 @@ int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,\n \t * a \"real\" type later if the caller is interested.\n \t */\n \tif (oi->contentp) {\n-\t\t*oi->contentp = cache_or_unpack_entry(the_repository, p, obj_offset, oi->sizep,\n+\t\t*oi->contentp = cache_or_unpack_entry(r, p, obj_offset, oi->sizep,\n \t\t\t\t\t\t      &type);\n \t\tif (!*oi->contentp)\n \t\t\ttype = OBJ_BAD;\n@@ -1381,7 +1380,7 @@ int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,\n \n \tif (oi->typep || oi->type_name) {\n \t\tenum object_type ptot;\n-\t\tptot = packed_to_object_type(the_repository, p, obj_offset,\n+\t\tptot = packed_to_object_type(r, p, obj_offset,\n \t\t\t\t\t     type, &w_curs, curpos);\n \t\tif (oi->typep)\n \t\t\t*oi->typep = ptot;\n@@ -1470,10 +1469,10 @@ struct unpack_entry_stack_ent {\n \tunsigned long size;\n };\n \n-#define read_object(r, o, t, s) read_object_##r(o, t, s)\n-static void *read_object_the_repository(const struct object_id *oid,\n-\t\t\t\t\tenum object_type *type,\n-\t\t\t\t\tunsigned long *size)\n+static void *read_object(struct repository *r,\n+\t\t\t const struct object_id *oid,\n+\t\t\t enum object_type *type,\n+\t\t\t unsigned long *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tvoid *content;\n@@ -1481,14 +1480,13 @@ static void *read_object_the_repository(const struct object_id *oid,\n \toi.sizep = size;\n \toi.contentp = &content;\n \n-\tif (oid_object_info_extended(the_repository, oid, &oi, 0) < 0)\n+\tif (oid_object_info_extended(r, oid, &oi, 0) < 0)\n \t\treturn NULL;\n \treturn content;\n }\n \n-void *unpack_entry_the_repository(struct packed_git *p, off_t obj_offset,\n-\t\t\t\t  enum object_type *final_type,\n-\t\t\t\t  unsigned long *final_size)\n+void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n+\t\t   enum object_type *final_type, unsigned long *final_size)\n {\n \tstruct pack_window *w_curs = NULL;\n \toff_t curpos = obj_offset;\n@@ -1618,7 +1616,7 @@ void *unpack_entry_the_repository(struct packed_git *p, off_t obj_offset,\n \t\t\t\t      oid_to_hex(&base_oid), (uintmax_t)obj_offset,\n \t\t\t\t      p->pack_name);\n \t\t\t\tmark_bad_packed_object(p, base_oid.hash);\n-\t\t\t\tbase = read_object(the_repository, &base_oid, &type, &base_size);\n+\t\t\t\tbase = read_object(r, &base_oid, &type, &base_size);\n \t\t\t\texternal_base = base;\n \t\t\t}\n \t\t}\ndiff --git a/packfile.h b/packfile.h\nindex 1efa57a90e..fdfddb89b5 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -115,8 +115,7 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);\n extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);\n \n extern int is_pack_valid(struct packed_git *);\n-#define unpack_entry(r, p, of, ot, s) unpack_entry_##r(p, of, ot, s)\n-extern void *unpack_entry_the_repository(struct packed_git *, off_t, enum object_type *, unsigned long *);\n+extern void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object_type *, unsigned long *);\n extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);\n extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);\n@@ -126,8 +125,9 @@ extern void release_pack_memory(size_t);\n /* global flag to enable extra checks when accessing packed objects */\n extern int do_check_packed_object_crc;\n \n-#define packed_object_info(r, p, o, oi) packed_object_info_##r(p, o, oi)\n-extern int packed_object_info_the_repository(struct packed_git *pack, off_t offset, struct object_info *);\n+extern int packed_object_info(struct repository *r,\n+\t\t\t      struct packed_git *pack,\n+\t\t\t      off_t offset, struct object_info *);\n \n extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1);\n extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 746ff8297a..94123e0299 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1231,7 +1231,8 @@ static int sha1_loose_object_info(struct repository *r,\n \n int fetch_if_missing = 1;\n \n-int oid_object_info_extended_the_repository(const struct object_id *oid, struct object_info *oi, unsigned flags)\n+int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n+\t\t\t     struct object_info *oi, unsigned flags)\n {\n \tstatic struct object_info blank_oi = OBJECT_INFO_INIT;\n \tstruct pack_entry e;\n@@ -1240,7 +1241,7 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \tint already_retried = 0;\n \n \tif (flags & OBJECT_INFO_LOOKUP_REPLACE)\n-\t\treal = lookup_replace_object(the_repository, oid);\n+\t\treal = lookup_replace_object(r, oid);\n \n \tif (is_null_oid(real))\n \t\treturn -1;\n@@ -1269,20 +1270,20 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \t}\n \n \twhile (1) {\n-\t\tif (find_pack_entry(the_repository, real->hash, &e))\n+\t\tif (find_pack_entry(r, real->hash, &e))\n \t\t\tbreak;\n \n \t\tif (flags & OBJECT_INFO_IGNORE_LOOSE)\n \t\t\treturn -1;\n \n \t\t/* Most likely it's a loose object. */\n-\t\tif (!sha1_loose_object_info(the_repository, real->hash, oi, flags))\n+\t\tif (!sha1_loose_object_info(r, real->hash, oi, flags))\n \t\t\treturn 0;\n \n \t\t/* Not a loose object; someone else may have just packed it. */\n \t\tif (!(flags & OBJECT_INFO_QUICK)) {\n-\t\t\treprepare_packed_git(the_repository);\n-\t\t\tif (find_pack_entry(the_repository, real->hash, &e))\n+\t\t\treprepare_packed_git(r);\n+\t\t\tif (find_pack_entry(r, real->hash, &e))\n \t\t\t\tbreak;\n \t\t}\n \n@@ -1290,9 +1291,12 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \t\tif (fetch_if_missing && repository_format_partial_clone &&\n \t\t    !already_retried) {\n \t\t\t/*\n-\t\t\t * TODO Investigate haveing fetch_object() return\n+\t\t\t * TODO Investigate having fetch_object() return\n \t\t\t * TODO error/success and stopping the music here.\n+\t\t\t * TODO Pass a repository struct through fetch_object.\n \t\t\t */\n+\t\t\tif (r != the_repository)\n+\t\t\t\tdie(_(\"partial clones only supported in the_repository\"));\n \t\t\tfetch_object(repository_format_partial_clone, real->hash);\n \t\t\talready_retried = 1;\n \t\t\tcontinue;\n@@ -1307,10 +1311,10 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \t\t * information below, so return early.\n \t\t */\n \t\treturn 0;\n-\trtype = packed_object_info(the_repository, e.p, e.offset, oi);\n+\trtype = packed_object_info(r, e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real->hash);\n-\t\treturn oid_object_info_extended(the_repository, real, oi, 0);\n+\t\treturn oid_object_info_extended(r, real, oi, 0);\n \t} else if (oi->whence == OI_PACKED) {\n \t\toi->u.packed.offset = e.offset;\n \t\toi->u.packed.pack = e.p;\n@@ -1322,15 +1326,17 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n }\n \n /* returns enum object_type or negative */\n-int oid_object_info_the_repository(const struct object_id *oid, unsigned long *sizep)\n+int oid_object_info(struct repository *r,\n+\t\t    const struct object_id *oid,\n+\t\t    unsigned long *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \n \toi.typep = &type;\n \toi.sizep = sizep;\n-\tif (oid_object_info_extended(the_repository, oid, &oi,\n-\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\tif (oid_object_info_extended(r, oid, &oi,\n+\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\treturn -1;\n \treturn type;\n }\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345709","messageId":"20180424154911.54ab50bc2f95bc92ef88350a@google.com","threadId":"48355","inReplyTo":"20180424215910.22201-10-sbeller@google.com","subject":"Re: [PATCHv2 9/9] cache.h: allow oid_object_info to handle arbitrary repositories","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-04-24T22:49:11Z","receivedAt":"2018-04-24T22:49:17Z","isPatch":false,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"On Tue, 24 Apr 2018 14:59:09 -0700\nStefan Beller <sbeller@google.com> wrote:\n\n> This involves also adapting oid_object_info_extended and a some\n> internal functions that are used to implement these. It all has to\n> happen in one patch, because of a single recursive chain of calls visits\n> all these functions.\n\nI wrote about delta_base_cache in a reply [1] to an earlier version,\nwhich is indeed safe (as discussed), but I think that other reviewers\nmight have questions about that too so I think it's worth noting that in\nthe commit message. Maybe write something like:\n\n  Among the functions modified to handle arbitrary repositories,\n  unpack_entry() is one of them. Note that it still references the\n  globals \"delta_base_cache\" and \"delta_base_cached\", but those are safe\n  to be referenced (the former is indexed partly by \"struct packed_git\n  *\", which is repo-specific, and the latter is only used to limit the\n  size of the former as an optimization).\n\n[1] https://public-inbox.org/git/20180424112332.38c0d04d96689f030e96825a@google.com/\n\n> sha1_object_info_extended is also used in partial clones, which allow\n> fetching missing objects. As this series will not add the repository\n> struct to the transport code and fetch_object(), add a TODO note and\n> bug out if a user tries to use a partial clone in a repository other than\n> the_repository.\n\ns/sha1_object/oid_object/ (in the 2nd paragraph)\n\nAlso, you sent 2 versions of PATCHv2 9/9.\n  \n> @@ -1290,9 +1291,12 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n>  \t\tif (fetch_if_missing && repository_format_partial_clone &&\n>  \t\t    !already_retried) {\n>  \t\t\t/*\n> -\t\t\t * TODO Investigate haveing fetch_object() return\n> +\t\t\t * TODO Investigate having fetch_object() return\n>  \t\t\t * TODO error/success and stopping the music here.\n> +\t\t\t * TODO Pass a repository struct through fetch_object.\n>  \t\t\t */\n> +\t\t\tif (r != the_repository)\n> +\t\t\t\tdie(_(\"partial clones only supported in the_repository\"));\n>  \t\t\tfetch_object(repository_format_partial_clone, real->hash);\n>  \t\t\talready_retried = 1;\n>  \t\t\tcontinue;\n\nThis most likely means that a partial clone with a submodule would\nwrongly error out here. Instead, the \"r == the_repository\" check should\nbe done in the same \"if\" statement as repository_format_partial_clone\n(and no \"die\"-ing occurs if it fails - just that there will be no\nfetching of objects).\n"},{"id":"345831","messageId":"20180425182106.162972-1-sbeller@google.com","threadId":"48355","inReplyTo":"20180424215910.22201-1-sbeller@google.com","subject":"[PATCHv3 0/9] object store: oid_object_info is the next contender","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-25T18:20:57Z","receivedAt":"2018-04-25T18:21:20Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"v3:\n* fixed and extended the commit message of last commit\n* fixed the last patch, as Jonathan Tan suggested, see interdiff:\n\n    $ git diff remotes/origin/sb/oid-object-info (which is v2)\n    diff --git c/sha1_file.c w/sha1_file.c\n    index 94123e0299..dcd6b879ac 100644\n    --- c/sha1_file.c\n    +++ w/sha1_file.c\n    @@ -1289,14 +1289,13 @@ int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n     \n                    /* Check if it is a missing object */\n                    if (fetch_if_missing && repository_format_partial_clone &&\n    -                   !already_retried) {\n    +                   !already_retried && r == the_repository) {\n                            /*\n                             * TODO Investigate having fetch_object() return\n                             * TODO error/success and stopping the music here.\n    -                        * TODO Pass a repository struct through fetch_object.\n    +                        * TODO Pass a repository struct through fetch_object,\n    +                        * such that arbitrary repositories work.\n                             */\n    -                       if (r != the_repository)\n    -                               die(_(\"partial clones only supported in the_repository\"));\n                            fetch_object(repository_format_partial_clone, real->hash);\n                            already_retried = 1;\n                            continue;\n    \nThanks,\nStefan\n\nv2:\n\n* fixed the sha1/oid typo\n* removed spurious new line\n* Brandon and Jonthan discovered another dependency that I missed due\n  to cherrypicking that commit from a tree before partial clone was a thing.\n  We error out when attempting to use fetch_object for repos that are not\n  the_repository.\n\nThanks,\nStefan\n\nv1:\nThis applies on top of origin/sb/object-store-replace and is available as\nhttps://github.com/stefanbeller/git/tree/oid_object_info\n\nThis continues the work of sb/packfiles-in-repository,\nextending the layer at which we have to pass in an explicit\nrepository object to oid_object_info.\n\nA test merge to next shows only a minor merge conflicit (adding\ndifferent #include lines in one c file), so this might be a good next\nstep for the object store series.\n\nNotes on further object store series:\nI plan on converting the \"parsed object store\" next,\nwhich would be {alloc, object, tree, commit, tag}.c as that is a prerequisite\nfor migrating shallow (which is intermingled with grafts) information to the\nobject store.\n\nThere is currently work going on in allocation (mempool - Jameson Miller)\nand grafts (deprecate grafts - DScho), which is why I am sending this\nseries first. I think it can go in parallel to the \"parsed object store\"\nthat is coming next.\n\nThanks,\nStefan\n\nJonathan Nieder (1):\n  packfile: add repository argument to packed_object_info\n\nStefan Beller (8):\n  cache.h: add repository argument to oid_object_info_extended\n  cache.h: add repository argument to oid_object_info\n  packfile: add repository argument to retry_bad_packed_offset\n  packfile: add repository argument to packed_to_object_type\n  packfile: add repository argument to read_object\n  packfile: add repository argument to unpack_entry\n  packfile: add repository argument to cache_or_unpack_entry\n  cache.h: allow oid_object_info to handle arbitrary repositories\n\n archive-tar.c            |  2 +-\n archive-zip.c            |  3 ++-\n blame.c                  |  4 ++--\n builtin/blame.c          |  2 +-\n builtin/cat-file.c       | 12 ++++++------\n builtin/describe.c       |  2 +-\n builtin/fast-export.c    |  2 +-\n builtin/fetch.c          |  2 +-\n builtin/fsck.c           |  3 ++-\n builtin/index-pack.c     |  4 ++--\n builtin/ls-tree.c        |  2 +-\n builtin/mktree.c         |  2 +-\n builtin/pack-objects.c   | 11 +++++++----\n builtin/prune.c          |  3 ++-\n builtin/replace.c        | 11 ++++++-----\n builtin/tag.c            |  4 ++--\n builtin/unpack-objects.c |  2 +-\n cache.h                  |  7 +++++--\n diff.c                   |  3 ++-\n fast-import.c            | 16 ++++++++++------\n list-objects-filter.c    |  2 +-\n object.c                 |  2 +-\n pack-bitmap-write.c      |  3 ++-\n pack-check.c             |  3 ++-\n packfile.c               | 40 +++++++++++++++++++++++-----------------\n packfile.h               |  6 ++++--\n reachable.c              |  2 +-\n refs.c                   |  2 +-\n remote.c                 |  2 +-\n sequencer.c              |  3 ++-\n sha1_file.c              | 37 +++++++++++++++++++++----------------\n sha1_name.c              | 12 ++++++------\n streaming.c              |  2 +-\n submodule.c              |  2 +-\n tag.c                    |  2 +-\n 35 files changed, 124 insertions(+), 93 deletions(-)\n\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345832","messageId":"20180425182106.162972-2-sbeller@google.com","threadId":"48355","inReplyTo":"20180425182106.162972-1-sbeller@google.com","subject":"[PATCHv3 1/9] cache.h: add repository argument to oid_object_info_extended","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-25T18:20:58Z","receivedAt":"2018-04-25T18:21:21Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow oid_object_info_extended callers\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\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/cat-file.c |  6 +++---\n cache.h            |  5 ++++-\n packfile.c         |  2 +-\n sha1_file.c        | 10 +++++-----\n streaming.c        |  2 +-\n 5 files changed, 14 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 2c46d257cd..4ecdb9ff54 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -77,7 +77,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tswitch (opt) {\n \tcase 't':\n \t\toi.type_name = &sb;\n-\t\tif (oid_object_info_extended(&oid, &oi, flags) < 0)\n+\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \t\tif (sb.len) {\n \t\t\tprintf(\"%s\\n\", sb.buf);\n@@ -88,7 +88,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \n \tcase 's':\n \t\toi.sizep = &size;\n-\t\tif (oid_object_info_extended(&oid, &oi, flags) < 0)\n+\t\tif (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n \t\tprintf(\"%lu\\n\", size);\n \t\treturn 0;\n@@ -342,7 +342,7 @@ static void batch_object_write(const char *obj_name, struct batch_options *opt,\n \tstruct strbuf buf = STRBUF_INIT;\n \n \tif (!data->skip_object_info &&\n-\t    oid_object_info_extended(&data->oid, &data->info,\n+\t    oid_object_info_extended(the_repository, &data->oid, &data->info,\n \t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE) < 0) {\n \t\tprintf(\"%s missing\\n\",\n \t\t       obj_name ? obj_name : oid_to_hex(&data->oid));\ndiff --git a/cache.h b/cache.h\nindex 027bd7ffc8..588c4fff9a 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1673,7 +1673,10 @@ struct object_info {\n #define OBJECT_INFO_QUICK 8\n /* Do not check loose object */\n #define OBJECT_INFO_IGNORE_LOOSE 16\n-extern int oid_object_info_extended(const struct object_id *, struct object_info *, unsigned flags);\n+\n+#define oid_object_info_extended(r, oid, oi, flags) \\\n+\toid_object_info_extended_##r(oid, oi, flags)\n+int oid_object_info_extended_the_repository(const struct object_id *, struct object_info *, unsigned flags);\n \n /*\n  * Set this to 0 to prevent sha1_object_info_extended() from fetching missing\ndiff --git a/packfile.c b/packfile.c\nindex 0bc67d0e00..d9914ba723 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1474,7 +1474,7 @@ static void *read_object(const struct object_id *oid, enum object_type *type,\n \toi.sizep = size;\n \toi.contentp = &content;\n \n-\tif (oid_object_info_extended(oid, &oi, 0) < 0)\n+\tif (oid_object_info_extended(the_repository, oid, &oi, 0) < 0)\n \t\treturn NULL;\n \treturn content;\n }\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 64a5bd7d87..50a2dc5f0a 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1231,7 +1231,7 @@ static int sha1_loose_object_info(struct repository *r,\n \n int fetch_if_missing = 1;\n \n-int oid_object_info_extended(const struct object_id *oid, struct object_info *oi, unsigned flags)\n+int oid_object_info_extended_the_repository(const struct object_id *oid, struct object_info *oi, unsigned flags)\n {\n \tstatic struct object_info blank_oi = OBJECT_INFO_INIT;\n \tstruct pack_entry e;\n@@ -1310,7 +1310,7 @@ int oid_object_info_extended(const struct object_id *oid, struct object_info *oi\n \trtype = packed_object_info(e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real->hash);\n-\t\treturn oid_object_info_extended(real, oi, 0);\n+\t\treturn oid_object_info_extended(the_repository, real, oi, 0);\n \t} else if (oi->whence == OI_PACKED) {\n \t\toi->u.packed.offset = e.offset;\n \t\toi->u.packed.pack = e.p;\n@@ -1329,7 +1329,7 @@ int oid_object_info(const struct object_id *oid, unsigned long *sizep)\n \n \toi.typep = &type;\n \toi.sizep = sizep;\n-\tif (oid_object_info_extended(oid, &oi,\n+\tif (oid_object_info_extended(the_repository, oid, &oi,\n \t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\treturn -1;\n \treturn type;\n@@ -1347,7 +1347,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,\n \n \thashcpy(oid.hash, sha1);\n \n-\tif (oid_object_info_extended(&oid, &oi, 0) < 0)\n+\tif (oid_object_info_extended(the_repository, &oid, &oi, 0) < 0)\n \t\treturn NULL;\n \treturn content;\n }\n@@ -1745,7 +1745,7 @@ int has_sha1_file_with_flags(const unsigned char *sha1, int flags)\n \tif (!startup_info->have_repository)\n \t\treturn 0;\n \thashcpy(oid.hash, sha1);\n-\treturn oid_object_info_extended(&oid, NULL,\n+\treturn oid_object_info_extended(the_repository, &oid, NULL,\n \t\t\t\t\tflags | OBJECT_INFO_SKIP_CACHED) >= 0;\n }\n \ndiff --git a/streaming.c b/streaming.c\nindex cce7b17ea7..d1e6b2dce6 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -117,7 +117,7 @@ static enum input_source istream_source(const struct object_id *oid,\n \n \toi->typep = type;\n \toi->sizep = &size;\n-\tstatus = oid_object_info_extended(oid, oi, 0);\n+\tstatus = oid_object_info_extended(the_repository, oid, oi, 0);\n \tif (status < 0)\n \t\treturn stream_error;\n \n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345833","messageId":"20180425182106.162972-4-sbeller@google.com","threadId":"48355","inReplyTo":"20180425182106.162972-1-sbeller@google.com","subject":"[PATCHv3 3/9] packfile: add repository argument to retry_bad_packed_offset","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-25T18:21:00Z","receivedAt":"2018-04-25T18:21:32Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of retry_bad_packed_offset\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: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n packfile.c | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/packfile.c b/packfile.c\nindex 80c7fa734f..d2b3f3503b 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1104,7 +1104,9 @@ static const unsigned char *get_delta_base_sha1(struct packed_git *p,\n \t\treturn NULL;\n }\n \n-static int retry_bad_packed_offset(struct packed_git *p, off_t obj_offset)\n+#define retry_bad_packed_offset(r, p, o) \\\n+\tretry_bad_packed_offset_##r(p, o)\n+static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t obj_offset)\n {\n \tint type;\n \tstruct revindex_entry *revidx;\n@@ -1153,7 +1155,7 @@ static enum object_type packed_to_object_type(struct packed_git *p,\n \t\tif (type <= OBJ_NONE) {\n \t\t\t/* If getting the base itself fails, we first\n \t\t\t * retry the base, otherwise unwind */\n-\t\t\ttype = retry_bad_packed_offset(p, base_offset);\n+\t\t\ttype = retry_bad_packed_offset(the_repository, p, base_offset);\n \t\t\tif (type > OBJ_NONE)\n \t\t\t\tgoto out;\n \t\t\tgoto unwind;\n@@ -1181,7 +1183,7 @@ static enum object_type packed_to_object_type(struct packed_git *p,\n unwind:\n \twhile (poi_stack_nr) {\n \t\tobj_offset = poi_stack[--poi_stack_nr];\n-\t\ttype = retry_bad_packed_offset(p, obj_offset);\n+\t\ttype = retry_bad_packed_offset(the_repository, p, obj_offset);\n \t\tif (type > OBJ_NONE)\n \t\t\tgoto out;\n \t}\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345834","messageId":"20180425182106.162972-7-sbeller@google.com","threadId":"48355","inReplyTo":"20180425182106.162972-1-sbeller@google.com","subject":"[PATCHv3 6/9] packfile: add repository argument to read_object","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-25T18:21:03Z","receivedAt":"2018-04-25T18:21:35Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of read_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: Stefan Beller <sbeller@google.com>\n---\n packfile.c | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/packfile.c b/packfile.c\nindex 5fa7d27d3b..2876e04bb1 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1469,8 +1469,10 @@ struct unpack_entry_stack_ent {\n \tunsigned long size;\n };\n \n-static void *read_object(const struct object_id *oid, enum object_type *type,\n-\t\t\t unsigned long *size)\n+#define read_object(r, o, t, s) read_object_##r(o, t, s)\n+static void *read_object_the_repository(const struct object_id *oid,\n+\t\t\t\t\tenum object_type *type,\n+\t\t\t\t\tunsigned long *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tvoid *content;\n@@ -1614,7 +1616,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,\n \t\t\t\t      oid_to_hex(&base_oid), (uintmax_t)obj_offset,\n \t\t\t\t      p->pack_name);\n \t\t\t\tmark_bad_packed_object(p, base_oid.hash);\n-\t\t\t\tbase = read_object(&base_oid, &type, &base_size);\n+\t\t\t\tbase = read_object(the_repository, &base_oid, &type, &base_size);\n \t\t\t\texternal_base = base;\n \t\t\t}\n \t\t}\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345835","messageId":"20180425182106.162972-10-sbeller@google.com","threadId":"48355","inReplyTo":"20180425182106.162972-1-sbeller@google.com","subject":"[PATCHv3 9/9] cache.h: allow oid_object_info to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-25T18:21:06Z","receivedAt":"2018-04-25T18:21:42Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This involves also adapting oid_object_info_extended and a some\ninternal functions that are used to implement these. It all has to\nhappen in one patch, because of a single recursive chain of calls visits\nall these functions.\n\noid_object_info_extended is also used in partial clones, which allow\nfetching missing objects. As this series will not add the repository\nstruct to the transport code and fetch_object(), add a TODO note and\nomit fetching if a user tries to use a partial clone in a repository\nother than the_repository.\n\nAmong the functions modified to handle arbitrary repositories,\nunpack_entry() is one of them. Note that it still references the globals\n\"delta_base_cache\" and \"delta_base_cached\", but those are safe to be\nreferenced (the former is indexed partly by \"struct packed_git *\", which\nis repo-specific, and the latter is only used to limit the size of the\nformer as an optimization).\n\nHelped-by: Brandon Williams <bmwill@google.com>\nHelped-by: Jonathan Tan <jonathantanmy@google.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n cache.h     |  9 ++++-----\n packfile.c  | 58 ++++++++++++++++++++++++++---------------------------\n packfile.h  |  8 ++++----\n sha1_file.c | 31 ++++++++++++++++------------\n 4 files changed, 54 insertions(+), 52 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 6340b2c572..3a4d80e92b 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1192,8 +1192,7 @@ static inline void *read_object_file(const struct object_id *oid, enum object_ty\n }\n \n /* Read and unpack an object file into memory, write memory to an object file */\n-#define oid_object_info(r, o, f) oid_object_info_##r(o, f)\n-int oid_object_info_the_repository(const struct object_id *, unsigned long *);\n+int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);\n \n extern int hash_object_file(const void *buf, unsigned long len,\n \t\t\t    const char *type, struct object_id *oid);\n@@ -1675,9 +1674,9 @@ struct object_info {\n /* Do not check loose object */\n #define OBJECT_INFO_IGNORE_LOOSE 16\n \n-#define oid_object_info_extended(r, oid, oi, flags) \\\n-\toid_object_info_extended_##r(oid, oi, flags)\n-int oid_object_info_extended_the_repository(const struct object_id *, struct object_info *, unsigned flags);\n+int oid_object_info_extended(struct repository *r,\n+\t\t\t     const struct object_id *,\n+\t\t\t     struct object_info *, unsigned flags);\n \n /*\n  * Set this to 0 to prevent sha1_object_info_extended() from fetching missing\ndiff --git a/packfile.c b/packfile.c\nindex 8de87f904b..55d383ed0a 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1104,9 +1104,9 @@ static const unsigned char *get_delta_base_sha1(struct packed_git *p,\n \t\treturn NULL;\n }\n \n-#define retry_bad_packed_offset(r, p, o) \\\n-\tretry_bad_packed_offset_##r(p, o)\n-static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t obj_offset)\n+static int retry_bad_packed_offset(struct repository *r,\n+\t\t\t\t   struct packed_git *p,\n+\t\t\t\t   off_t obj_offset)\n {\n \tint type;\n \tstruct revindex_entry *revidx;\n@@ -1116,7 +1116,7 @@ static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t ob\n \t\treturn OBJ_BAD;\n \tnth_packed_object_oid(&oid, p, revidx->nr);\n \tmark_bad_packed_object(p, oid.hash);\n-\ttype = oid_object_info(the_repository, &oid, NULL);\n+\ttype = oid_object_info(r, &oid, NULL);\n \tif (type <= OBJ_NONE)\n \t\treturn OBJ_BAD;\n \treturn type;\n@@ -1124,13 +1124,12 @@ static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t ob\n \n #define POI_STACK_PREALLOC 64\n \n-#define packed_to_object_type(r, p, o, t, w, c) \\\n-\tpacked_to_object_type_##r(p, o, t, w, c)\n-static enum object_type packed_to_object_type_the_repository(struct packed_git *p,\n-\t\t\t\t\t\t\t     off_t obj_offset,\n-\t\t\t\t\t\t\t     enum object_type type,\n-\t\t\t\t\t\t\t     struct pack_window **w_curs,\n-\t\t\t\t\t\t\t     off_t curpos)\n+static enum object_type packed_to_object_type(struct repository *r,\n+\t\t\t\t\t      struct packed_git *p,\n+\t\t\t\t\t      off_t obj_offset,\n+\t\t\t\t\t      enum object_type type,\n+\t\t\t\t\t      struct pack_window **w_curs,\n+\t\t\t\t\t      off_t curpos)\n {\n \toff_t small_poi_stack[POI_STACK_PREALLOC];\n \toff_t *poi_stack = small_poi_stack;\n@@ -1157,7 +1156,7 @@ static enum object_type packed_to_object_type_the_repository(struct packed_git *\n \t\tif (type <= OBJ_NONE) {\n \t\t\t/* If getting the base itself fails, we first\n \t\t\t * retry the base, otherwise unwind */\n-\t\t\ttype = retry_bad_packed_offset(the_repository, p, base_offset);\n+\t\t\ttype = retry_bad_packed_offset(r, p, base_offset);\n \t\t\tif (type > OBJ_NONE)\n \t\t\t\tgoto out;\n \t\t\tgoto unwind;\n@@ -1185,7 +1184,7 @@ static enum object_type packed_to_object_type_the_repository(struct packed_git *\n unwind:\n \twhile (poi_stack_nr) {\n \t\tobj_offset = poi_stack[--poi_stack_nr];\n-\t\ttype = retry_bad_packed_offset(the_repository, p, obj_offset);\n+\t\ttype = retry_bad_packed_offset(r, p, obj_offset);\n \t\tif (type > OBJ_NONE)\n \t\t\tgoto out;\n \t}\n@@ -1272,15 +1271,15 @@ static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)\n \tfree(ent);\n }\n \n-#define cache_or_unpack_entry(r, p, bo, bs, t) cache_or_unpack_entry_##r(p, bo, bs, t)\n-static void *cache_or_unpack_entry_the_repository(struct packed_git *p, off_t base_offset,\n-\tunsigned long *base_size, enum object_type *type)\n+static void *cache_or_unpack_entry(struct repository *r, struct packed_git *p,\n+\t\t\t\t   off_t base_offset, unsigned long *base_size,\n+\t\t\t\t   enum object_type *type)\n {\n \tstruct delta_base_cache_entry *ent;\n \n \tent = get_delta_base_cache_entry(p, base_offset);\n \tif (!ent)\n-\t\treturn unpack_entry(the_repository, p, base_offset, type, base_size);\n+\t\treturn unpack_entry(r, p, base_offset, type, base_size);\n \n \tif (type)\n \t\t*type = ent->type;\n@@ -1334,8 +1333,8 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,\n \thashmap_add(&delta_base_cache, ent);\n }\n \n-int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,\n-\t\t\t\t      struct object_info *oi)\n+int packed_object_info(struct repository *r, struct packed_git *p,\n+\t\t       off_t obj_offset, struct object_info *oi)\n {\n \tstruct pack_window *w_curs = NULL;\n \tunsigned long size;\n@@ -1347,7 +1346,7 @@ int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,\n \t * a \"real\" type later if the caller is interested.\n \t */\n \tif (oi->contentp) {\n-\t\t*oi->contentp = cache_or_unpack_entry(the_repository, p, obj_offset, oi->sizep,\n+\t\t*oi->contentp = cache_or_unpack_entry(r, p, obj_offset, oi->sizep,\n \t\t\t\t\t\t      &type);\n \t\tif (!*oi->contentp)\n \t\t\ttype = OBJ_BAD;\n@@ -1381,7 +1380,7 @@ int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,\n \n \tif (oi->typep || oi->type_name) {\n \t\tenum object_type ptot;\n-\t\tptot = packed_to_object_type(the_repository, p, obj_offset,\n+\t\tptot = packed_to_object_type(r, p, obj_offset,\n \t\t\t\t\t     type, &w_curs, curpos);\n \t\tif (oi->typep)\n \t\t\t*oi->typep = ptot;\n@@ -1470,10 +1469,10 @@ struct unpack_entry_stack_ent {\n \tunsigned long size;\n };\n \n-#define read_object(r, o, t, s) read_object_##r(o, t, s)\n-static void *read_object_the_repository(const struct object_id *oid,\n-\t\t\t\t\tenum object_type *type,\n-\t\t\t\t\tunsigned long *size)\n+static void *read_object(struct repository *r,\n+\t\t\t const struct object_id *oid,\n+\t\t\t enum object_type *type,\n+\t\t\t unsigned long *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tvoid *content;\n@@ -1481,14 +1480,13 @@ static void *read_object_the_repository(const struct object_id *oid,\n \toi.sizep = size;\n \toi.contentp = &content;\n \n-\tif (oid_object_info_extended(the_repository, oid, &oi, 0) < 0)\n+\tif (oid_object_info_extended(r, oid, &oi, 0) < 0)\n \t\treturn NULL;\n \treturn content;\n }\n \n-void *unpack_entry_the_repository(struct packed_git *p, off_t obj_offset,\n-\t\t\t\t  enum object_type *final_type,\n-\t\t\t\t  unsigned long *final_size)\n+void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n+\t\t   enum object_type *final_type, unsigned long *final_size)\n {\n \tstruct pack_window *w_curs = NULL;\n \toff_t curpos = obj_offset;\n@@ -1618,7 +1616,7 @@ void *unpack_entry_the_repository(struct packed_git *p, off_t obj_offset,\n \t\t\t\t      oid_to_hex(&base_oid), (uintmax_t)obj_offset,\n \t\t\t\t      p->pack_name);\n \t\t\t\tmark_bad_packed_object(p, base_oid.hash);\n-\t\t\t\tbase = read_object(the_repository, &base_oid, &type, &base_size);\n+\t\t\t\tbase = read_object(r, &base_oid, &type, &base_size);\n \t\t\t\texternal_base = base;\n \t\t\t}\n \t\t}\ndiff --git a/packfile.h b/packfile.h\nindex 1efa57a90e..fdfddb89b5 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -115,8 +115,7 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);\n extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);\n \n extern int is_pack_valid(struct packed_git *);\n-#define unpack_entry(r, p, of, ot, s) unpack_entry_##r(p, of, ot, s)\n-extern void *unpack_entry_the_repository(struct packed_git *, off_t, enum object_type *, unsigned long *);\n+extern void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object_type *, unsigned long *);\n extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);\n extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);\n@@ -126,8 +125,9 @@ extern void release_pack_memory(size_t);\n /* global flag to enable extra checks when accessing packed objects */\n extern int do_check_packed_object_crc;\n \n-#define packed_object_info(r, p, o, oi) packed_object_info_##r(p, o, oi)\n-extern int packed_object_info_the_repository(struct packed_git *pack, off_t offset, struct object_info *);\n+extern int packed_object_info(struct repository *r,\n+\t\t\t      struct packed_git *pack,\n+\t\t\t      off_t offset, struct object_info *);\n \n extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1);\n extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 746ff8297a..dcd6b879ac 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1231,7 +1231,8 @@ static int sha1_loose_object_info(struct repository *r,\n \n int fetch_if_missing = 1;\n \n-int oid_object_info_extended_the_repository(const struct object_id *oid, struct object_info *oi, unsigned flags)\n+int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n+\t\t\t     struct object_info *oi, unsigned flags)\n {\n \tstatic struct object_info blank_oi = OBJECT_INFO_INIT;\n \tstruct pack_entry e;\n@@ -1240,7 +1241,7 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \tint already_retried = 0;\n \n \tif (flags & OBJECT_INFO_LOOKUP_REPLACE)\n-\t\treal = lookup_replace_object(the_repository, oid);\n+\t\treal = lookup_replace_object(r, oid);\n \n \tif (is_null_oid(real))\n \t\treturn -1;\n@@ -1269,29 +1270,31 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \t}\n \n \twhile (1) {\n-\t\tif (find_pack_entry(the_repository, real->hash, &e))\n+\t\tif (find_pack_entry(r, real->hash, &e))\n \t\t\tbreak;\n \n \t\tif (flags & OBJECT_INFO_IGNORE_LOOSE)\n \t\t\treturn -1;\n \n \t\t/* Most likely it's a loose object. */\n-\t\tif (!sha1_loose_object_info(the_repository, real->hash, oi, flags))\n+\t\tif (!sha1_loose_object_info(r, real->hash, oi, flags))\n \t\t\treturn 0;\n \n \t\t/* Not a loose object; someone else may have just packed it. */\n \t\tif (!(flags & OBJECT_INFO_QUICK)) {\n-\t\t\treprepare_packed_git(the_repository);\n-\t\t\tif (find_pack_entry(the_repository, real->hash, &e))\n+\t\t\treprepare_packed_git(r);\n+\t\t\tif (find_pack_entry(r, real->hash, &e))\n \t\t\t\tbreak;\n \t\t}\n \n \t\t/* Check if it is a missing object */\n \t\tif (fetch_if_missing && repository_format_partial_clone &&\n-\t\t    !already_retried) {\n+\t\t    !already_retried && r == the_repository) {\n \t\t\t/*\n-\t\t\t * TODO Investigate haveing fetch_object() return\n+\t\t\t * TODO Investigate having fetch_object() return\n \t\t\t * TODO error/success and stopping the music here.\n+\t\t\t * TODO Pass a repository struct through fetch_object,\n+\t\t\t * such that arbitrary repositories work.\n \t\t\t */\n \t\t\tfetch_object(repository_format_partial_clone, real->hash);\n \t\t\talready_retried = 1;\n@@ -1307,10 +1310,10 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \t\t * information below, so return early.\n \t\t */\n \t\treturn 0;\n-\trtype = packed_object_info(the_repository, e.p, e.offset, oi);\n+\trtype = packed_object_info(r, e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real->hash);\n-\t\treturn oid_object_info_extended(the_repository, real, oi, 0);\n+\t\treturn oid_object_info_extended(r, real, oi, 0);\n \t} else if (oi->whence == OI_PACKED) {\n \t\toi->u.packed.offset = e.offset;\n \t\toi->u.packed.pack = e.p;\n@@ -1322,15 +1325,17 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n }\n \n /* returns enum object_type or negative */\n-int oid_object_info_the_repository(const struct object_id *oid, unsigned long *sizep)\n+int oid_object_info(struct repository *r,\n+\t\t    const struct object_id *oid,\n+\t\t    unsigned long *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \n \toi.typep = &type;\n \toi.sizep = sizep;\n-\tif (oid_object_info_extended(the_repository, oid, &oi,\n-\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE) < 0)\n+\tif (oid_object_info_extended(r, oid, &oi,\n+\t\t\t\t      OBJECT_INFO_LOOKUP_REPLACE) < 0)\n \t\treturn -1;\n \treturn type;\n }\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345836","messageId":"20180425182106.162972-3-sbeller@google.com","threadId":"48355","inReplyTo":"20180425182106.162972-1-sbeller@google.com","subject":"[PATCHv3 2/9] cache.h: add repository argument to oid_object_info","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-25T18:20:59Z","receivedAt":"2018-04-25T18:21:43Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of oid_object_info\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 archive-tar.c            |  2 +-\n archive-zip.c            |  3 ++-\n blame.c                  |  4 ++--\n builtin/blame.c          |  2 +-\n builtin/cat-file.c       |  6 +++---\n builtin/describe.c       |  2 +-\n builtin/fast-export.c    |  2 +-\n builtin/fetch.c          |  2 +-\n builtin/fsck.c           |  3 ++-\n builtin/index-pack.c     |  4 ++--\n builtin/ls-tree.c        |  2 +-\n builtin/mktree.c         |  2 +-\n builtin/pack-objects.c   |  8 +++++---\n builtin/prune.c          |  3 ++-\n builtin/replace.c        | 11 ++++++-----\n builtin/tag.c            |  4 ++--\n builtin/unpack-objects.c |  2 +-\n cache.h                  |  3 ++-\n diff.c                   |  3 ++-\n fast-import.c            | 14 +++++++++-----\n list-objects-filter.c    |  2 +-\n object.c                 |  2 +-\n pack-bitmap-write.c      |  3 ++-\n packfile.c               |  2 +-\n reachable.c              |  2 +-\n refs.c                   |  2 +-\n remote.c                 |  2 +-\n sequencer.c              |  3 ++-\n sha1_file.c              |  4 ++--\n sha1_name.c              | 12 ++++++------\n submodule.c              |  2 +-\n tag.c                    |  2 +-\n 32 files changed, 67 insertions(+), 53 deletions(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 3563bcb9f2..f93409324f 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -276,7 +276,7 @@ static int write_tar_entry(struct archiver_args *args,\n \t\tmemcpy(header.name, path, pathlen);\n \n \tif (S_ISREG(mode) && !args->convert &&\n-\t    oid_object_info(oid, &size) == OBJ_BLOB &&\n+\t    oid_object_info(the_repository, oid, &size) == OBJ_BLOB &&\n \t    size > big_file_threshold)\n \t\tbuffer = NULL;\n \telse if (S_ISLNK(mode) || S_ISREG(mode)) {\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 6b20bce4d1..74f3fe9103 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -325,7 +325,8 @@ static int write_zip_entry(struct archiver_args *args,\n \t\tcompressed_size = 0;\n \t\tbuffer = NULL;\n \t} else if (S_ISREG(mode) || S_ISLNK(mode)) {\n-\t\tenum object_type type = oid_object_info(oid, &size);\n+\t\tenum object_type type = oid_object_info(the_repository, oid,\n+\t\t\t\t\t\t\t&size);\n \n \t\tmethod = 0;\n \t\tattr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :\ndiff --git a/blame.c b/blame.c\nindex 78c9808bd1..dfa24473dc 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -81,7 +81,7 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)\n \t\tunsigned mode;\n \n \t\tif (!get_tree_entry(commit_oid, path, &blob_oid, &mode) &&\n-\t\t    oid_object_info(&blob_oid, NULL) == OBJ_BLOB)\n+\t\t    oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB)\n \t\t\treturn;\n \t}\n \n@@ -504,7 +504,7 @@ static int fill_blob_sha1_and_mode(struct blame_origin *origin)\n \t\treturn 0;\n \tif (get_tree_entry(&origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))\n \t\tgoto error_out;\n-\tif (oid_object_info(&origin->blob_oid, NULL) != OBJ_BLOB)\n+\tif (oid_object_info(the_repository, &origin->blob_oid, NULL) != OBJ_BLOB)\n \t\tgoto error_out;\n \treturn 0;\n  error_out:\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex db38c0b307..bfdf7cc132 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -655,7 +655,7 @@ static int is_a_rev(const char *name)\n \n \tif (get_oid(name, &oid))\n \t\treturn 0;\n-\treturn OBJ_NONE < oid_object_info(&oid, NULL);\n+\treturn OBJ_NONE < oid_object_info(the_repository, &oid, NULL);\n }\n \n int cmd_blame(int argc, const char **argv, const char *prefix)\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 4ecdb9ff54..b8ecbea98e 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -116,7 +116,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t/* else fallthrough */\n \n \tcase 'p':\n-\t\ttype = oid_object_info(&oid, NULL);\n+\t\ttype = oid_object_info(the_repository, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Not a valid object name %s\", obj_name);\n \n@@ -140,7 +140,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tcase 0:\n \t\tif (type_from_string(exp_type) == OBJ_BLOB) {\n \t\t\tstruct object_id blob_oid;\n-\t\t\tif (oid_object_info(&oid, NULL) == OBJ_TAG) {\n+\t\t\tif (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {\n \t\t\t\tchar *buffer = read_object_file(&oid, &type,\n \t\t\t\t\t\t\t\t&size);\n \t\t\t\tconst char *target;\n@@ -151,7 +151,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\t\t} else\n \t\t\t\toidcpy(&blob_oid, &oid);\n \n-\t\t\tif (oid_object_info(&blob_oid, NULL) == OBJ_BLOB)\n+\t\t\tif (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB)\n \t\t\t\treturn stream_blob_to_fd(1, &blob_oid, NULL, 0);\n \t\t\t/*\n \t\t\t * we attempted to dereference a tag to a blob\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex de840f96a4..66c497f789 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -502,7 +502,7 @@ static void describe(const char *arg, int last_one)\n \n \tif (cmit)\n \t\tdescribe_commit(&oid, &sb);\n-\telse if (oid_object_info(&oid, NULL) == OBJ_BLOB)\n+\telse if (oid_object_info(the_repository, &oid, NULL) == OBJ_BLOB)\n \t\tdescribe_blob(oid, &sb);\n \telse\n \t\tdie(_(\"%s is neither a commit nor blob\"), arg);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex a15898d641..373c794873 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -947,7 +947,7 @@ static void import_marks(char *input_file)\n \t\tif (last_idnum < mark)\n \t\t\tlast_idnum = mark;\n \n-\t\ttype = oid_object_info(&oid, NULL);\n+\t\ttype = oid_object_info(the_repository, &oid, NULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(&oid));\n \ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex dcdfc66f09..73be393b2e 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -637,7 +637,7 @@ static int update_local_ref(struct ref *ref,\n \tstruct branch *current_branch = branch_get(NULL);\n \tconst char *pretty_ref = prettify_refname(ref->name);\n \n-\ttype = oid_object_info(&ref->new_oid, NULL);\n+\ttype = oid_object_info(the_repository, &ref->new_oid, NULL);\n \tif (type < 0)\n \t\tdie(_(\"object %s not found\"), oid_to_hex(&ref->new_oid));\n \ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 087360a675..9d59d7d5a2 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -67,7 +67,8 @@ static const char *printable_type(struct object *obj)\n \tconst char *ret;\n \n \tif (obj->type == OBJ_NONE) {\n-\t\tenum object_type type = oid_object_info(&obj->oid, NULL);\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}\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex d81473e722..2d04a596f5 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -223,7 +223,7 @@ static unsigned check_object(struct object *obj)\n \n \tif (!(obj->flags & FLAG_CHECKED)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(&obj->oid, &size);\n+\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n \t\t\t      oid_to_hex(&obj->oid));\n@@ -812,7 +812,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\tenum object_type has_type;\n \t\tunsigned long has_size;\n \t\tread_lock();\n-\t\thas_type = oid_object_info(oid, &has_size);\n+\t\thas_type = oid_object_info(the_repository, oid, &has_size);\n \t\tif (has_type < 0)\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex d44b4f9c27..409da4e835 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -94,7 +94,7 @@ static int show_tree(const struct object_id *oid, struct strbuf *base,\n \t\t\tchar size_text[24];\n \t\t\tif (!strcmp(type, blob_type)) {\n \t\t\t\tunsigned long size;\n-\t\t\t\tif (oid_object_info(oid, &size) == OBJ_BAD)\n+\t\t\t\tif (oid_object_info(the_repository, oid, &size) == OBJ_BAD)\n \t\t\t\t\txsnprintf(size_text, sizeof(size_text),\n \t\t\t\t\t\t  \"BAD\");\n \t\t\t\telse\ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex 263c530315..bb76b469fd 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -116,7 +116,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss\n \t}\n \n \t/* Check the type of object identified by sha1 */\n-\tobj_type = oid_object_info(&oid, NULL);\n+\tobj_type = oid_object_info(the_repository, &oid, NULL);\n \tif (obj_type < 0) {\n \t\tif (allow_missing) {\n \t\t\t; /* no problem - missing objects are presumed to be of the right type */\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 4bdae5a1d8..8d4111f748 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1516,7 +1516,8 @@ static void check_object(struct object_entry *entry)\n \t\tunuse_pack(&w_curs);\n \t}\n \n-\tentry->type = oid_object_info(&entry->idx.oid, &entry->size);\n+\tentry->type = oid_object_info(the_repository, &entry->idx.oid,\n+\t\t\t\t      &entry->size);\n \t/*\n \t * The error condition is checked in prepare_pack().  This is\n \t * to permit a missing preferred base object to be ignored\n@@ -1578,7 +1579,8 @@ static void drop_reused_delta(struct object_entry *entry)\n \t\t * And if that fails, the error will be recorded in entry->type\n \t\t * and dealt with in prepare_pack().\n \t\t */\n-\t\tentry->type = oid_object_info(&entry->idx.oid, &entry->size);\n+\t\tentry->type = oid_object_info(the_repository, &entry->idx.oid,\n+\t\t\t\t\t      &entry->size);\n \t}\n }\n \n@@ -2706,7 +2708,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)\n static int add_loose_object(const struct object_id *oid, const char *path,\n \t\t\t    void *data)\n {\n-\tenum object_type type = oid_object_info(oid, NULL);\n+\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n \n \tif (type < 0) {\n \t\twarning(\"loose object at %s could not be examined\", path);\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 38ced18dad..518ffbea13 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -50,7 +50,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath,\n \tif (st.st_mtime > expire)\n \t\treturn 0;\n \tif (show_only || verbose) {\n-\t\tenum object_type type = oid_object_info(oid, NULL);\n+\t\tenum object_type type = oid_object_info(the_repository, oid,\n+\t\t\t\t\t\t\tNULL);\n \t\tprintf(\"%s %s\\n\", oid_to_hex(oid),\n \t\t       (type > 0) ? type_name(type) : \"unknown\");\n \t}\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 237ea656cf..14e142d5a8 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -55,8 +55,9 @@ static int show_reference(const char *refname, const struct object_id *oid,\n \t\t\tif (get_oid(refname, &object))\n \t\t\t\treturn error(\"Failed to resolve '%s' as a valid ref.\", refname);\n \n-\t\t\tobj_type = oid_object_info(&object, NULL);\n-\t\t\trepl_type = oid_object_info(oid, NULL);\n+\t\t\tobj_type = oid_object_info(the_repository, &object,\n+\t\t\t\t\t\t   NULL);\n+\t\t\trepl_type = oid_object_info(the_repository, oid, NULL);\n \n \t\t\tprintf(\"%s (%s) -> %s (%s)\\n\", refname, type_name(obj_type),\n \t\t\t       oid_to_hex(oid), type_name(repl_type));\n@@ -164,8 +165,8 @@ static int replace_object_oid(const char *object_ref,\n \tstruct ref_transaction *transaction;\n \tstruct strbuf err = STRBUF_INIT;\n \n-\tobj_type = oid_object_info(object, NULL);\n-\trepl_type = oid_object_info(repl, NULL);\n+\tobj_type = oid_object_info(the_repository, object, NULL);\n+\trepl_type = oid_object_info(the_repository, repl, NULL);\n \tif (!force && obj_type != repl_type)\n \t\tdie(\"Objects must be of the same type.\\n\"\n \t\t    \"'%s' points to a replaced object of type '%s'\\n\"\n@@ -292,7 +293,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)\n \tif (get_oid(object_ref, &old_oid) < 0)\n \t\tdie(\"Not a valid object name: '%s'\", object_ref);\n \n-\ttype = oid_object_info(&old_oid, NULL);\n+\ttype = oid_object_info(the_repository, &old_oid, NULL);\n \tif (type < 0)\n \t\tdie(\"unable to get object type for %s\", oid_to_hex(&old_oid));\n \ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 8cff6d0b72..26d7729f57 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -212,7 +212,7 @@ static void create_tag(const struct object_id *object, const char *tag,\n \tstruct strbuf header = STRBUF_INIT;\n \tchar *path = NULL;\n \n-\ttype = oid_object_info(object, NULL);\n+\ttype = oid_object_info(the_repository, object, NULL);\n \tif (type <= OBJ_NONE)\n \t    die(_(\"bad object type.\"));\n \n@@ -298,7 +298,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t}\n \n \tstrbuf_addstr(sb, \" (\");\n-\ttype = oid_object_info(oid, NULL);\n+\ttype = oid_object_info(the_repository, oid, NULL);\n \tswitch (type) {\n \tdefault:\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex b7755c6cc5..cfe9019f80 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -199,7 +199,7 @@ static int check_object(struct object *obj, int type, void *data, struct fsck_op\n \n \tif (!(obj->flags & FLAG_OPEN)) {\n \t\tunsigned long size;\n-\t\tint type = oid_object_info(&obj->oid, &size);\n+\t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n \t\tobj->flags |= FLAG_WRITTEN;\ndiff --git a/cache.h b/cache.h\nindex 588c4fff9a..6340b2c572 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1192,7 +1192,8 @@ static inline void *read_object_file(const struct object_id *oid, enum object_ty\n }\n \n /* Read and unpack an object file into memory, write memory to an object file */\n-extern int oid_object_info(const struct object_id *, unsigned long *);\n+#define oid_object_info(r, o, f) oid_object_info_##r(o, f)\n+int oid_object_info_the_repository(const struct object_id *, unsigned long *);\n \n extern int hash_object_file(const void *buf, unsigned long len,\n \t\t\t    const char *type, struct object_id *oid);\ndiff --git a/diff.c b/diff.c\nindex 1289df4b1f..4753170fe1 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3638,7 +3638,8 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)\n \telse {\n \t\tenum object_type type;\n \t\tif (size_only || (flags & CHECK_BINARY)) {\n-\t\t\ttype = oid_object_info(&s->oid, &s->size);\n+\t\t\ttype = oid_object_info(the_repository, &s->oid,\n+\t\t\t\t\t       &s->size);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"unable to read %s\",\n \t\t\t\t    oid_to_hex(&s->oid));\ndiff --git a/fast-import.c b/fast-import.c\nindex 99f8f56e8c..afe06bd7c1 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1917,7 +1917,8 @@ static void read_marks(void)\n \t\t\tdie(\"corrupt mark line: %s\", line);\n \t\te = find_object(&oid);\n \t\tif (!e) {\n-\t\t\tenum object_type type = oid_object_info(&oid, NULL);\n+\t\t\tenum object_type type = oid_object_info(the_repository,\n+\t\t\t\t\t\t\t\t&oid, NULL);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"object not found: %s\", oid_to_hex(&oid));\n \t\t\te = insert_object(&oid);\n@@ -2447,7 +2448,8 @@ static void file_change_m(const char *p, struct branch *b)\n \t\tenum object_type expected = S_ISDIR(mode) ?\n \t\t\t\t\t\tOBJ_TREE: OBJ_BLOB;\n \t\tenum object_type type = oe ? oe->type :\n-\t\t\t\t\toid_object_info(&oid, NULL);\n+\t\t\t\t\toid_object_info(the_repository, &oid,\n+\t\t\t\t\t\t\tNULL);\n \t\tif (type < 0)\n \t\t\tdie(\"%s not found: %s\",\n \t\t\t\t\tS_ISDIR(mode) ?  \"Tree\" : \"Blob\",\n@@ -2608,7 +2610,8 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tdie(\"Not a blob (actually a %s): %s\",\n \t\t\t\ttype_name(oe->type), command_buf.buf);\n \t} else if (!is_null_oid(&oid)) {\n-\t\tenum object_type type = oid_object_info(&oid, NULL);\n+\t\tenum object_type type = oid_object_info(the_repository, &oid,\n+\t\t\t\t\t\t\tNULL);\n \t\tif (type < 0)\n \t\t\tdie(\"Blob not found: %s\", command_buf.buf);\n \t\tif (type != OBJ_BLOB)\n@@ -2895,7 +2898,7 @@ static void parse_new_tag(const char *arg)\n \t} else if (!get_oid(from, &oid)) {\n \t\tstruct object_entry *oe = find_object(&oid);\n \t\tif (!oe) {\n-\t\t\ttype = oid_object_info(&oid, NULL);\n+\t\t\ttype = oid_object_info(the_repository, &oid, NULL);\n \t\t\tif (type < 0)\n \t\t\t\tdie(\"Not a valid object: %s\", from);\n \t\t} else\n@@ -3053,7 +3056,8 @@ static struct object_entry *dereference(struct object_entry *oe,\n \tunsigned long size;\n \tchar *buf = NULL;\n \tif (!oe) {\n-\t\tenum object_type type = oid_object_info(oid, NULL);\n+\t\tenum object_type type = oid_object_info(the_repository, oid,\n+\t\t\t\t\t\t\tNULL);\n \t\tif (type < 0)\n \t\t\tdie(\"object not found: %s\", oid_to_hex(oid));\n \t\t/* cache it! */\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex 0ec83aaf18..ea94fe8af2 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -117,7 +117,7 @@ static enum list_objects_filter_result filter_blobs_limit(\n \t\tassert(obj->type == OBJ_BLOB);\n \t\tassert((obj->flags & SEEN) == 0);\n \n-\t\tt = oid_object_info(&obj->oid, &object_length);\n+\t\tt = oid_object_info(the_repository, &obj->oid, &object_length);\n \t\tif (t != OBJ_BLOB) { /* probably OBJ_NONE */\n \t\t\t/*\n \t\t\t * We DO NOT have the blob locally, so we cannot\ndiff --git a/object.c b/object.c\nindex 66cffaf6e5..5044d08e96 100644\n--- a/object.c\n+++ b/object.c\n@@ -257,7 +257,7 @@ struct object *parse_object(const struct object_id *oid)\n \n \tif ((obj && obj->type == OBJ_BLOB && has_object_file(oid)) ||\n \t    (!obj && has_object_file(oid) &&\n-\t     oid_object_info(oid, NULL) == OBJ_BLOB)) {\n+\t     oid_object_info(the_repository, 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;\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 41ae27fb19..cd1903e717 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -73,7 +73,8 @@ void bitmap_writer_build_type_index(struct pack_idx_entry **index,\n \t\t\tbreak;\n \n \t\tdefault:\n-\t\t\treal_type = oid_object_info(&entry->idx.oid, NULL);\n+\t\t\treal_type = oid_object_info(the_repository,\n+\t\t\t\t\t\t    &entry->idx.oid, NULL);\n \t\t\tbreak;\n \t\t}\n \ndiff --git a/packfile.c b/packfile.c\nindex d9914ba723..80c7fa734f 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1114,7 +1114,7 @@ static int retry_bad_packed_offset(struct packed_git *p, off_t obj_offset)\n \t\treturn OBJ_BAD;\n \tnth_packed_object_oid(&oid, p, revidx->nr);\n \tmark_bad_packed_object(p, oid.hash);\n-\ttype = oid_object_info(&oid, NULL);\n+\ttype = oid_object_info(the_repository, &oid, NULL);\n \tif (type <= OBJ_NONE)\n \t\treturn OBJ_BAD;\n \treturn type;\ndiff --git a/reachable.c b/reachable.c\nindex a6ea33a5db..ffb976c33c 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -78,7 +78,7 @@ static void add_recent_object(const struct object_id *oid,\n \t * later processing, and the revision machinery expects\n \t * commits and tags to have been parsed.\n \t */\n-\ttype = oid_object_info(oid, NULL);\n+\ttype = oid_object_info(the_repository, oid, NULL);\n \tif (type < 0)\n \t\tdie(\"unable to get object info for %s\", oid_to_hex(oid));\n \ndiff --git a/refs.c b/refs.c\nindex 9b56fa9b81..27c88ba768 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -302,7 +302,7 @@ enum peel_status peel_object(const struct object_id *name, struct object_id *oid\n \tstruct object *o = lookup_unknown_object(name->hash);\n \n \tif (o->type == OBJ_NONE) {\n-\t\tint type = oid_object_info(name, NULL);\n+\t\tint type = oid_object_info(the_repository, name, NULL);\n \t\tif (type < 0 || !object_as_type(o, type, 0))\n \t\t\treturn PEEL_INVALID;\n \t}\ndiff --git a/remote.c b/remote.c\nindex 91eb010ca9..481bf933f3 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1376,7 +1376,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds\n \t\t\tcontinue; /* not a tag */\n \t\tif (string_list_has_string(&dst_tag, ref->name))\n \t\t\tcontinue; /* they already have it */\n-\t\tif (oid_object_info(&ref->new_oid, NULL) != OBJ_TAG)\n+\t\tif (oid_object_info(the_repository, &ref->new_oid, NULL) != OBJ_TAG)\n \t\t\tcontinue; /* be conservative */\n \t\titem = string_list_append(&src_tag, ref->name);\n \t\titem->util = ref;\ndiff --git a/sequencer.c b/sequencer.c\nindex 667f35ebdf..44f0518b9c 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2876,7 +2876,8 @@ int sequencer_pick_revisions(struct replay_opts *opts)\n \n \t\tif (!get_oid(name, &oid)) {\n \t\t\tif (!lookup_commit_reference_gently(&oid, 1)) {\n-\t\t\t\tenum object_type type = oid_object_info(&oid,\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);\n \t\t\t\treturn error(_(\"%s: can't cherry-pick a %s\"),\n \t\t\t\t\tname, type_name(type));\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 50a2dc5f0a..93f25c6c6a 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1322,7 +1322,7 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n }\n \n /* returns enum object_type or negative */\n-int oid_object_info(const struct object_id *oid, unsigned long *sizep)\n+int oid_object_info_the_repository(const struct object_id *oid, unsigned long *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n@@ -1988,7 +1988,7 @@ int read_pack_header(int fd, struct pack_header *header)\n \n void assert_oid_type(const struct object_id *oid, enum object_type expect)\n {\n-\tenum object_type type = oid_object_info(oid, NULL);\n+\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n \tif (type < 0)\n \t\tdie(\"%s is not a valid object\", oid_to_hex(oid));\n \tif (type != expect)\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 5b93bf8da3..b5406b6eb2 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -223,7 +223,7 @@ static int finish_object_disambiguation(struct disambiguate_state *ds,\n \n static int disambiguate_commit_only(const struct object_id *oid, void *cb_data_unused)\n {\n-\tint kind = oid_object_info(oid, NULL);\n+\tint kind = oid_object_info(the_repository, oid, NULL);\n \treturn kind == OBJ_COMMIT;\n }\n \n@@ -232,7 +232,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(oid, NULL);\n+\tkind = oid_object_info(the_repository, oid, NULL);\n \tif (kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -247,7 +247,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da\n \n static int disambiguate_tree_only(const struct object_id *oid, void *cb_data_unused)\n {\n-\tint kind = oid_object_info(oid, NULL);\n+\tint kind = oid_object_info(the_repository, oid, NULL);\n \treturn kind == OBJ_TREE;\n }\n \n@@ -256,7 +256,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_\n \tstruct object *obj;\n \tint kind;\n \n-\tkind = oid_object_info(oid, NULL);\n+\tkind = oid_object_info(the_repository, oid, NULL);\n \tif (kind == OBJ_TREE || kind == OBJ_COMMIT)\n \t\treturn 1;\n \tif (kind != OBJ_TAG)\n@@ -271,7 +271,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_\n \n static int disambiguate_blob_only(const struct object_id *oid, void *cb_data_unused)\n {\n-\tint kind = oid_object_info(oid, NULL);\n+\tint kind = oid_object_info(the_repository, oid, NULL);\n \treturn kind == OBJ_BLOB;\n }\n \n@@ -350,7 +350,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \tif (ds->fn && !ds->fn(oid, ds->cb_data))\n \t\treturn 0;\n \n-\ttype = oid_object_info(oid, NULL);\n+\ttype = oid_object_info(the_repository, oid, NULL);\n \tif (type == OBJ_COMMIT) {\n \t\tstruct commit *commit = lookup_commit(oid);\n \t\tif (commit) {\ndiff --git a/submodule.c b/submodule.c\nindex 9a50168b23..bb133e9b93 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -818,7 +818,7 @@ static int check_has_commit(const struct object_id *oid, void *data)\n {\n \tstruct has_commit_data *cb = data;\n \n-\tenum object_type type = oid_object_info(oid, NULL);\n+\tenum object_type type = oid_object_info(the_repository, oid, NULL);\n \n \tswitch (type) {\n \tcase OBJ_COMMIT:\ndiff --git a/tag.c b/tag.c\nindex 86b1dcbb82..3d37c1bd25 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -41,7 +41,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \tunsigned long size;\n \tint ret;\n \n-\ttype = oid_object_info(oid, NULL);\n+\ttype = oid_object_info(the_repository, oid, NULL);\n \tif (type != OBJ_TAG)\n \t\treturn error(\"%s: cannot verify a non-tag object of type %s.\",\n \t\t\t\tname_to_report ?\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345838","messageId":"20180425182106.162972-6-sbeller@google.com","threadId":"48355","inReplyTo":"20180425182106.162972-1-sbeller@google.com","subject":"[PATCHv3 5/9] packfile: add repository argument to packed_object_info","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-25T18:21:02Z","receivedAt":"2018-04-25T18:23:01Z","isPatch":false,"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 packed_object_info to be\nmore 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: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/pack-objects.c | 3 ++-\n packfile.c             | 4 ++--\n packfile.h             | 3 ++-\n sha1_file.c            | 2 +-\n 4 files changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 8d4111f748..d65eb4a947 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1572,7 +1572,8 @@ static void drop_reused_delta(struct object_entry *entry)\n \n \toi.sizep = &entry->size;\n \toi.typep = &entry->type;\n-\tif (packed_object_info(entry->in_pack, entry->in_pack_offset, &oi) < 0) {\n+\tif (packed_object_info(the_repository, entry->in_pack,\n+\t\t\t       entry->in_pack_offset, &oi) < 0) {\n \t\t/*\n \t\t * We failed to get the info from this pack for some reason;\n \t\t * fall back to sha1_object_info, which may find another copy.\ndiff --git a/packfile.c b/packfile.c\nindex 3ecfba66af..5fa7d27d3b 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1333,8 +1333,8 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,\n \thashmap_add(&delta_base_cache, ent);\n }\n \n-int packed_object_info(struct packed_git *p, off_t obj_offset,\n-\t\t       struct object_info *oi)\n+int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,\n+\t\t\t\t      struct object_info *oi)\n {\n \tstruct pack_window *w_curs = NULL;\n \tunsigned long size;\ndiff --git a/packfile.h b/packfile.h\nindex a92c0b241c..bc8d840b1b 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -125,7 +125,8 @@ extern void release_pack_memory(size_t);\n /* global flag to enable extra checks when accessing packed objects */\n extern int do_check_packed_object_crc;\n \n-extern int packed_object_info(struct packed_git *pack, off_t offset, struct object_info *);\n+#define packed_object_info(r, p, o, oi) packed_object_info_##r(p, o, oi)\n+extern int packed_object_info_the_repository(struct packed_git *pack, off_t offset, struct object_info *);\n \n extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1);\n extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 93f25c6c6a..746ff8297a 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1307,7 +1307,7 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \t\t * information below, so return early.\n \t\t */\n \t\treturn 0;\n-\trtype = packed_object_info(e.p, e.offset, oi);\n+\trtype = packed_object_info(the_repository, e.p, e.offset, oi);\n \tif (rtype < 0) {\n \t\tmark_bad_packed_object(e.p, real->hash);\n \t\treturn oid_object_info_extended(the_repository, real, oi, 0);\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345839","messageId":"20180425182106.162972-5-sbeller@google.com","threadId":"48355","inReplyTo":"20180425182106.162972-1-sbeller@google.com","subject":"[PATCHv3 4/9] packfile: add repository argument to packed_to_object_type","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-25T18:21:01Z","receivedAt":"2018-04-25T18:23:06Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of packed_to_object_type\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: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n packfile.c | 16 +++++++++-------\n 1 file changed, 9 insertions(+), 7 deletions(-)\n\ndiff --git a/packfile.c b/packfile.c\nindex d2b3f3503b..3ecfba66af 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1124,11 +1124,13 @@ static int retry_bad_packed_offset_the_repository(struct packed_git *p, off_t ob\n \n #define POI_STACK_PREALLOC 64\n \n-static enum object_type packed_to_object_type(struct packed_git *p,\n-\t\t\t\t\t      off_t obj_offset,\n-\t\t\t\t\t      enum object_type type,\n-\t\t\t\t\t      struct pack_window **w_curs,\n-\t\t\t\t\t      off_t curpos)\n+#define packed_to_object_type(r, p, o, t, w, c) \\\n+\tpacked_to_object_type_##r(p, o, t, w, c)\n+static enum object_type packed_to_object_type_the_repository(struct packed_git *p,\n+\t\t\t\t\t\t\t     off_t obj_offset,\n+\t\t\t\t\t\t\t     enum object_type type,\n+\t\t\t\t\t\t\t     struct pack_window **w_curs,\n+\t\t\t\t\t\t\t     off_t curpos)\n {\n \toff_t small_poi_stack[POI_STACK_PREALLOC];\n \toff_t *poi_stack = small_poi_stack;\n@@ -1378,8 +1380,8 @@ int packed_object_info(struct packed_git *p, off_t obj_offset,\n \n \tif (oi->typep || oi->type_name) {\n \t\tenum object_type ptot;\n-\t\tptot = packed_to_object_type(p, obj_offset, type, &w_curs,\n-\t\t\t\t\t     curpos);\n+\t\tptot = packed_to_object_type(the_repository, p, obj_offset,\n+\t\t\t\t\t     type, &w_curs, curpos);\n \t\tif (oi->typep)\n \t\t\t*oi->typep = ptot;\n \t\tif (oi->type_name) {\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345840","messageId":"20180425182106.162972-9-sbeller@google.com","threadId":"48355","inReplyTo":"20180425182106.162972-1-sbeller@google.com","subject":"[PATCHv3 8/9] packfile: add repository argument to cache_or_unpack_entry","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-25T18:21:05Z","receivedAt":"2018-04-25T18:24:20Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of cache_or_unpack_entry\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 packfile.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/packfile.c b/packfile.c\nindex d5ac48ef18..8de87f904b 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1272,7 +1272,8 @@ static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)\n \tfree(ent);\n }\n \n-static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,\n+#define cache_or_unpack_entry(r, p, bo, bs, t) cache_or_unpack_entry_##r(p, bo, bs, t)\n+static void *cache_or_unpack_entry_the_repository(struct packed_git *p, off_t base_offset,\n \tunsigned long *base_size, enum object_type *type)\n {\n \tstruct delta_base_cache_entry *ent;\n@@ -1346,7 +1347,7 @@ int packed_object_info_the_repository(struct packed_git *p, off_t obj_offset,\n \t * a \"real\" type later if the caller is interested.\n \t */\n \tif (oi->contentp) {\n-\t\t*oi->contentp = cache_or_unpack_entry(p, obj_offset, oi->sizep,\n+\t\t*oi->contentp = cache_or_unpack_entry(the_repository, p, obj_offset, oi->sizep,\n \t\t\t\t\t\t      &type);\n \t\tif (!*oi->contentp)\n \t\t\ttype = OBJ_BAD;\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345841","messageId":"20180425182106.162972-8-sbeller@google.com","threadId":"48355","inReplyTo":"20180425182106.162972-1-sbeller@google.com","subject":"[PATCHv3 7/9] packfile: add repository argument to unpack_entry","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-25T18:21:04Z","receivedAt":"2018-04-25T18:24:23Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of unpack_entry\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 fast-import.c | 2 +-\n pack-check.c  | 3 ++-\n packfile.c    | 7 ++++---\n packfile.h    | 3 ++-\n 4 files changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex afe06bd7c1..b009353e93 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1376,7 +1376,7 @@ static void *gfi_unpack_entry(\n \t\t */\n \t\tp->pack_size = pack_size + the_hash_algo->rawsz;\n \t}\n-\treturn unpack_entry(p, oe->idx.offset, &type, sizep);\n+\treturn unpack_entry(the_repository, p, oe->idx.offset, &type, sizep);\n }\n \n static const char *get_mode(const char *str, uint16_t *modep)\ndiff --git a/pack-check.c b/pack-check.c\nindex 385d964bdd..d3a57df34f 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"repository.h\"\n #include \"pack.h\"\n #include \"pack-revindex.h\"\n #include \"progress.h\"\n@@ -134,7 +135,7 @@ static int verify_packfile(struct packed_git *p,\n \t\t\tdata = NULL;\n \t\t\tdata_valid = 0;\n \t\t} else {\n-\t\t\tdata = unpack_entry(p, entries[i].offset, &type, &size);\n+\t\t\tdata = unpack_entry(the_repository, p, entries[i].offset, &type, &size);\n \t\t\tdata_valid = 1;\n \t\t}\n \ndiff --git a/packfile.c b/packfile.c\nindex 2876e04bb1..d5ac48ef18 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1279,7 +1279,7 @@ static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,\n \n \tent = get_delta_base_cache_entry(p, base_offset);\n \tif (!ent)\n-\t\treturn unpack_entry(p, base_offset, type, base_size);\n+\t\treturn unpack_entry(the_repository, p, base_offset, type, base_size);\n \n \tif (type)\n \t\t*type = ent->type;\n@@ -1485,8 +1485,9 @@ static void *read_object_the_repository(const struct object_id *oid,\n \treturn content;\n }\n \n-void *unpack_entry(struct packed_git *p, off_t obj_offset,\n-\t\t   enum object_type *final_type, unsigned long *final_size)\n+void *unpack_entry_the_repository(struct packed_git *p, off_t obj_offset,\n+\t\t\t\t  enum object_type *final_type,\n+\t\t\t\t  unsigned long *final_size)\n {\n \tstruct pack_window *w_curs = NULL;\n \toff_t curpos = obj_offset;\ndiff --git a/packfile.h b/packfile.h\nindex bc8d840b1b..1efa57a90e 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -115,7 +115,8 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);\n extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);\n \n extern int is_pack_valid(struct packed_git *);\n-extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);\n+#define unpack_entry(r, p, of, ot, s) unpack_entry_##r(p, of, ot, s)\n+extern void *unpack_entry_the_repository(struct packed_git *, off_t, enum object_type *, unsigned long *);\n extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);\n extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);\n-- \n2.17.0.441.gb46fe60e1d-goog\n\n"},{"id":"345847","messageId":"20180425133704.1a8914061b2712d986f1cbcb@google.com","threadId":"48355","inReplyTo":"20180425182106.162972-1-sbeller@google.com","subject":"Re: [PATCHv3 0/9] object store: oid_object_info is the next contender","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-04-25T20:37:04Z","receivedAt":"2018-04-25T20:37:11Z","isPatch":false,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"On Wed, 25 Apr 2018 11:20:57 -0700\nStefan Beller <sbeller@google.com> wrote:\n\n> v3:\n> * fixed and extended the commit message of last commit\n> * fixed the last patch, as Jonathan Tan suggested, see interdiff:\n\nThanks, all my comments have been addressed.\n\nReviewed-by: Jonathan Tan <jonathantanmy@google.com>\n"},{"id":"345900","messageId":"20180426163027.GA101170@google.com","threadId":"48355","inReplyTo":"20180425182106.162972-1-sbeller@google.com","subject":"Re: [PATCHv3 0/9] object store: oid_object_info is the next contender","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2018-04-26T16:30:27Z","receivedAt":"2018-04-26T16:30:33Z","isPatch":false,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 04/25, Stefan Beller wrote:\n> v3:\n> * fixed and extended the commit message of last commit\n> * fixed the last patch, as Jonathan Tan suggested, see interdiff:\n> \n>     $ git diff remotes/origin/sb/oid-object-info (which is v2)\n>     diff --git c/sha1_file.c w/sha1_file.c\n>     index 94123e0299..dcd6b879ac 100644\n>     --- c/sha1_file.c\n>     +++ w/sha1_file.c\n>     @@ -1289,14 +1289,13 @@ int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n>      \n>                     /* Check if it is a missing object */\n>                     if (fetch_if_missing && repository_format_partial_clone &&\n>     -                   !already_retried) {\n>     +                   !already_retried && r == the_repository) {\n>                             /*\n>                              * TODO Investigate having fetch_object() return\n>                              * TODO error/success and stopping the music here.\n>     -                        * TODO Pass a repository struct through fetch_object.\n>     +                        * TODO Pass a repository struct through fetch_object,\n>     +                        * such that arbitrary repositories work.\n>                              */\n>     -                       if (r != the_repository)\n>     -                               die(_(\"partial clones only supported in the_repository\"));\n>                             fetch_object(repository_format_partial_clone, real->hash);\n>                             already_retried = 1;\n>                             continue;\n>     \n> Thanks,\n> Stefan\n\nv3 looks good, thanks for taking care of this.\n\n> \n> v2:\n> \n> * fixed the sha1/oid typo\n> * removed spurious new line\n> * Brandon and Jonthan discovered another dependency that I missed due\n>   to cherrypicking that commit from a tree before partial clone was a thing.\n>   We error out when attempting to use fetch_object for repos that are not\n>   the_repository.\n> \n> Thanks,\n> Stefan\n> \n> v1:\n> This applies on top of origin/sb/object-store-replace and is available as\n> https://github.com/stefanbeller/git/tree/oid_object_info\n> \n> This continues the work of sb/packfiles-in-repository,\n> extending the layer at which we have to pass in an explicit\n> repository object to oid_object_info.\n> \n> A test merge to next shows only a minor merge conflicit (adding\n> different #include lines in one c file), so this might be a good next\n> step for the object store series.\n> \n> Notes on further object store series:\n> I plan on converting the \"parsed object store\" next,\n> which would be {alloc, object, tree, commit, tag}.c as that is a prerequisite\n> for migrating shallow (which is intermingled with grafts) information to the\n> object store.\n> \n> There is currently work going on in allocation (mempool - Jameson Miller)\n> and grafts (deprecate grafts - DScho), which is why I am sending this\n> series first. I think it can go in parallel to the \"parsed object store\"\n> that is coming next.\n> \n> Thanks,\n> Stefan\n> \n> Jonathan Nieder (1):\n>   packfile: add repository argument to packed_object_info\n> \n> Stefan Beller (8):\n>   cache.h: add repository argument to oid_object_info_extended\n>   cache.h: add repository argument to oid_object_info\n>   packfile: add repository argument to retry_bad_packed_offset\n>   packfile: add repository argument to packed_to_object_type\n>   packfile: add repository argument to read_object\n>   packfile: add repository argument to unpack_entry\n>   packfile: add repository argument to cache_or_unpack_entry\n>   cache.h: allow oid_object_info to handle arbitrary repositories\n> \n>  archive-tar.c            |  2 +-\n>  archive-zip.c            |  3 ++-\n>  blame.c                  |  4 ++--\n>  builtin/blame.c          |  2 +-\n>  builtin/cat-file.c       | 12 ++++++------\n>  builtin/describe.c       |  2 +-\n>  builtin/fast-export.c    |  2 +-\n>  builtin/fetch.c          |  2 +-\n>  builtin/fsck.c           |  3 ++-\n>  builtin/index-pack.c     |  4 ++--\n>  builtin/ls-tree.c        |  2 +-\n>  builtin/mktree.c         |  2 +-\n>  builtin/pack-objects.c   | 11 +++++++----\n>  builtin/prune.c          |  3 ++-\n>  builtin/replace.c        | 11 ++++++-----\n>  builtin/tag.c            |  4 ++--\n>  builtin/unpack-objects.c |  2 +-\n>  cache.h                  |  7 +++++--\n>  diff.c                   |  3 ++-\n>  fast-import.c            | 16 ++++++++++------\n>  list-objects-filter.c    |  2 +-\n>  object.c                 |  2 +-\n>  pack-bitmap-write.c      |  3 ++-\n>  pack-check.c             |  3 ++-\n>  packfile.c               | 40 +++++++++++++++++++++++-----------------\n>  packfile.h               |  6 ++++--\n>  reachable.c              |  2 +-\n>  refs.c                   |  2 +-\n>  remote.c                 |  2 +-\n>  sequencer.c              |  3 ++-\n>  sha1_file.c              | 37 +++++++++++++++++++++----------------\n>  sha1_name.c              | 12 ++++++------\n>  streaming.c              |  2 +-\n>  submodule.c              |  2 +-\n>  tag.c                    |  2 +-\n>  35 files changed, 124 insertions(+), 93 deletions(-)\n> \n> -- \n> 2.17.0.441.gb46fe60e1d-goog\n> \n\n-- \nBrandon Williams\n"}]}