{"thread":{"id":"48350","subject":"[PATCH 0/9] object store: oid_object_info is the next contender","startedAt":"2018-04-23T23:43:34Z","lastAt":"2018-04-25T00:23:08Z","messageCount":19,"participants":["Stefan Beller","brian m. carlson","Jonathan Tan","Brandon Williams","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":9},"messages":[{"id":"345568","messageId":"20180423234327.250484-1-sbeller@google.com","threadId":"48350","inReplyTo":null,"subject":"[PATCH 0/9] object store: oid_object_info is the next contender","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-23T23:43:18Z","receivedAt":"2018-04-23T23:43:34Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This 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 sha1_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              | 32 ++++++++++++++++++--------------\n sha1_name.c              | 12 ++++++------\n streaming.c              |  2 +-\n submodule.c              |  2 +-\n tag.c                    |  2 +-\n 35 files changed, 121 insertions(+), 91 deletions(-)\n\n-- \n2.17.0.484.g0c8726318c-goog\n\n"},{"id":"345569","messageId":"20180423234327.250484-2-sbeller@google.com","threadId":"48350","inReplyTo":"20180423234327.250484-1-sbeller@google.com","subject":"[PATCH 1/9] cache.h: add repository argument to oid_object_info_extended","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-23T23:43:19Z","receivedAt":"2018-04-23T23:43:38Z","isPatch":true,"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.484.g0c8726318c-goog\n\n"},{"id":"345570","messageId":"20180423234327.250484-3-sbeller@google.com","threadId":"48350","inReplyTo":"20180423234327.250484-1-sbeller@google.com","subject":"[PATCH 2/9] cache.h: add repository argument to oid_object_info","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-23T23:43:20Z","receivedAt":"2018-04-23T23:43:41Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of 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\nIn the expanded macro the identifier `the_repository` is not actually used,\nso the compiler does not catch if the repository.h header is not included\nat the call site. call sites needing that #include were identified by\nchanging the macro to definition to\n\n      #define sha1_object_info(r, sha1, size) \\\n          (r, sha1_object_info_##r(sha1, size)).\n\nThis produces a compiler warning about the left hand side of the comma\noperator being unused, which can be suppressed using -Wno-unused-value.\n\nTo avoid breaking bisection, do not include this trick in the patch.\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.484.g0c8726318c-goog\n\n"},{"id":"345571","messageId":"20180423234327.250484-4-sbeller@google.com","threadId":"48350","inReplyTo":"20180423234327.250484-1-sbeller@google.com","subject":"[PATCH 3/9] packfile: add repository argument to retry_bad_packed_offset","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-23T23:43:21Z","receivedAt":"2018-04-23T23:43:45Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of 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.484.g0c8726318c-goog\n\n"},{"id":"345572","messageId":"20180423234327.250484-7-sbeller@google.com","threadId":"48350","inReplyTo":"20180423234327.250484-1-sbeller@google.com","subject":"[PATCH 6/9] packfile: add repository argument to read_object","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-23T23:43:24Z","receivedAt":"2018-04-23T23:43:48Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of 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.484.g0c8726318c-goog\n\n"},{"id":"345573","messageId":"20180423234327.250484-6-sbeller@google.com","threadId":"48350","inReplyTo":"20180423234327.250484-1-sbeller@google.com","subject":"[PATCH 5/9] packfile: add repository argument to packed_object_info","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-23T23:43:23Z","receivedAt":"2018-04-23T23:43:51Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nAdd a repository argument to allow callers of 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            | 3 ++-\n 4 files changed, 8 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..b292e04fd3 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1307,7 +1307,8 @@ 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+\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.484.g0c8726318c-goog\n\n"},{"id":"345574","messageId":"20180423234327.250484-5-sbeller@google.com","threadId":"48350","inReplyTo":"20180423234327.250484-1-sbeller@google.com","subject":"[PATCH 4/9] packfile: add repository argument to packed_to_object_type","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-23T23:43:22Z","receivedAt":"2018-04-23T23:43:51Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of 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.484.g0c8726318c-goog\n\n"},{"id":"345575","messageId":"20180423234327.250484-8-sbeller@google.com","threadId":"48350","inReplyTo":"20180423234327.250484-1-sbeller@google.com","subject":"[PATCH 7/9] packfile: add repository argument to unpack_entry","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-23T23:43:25Z","receivedAt":"2018-04-23T23:43:54Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of 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.484.g0c8726318c-goog\n\n"},{"id":"345576","messageId":"20180423234327.250484-9-sbeller@google.com","threadId":"48350","inReplyTo":"20180423234327.250484-1-sbeller@google.com","subject":"[PATCH 8/9] packfile: add repository argument to cache_or_unpack_entry","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-23T23:43:26Z","receivedAt":"2018-04-23T23:43:55Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow the callers of 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.484.g0c8726318c-goog\n\n"},{"id":"345577","messageId":"20180423234327.250484-10-sbeller@google.com","threadId":"48350","inReplyTo":"20180423234327.250484-1-sbeller@google.com","subject":"[PATCH 9/9] cache.h: allow sha1_object_info to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-23T23:43:27Z","receivedAt":"2018-04-23T23:44:03Z","isPatch":true,"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\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 | 25 +++++++++++++----------\n 4 files changed, 50 insertions(+), 50 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 b292e04fd3..9e0b81eadb 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@@ -1308,10 +1309,10 @@ int oid_object_info_extended_the_repository(const struct object_id *oid, struct\n \t\t */\n \t\treturn 0;\n \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@@ -1323,15 +1324,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.484.g0c8726318c-goog\n\n"},{"id":"345585","messageId":"20180424003109.GA245996@genre.crustytoothpaste.net","threadId":"48350","inReplyTo":"20180423234327.250484-3-sbeller@google.com","subject":"Re: [PATCH 2/9] cache.h: add repository argument to oid_object_info","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-04-24T00:31:09Z","receivedAt":"2018-04-24T00:31:21Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Mon, Apr 23, 2018 at 04:43:20PM -0700, Stefan Beller wrote:\n> Add a repository argument to allow the callers of oid_object_info\n> to be more specific about which repository to handle. This is a small\n> mechanical change; it doesn't change the implementation to handle\n> repositories other than the_repository yet.\n> \n> In the expanded macro the identifier `the_repository` is not actually used,\n> so the compiler does not catch if the repository.h header is not included\n> at the call site. call sites needing that #include were identified by\n> changing the macro to definition to\n> \n>       #define sha1_object_info(r, sha1, size) \\\n>           (r, sha1_object_info_##r(sha1, size)).\n\nI think you may have wanted to write \"oid_object_info\" here.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"345586","messageId":"20180424003414.GB245996@genre.crustytoothpaste.net","threadId":"48350","inReplyTo":"20180423234327.250484-10-sbeller@google.com","subject":"Re: [PATCH 9/9] cache.h: allow sha1_object_info to handle arbitrary repositories","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-04-24T00:34:15Z","receivedAt":"2018-04-24T00:34:24Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Mon, Apr 23, 2018 at 04:43:27PM -0700, Stefan Beller wrote:\n> This involves also adapting sha1_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\nAh, yes, I remember that recursive call chain.\n\nAnyway, other than the one item I mentioned earlier, this series looked\ngood to me.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"345587","messageId":"CAGZ79kYzUbR-OSUn-174f9SwKjNQ7LTw2FcSiSpnZmmdPrAuMA@mail.gmail.com","threadId":"48350","inReplyTo":"20180424003414.GB245996@genre.crustytoothpaste.net","subject":"Re: [PATCH 9/9] cache.h: allow sha1_object_info to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-04-24T00:38:24Z","receivedAt":"2018-04-24T00:38:29Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Mon, Apr 23, 2018 at 5:34 PM, brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n> On Mon, Apr 23, 2018 at 04:43:27PM -0700, Stefan Beller wrote:\n>> This involves also adapting sha1_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>\n> Ah, yes, I remember that recursive call chain.\n>\n> Anyway, other than the one item I mentioned earlier, this series looked\n> good to me.\n\nThanks for the quick review!\n\nWell, this very paragraph that you quote also mentions\n*sha1*_object_info_extended, so I'll fix that, too\n\nI'll wait until tomorrow for a resend to give others\nthe opportunity to weigh in as well.\n\nThanks,\nStefan\n"},{"id":"345659","messageId":"20180424111535.67beac25e0d342b15804896d@google.com","threadId":"48350","inReplyTo":"20180423234327.250484-3-sbeller@google.com","subject":"Re: [PATCH 2/9] cache.h: add repository argument to oid_object_info","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-04-24T18:15:35Z","receivedAt":"2018-04-24T18:15:41Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"On Mon, 23 Apr 2018 16:43:20 -0700\nStefan Beller <sbeller@google.com> wrote:\n\n> Add a repository argument to allow the callers of oid_object_info\n> to be more specific about which repository to handle. This is a small\n> mechanical change; it doesn't change the implementation to handle\n> repositories other than the_repository yet.\n\nFrom here...\n\n> In the expanded macro the identifier `the_repository` is not actually used,\n> so the compiler does not catch if the repository.h header is not included\n> at the call site. call sites needing that #include were identified by\n> changing the macro to definition to\n> \n>       #define sha1_object_info(r, sha1, size) \\\n>           (r, sha1_object_info_##r(sha1, size)).\n> \n> This produces a compiler warning about the left hand side of the comma\n> operator being unused, which can be suppressed using -Wno-unused-value.\n> \n> To avoid breaking bisection, do not include this trick in the patch.\n\n...until here: I don't think this explanation is necessary - this macro\ntrick is temporary anyway in all our patch sets. Also, wouldn't\nrepository.h be needed anyway if we reference \"struct repository\"?\n\nI would replace this section with the \"As with the previous commits\"\nexplanation you have in PATCH 3/9 and others.\n"},{"id":"345660","messageId":"20180424111616.bc81c1d16f1c511a497891ed@google.com","threadId":"48350","inReplyTo":"20180423234327.250484-6-sbeller@google.com","subject":"Re: [PATCH 5/9] packfile: add repository argument to packed_object_info","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-04-24T18:16:16Z","receivedAt":"2018-04-24T18:16:21Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"On Mon, 23 Apr 2018 16:43:23 -0700\nStefan Beller <sbeller@google.com> wrote:\n\n> diff --git a/sha1_file.c b/sha1_file.c\n> index 93f25c6c6a..b292e04fd3 100644\n> --- a/sha1_file.c\n> +++ b/sha1_file.c\n> @@ -1307,7 +1307,8 @@ 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> +\n> +\trtype = packed_object_info(the_repository, e.p, e.offset, oi);\n\nExtra blank line introduced.\n"},{"id":"345661","messageId":"20180424112332.38c0d04d96689f030e96825a@google.com","threadId":"48350","inReplyTo":"20180423234327.250484-10-sbeller@google.com","subject":"Re: [PATCH 9/9] cache.h: allow sha1_object_info to handle arbitrary repositories","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-04-24T18:23:32Z","receivedAt":"2018-04-24T18:23:43Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"On Mon, 23 Apr 2018 16:43:27 -0700\nStefan Beller <sbeller@google.com> wrote:\n\n> This involves also adapting sha1_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\nIn packfile.c, unpack_entry() invokes get_delta_base_cache_entry(),\nwhich references a global (delta_base_cache). Does delta_base_cache need\nto be moved to the repo object (or object store object) first, or is\nthis safe?\n\nAlso, in sha1_file.c, oid_object_info_extended() invokes fetch_object(),\nwhich attempts to fetch a missing object. For this, I think that it's\nbest to guard with a \"r == the_repository\" check, or if there's a better\nway to distinguish between the \"default\" repository and any repository\nthat we newly create (I vaguely remember some distinction when parsing\nenvironment variables when determining repo paths - the envvars were\nonly used for the \"default\" repository, but not for the others).\n"},{"id":"345664","messageId":"20180424184233.GA90854@google.com","threadId":"48350","inReplyTo":"20180424112332.38c0d04d96689f030e96825a@google.com","subject":"Re: [PATCH 9/9] cache.h: allow sha1_object_info to handle arbitrary repositories","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2018-04-24T18:42:33Z","receivedAt":"2018-04-24T18:42:39Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 04/24, Jonathan Tan wrote:\n> On Mon, 23 Apr 2018 16:43:27 -0700\n> Stefan Beller <sbeller@google.com> wrote:\n> \n> > This involves also adapting sha1_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> \n> In packfile.c, unpack_entry() invokes get_delta_base_cache_entry(),\n> which references a global (delta_base_cache). Does delta_base_cache need\n> to be moved to the repo object (or object store object) first, or is\n> this safe?\n\nAfter looking at this, I think it should be safe for now since its a\ncache that requires a packed_git pointer to access (and those would be\nper repository).  We may want to move it in to the repository at some\npoint though.\n\n> \n> Also, in sha1_file.c, oid_object_info_extended() invokes fetch_object(),\n> which attempts to fetch a missing object. For this, I think that it's\n> best to guard with a \"r == the_repository\" check, or if there's a better\n> way to distinguish between the \"default\" repository and any repository\n> that we newly create (I vaguely remember some distinction when parsing\n> environment variables when determining repo paths - the envvars were\n> only used for the \"default\" repository, but not for the others).\n\nThis is a little more difficult and I'm not sure I know what the best\ncourse of action would be for this.  Mostly because then this puts a big\nrecursive dependency on the whole fetch mechanism to handle arbitrary\nrepositories at the same time these functions are converted.  So maybe\nthrowing in the runtime check would be the best way to break the\ndependencies for now.\n\n-- \nBrandon Williams\n"},{"id":"345666","messageId":"20180424115536.54fe1a62541624b2dbe06619@google.com","threadId":"48350","inReplyTo":"20180424184233.GA90854@google.com","subject":"Re: [PATCH 9/9] cache.h: allow sha1_object_info to handle arbitrary repositories","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-04-24T18:55:36Z","receivedAt":"2018-04-24T18:55:42Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"On Tue, 24 Apr 2018 11:42:33 -0700\nBrandon Williams <bmwill@google.com> wrote:\n\n> On 04/24, Jonathan Tan wrote:\n> > On Mon, 23 Apr 2018 16:43:27 -0700\n> > Stefan Beller <sbeller@google.com> wrote:\n> > \n> > > This involves also adapting sha1_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> > \n> > In packfile.c, unpack_entry() invokes get_delta_base_cache_entry(),\n> > which references a global (delta_base_cache). Does delta_base_cache need\n> > to be moved to the repo object (or object store object) first, or is\n> > this safe?\n> \n> After looking at this, I think it should be safe for now since its a\n> cache that requires a packed_git pointer to access (and those would be\n> per repository).  We may want to move it in to the repository at some\n> point though.\n\nThanks for the pointer. I see that a packed_git pointer is part of the\nkey to that hashmap, so this is indeed safe. (Probably worth discussing\nthis in the commit message.)\n\nThere is another global, delta_base_cached, but it just limits the total\nsize of the hashmap, so it's safe to use that too.\n"},{"id":"345721","messageId":"xmqq8t9c5e6n.fsf@gitster-ct.c.googlers.com","threadId":"48350","inReplyTo":"20180424111616.bc81c1d16f1c511a497891ed@google.com","subject":"Re: [PATCH 5/9] packfile: add repository argument to packed_object_info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-04-25T00:21:04Z","receivedAt":"2018-04-25T00:23:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Tan <jonathantanmy@google.com> writes:\n\n> On Mon, 23 Apr 2018 16:43:23 -0700\n> Stefan Beller <sbeller@google.com> wrote:\n>\n>> diff --git a/sha1_file.c b/sha1_file.c\n>> index 93f25c6c6a..b292e04fd3 100644\n>> --- a/sha1_file.c\n>> +++ b/sha1_file.c\n>> @@ -1307,7 +1307,8 @@ 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>> +\n>> +\trtype = packed_object_info(the_repository, e.p, e.offset, oi);\n>\n> Extra blank line introduced.\n\nYes, but from the way this function is formatted, I think the\nnew paragraph break there makes sort of sense.\n"}]}