{"thread":{"id":"49542","subject":"[RFC PATCH 00/19] Bring more repository handles into our code base","startedAt":"2018-10-11T21:18:01Z","lastAt":"2018-10-16T23:17:04Z","messageCount":37,"participants":["Stefan Beller","Jonathan Tan","Junio C Hamano","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":19},"messages":[{"id":"360211","messageId":"20181011211754.31369-1-sbeller@google.com","threadId":"49542","inReplyTo":null,"subject":"[RFC PATCH 00/19] Bring more repository handles into our code base","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:35Z","receivedAt":"2018-10-11T21:18:01Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This applies on nd/the-index (b3c7eef9b05) and is the logical continuation of\nthe object store series, which I sent over the last year.\n\nThe previous series did take a very slow and pedantic approach,\nusing a #define trick, see cfc62fc98c for details, but it turns out,\nthat it doesn't work:\n   When changing the signature of widely used functions, it burdens the\n   maintainer in resolving the semantic conflicts.\n   \n   In the orginal approach this was called a feature, as then we can ensure\n   that not bugs creep into the code base during the merge window (while such\n   a refactoring series wanders from pu to master). It turns out this\n   was not well received and was just burdensome.\n   \n   The #define trick doesn't buy us much to begin with when dealing with\n   non-merge-conflicts.  For example, see deref_tag at tag.c:68, which got\n   the repository argument in 286d258d4f (tag.c: allow deref_tag to handle\n   arbitrary repositories, 2018-06-28) but lost its property of working on any\n   repository while 8c4cc32689 (tag: don't warn if target is missing but\n   promised, 2018-07-12) was in flight simultaneously.\n   \n   Another example of failure of this approach is seen in patch 5, which\n   shows that the pedantry was missed.\n        \nThis series takes another approach as it doesn't change the signature of\nfunctions, but introduces new functions that can deal with arbitrary \nrepositories, keeping the old function signature around using a shallow wrapper.\n\nAdditionally each patch adds a semantic patch, that would port from the old to\nthe new function. These semantic patches are all applied in the very last patch,\nbut we could omit applying the last patch if it causes too many merge conflicts\nand trickl in the semantic patches over time when there are no merge conflicts.\n\n\nThe original goal of all these refactoring series was to remove add_submodule_odb \nin submodule.c, which was partially reached with this series. I'll investigate the\nremaining calls in another series, but it shows we're close to be done with these\nlarge refactorings as far as I am concerned.\n\nThanks,\nStefan\n\nStefan Beller (19):\n  sha1_file: allow read_object to read objects in arbitrary repositories\n  packfile: allow has_packed_and_bad to handle arbitrary repositories\n  object-store: allow read_object_file_extended to read from arbitrary\n    repositories\n  object-store: prepare read_object_file to deal with arbitrary\n    repositories\n  object: parse_object to honor its repository argument\n  commit: allow parse_commit* to handle arbitrary repositories\n  commit.c: allow paint_down_to_common to handle arbitrary repositories\n  commit.c: allow merge_bases_many to handle arbitrary repositories\n  commit.c: allow remove_redundant to handle arbitrary repositories\n  commit: allow get_merge_bases_many_0 to handle arbitrary repositories\n  commit: prepare get_merge_bases to handle arbitrary repositories\n  commit: prepare get_commit_buffer to handle arbitrary repositories\n  commit: prepare in_merge_bases[_many] to handle arbitrary repositories\n  commit: prepare repo_unuse_commit_buffer to handle arbitrary\n    repositories\n  commit: prepare logmsg_reencode to handle arbitrary repositories\n  pretty: prepare format_commit_message to handle arbitrary repositories\n  submodule: use submodule repos for object lookup\n  submodule: don't add submodule as odb for push\n  Apply semantic patches from previous patches\n\n apply.c                                 |   6 +-\n archive.c                               |   5 +-\n bisect.c                                |   5 +-\n blame.c                                 |  15 +--\n builtin/am.c                            |   2 +-\n builtin/blame.c                         |   4 +-\n builtin/cat-file.c                      |  21 +++--\n builtin/checkout.c                      |   4 +-\n builtin/commit.c                        |  13 ++-\n builtin/describe.c                      |   4 +-\n builtin/difftool.c                      |   3 +-\n builtin/fast-export.c                   |   7 +-\n builtin/fmt-merge-msg.c                 |   8 +-\n builtin/grep.c                          |   2 +-\n builtin/index-pack.c                    |   8 +-\n builtin/log.c                           |   4 +-\n builtin/merge-base.c                    |   2 +-\n builtin/merge-tree.c                    |   9 +-\n builtin/mktag.c                         |   3 +-\n builtin/name-rev.c                      |   2 +-\n builtin/notes.c                         |  12 ++-\n builtin/pack-objects.c                  |  22 +++--\n builtin/reflog.c                        |   5 +-\n builtin/replace.c                       |   2 +-\n builtin/shortlog.c                      |   5 +-\n builtin/show-branch.c                   |   4 +-\n builtin/tag.c                           |   4 +-\n builtin/unpack-file.c                   |   2 +-\n builtin/unpack-objects.c                |   3 +-\n builtin/verify-commit.c                 |   2 +-\n bundle.c                                |   2 +-\n combine-diff.c                          |   2 +-\n commit-graph.c                          |   8 +-\n commit.c                                | 120 ++++++++++++++----------\n commit.h                                |  67 ++++++++++---\n config.c                                |   2 +-\n contrib/coccinelle/the_repository.cocci | 114 ++++++++++++++++++++++\n diff.c                                  |   3 +-\n dir.c                                   |   2 +-\n entry.c                                 |   3 +-\n fast-import.c                           |   7 +-\n fsck.c                                  |   9 +-\n grep.c                                  |   3 +-\n http-push.c                             |   3 +-\n log-tree.c                              |   3 +-\n mailmap.c                               |   2 +-\n match-trees.c                           |   4 +-\n merge-blobs.c                           |   6 +-\n merge-recursive.c                       |  13 +--\n negotiator/default.c                    |   6 +-\n negotiator/skipping.c                   |   2 +-\n notes-cache.c                           |   5 +-\n notes-merge.c                           |   4 +-\n notes-utils.c                           |   2 +-\n notes.c                                 |  10 +-\n object-store.h                          |  13 ++-\n object.c                                |   2 +-\n packfile.c                              |   5 +-\n packfile.h                              |   2 +-\n pretty.c                                |  33 ++++---\n pretty.h                                |   7 +-\n read-cache.c                            |   5 +-\n remote-testsvn.c                        |   4 +-\n remote.c                                |   2 +-\n rerere.c                                |   5 +-\n revision.c                              |  12 +--\n sequencer.c                             |  55 ++++++-----\n sha1-file.c                             |  22 +++--\n sha1-name.c                             |   9 +-\n shallow.c                               |   4 +-\n streaming.c                             |   2 +-\n submodule-config.c                      |   3 +-\n submodule.c                             |  51 +++++++---\n t/helper/test-revision-walking.c        |   3 +-\n tag.c                                   |   5 +-\n tree-walk.c                             |   6 +-\n tree.c                                  |   5 +-\n walker.c                                |   2 +-\n xdiff-interface.c                       |   2 +-\n 79 files changed, 571 insertions(+), 278 deletions(-)\n create mode 100644 contrib/coccinelle/the_repository.cocci\n\n-- \n2.19.0\n\n"},{"id":"360212","messageId":"20181011211754.31369-2-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 01/19] sha1_file: allow read_object to read objects in arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:36Z","receivedAt":"2018-10-11T21:18:02Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Allow read_object (a file local functon in sha1_file) to\nhandle arbitrary repositories by passing the repository down\nto oid_object_info_extended.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n sha1-file.c | 10 ++++++----\n 1 file changed, 6 insertions(+), 4 deletions(-)\n\ndiff --git a/sha1-file.c b/sha1-file.c\nindex 308d5e20e2..647068a836 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -1361,7 +1361,9 @@ int oid_object_info(struct repository *r,\n \treturn type;\n }\n \n-static void *read_object(const unsigned char *sha1, enum object_type *type,\n+static void *read_object(struct repository *r,\n+\t\t\t const unsigned char *sha1,\n+\t\t\t enum object_type *type,\n \t\t\t unsigned long *size)\n {\n \tstruct object_id oid;\n@@ -1373,7 +1375,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(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@@ -1414,7 +1416,7 @@ void *read_object_file_extended(const struct object_id *oid,\n \t\tlookup_replace_object(the_repository, oid) : oid;\n \n \terrno = 0;\n-\tdata = read_object(repl->hash, type, size);\n+\tdata = read_object(the_repository, repl->hash, type, size);\n \tif (data)\n \t\treturn data;\n \n@@ -1755,7 +1757,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)\n \n \tif (has_loose_object(oid))\n \t\treturn 0;\n-\tbuf = read_object(oid->hash, &type, &len);\n+\tbuf = read_object(the_repository, oid->hash, &type, &len);\n \tif (!buf)\n \t\treturn error(_(\"cannot read sha1_file for %s\"), oid_to_hex(oid));\n \thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %lu\", type_name(type), len) + 1;\n-- \n2.19.0\n\n"},{"id":"360213","messageId":"20181011211754.31369-3-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 02/19] packfile: allow has_packed_and_bad to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:37Z","receivedAt":"2018-10-11T21:18:04Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"has_packed_and_bad is not widely used, so just migrate it all at once.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n packfile.c  | 5 +++--\n packfile.h  | 2 +-\n sha1-file.c | 2 +-\n 3 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/packfile.c b/packfile.c\nindex ebcb5742ec..40085fe160 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -1024,12 +1024,13 @@ void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1)\n \tp->num_bad_objects++;\n }\n \n-const struct packed_git *has_packed_and_bad(const unsigned char *sha1)\n+const struct packed_git *has_packed_and_bad(struct repository *r,\n+\t\t\t\t\t    const unsigned char *sha1)\n {\n \tstruct packed_git *p;\n \tunsigned i;\n \n-\tfor (p = the_repository->objects->packed_git; p; p = p->next)\n+\tfor (p = r->objects->packed_git; p; p = p->next)\n \t\tfor (i = 0; i < p->num_bad_objects; i++)\n \t\t\tif (!hashcmp(sha1,\n \t\t\t\t     p->bad_object_sha1 + the_hash_algo->rawsz * i))\ndiff --git a/packfile.h b/packfile.h\nindex 630f35cf31..1d2d170bf8 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -136,7 +136,7 @@ extern int packed_object_info(struct repository *r,\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);\n+extern const struct packed_git *has_packed_and_bad(struct repository *r, const unsigned char *sha1);\n \n /*\n  * Iff a pack file in the given repository contains the object named by sha1,\ndiff --git a/sha1-file.c b/sha1-file.c\nindex 647068a836..13b3c5cb79 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -1432,7 +1432,7 @@ void *read_object_file_extended(const struct object_id *oid,\n \t\tdie(_(\"loose object %s (stored in %s) is corrupt\"),\n \t\t    oid_to_hex(repl), path);\n \n-\tif ((p = has_packed_and_bad(repl->hash)) != NULL)\n+\tif ((p = has_packed_and_bad(the_repository, repl->hash)) != NULL)\n \t\tdie(_(\"packed object %s (stored in %s) is corrupt\"),\n \t\t    oid_to_hex(repl), p->pack_name);\n \n-- \n2.19.0\n\n"},{"id":"360214","messageId":"20181011211754.31369-4-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 03/19] object-store: allow read_object_file_extended to read from arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:38Z","receivedAt":"2018-10-11T21:18:07Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"read_object_file_extended is not widely used, so migrate it all at once.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n object-store.h |  5 +++--\n sha1-file.c    | 11 ++++++-----\n streaming.c    |  2 +-\n 3 files changed, 10 insertions(+), 8 deletions(-)\n\ndiff --git a/object-store.h b/object-store.h\nindex 67e66227d9..6bb0ccbf05 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -146,12 +146,13 @@ void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned cha\n \n void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size);\n \n-extern void *read_object_file_extended(const struct object_id *oid,\n+extern void *read_object_file_extended(struct repository *r,\n+\t\t\t\t       const struct object_id *oid,\n \t\t\t\t       enum object_type *type,\n \t\t\t\t       unsigned long *size, int lookup_replace);\n static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size)\n {\n-\treturn read_object_file_extended(oid, type, size, 1);\n+\treturn read_object_file_extended(the_repository, oid, type, size, 1);\n }\n \n /* Read and unpack an object file into memory, write memory to an object file */\ndiff --git a/sha1-file.c b/sha1-file.c\nindex 13b3c5cb79..ce47524679 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -1403,7 +1403,8 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type,\n  * deal with them should arrange to call read_object() and give error\n  * messages themselves.\n  */\n-void *read_object_file_extended(const struct object_id *oid,\n+void *read_object_file_extended(struct repository *r,\n+\t\t\t\tconst struct object_id *oid,\n \t\t\t\tenum object_type *type,\n \t\t\t\tunsigned long *size,\n \t\t\t\tint lookup_replace)\n@@ -1413,10 +1414,10 @@ void *read_object_file_extended(const struct object_id *oid,\n \tconst char *path;\n \tstruct stat st;\n \tconst struct object_id *repl = lookup_replace ?\n-\t\tlookup_replace_object(the_repository, oid) : oid;\n+\t\tlookup_replace_object(r, oid) : oid;\n \n \terrno = 0;\n-\tdata = read_object(the_repository, repl->hash, type, size);\n+\tdata = read_object(r, repl->hash, type, size);\n \tif (data)\n \t\treturn data;\n \n@@ -1428,11 +1429,11 @@ void *read_object_file_extended(const struct object_id *oid,\n \t\tdie(_(\"replacement %s not found for %s\"),\n \t\t    oid_to_hex(repl), oid_to_hex(oid));\n \n-\tif (!stat_sha1_file(the_repository, repl->hash, &st, &path))\n+\tif (!stat_sha1_file(r, repl->hash, &st, &path))\n \t\tdie(_(\"loose object %s (stored in %s) is corrupt\"),\n \t\t    oid_to_hex(repl), path);\n \n-\tif ((p = has_packed_and_bad(the_repository, repl->hash)) != NULL)\n+\tif ((p = has_packed_and_bad(r, repl->hash)) != NULL)\n \t\tdie(_(\"packed object %s (stored in %s) is corrupt\"),\n \t\t    oid_to_hex(repl), p->pack_name);\n \ndiff --git a/streaming.c b/streaming.c\nindex d1e6b2dce6..c843a1230f 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -490,7 +490,7 @@ static struct stream_vtbl incore_vtbl = {\n \n static open_method_decl(incore)\n {\n-\tst->u.incore.buf = read_object_file_extended(oid, type, &st->size, 0);\n+\tst->u.incore.buf = read_object_file_extended(the_repository, oid, type, &st->size, 0);\n \tst->u.incore.read_ptr = 0;\n \tst->vtbl = &incore_vtbl;\n \n-- \n2.19.0\n\n"},{"id":"360215","messageId":"20181011211754.31369-5-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 04/19] object-store: prepare read_object_file to deal with arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:39Z","receivedAt":"2018-10-11T21:18:09Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"As read_object_file is a widely used function (which is also regularly used\nin new code in flight between master..pu), changing its signature is painful\nis hard, as other series in flight rely on the original signature. It would\nburden the maintainer if we'd just change the signature.\n\nIntroduce repo_read_object_file which takes the repository argument, and\nhide the original read_object_file as a macro behind\nNO_THE_REPOSITORY_COMPATIBILITY_MACROS, which we planned for in\ne675765235 (diff.c: remove implicit dependency on the_index, 2018-09-21)\n\nAdd a coccinelle patch to convert existing callers, but do not apply\nthe resulting patch from 'make coccicheck' to keep the diff of this\npatch small.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n contrib/coccinelle/the_repository.cocci | 13 +++++++++++++\n object-store.h                          | 10 ++++++++--\n 2 files changed, 21 insertions(+), 2 deletions(-)\n create mode 100644 contrib/coccinelle/the_repository.cocci\n\ndiff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci\nnew file mode 100644\nindex 0000000000..3c7fa70502\n--- /dev/null\n+++ b/contrib/coccinelle/the_repository.cocci\n@@ -0,0 +1,13 @@\n+// This file is used for the ongoing refactoring of\n+// bringing the index or repository struct in all of\n+// our code base.\n+\n+@@\n+expression E;\n+expression F;\n+expression G;\n+@@\n+- read_object_file(\n++ repo_read_object_file(the_repository,\n+  E, F, G)\n+\ndiff --git a/object-store.h b/object-store.h\nindex 6bb0ccbf05..41ceebca48 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -150,10 +150,16 @@ extern void *read_object_file_extended(struct repository *r,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       enum object_type *type,\n \t\t\t\t       unsigned long *size, int lookup_replace);\n-static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size)\n+static inline void *repo_read_object_file(struct repository *r,\n+\t\t\t\t\t  const struct object_id *oid,\n+\t\t\t\t\t  enum object_type *type,\n+\t\t\t\t\t  unsigned long *size)\n {\n-\treturn read_object_file_extended(the_repository, oid, type, size, 1);\n+\treturn read_object_file_extended(r, oid, type, size, 1);\n }\n+#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS\n+#define read_object_file(oid, type, size) repo_read_object_file(the_repository, oid, type, size)\n+#endif\n \n /* Read and unpack an object file into memory, write memory to an object file */\n int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);\n-- \n2.19.0\n\n"},{"id":"360216","messageId":"20181011211754.31369-6-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 05/19] object: parse_object to honor its repository argument","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:40Z","receivedAt":"2018-10-11T21:18:12Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"In 8e4b0b6047 (object.c: allow parse_object to handle\narbitrary repositories, 2018-06-28), we forgot to pass the\nrepository down to the read_object_file.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n object.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/object.c b/object.c\nindex 51c4594515..61f49d8b99 100644\n--- a/object.c\n+++ b/object.c\n@@ -270,7 +270,7 @@ struct object *parse_object(struct repository *r, const struct object_id *oid)\n \t\treturn lookup_object(r, oid->hash);\n \t}\n \n-\tbuffer = read_object_file(oid, &type, &size);\n+\tbuffer = repo_read_object_file(r, oid, &type, &size);\n \tif (buffer) {\n \t\tif (check_object_signature(repl, buffer, size, type_name(type)) < 0) {\n \t\t\tfree(buffer);\n-- \n2.19.0\n\n"},{"id":"360217","messageId":"20181011211754.31369-7-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 06/19] commit: allow parse_commit* to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:41Z","receivedAt":"2018-10-11T21:18:14Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Just like the previous commit, parse_commit and friends are used a lot\nand are found in new patches, so we cannot change their signature easily.\n\nRe-introduce these function prefixed with 'repo_' that take a repository\nargument and keep the original as a shallow macro.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c                                | 18 +++++++++++-------\n commit.h                                | 17 +++++++++++++----\n contrib/coccinelle/the_repository.cocci | 24 ++++++++++++++++++++++++\n 3 files changed, 48 insertions(+), 11 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 449c1f4920..c6aeedc3d8 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -443,7 +443,10 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b\n \treturn 0;\n }\n \n-int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_commit_graph)\n+int repo_parse_commit_internal(struct repository *r,\n+\t\t\t       struct commit *item,\n+\t\t\t       int quiet_on_missing,\n+\t\t\t       int use_commit_graph)\n {\n \tenum object_type type;\n \tvoid *buffer;\n@@ -454,9 +457,9 @@ int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_com\n \t\treturn -1;\n \tif (item->object.parsed)\n \t\treturn 0;\n-\tif (use_commit_graph && parse_commit_in_graph(the_repository, item))\n+\tif (use_commit_graph && parse_commit_in_graph(r, item))\n \t\treturn 0;\n-\tbuffer = read_object_file(&item->object.oid, &type, &size);\n+\tbuffer = repo_read_object_file(r, &item->object.oid, &type, &size);\n \tif (!buffer)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\n@@ -467,18 +470,19 @@ int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_com\n \t\t\t     oid_to_hex(&item->object.oid));\n \t}\n \n-\tret = parse_commit_buffer(the_repository, item, buffer, size, 0);\n+\tret = parse_commit_buffer(r, item, buffer, size, 0);\n \tif (save_commit_buffer && !ret) {\n-\t\tset_commit_buffer(the_repository, item, buffer, size);\n+\t\tset_commit_buffer(r, item, buffer, size);\n \t\treturn 0;\n \t}\n \tfree(buffer);\n \treturn ret;\n }\n \n-int parse_commit_gently(struct commit *item, int quiet_on_missing)\n+int repo_parse_commit_gently(struct repository *r,\n+\t\t\t     struct commit *item, int quiet_on_missing)\n {\n-\treturn parse_commit_internal(item, quiet_on_missing, 1);\n+\treturn repo_parse_commit_internal(r, item, quiet_on_missing, 1);\n }\n \n void parse_commit_or_die(struct commit *item)\ndiff --git a/commit.h b/commit.h\nindex da0db36eba..b8d1f6728f 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -79,12 +79,21 @@ struct commit *lookup_commit_reference_by_name(const char *name);\n struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);\n \n int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph);\n-int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_commit_graph);\n-int parse_commit_gently(struct commit *item, int quiet_on_missing);\n-static inline int parse_commit(struct commit *item)\n+int repo_parse_commit_internal(struct repository *r, struct commit *item,\n+\t\t\t       int quiet_on_missing, int use_commit_graph);\n+int repo_parse_commit_gently(struct repository *r,\n+\t\t\t     struct commit *item,\n+\t\t\t     int quiet_on_missing);\n+static inline int repo_parse_commit(struct repository *r, struct commit *item)\n {\n-\treturn parse_commit_gently(item, 0);\n+\treturn repo_parse_commit_gently(r, item, 0);\n }\n+#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS\n+#define parse_commit_internal(item, quiet, use) repo_parse_commit_internal(the_repository, item, quiet, use)\n+#define parse_commit_gently(item, quiet) repo_parse_commit_gently(the_repository, item, quiet)\n+#define parse_commit(item) repo_parse_commit(the_repository, item)\n+#endif\n+\n void parse_commit_or_die(struct commit *item);\n \n struct buffer_slab;\ndiff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci\nindex 3c7fa70502..7189a7293a 100644\n--- a/contrib/coccinelle/the_repository.cocci\n+++ b/contrib/coccinelle/the_repository.cocci\n@@ -11,3 +11,27 @@ expression G;\n + repo_read_object_file(the_repository,\n   E, F, G)\n \n+@@\n+expression E;\n+expression F;\n+expression G;\n+@@\n+- parse_commit_internal(\n++ repo_parse_commit_internal(the_repository,\n+  E, F, G)\n+\n+@@\n+expression E;\n+expression F;\n+@@\n+- parse_commit_gently(\n++ repo_parse_commit_gently(the_repository,\n+  E, F)\n+\n+@@\n+expression E;\n+@@\n+- parse_commit(\n++ repo_parse_commit(the_repository,\n+  E)\n+\n-- \n2.19.0\n\n"},{"id":"360218","messageId":"20181011211754.31369-8-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 07/19] commit.c: allow paint_down_to_common to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:42Z","receivedAt":"2018-10-11T21:18:16Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"As the function is file local and not widely used, migrate it all at once.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 15 +++++++++------\n 1 file changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex c6aeedc3d8..f493a82f72 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -869,7 +869,8 @@ static int queue_has_nonstale(struct prio_queue *queue)\n }\n \n /* all input commits in one and twos[] must have been parsed! */\n-static struct commit_list *paint_down_to_common(struct commit *one, int n,\n+static struct commit_list *paint_down_to_common(struct repository *r,\n+\t\t\t\t\t\tstruct commit *one, int n,\n \t\t\t\t\t\tstruct commit **twos,\n \t\t\t\t\t\tint min_generation)\n {\n@@ -922,7 +923,7 @@ static struct commit_list *paint_down_to_common(struct commit *one, int n,\n \t\t\tparents = parents->next;\n \t\t\tif ((p->object.flags & flags) == flags)\n \t\t\t\tcontinue;\n-\t\t\tif (parse_commit(p))\n+\t\t\tif (repo_parse_commit(r, p))\n \t\t\t\treturn NULL;\n \t\t\tp->object.flags |= flags;\n \t\t\tprio_queue_put(&queue, p);\n@@ -955,7 +956,7 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct co\n \t\t\treturn NULL;\n \t}\n \n-\tlist = paint_down_to_common(one, n, twos, 0);\n+\tlist = paint_down_to_common(the_repository, one, n, twos, 0);\n \n \twhile (list) {\n \t\tstruct commit *commit = pop_commit(&list);\n@@ -1026,8 +1027,8 @@ static int remove_redundant(struct commit **array, int cnt)\n \t\t\tif (array[j]->generation < min_generation)\n \t\t\t\tmin_generation = array[j]->generation;\n \t\t}\n-\t\tcommon = paint_down_to_common(array[i], filled, work,\n-\t\t\t\t\t      min_generation);\n+\t\tcommon = paint_down_to_common(the_repository, array[i], filled,\n+\t\t\t\t\t      work, min_generation);\n \t\tif (array[i]->object.flags & PARENT2)\n \t\t\tredundant[i] = 1;\n \t\tfor (j = 0; j < filled; j++)\n@@ -1151,7 +1152,9 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit *\n \tif (commit->generation > min_generation)\n \t\treturn ret;\n \n-\tbases = paint_down_to_common(commit, nr_reference, reference, commit->generation);\n+\tbases = paint_down_to_common(the_repository, commit,\n+\t\t\t\t     nr_reference, reference,\n+\t\t\t\t     commit->generation);\n \tif (commit->object.flags & PARENT2)\n \t\tret = 1;\n \tclear_commit_marks(commit, all_flags);\n-- \n2.19.0\n\n"},{"id":"360219","messageId":"20181011211754.31369-9-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 08/19] commit.c: allow merge_bases_many to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:43Z","receivedAt":"2018-10-11T21:18:18Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex f493a82f72..5e8791f0c1 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -934,7 +934,9 @@ static struct commit_list *paint_down_to_common(struct repository *r,\n \treturn result;\n }\n \n-static struct commit_list *merge_bases_many(struct commit *one, int n, struct commit **twos)\n+static struct commit_list *merge_bases_many(struct repository *r,\n+\t\t\t\t\t    struct commit *one, int n,\n+\t\t\t\t\t    struct commit **twos)\n {\n \tstruct commit_list *list = NULL;\n \tstruct commit_list *result = NULL;\n@@ -949,14 +951,14 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct co\n \t\t\treturn commit_list_insert(one, &result);\n \t}\n \n-\tif (parse_commit(one))\n+\tif (repo_parse_commit(r, one))\n \t\treturn NULL;\n \tfor (i = 0; i < n; i++) {\n-\t\tif (parse_commit(twos[i]))\n+\t\tif (repo_parse_commit(r, twos[i]))\n \t\t\treturn NULL;\n \t}\n \n-\tlist = paint_down_to_common(the_repository, one, n, twos, 0);\n+\tlist = paint_down_to_common(r, one, n, twos, 0);\n \n \twhile (list) {\n \t\tstruct commit *commit = pop_commit(&list);\n@@ -1063,7 +1065,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one,\n \tstruct commit_list *result;\n \tint cnt, i;\n \n-\tresult = merge_bases_many(one, n, twos);\n+\tresult = merge_bases_many(the_repository, one, n, twos);\n \tfor (i = 0; i < n; i++) {\n \t\tif (one == twos[i])\n \t\t\treturn result;\n-- \n2.19.0\n\n"},{"id":"360220","messageId":"20181011211754.31369-10-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 09/19] commit.c: allow remove_redundant to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:44Z","receivedAt":"2018-10-11T21:18:21Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 5e8791f0c1..f8a8844a72 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -995,7 +995,7 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in)\n \treturn ret;\n }\n \n-static int remove_redundant(struct commit **array, int cnt)\n+static int remove_redundant(struct repository *r, struct commit **array, int cnt)\n {\n \t/*\n \t * Some commit in the array may be an ancestor of\n@@ -1013,7 +1013,7 @@ static int remove_redundant(struct commit **array, int cnt)\n \tALLOC_ARRAY(filled_index, cnt - 1);\n \n \tfor (i = 0; i < cnt; i++)\n-\t\tparse_commit(array[i]);\n+\t\trepo_parse_commit(r, array[i]);\n \tfor (i = 0; i < cnt; i++) {\n \t\tstruct commit_list *common;\n \t\tuint32_t min_generation = array[i]->generation;\n@@ -1029,7 +1029,7 @@ static int remove_redundant(struct commit **array, int cnt)\n \t\t\tif (array[j]->generation < min_generation)\n \t\t\t\tmin_generation = array[j]->generation;\n \t\t}\n-\t\tcommon = paint_down_to_common(the_repository, array[i], filled,\n+\t\tcommon = paint_down_to_common(r, array[i], filled,\n \t\t\t\t\t      work, min_generation);\n \t\tif (array[i]->object.flags & PARENT2)\n \t\t\tredundant[i] = 1;\n@@ -1088,7 +1088,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one,\n \tclear_commit_marks(one, all_flags);\n \tclear_commit_marks_many(n, twos, all_flags);\n \n-\tcnt = remove_redundant(rslt, cnt);\n+\tcnt = remove_redundant(the_repository, rslt, cnt);\n \tresult = NULL;\n \tfor (i = 0; i < cnt; i++)\n \t\tcommit_list_insert_by_date(rslt[i], &result);\n@@ -1199,7 +1199,7 @@ struct commit_list *reduce_heads(struct commit_list *heads)\n \t\t\tp->item->object.flags &= ~STALE;\n \t\t}\n \t}\n-\tnum_head = remove_redundant(array, num_head);\n+\tnum_head = remove_redundant(the_repository, array, num_head);\n \tfor (i = 0; i < num_head; i++)\n \t\ttail = &commit_list_insert(array[i], tail)->next;\n \tfree(array);\n-- \n2.19.0\n\n"},{"id":"360221","messageId":"20181011211754.31369-11-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 10/19] commit: allow get_merge_bases_many_0 to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:45Z","receivedAt":"2018-10-11T21:18:22Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 13 +++++++------\n 1 file changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex f8a8844a72..b36c2aa0bf 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1055,7 +1055,8 @@ static int remove_redundant(struct repository *r, struct commit **array, int cnt\n \treturn filled;\n }\n \n-static struct commit_list *get_merge_bases_many_0(struct commit *one,\n+static struct commit_list *get_merge_bases_many_0(struct repository *r,\n+\t\t\t\t\t\t  struct commit *one,\n \t\t\t\t\t\t  int n,\n \t\t\t\t\t\t  struct commit **twos,\n \t\t\t\t\t\t  int cleanup)\n@@ -1065,7 +1066,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one,\n \tstruct commit_list *result;\n \tint cnt, i;\n \n-\tresult = merge_bases_many(the_repository, one, n, twos);\n+\tresult = merge_bases_many(r, one, n, twos);\n \tfor (i = 0; i < n; i++) {\n \t\tif (one == twos[i])\n \t\t\treturn result;\n@@ -1088,7 +1089,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one,\n \tclear_commit_marks(one, all_flags);\n \tclear_commit_marks_many(n, twos, all_flags);\n \n-\tcnt = remove_redundant(the_repository, rslt, cnt);\n+\tcnt = remove_redundant(r, rslt, cnt);\n \tresult = NULL;\n \tfor (i = 0; i < cnt; i++)\n \t\tcommit_list_insert_by_date(rslt[i], &result);\n@@ -1100,19 +1101,19 @@ struct commit_list *get_merge_bases_many(struct commit *one,\n \t\t\t\t\t int n,\n \t\t\t\t\t struct commit **twos)\n {\n-\treturn get_merge_bases_many_0(one, n, twos, 1);\n+\treturn get_merge_bases_many_0(the_repository, one, n, twos, 1);\n }\n \n struct commit_list *get_merge_bases_many_dirty(struct commit *one,\n \t\t\t\t\t       int n,\n \t\t\t\t\t       struct commit **twos)\n {\n-\treturn get_merge_bases_many_0(one, n, twos, 0);\n+\treturn get_merge_bases_many_0(the_repository, one, n, twos, 0);\n }\n \n struct commit_list *get_merge_bases(struct commit *one, struct commit *two)\n {\n-\treturn get_merge_bases_many_0(one, 1, &two, 1);\n+\treturn get_merge_bases_many_0(the_repository, one, 1, &two, 1);\n }\n \n /*\n-- \n2.19.0\n\n"},{"id":"360222","messageId":"20181011211754.31369-12-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 11/19] commit: prepare get_merge_bases to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:46Z","receivedAt":"2018-10-11T21:18:25Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Similarly to previous patches, the get_merge_base functions are used\noften in the code base, which makes migrating them hard.\n\nImplement the new functions, prefixed with 'repo_' and hide the old\nfunctions behind a wrapper macro.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c                                | 24 +++++++++++++----------\n commit.h                                | 20 ++++++++++++++-----\n contrib/coccinelle/the_repository.cocci | 26 +++++++++++++++++++++++++\n 3 files changed, 55 insertions(+), 15 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex b36c2aa0bf..2733bef019 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1097,23 +1097,27 @@ static struct commit_list *get_merge_bases_many_0(struct repository *r,\n \treturn result;\n }\n \n-struct commit_list *get_merge_bases_many(struct commit *one,\n-\t\t\t\t\t int n,\n-\t\t\t\t\t struct commit **twos)\n+struct commit_list *repo_get_merge_bases_many(struct repository *r,\n+\t\t\t\t\t      struct commit *one,\n+\t\t\t\t\t      int n,\n+\t\t\t\t\t      struct commit **twos)\n {\n-\treturn get_merge_bases_many_0(the_repository, one, n, twos, 1);\n+\treturn get_merge_bases_many_0(r, one, n, twos, 1);\n }\n \n-struct commit_list *get_merge_bases_many_dirty(struct commit *one,\n-\t\t\t\t\t       int n,\n-\t\t\t\t\t       struct commit **twos)\n+struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r,\n+\t\t\t\t\t\t    struct commit *one,\n+\t\t\t\t\t\t    int n,\n+\t\t\t\t\t\t    struct commit **twos)\n {\n-\treturn get_merge_bases_many_0(the_repository, one, n, twos, 0);\n+\treturn get_merge_bases_many_0(r, one, n, twos, 0);\n }\n \n-struct commit_list *get_merge_bases(struct commit *one, struct commit *two)\n+struct commit_list *repo_get_merge_bases(struct repository *r,\n+\t\t\t\t\t struct commit *one,\n+\t\t\t\t\t struct commit *two)\n {\n-\treturn get_merge_bases_many_0(the_repository, one, 1, &two, 1);\n+\treturn get_merge_bases_many_0(r, one, 1, &two, 1);\n }\n \n /*\ndiff --git a/commit.h b/commit.h\nindex b8d1f6728f..f311911785 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -213,12 +213,22 @@ struct commit_graft *read_graft_line(struct strbuf *line);\n int register_commit_graft(struct repository *r, struct commit_graft *, int);\n struct commit_graft *lookup_commit_graft(struct repository *r, const struct object_id *oid);\n \n-extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2);\n-extern struct commit_list *get_merge_bases_many(struct commit *one, int n, struct commit **twos);\n-extern struct commit_list *get_octopus_merge_bases(struct commit_list *in);\n-\n+struct commit_list *repo_get_merge_bases(struct repository *r,\n+\t\t\t\t\t struct commit *rev1,\n+\t\t\t\t\t struct commit *rev2);\n+struct commit_list *repo_get_merge_bases_many(struct repository *r,\n+\t\t\t\t\t      struct commit *one, int n,\n+\t\t\t\t\t      struct commit **twos);\n /* To be used only when object flags after this call no longer matter */\n-extern struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n, struct commit **twos);\n+struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r,\n+\t\t\t\t\t\t    struct commit *one, int n,\n+\t\t\t\t\t\t    struct commit **twos);\n+#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS\n+#define get_merge_bases(r1, r2)           repo_get_merge_bases(the_repository, r1, r2)\n+#define get_merge_bases_many(one, n, two) repo_get_merge_bases_many(the_repository, one, n, two)\n+#define get_merge_bases_many_dirty(one, n, twos) repo_get_merge_bases_many_dirty(the_repository, one, n, twos)\n+#endif\n+extern struct commit_list *get_octopus_merge_bases(struct commit_list *in);\n \n /* largest positive number a signed 32-bit integer can contain */\n #define INFINITE_DEPTH 0x7fffffff\ndiff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci\nindex 7189a7293a..7814f8fa1c 100644\n--- a/contrib/coccinelle/the_repository.cocci\n+++ b/contrib/coccinelle/the_repository.cocci\n@@ -35,3 +35,29 @@ expression E;\n + repo_parse_commit(the_repository,\n   E)\n \n+@@\n+expression E;\n+expression F;\n+@@\n+- get_merge_bases(\n++ repo_get_merge_bases(the_repository,\n+  E, F);\n+\n+@@\n+expression E;\n+expression F;\n+expression G;\n+@@\n+- get_merge_bases_many(\n++ repo_get_merge_bases_many(the_repository,\n+  E, F, G);\n+\n+@@\n+expression E;\n+expression F;\n+expression G;\n+@@\n+- get_merge_bases_many_dirty(\n++ repo_get_merge_bases_many_dirty(the_repository,\n+  E, F, G);\n+\n-- \n2.19.0\n\n"},{"id":"360223","messageId":"20181011211754.31369-13-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 12/19] commit: prepare get_commit_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:47Z","receivedAt":"2018-10-11T21:18:27Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c                                | 8 +++++---\n commit.h                                | 7 ++++++-\n contrib/coccinelle/the_repository.cocci | 7 +++++++\n 3 files changed, 18 insertions(+), 4 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 2733bef019..31f2ca4c78 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -297,13 +297,15 @@ const void *get_cached_commit_buffer(struct repository *r, const struct commit *\n \treturn v->buffer;\n }\n \n-const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)\n+const void *repo_get_commit_buffer(struct repository *r,\n+\t\t\t\t   const struct commit *commit,\n+\t\t\t\t   unsigned long *sizep)\n {\n-\tconst void *ret = get_cached_commit_buffer(the_repository, commit, sizep);\n+\tconst void *ret = get_cached_commit_buffer(r, commit, sizep);\n \tif (!ret) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tret = read_object_file(&commit->object.oid, &type, &size);\n+\t\tret = repo_read_object_file(r, &commit->object.oid, &type, &size);\n \t\tif (!ret)\n \t\t\tdie(\"cannot read commit object %s\",\n \t\t\t    oid_to_hex(&commit->object.oid));\ndiff --git a/commit.h b/commit.h\nindex f311911785..89b245be03 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -117,7 +117,12 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,\n  * from disk. The resulting memory should not be modified, and must be given\n  * to unuse_commit_buffer when the caller is done.\n  */\n-const void *get_commit_buffer(const struct commit *, unsigned long *size);\n+const void *repo_get_commit_buffer(struct repository *r,\n+\t\t\t\t   const struct commit *,\n+\t\t\t\t   unsigned long *size);\n+#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS\n+#define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s)\n+#endif\n \n /*\n  * Tell the commit subsytem that we are done with a particular commit buffer.\ndiff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci\nindex 7814f8fa1c..6dad83f17b 100644\n--- a/contrib/coccinelle/the_repository.cocci\n+++ b/contrib/coccinelle/the_repository.cocci\n@@ -61,3 +61,10 @@ expression G;\n + repo_get_merge_bases_many_dirty(the_repository,\n   E, F, G);\n \n+@@\n+expression E;\n+expression F;\n+@@\n+- get_commit_buffer(\n++ repo_get_commit_buffer(the_repository,\n+  E, F);\n-- \n2.19.0\n\n"},{"id":"360224","messageId":"20181011211754.31369-14-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 13/19] commit: prepare in_merge_bases[_many] to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:48Z","receivedAt":"2018-10-11T21:18:30Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c                                | 15 +++++++++------\n commit.h                                |  8 ++++++--\n contrib/coccinelle/the_repository.cocci | 17 +++++++++++++++++\n 3 files changed, 32 insertions(+), 8 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 31f2ca4c78..eca9a475c7 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1143,16 +1143,17 @@ int is_descendant_of(struct commit *commit, struct commit_list *with_commit)\n /*\n  * Is \"commit\" an ancestor of one of the \"references\"?\n  */\n-int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit **reference)\n+int repo_in_merge_bases_many(struct repository *r, struct commit *commit,\n+\t\t\t     int nr_reference, struct commit **reference)\n {\n \tstruct commit_list *bases;\n \tint ret = 0, i;\n \tuint32_t min_generation = GENERATION_NUMBER_INFINITY;\n \n-\tif (parse_commit(commit))\n+\tif (repo_parse_commit(r, commit))\n \t\treturn ret;\n \tfor (i = 0; i < nr_reference; i++) {\n-\t\tif (parse_commit(reference[i]))\n+\t\tif (repo_parse_commit(r, reference[i]))\n \t\t\treturn ret;\n \t\tif (reference[i]->generation < min_generation)\n \t\t\tmin_generation = reference[i]->generation;\n@@ -1161,7 +1162,7 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit *\n \tif (commit->generation > min_generation)\n \t\treturn ret;\n \n-\tbases = paint_down_to_common(the_repository, commit,\n+\tbases = paint_down_to_common(r, commit,\n \t\t\t\t     nr_reference, reference,\n \t\t\t\t     commit->generation);\n \tif (commit->object.flags & PARENT2)\n@@ -1175,9 +1176,11 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit *\n /*\n  * Is \"commit\" an ancestor of (i.e. reachable from) the \"reference\"?\n  */\n-int in_merge_bases(struct commit *commit, struct commit *reference)\n+int repo_in_merge_bases(struct repository *r,\n+\t\t\tstruct commit *commit,\n+\t\t\tstruct commit *reference)\n {\n-\treturn in_merge_bases_many(commit, 1, &reference);\n+\treturn repo_in_merge_bases_many(r, commit, 1, &reference);\n }\n \n struct commit_list *reduce_heads(struct commit_list *heads)\ndiff --git a/commit.h b/commit.h\nindex 89b245be03..fead381651 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -283,8 +283,12 @@ extern void prune_shallow(int show_only);\n extern struct trace_key trace_shallow;\n \n int is_descendant_of(struct commit *, struct commit_list *);\n-int in_merge_bases(struct commit *, struct commit *);\n-int in_merge_bases_many(struct commit *, int, struct commit **);\n+int repo_in_merge_bases(struct repository *r, struct commit *, struct commit *);\n+int repo_in_merge_bases_many(struct repository *r, struct commit *, int, struct commit **);\n+#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS\n+#define in_merge_bases(c1, c2) repo_in_merge_bases(the_repository, c1, c2)\n+#define in_merge_bases_many(c1, n, cs) repo_in_merge_bases_many(the_repository, c1, n, cs)\n+#endif\n \n extern int interactive_add(int argc, const char **argv, const char *prefix, int patch);\n extern int run_add_interactive(const char *revision, const char *patch_mode,\ndiff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci\nindex 6dad83f17b..ec579682f6 100644\n--- a/contrib/coccinelle/the_repository.cocci\n+++ b/contrib/coccinelle/the_repository.cocci\n@@ -68,3 +68,20 @@ expression F;\n - get_commit_buffer(\n + repo_get_commit_buffer(the_repository,\n   E, F);\n+\n+@@\n+expression E;\n+expression F;\n+@@\n+- in_merge_bases(\n++ repo_in_merge_bases(the_repository,\n+  E, F);\n+\n+@@\n+expression E;\n+expression F;\n+expression G;\n+@@\n+- in_merge_bases_many(\n++ repo_in_merge_bases_many(the_repository,\n+  E, F, G);\n-- \n2.19.0\n\n"},{"id":"360225","messageId":"20181011211754.31369-15-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 14/19] commit: prepare repo_unuse_commit_buffer to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:49Z","receivedAt":"2018-10-11T21:18:33Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c                                | 6 ++++--\n commit.h                                | 7 ++++++-\n contrib/coccinelle/the_repository.cocci | 8 ++++++++\n 3 files changed, 18 insertions(+), 3 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex eca9a475c7..526b33758d 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -318,10 +318,12 @@ const void *repo_get_commit_buffer(struct repository *r,\n \treturn ret;\n }\n \n-void unuse_commit_buffer(const struct commit *commit, const void *buffer)\n+void repo_unuse_commit_buffer(struct repository *r,\n+\t\t\t      const struct commit *commit,\n+\t\t\t      const void *buffer)\n {\n \tstruct commit_buffer *v = buffer_slab_peek(\n-\t\tthe_repository->parsed_objects->buffer_slab, commit);\n+\t\tr->parsed_objects->buffer_slab, commit);\n \tif (!(v && v->buffer == buffer))\n \t\tfree((void *)buffer);\n }\ndiff --git a/commit.h b/commit.h\nindex fead381651..0976bf2562 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -130,7 +130,12 @@ const void *repo_get_commit_buffer(struct repository *r,\n  * from an earlier call to get_commit_buffer.  The buffer may or may not be\n  * freed by this call; callers should not access the memory afterwards.\n  */\n-void unuse_commit_buffer(const struct commit *, const void *buffer);\n+void repo_unuse_commit_buffer(struct repository *r,\n+\t\t\t      const struct commit *,\n+\t\t\t      const void *buffer);\n+#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS\n+#define unuse_commit_buffer(c, b) repo_unuse_commit_buffer(the_repository, c, b)\n+#endif\n \n /*\n  * Free any cached object buffer associated with the commit.\ndiff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci\nindex ec579682f6..8c07185195 100644\n--- a/contrib/coccinelle/the_repository.cocci\n+++ b/contrib/coccinelle/the_repository.cocci\n@@ -69,6 +69,14 @@ expression F;\n + repo_get_commit_buffer(the_repository,\n   E, F);\n \n+@@\n+expression E;\n+expression F;\n+@@\n+- unuse_commit_buffer(\n++ repo_unuse_commit_buffer(the_repository,\n+  E, F);\n+\n @@\n expression E;\n expression F;\n-- \n2.19.0\n\n"},{"id":"360226","messageId":"20181011211754.31369-16-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 15/19] commit: prepare logmsg_reencode to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:50Z","receivedAt":"2018-10-11T21:18:35Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.h                                |  8 ++++++++\n contrib/coccinelle/the_repository.cocci |  9 +++++++++\n pretty.c                                | 13 +++++++------\n 3 files changed, 24 insertions(+), 6 deletions(-)\n\ndiff --git a/commit.h b/commit.h\nindex 0976bf2562..61b05ddd91 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -180,6 +180,14 @@ extern int has_non_ascii(const char *text);\n extern const char *logmsg_reencode(const struct commit *commit,\n \t\t\t\t   char **commit_encoding,\n \t\t\t\t   const char *output_encoding);\n+const char *repo_logmsg_reencode(struct repository *r,\n+\t\t\t\t const struct commit *commit,\n+\t\t\t\t char **commit_encoding,\n+\t\t\t\t const char *output_encoding);\n+#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS\n+#define logmsg_reencode(c, enc, out) repo_logmsg_reencode(the_repository, c, enc, out)\n+#endif\n+\n extern const char *skip_blank_lines(const char *msg);\n \n /** Removes the first commit from a list sorted by date, and adds all\ndiff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci\nindex 8c07185195..c81708bb73 100644\n--- a/contrib/coccinelle/the_repository.cocci\n+++ b/contrib/coccinelle/the_repository.cocci\n@@ -93,3 +93,12 @@ expression G;\n - in_merge_bases_many(\n + repo_in_merge_bases_many(the_repository,\n   E, F, G);\n+\n+@@\n+expression E;\n+expression F;\n+expression G;\n+@@\n+- logmsg_reencode(\n++ repo_logmsg_reencode(the_repository,\n+  E, F, G);\ndiff --git a/pretty.c b/pretty.c\nindex 98cf5228f9..26e44472bb 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -595,14 +595,15 @@ static char *replace_encoding_header(char *buf, const char *encoding)\n \treturn strbuf_detach(&tmp, NULL);\n }\n \n-const char *logmsg_reencode(const struct commit *commit,\n-\t\t\t    char **commit_encoding,\n-\t\t\t    const char *output_encoding)\n+const char *repo_logmsg_reencode(struct repository *r,\n+\t\t\t\t const struct commit *commit,\n+\t\t\t\t char **commit_encoding,\n+\t\t\t\t const char *output_encoding)\n {\n \tstatic const char *utf8 = \"UTF-8\";\n \tconst char *use_encoding;\n \tchar *encoding;\n-\tconst char *msg = get_commit_buffer(commit, NULL);\n+\tconst char *msg = repo_get_commit_buffer(r, commit, NULL);\n \tchar *out;\n \n \tif (!output_encoding || !*output_encoding) {\n@@ -630,7 +631,7 @@ const char *logmsg_reencode(const struct commit *commit,\n \t\t * the cached copy from get_commit_buffer, we need to duplicate it\n \t\t * to avoid munging the cached copy.\n \t\t */\n-\t\tif (msg == get_cached_commit_buffer(the_repository, commit, NULL))\n+\t\tif (msg == get_cached_commit_buffer(r, commit, NULL))\n \t\t\tout = xstrdup(msg);\n \t\telse\n \t\t\tout = (char *)msg;\n@@ -644,7 +645,7 @@ const char *logmsg_reencode(const struct commit *commit,\n \t\t */\n \t\tout = reencode_string(msg, output_encoding, use_encoding);\n \t\tif (out)\n-\t\t\tunuse_commit_buffer(commit, msg);\n+\t\t\trepo_unuse_commit_buffer(r, commit, msg);\n \t}\n \n \t/*\n-- \n2.19.0\n\n"},{"id":"360227","messageId":"20181011211754.31369-17-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 16/19] pretty: prepare format_commit_message to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:51Z","receivedAt":"2018-10-11T21:18:36Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n contrib/coccinelle/the_repository.cocci | 10 ++++++++++\n pretty.c                                | 15 ++++++++-------\n pretty.h                                |  7 ++++++-\n 3 files changed, 24 insertions(+), 8 deletions(-)\n\ndiff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci\nindex c81708bb73..c86decd418 100644\n--- a/contrib/coccinelle/the_repository.cocci\n+++ b/contrib/coccinelle/the_repository.cocci\n@@ -102,3 +102,13 @@ expression G;\n - logmsg_reencode(\n + repo_logmsg_reencode(the_repository,\n   E, F, G);\n+\n+@@\n+expression E;\n+expression F;\n+expression G;\n+expression H;\n+@@\n+- format_commit_message(\n++ repo_format_commit_message(the_repository,\n+  E, F, G, H);\ndiff --git a/pretty.c b/pretty.c\nindex 26e44472bb..948f5346cf 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1505,9 +1505,10 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)\n \tstrbuf_release(&dummy);\n }\n \n-void format_commit_message(const struct commit *commit,\n-\t\t\t   const char *format, struct strbuf *sb,\n-\t\t\t   const struct pretty_print_context *pretty_ctx)\n+void repo_format_commit_message(struct repository *r,\n+\t\t\t\tconst struct commit *commit,\n+\t\t\t\tconst char *format, struct strbuf *sb,\n+\t\t\t\tconst struct pretty_print_context *pretty_ctx)\n {\n \tstruct format_commit_context context;\n \tconst char *output_enc = pretty_ctx->output_encoding;\n@@ -1521,9 +1522,9 @@ void format_commit_message(const struct commit *commit,\n \t * convert a commit message to UTF-8 first\n \t * as far as 'format_commit_item' assumes it in UTF-8\n \t */\n-\tcontext.message = logmsg_reencode(commit,\n-\t\t\t\t\t  &context.commit_encoding,\n-\t\t\t\t\t  utf8);\n+\tcontext.message = repo_logmsg_reencode(r, commit,\n+\t\t\t\t\t       &context.commit_encoding,\n+\t\t\t\t\t       utf8);\n \n \tstrbuf_expand(sb, format, format_commit_item, &context);\n \trewrap_message_tail(sb, &context, 0, 0, 0);\n@@ -1547,7 +1548,7 @@ void format_commit_message(const struct commit *commit,\n \t}\n \n \tfree(context.commit_encoding);\n-\tunuse_commit_buffer(commit, context.message);\n+\trepo_unuse_commit_buffer(r, commit, context.message);\n }\n \n static void pp_header(struct pretty_print_context *pp,\ndiff --git a/pretty.h b/pretty.h\nindex 7359d318a9..e6625269cf 100644\n--- a/pretty.h\n+++ b/pretty.h\n@@ -103,9 +103,14 @@ void pp_remainder(struct pretty_print_context *pp, const char **msg_p,\n  * Put the result to \"sb\".\n  * Please use this function for custom formats.\n  */\n-void format_commit_message(const struct commit *commit,\n+void repo_format_commit_message(struct repository *r,\n+\t\t\tconst struct commit *commit,\n \t\t\tconst char *format, struct strbuf *sb,\n \t\t\tconst struct pretty_print_context *context);\n+#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS\n+#define format_commit_message(c, f, s, con) \\\n+\trepo_format_commit_message(the_repository, c, f, s, con)\n+#endif\n \n /*\n  * Parse given arguments from \"arg\", check it for correctness and\n-- \n2.19.0\n\n"},{"id":"360228","messageId":"20181011211754.31369-18-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 17/19] submodule: use submodule repos for object lookup","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:52Z","receivedAt":"2018-10-11T21:18:39Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This converts the 'show_submodule_header' function to use\nthe repository API properly, such that the submodule objects\nare not added to the main object store.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n submodule.c | 48 ++++++++++++++++++++++++++++++++++++++----------\n 1 file changed, 38 insertions(+), 10 deletions(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex 442229bb49..5e1a6c0b7c 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -443,7 +443,7 @@ static int prepare_submodule_summary(struct rev_info *rev, const char *path,\n \treturn prepare_revision_walk(rev);\n }\n \n-static void print_submodule_summary(struct rev_info *rev, struct diff_options *o)\n+static void print_submodule_summary(struct repository *r, struct rev_info *rev, struct diff_options *o)\n {\n \tstatic const char format[] = \"  %m %s\";\n \tstruct strbuf sb = STRBUF_INIT;\n@@ -454,7 +454,8 @@ static void print_submodule_summary(struct rev_info *rev, struct diff_options *o\n \t\tctx.date_mode = rev->date_mode;\n \t\tctx.output_encoding = get_log_output_encoding();\n \t\tstrbuf_setlen(&sb, 0);\n-\t\tformat_commit_message(commit, format, &sb, &ctx);\n+\t\trepo_format_commit_message(r, commit, format, &sb,\n+\t\t\t\t      &ctx);\n \t\tstrbuf_addch(&sb, '\\n');\n \t\tif (commit->object.flags & SYMMETRIC_LEFT)\n \t\t\tdiff_emit_submodule_del(o, sb.buf);\n@@ -481,12 +482,37 @@ void prepare_submodule_repo_env(struct argv_array *out)\n \t\t\t DEFAULT_GIT_DIR_ENVIRONMENT);\n }\n \n+/*\n+ * Initialize 'out' based on the provided submodule path.\n+ *\n+ * Unlike repo_submodule_init, this tolerates submodules not present\n+ * in .gitmodules. NEEDSWORK: The repo_submodule_init behavior is\n+ * preferrable. This function exists only to preserve historical behavior.\n+ *\n+ * Returns 0 on success, -1 when the submodule is not present.\n+ */\n+static int open_submodule(struct repository *out, const char *path)\n+{\n+\tstruct strbuf sb = STRBUF_INIT;\n+\n+\tif (submodule_to_gitdir(&sb, path) || repo_init(out, sb.buf, NULL)) {\n+\t\tstrbuf_release(&sb);\n+\t\treturn -1;\n+\t}\n+\n+\tout->submodule_prefix = xstrdup(path);\n+\n+\tstrbuf_release(&sb);\n+\treturn 0;\n+}\n+\n /* Helper function to display the submodule header line prior to the full\n  * summary output. If it can locate the submodule objects directory it will\n  * attempt to lookup both the left and right commits and put them into the\n  * left and right pointers.\n  */\n-static void show_submodule_header(struct diff_options *o, const char *path,\n+static void show_submodule_header(struct diff_options *o, struct repository *sub,\n+\t\tconst char *path,\n \t\tstruct object_id *one, struct object_id *two,\n \t\tunsigned dirty_submodule,\n \t\tstruct commit **left, struct commit **right,\n@@ -507,7 +533,7 @@ static void show_submodule_header(struct diff_options *o, const char *path,\n \telse if (is_null_oid(two))\n \t\tmessage = \"(submodule deleted)\";\n \n-\tif (add_submodule_odb(path)) {\n+\tif (open_submodule(sub, path) < 0) {\n \t\tif (!message)\n \t\t\tmessage = \"(commits not present)\";\n \t\tgoto output_header;\n@@ -517,8 +543,8 @@ static void show_submodule_header(struct diff_options *o, const char *path,\n \t * Attempt to lookup the commit references, and determine if this is\n \t * a fast forward or fast backwards update.\n \t */\n-\t*left = lookup_commit_reference(the_repository, one);\n-\t*right = lookup_commit_reference(the_repository, two);\n+\t*left = lookup_commit_reference(sub, one);\n+\t*right = lookup_commit_reference(sub, two);\n \n \t/*\n \t * Warn about missing commits in the submodule project, but only if\n@@ -528,7 +554,7 @@ static void show_submodule_header(struct diff_options *o, const char *path,\n \t     (!is_null_oid(two) && !*right))\n \t\tmessage = \"(commits not present)\";\n \n-\t*merge_bases = get_merge_bases(*left, *right);\n+\t*merge_bases = repo_get_merge_bases(sub, *left, *right);\n \tif (*merge_bases) {\n \t\tif ((*merge_bases)->item == *left)\n \t\t\tfast_forward = 1;\n@@ -562,8 +588,9 @@ void show_submodule_summary(struct diff_options *o, const char *path,\n \tstruct rev_info rev;\n \tstruct commit *left = NULL, *right = NULL;\n \tstruct commit_list *merge_bases = NULL;\n+\tstruct repository sub;\n \n-\tshow_submodule_header(o, path, one, two, dirty_submodule,\n+\tshow_submodule_header(o, &sub, path, one, two, dirty_submodule,\n \t\t\t      &left, &right, &merge_bases);\n \n \t/*\n@@ -580,7 +607,7 @@ void show_submodule_summary(struct diff_options *o, const char *path,\n \t\tgoto out;\n \t}\n \n-\tprint_submodule_summary(&rev, o);\n+\tprint_submodule_summary(&sub, &rev, o);\n \n out:\n \tif (merge_bases)\n@@ -598,8 +625,9 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,\n \tstruct commit_list *merge_bases = NULL;\n \tstruct child_process cp = CHILD_PROCESS_INIT;\n \tstruct strbuf sb = STRBUF_INIT;\n+\tstruct repository sub;\n \n-\tshow_submodule_header(o, path, one, two, dirty_submodule,\n+\tshow_submodule_header(o, &sub, path, one, two, dirty_submodule,\n \t\t\t      &left, &right, &merge_bases);\n \n \t/* We need a valid left and right commit to display a difference */\n-- \n2.19.0\n\n"},{"id":"360229","messageId":"20181011211754.31369-19-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 18/19] submodule: don't add submodule as odb for push","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:53Z","receivedAt":"2018-10-11T21:18:41Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"The submodule was added as an alternative in eb21c732d6 (push: teach\n--recurse-submodules the on-demand option, 2012-03-29), but was\nnot explained, why.\n\nIn similar code, submodule_has_commits, the submodule is added as an\nalternative to perform a quick check if we need to dive into the submodule.\n\nHowever in push_submodule\n(a) for_each_remote_ref_submodule will also provide the quick check and\n(b) after that we don't need to have submodule objects around, as all\n    further code is to spawn a separate process.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n submodule.c | 3 ---\n 1 file changed, 3 deletions(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex 5e1a6c0b7c..f70d75ef45 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -1006,9 +1006,6 @@ static int push_submodule(const char *path,\n \t\t\t  const struct string_list *push_options,\n \t\t\t  int dry_run)\n {\n-\tif (add_submodule_odb(path))\n-\t\treturn 1;\n-\n \tif (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) {\n \t\tstruct child_process cp = CHILD_PROCESS_INIT;\n \t\targv_array_push(&cp.args, \"push\");\n-- \n2.19.0\n\n"},{"id":"360230","messageId":"20181011211754.31369-20-sbeller@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"[PATCH 19/19] Apply semantic patches from previous patches","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T21:17:54Z","receivedAt":"2018-10-11T21:18:46Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Previous commits added some cocci rules, but did not patch the whole tree,\nas to not dilute the focus for reviewing the previous patches.\n\nThis patch is generated by 'make coccicheck' and applying the resulting\ndiff, which was white space damaged (>8 spaces after a tab) in blame.c,\nwhich has been fixed.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n apply.c                          |  6 ++--\n archive.c                        |  5 +--\n bisect.c                         |  5 +--\n blame.c                          | 15 +++++----\n builtin/am.c                     |  2 +-\n builtin/blame.c                  |  4 +--\n builtin/cat-file.c               | 21 +++++++-----\n builtin/checkout.c               |  4 +--\n builtin/commit.c                 | 13 +++++---\n builtin/describe.c               |  4 +--\n builtin/difftool.c               |  3 +-\n builtin/fast-export.c            |  7 ++--\n builtin/fmt-merge-msg.c          |  8 +++--\n builtin/grep.c                   |  2 +-\n builtin/index-pack.c             |  8 +++--\n builtin/log.c                    |  4 +--\n builtin/merge-base.c             |  2 +-\n builtin/merge-tree.c             |  9 ++++--\n builtin/mktag.c                  |  3 +-\n builtin/name-rev.c               |  2 +-\n builtin/notes.c                  | 12 ++++---\n builtin/pack-objects.c           | 22 +++++++++----\n builtin/reflog.c                 |  5 +--\n builtin/replace.c                |  2 +-\n builtin/shortlog.c               |  5 +--\n builtin/show-branch.c            |  4 +--\n builtin/tag.c                    |  4 +--\n builtin/unpack-file.c            |  2 +-\n builtin/unpack-objects.c         |  3 +-\n builtin/verify-commit.c          |  2 +-\n bundle.c                         |  2 +-\n combine-diff.c                   |  2 +-\n commit-graph.c                   |  8 ++---\n commit.c                         | 15 +++++----\n config.c                         |  2 +-\n diff.c                           |  3 +-\n dir.c                            |  2 +-\n entry.c                          |  3 +-\n fast-import.c                    |  7 ++--\n fsck.c                           |  9 +++---\n grep.c                           |  3 +-\n http-push.c                      |  3 +-\n log-tree.c                       |  3 +-\n mailmap.c                        |  2 +-\n match-trees.c                    |  4 +--\n merge-blobs.c                    |  6 ++--\n merge-recursive.c                | 13 ++++----\n negotiator/default.c             |  6 ++--\n negotiator/skipping.c            |  2 +-\n notes-cache.c                    |  5 +--\n notes-merge.c                    |  4 +--\n notes-utils.c                    |  2 +-\n notes.c                          | 10 +++---\n pretty.c                         |  5 +--\n read-cache.c                     |  5 +--\n remote-testsvn.c                 |  4 +--\n remote.c                         |  2 +-\n rerere.c                         |  5 +--\n revision.c                       | 12 +++----\n sequencer.c                      | 55 +++++++++++++++++++-------------\n sha1-file.c                      |  3 +-\n sha1-name.c                      |  9 +++---\n shallow.c                        |  4 +--\n submodule-config.c               |  3 +-\n t/helper/test-revision-walking.c |  3 +-\n tag.c                            |  5 +--\n tree-walk.c                      |  6 ++--\n tree.c                           |  5 +--\n walker.c                         |  2 +-\n xdiff-interface.c                |  2 +-\n 70 files changed, 254 insertions(+), 180 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex fdae1d423b..5ac284b7e8 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3187,7 +3187,8 @@ static int apply_binary(struct apply_state *state,\n \t\tunsigned long size;\n \t\tchar *result;\n \n-\t\tresult = read_object_file(&oid, &type, &size);\n+\t\tresult = repo_read_object_file(the_repository, &oid, &type,\n+\t\t\t\t\t       &size);\n \t\tif (!result)\n \t\t\treturn error(_(\"the necessary postimage %s for \"\n \t\t\t\t       \"'%s' cannot be read\"),\n@@ -3249,7 +3250,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns\n \t\tunsigned long sz;\n \t\tchar *result;\n \n-\t\tresult = read_object_file(oid, &type, &sz);\n+\t\tresult = repo_read_object_file(the_repository, oid, &type,\n+\t\t\t\t\t       &sz);\n \t\tif (!result)\n \t\t\treturn -1;\n \t\t/* XXX read_sha1_file NUL-terminates */\ndiff --git a/archive.c b/archive.c\nindex 994495af05..70e5eed535 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -55,7 +55,8 @@ static void format_subst(const struct commit *commit,\n \t\tstrbuf_add(&fmt, b + 8, c - b - 8);\n \n \t\tstrbuf_add(buf, src, b - src);\n-\t\tformat_commit_message(commit, fmt.buf, buf, &ctx);\n+\t\trepo_format_commit_message(the_repository, commit, fmt.buf,\n+\t\t\t\t\t   buf, &ctx);\n \t\tlen -= c + 1 - src;\n \t\tsrc  = c + 1;\n \t}\n@@ -73,7 +74,7 @@ void *object_file_to_archive(const struct archiver_args *args,\n \tconst struct commit *commit = args->convert ? args->commit : NULL;\n \n \tpath += args->baselen;\n-\tbuffer = read_object_file(oid, type, sizep);\n+\tbuffer = repo_read_object_file(the_repository, oid, type, sizep);\n \tif (buffer && S_ISREG(mode)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tsize_t size = 0;\ndiff --git a/bisect.c b/bisect.c\nindex 6ae5e5b49e..ae92367738 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -136,8 +136,9 @@ static void show_list(const char *debug, int counted, int nr,\n \t\tunsigned flags = commit->object.flags;\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tchar *buf = read_object_file(&commit->object.oid, &type,\n-\t\t\t\t\t     &size);\n+\t\tchar *buf = repo_read_object_file(the_repository,\n+\t\t\t\t\t\t  &commit->object.oid, &type,\n+\t\t\t\t\t\t  &size);\n \t\tconst char *subject_start;\n \t\tint subject_len;\n \ndiff --git a/blame.c b/blame.c\nindex c229a10c0e..fc2764d036 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -322,8 +322,9 @@ static void fill_origin_blob(struct diff_options *opt,\n \t\t\t\t    &o->blob_oid, 1, &file->ptr, &file_size))\n \t\t\t;\n \t\telse\n-\t\t\tfile->ptr = read_object_file(&o->blob_oid, &type,\n-\t\t\t\t\t\t     &file_size);\n+\t\t\tfile->ptr = repo_read_object_file(the_repository,\n+\t\t\t\t\t\t\t  &o->blob_oid, &type,\n+\t\t\t\t\t\t\t  &file_size);\n \t\tfile->size = file_size;\n \n \t\tif (!file->ptr)\n@@ -1455,7 +1456,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,\n \n \t\t\tif (sg_origin[i])\n \t\t\t\tcontinue;\n-\t\t\tif (parse_commit(p))\n+\t\t\tif (repo_parse_commit(the_repository, p))\n \t\t\t\tcontinue;\n \t\t\tporigin = find(sb->repo, p, origin);\n \t\t\tif (!porigin)\n@@ -1594,7 +1595,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt)\n \t\t * so hold onto it in the meantime.\n \t\t */\n \t\tblame_origin_incref(suspect);\n-\t\tparse_commit(commit);\n+\t\trepo_parse_commit(the_repository, commit);\n \t\tif (sb->reverse ||\n \t\t    (!(commit->object.flags & UNINTERESTING) &&\n \t\t     !(revs->max_age != -1 && commit->date < revs->max_age)))\n@@ -1864,8 +1865,10 @@ void setup_scoreboard(struct blame_scoreboard *sb,\n \t\t\t\t    &sb->final_buf_size))\n \t\t\t;\n \t\telse\n-\t\t\tsb->final_buf = read_object_file(&o->blob_oid, &type,\n-\t\t\t\t\t\t\t &sb->final_buf_size);\n+\t\t\tsb->final_buf = repo_read_object_file(the_repository,\n+\t\t\t\t\t\t\t      &o->blob_oid,\n+\t\t\t\t\t\t\t      &type,\n+\t\t\t\t\t\t\t      &sb->final_buf_size);\n \n \t\tif (!sb->final_buf)\n \t\t\tdie(_(\"cannot read blob %s for path %s\"),\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 601570dbef..3c992a93fb 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1360,7 +1360,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)\n \t\tdie(_(\"unable to parse commit %s\"), oid_to_hex(&commit->object.oid));\n \tstate->msg = xstrdup(msg + 2);\n \tstate->msg_len = strlen(state->msg);\n-\tunuse_commit_buffer(commit, buffer);\n+\trepo_unuse_commit_buffer(the_repository, commit, buffer);\n }\n \n /**\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex a443af9ee9..dcd300c0d3 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -197,7 +197,7 @@ static void get_commit_info(struct commit *commit,\n \t\t    &ret->author_time, &ret->author_tz);\n \n \tif (!detailed) {\n-\t\tunuse_commit_buffer(commit, message);\n+\t\trepo_unuse_commit_buffer(the_repository, commit, message);\n \t\treturn;\n \t}\n \n@@ -211,7 +211,7 @@ static void get_commit_info(struct commit *commit,\n \telse\n \t\tstrbuf_addf(&ret->summary, \"(%s)\", oid_to_hex(&commit->object.oid));\n \n-\tunuse_commit_buffer(commit, message);\n+\trepo_unuse_commit_buffer(the_repository, commit, message);\n }\n \n /*\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 8d97c84725..afad7b1c84 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -34,7 +34,7 @@ static int filter_object(const char *path, unsigned mode,\n {\n \tenum object_type type;\n \n-\t*buf = read_object_file(oid, &type, size);\n+\t*buf = repo_read_object_file(the_repository, oid, &type, size);\n \tif (!*buf)\n \t\treturn error(_(\"cannot read object %s '%s'\"),\n \t\t\t     oid_to_hex(oid), path);\n@@ -133,7 +133,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \n \t\tif (type == OBJ_BLOB)\n \t\t\treturn stream_blob_to_fd(1, &oid, NULL, 0);\n-\t\tbuf = read_object_file(&oid, &type, &size);\n+\t\tbuf = repo_read_object_file(the_repository, &oid, &type,\n+\t\t\t\t\t    &size);\n \t\tif (!buf)\n \t\t\tdie(\"Cannot read object %s\", obj_name);\n \n@@ -144,8 +145,10 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\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(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\tchar *buffer = repo_read_object_file(the_repository,\n+\t\t\t\t\t\t\t\t     &oid,\n+\t\t\t\t\t\t\t\t     &type,\n+\t\t\t\t\t\t\t\t     &size);\n \t\t\t\tconst char *target;\n \t\t\t\tif (!skip_prefix(buffer, \"object \", &target) ||\n \t\t\t\t    get_oid_hex(target, &blob_oid))\n@@ -309,9 +312,10 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\t\t\tif (!textconv_object(the_repository,\n \t\t\t\t\t\t     data->rest, 0100644, oid,\n \t\t\t\t\t\t     1, &contents, &size))\n-\t\t\t\t\tcontents = read_object_file(oid,\n-\t\t\t\t\t\t\t\t    &type,\n-\t\t\t\t\t\t\t\t    &size);\n+\t\t\t\t\tcontents = repo_read_object_file(the_repository,\n+\t\t\t\t\t\t\t\t\t oid,\n+\t\t\t\t\t\t\t\t\t &type,\n+\t\t\t\t\t\t\t\t\t &size);\n \t\t\t\tif (!contents)\n \t\t\t\t\tdie(\"could not convert '%s' %s\",\n \t\t\t\t\t    oid_to_hex(oid), data->rest);\n@@ -327,7 +331,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\tunsigned long size;\n \t\tvoid *contents;\n \n-\t\tcontents = read_object_file(oid, &type, &size);\n+\t\tcontents = repo_read_object_file(the_repository, oid, &type,\n+\t\t\t\t\t\t &size);\n \t\tif (!contents)\n \t\t\tdie(\"object %s disappeared\", oid_to_hex(oid));\n \t\tif (type != data->type)\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex ae28478ff8..0be05e0665 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -404,7 +404,7 @@ static void describe_detached_head(const char *msg, struct commit *commit)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n \n-\tif (!parse_commit(commit))\n+\tif (!repo_parse_commit(the_repository, commit))\n \t\tpp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);\n \tif (print_sha1_ellipsis()) {\n \t\tfprintf(stderr, \"%s %s... %s\\n\", msg,\n@@ -732,7 +732,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)\n \tstrbuf_addstr(sb, \"  \");\n \tstrbuf_add_unique_abbrev(sb, &commit->object.oid, DEFAULT_ABBREV);\n \tstrbuf_addch(sb, ' ');\n-\tif (!parse_commit(commit))\n+\tif (!repo_parse_commit(the_repository, commit))\n \t\tpp_commit_easy(CMIT_FMT_ONELINE, commit, sb);\n \tstrbuf_addch(sb, '\\n');\n }\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 9d8ce6cb3b..4c07dc5681 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -680,8 +680,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\tif (!c)\n \t\t\t\tdie(_(\"could not lookup commit %s\"), squash_message);\n \t\t\tctx.output_encoding = get_commit_output_encoding();\n-\t\t\tformat_commit_message(c, \"squash! %s\\n\\n\", &sb,\n-\t\t\t\t\t      &ctx);\n+\t\t\trepo_format_commit_message(the_repository, c,\n+\t\t\t\t\t\t   \"squash! %s\\n\\n\", &sb,\n+\t\t\t\t\t\t   &ctx);\n \t\t}\n \t}\n \n@@ -713,8 +714,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\tif (!commit)\n \t\t\tdie(_(\"could not lookup commit %s\"), fixup_message);\n \t\tctx.output_encoding = get_commit_output_encoding();\n-\t\tformat_commit_message(commit, \"fixup! %s\\n\\n\",\n-\t\t\t\t      &sb, &ctx);\n+\t\trepo_format_commit_message(the_repository, commit,\n+\t\t\t\t\t   \"fixup! %s\\n\\n\",\n+\t\t\t\t\t   &sb, &ctx);\n \t\tif (have_option_m)\n \t\t\tstrbuf_addbuf(&sb, &message);\n \t\thook_arg1 = \"message\";\n@@ -997,7 +999,8 @@ static const char *find_author_by_nickname(const char *name)\n \t\tstruct pretty_print_context ctx = {0};\n \t\tctx.date_mode.type = DATE_NORMAL;\n \t\tstrbuf_release(&buf);\n-\t\tformat_commit_message(commit, \"%aN <%aE>\", &buf, &ctx);\n+\t\trepo_format_commit_message(the_repository, commit,\n+\t\t\t\t\t   \"%aN <%aE>\", &buf, &ctx);\n \t\tclear_mailmap(&mailmap);\n \t\treturn strbuf_detach(&buf, NULL);\n \t}\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 1fde0563fe..290218c0d9 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -254,7 +254,7 @@ static unsigned long finish_depth_computation(\n \t\t\tbest->depth++;\n \t\twhile (parents) {\n \t\t\tstruct commit *p = parents->item;\n-\t\t\tparse_commit(p);\n+\t\t\trepo_parse_commit(the_repository, p);\n \t\t\tif (!(p->object.flags & SEEN))\n \t\t\t\tcommit_list_insert_by_date(p, list);\n \t\t\tp->object.flags |= c->object.flags;\n@@ -381,7 +381,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)\n \t\t}\n \t\twhile (parents) {\n \t\t\tstruct commit *p = parents->item;\n-\t\t\tparse_commit(p);\n+\t\t\trepo_parse_commit(the_repository, p);\n \t\t\tif (!(p->object.flags & SEEN))\n \t\t\t\tcommit_list_insert_by_date(p, &list);\n \t\t\tp->object.flags |= c->object.flags;\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex e7023e3adf..23720d4d64 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -307,7 +307,8 @@ static char *get_symlink(const struct object_id *oid, const char *path)\n \t} else {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tdata = read_object_file(oid, &type, &size);\n+\t\tdata = repo_read_object_file(the_repository, oid, &type,\n+\t\t\t\t\t     &size);\n \t\tif (!data)\n \t\t\tdie(_(\"could not read object %s for symlink %s\"),\n \t\t\t\toid_to_hex(oid), path);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 9bd4a95a47..9e65697524 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -239,7 +239,7 @@ static void export_blob(const struct object_id *oid)\n \t\tobject = (struct object *)lookup_blob(the_repository, oid);\n \t\teaten = 0;\n \t} else {\n-\t\tbuf = read_object_file(oid, &type, &size);\n+\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"could not read blob %s\", oid_to_hex(oid));\n \t\tif (check_object_signature(oid, buf, size, type_name(type)) < 0)\n@@ -617,7 +617,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,\n \t\t\t  ? strlen(message) : 0),\n \t       reencoded ? reencoded : message ? message : \"\");\n \tfree(reencoded);\n-\tunuse_commit_buffer(commit, commit_buffer);\n+\trepo_unuse_commit_buffer(the_repository, commit, commit_buffer);\n \n \tfor (i = 0, p = commit->parents; p; p = p->next) {\n \t\tint mark = get_object_mark(&p->item->object);\n@@ -689,7 +689,8 @@ static void handle_tag(const char *name, struct tag *tag)\n \t\treturn;\n \t}\n \n-\tbuf = read_object_file(&tag->object.oid, &type, &size);\n+\tbuf = repo_read_object_file(the_repository, &tag->object.oid, &type,\n+\t\t\t\t    &size);\n \tif (!buf)\n \t\tdie(\"could not read tag %s\", oid_to_hex(&tag->object.oid));\n \tmessage = memmem(buf, size, \"\\n\\n\", 2);\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 1adc84ed87..4248e3982d 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -264,7 +264,7 @@ static void record_person(int which, struct string_list *people,\n {\n \tconst char *buffer = get_commit_buffer(commit, NULL);\n \trecord_person_from_buf(which, people, buffer);\n-\tunuse_commit_buffer(commit, buffer);\n+\trepo_unuse_commit_buffer(the_repository, commit, buffer);\n }\n \n static int cmp_string_list_util_as_integral(const void *a_, const void *b_)\n@@ -375,7 +375,8 @@ static void shortlog(const char *name,\n \t\tif (subjects.nr > limit)\n \t\t\tcontinue;\n \n-\t\tformat_commit_message(commit, \"%s\", &sb, &ctx);\n+\t\trepo_format_commit_message(the_repository, commit, \"%s\", &sb,\n+\t\t\t\t\t   &ctx);\n \t\tstrbuf_ltrim(&sb);\n \n \t\tif (!sb.len)\n@@ -493,7 +494,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \t\tstruct object_id *oid = origins.items[i].util;\n \t\tenum object_type type;\n \t\tunsigned long size, len;\n-\t\tchar *buf = read_object_file(oid, &type, &size);\n+\t\tchar *buf = repo_read_object_file(the_repository, oid, &type,\n+\t\t\t\t\t\t  &size);\n \t\tstruct strbuf sig = STRBUF_INIT;\n \n \t\tif (!buf || type != OBJ_TAG)\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 0c3527242e..06f7711330 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -308,7 +308,7 @@ static void *lock_and_read_oid_file(const struct object_id *oid, enum object_typ\n \tvoid *data;\n \n \tgrep_read_lock();\n-\tdata = read_object_file(oid, type, size);\n+\tdata = repo_read_object_file(the_repository, oid, type, size);\n \tgrep_read_unlock();\n \treturn data;\n }\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 9582ead950..887c44e111 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -817,7 +817,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \t\t\tdie(_(\"cannot read existing object info %s\"), oid_to_hex(oid));\n \t\tif (has_type != type || has_size != size)\n \t\t\tdie(_(\"SHA1 COLLISION FOUND WITH %s !\"), oid_to_hex(oid));\n-\t\thas_data = read_object_file(oid, &has_type, &has_size);\n+\t\thas_data = repo_read_object_file(the_repository, oid,\n+\t\t\t\t\t\t &has_type, &has_size);\n \t\tread_unlock();\n \t\tif (!data)\n \t\t\tdata = new_data = get_data_from_pack(obj_entry);\n@@ -1379,8 +1380,9 @@ static void fix_unresolved_deltas(struct hashfile *f)\n \n \t\tif (objects[d->obj_no].real_type != OBJ_REF_DELTA)\n \t\t\tcontinue;\n-\t\tbase_obj->data = read_object_file(&d->oid, &type,\n-\t\t\t\t\t\t  &base_obj->size);\n+\t\tbase_obj->data = repo_read_object_file(the_repository,\n+\t\t\t\t\t\t       &d->oid, &type,\n+\t\t\t\t\t\t       &base_obj->size);\n \t\tif (!base_obj->data)\n \t\t\tcontinue;\n \ndiff --git a/builtin/log.c b/builtin/log.c\nindex 717d20e115..d4709ec63d 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -525,7 +525,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = read_object_file(oid, &type, &size);\n+\tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n \tint offset = 0;\n \n \tif (!buf)\n@@ -1032,7 +1032,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,\n \t\tconst char *buf = get_commit_buffer(list[i], NULL);\n \t\tif (has_non_ascii(buf))\n \t\t\tneed_8bit_cte = 1;\n-\t\tunuse_commit_buffer(list[i], buf);\n+\t\trepo_unuse_commit_buffer(the_repository, list[i], buf);\n \t}\n \n \tif (!branch_name)\ndiff --git a/builtin/merge-base.c b/builtin/merge-base.c\nindex 08d91b1f0c..82567bf79c 100644\n--- a/builtin/merge-base.c\n+++ b/builtin/merge-base.c\n@@ -127,7 +127,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)\n \tcommit = lookup_commit(the_repository, oid);\n \tif (!commit ||\n \t    (commit->object.flags & TMP_MARK) ||\n-\t    parse_commit(commit))\n+\t    repo_parse_commit(the_repository, commit))\n \t\treturn;\n \n \tALLOC_GROW(revs->commit, revs->nr + 1, revs->alloc);\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex f32941fdab..99403f70f4 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -62,7 +62,9 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \tconst char *path = entry->path;\n \n \tif (!entry->stage)\n-\t\treturn read_object_file(&entry->blob->object.oid, &type, size);\n+\t\treturn repo_read_object_file(the_repository,\n+\t\t\t\t\t     &entry->blob->object.oid, &type,\n+\t\t\t\t\t     size);\n \tbase = NULL;\n \tif (entry->stage == 1) {\n \t\tbase = entry->blob;\n@@ -84,8 +86,9 @@ static void *origin(struct merge_list *entry, unsigned long *size)\n \tenum object_type type;\n \twhile (entry) {\n \t\tif (entry->stage == 2)\n-\t\t\treturn read_object_file(&entry->blob->object.oid,\n-\t\t\t\t\t\t&type, size);\n+\t\t\treturn repo_read_object_file(the_repository,\n+\t\t\t\t\t\t     &entry->blob->object.oid,\n+\t\t\t\t\t\t     &type, size);\n \t\tentry = entry->link;\n \t}\n \treturn NULL;\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 6fb7dc8578..be4366b03f 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -25,7 +25,8 @@ static int verify_object(const struct object_id *oid, const char *expected_type)\n \tint ret = -1;\n \tenum object_type type;\n \tunsigned long size;\n-\tvoid *buffer = read_object_file(oid, &type, &size);\n+\tvoid *buffer = repo_read_object_file(the_repository, oid, &type,\n+\t\t\t\t\t     &size);\n \tconst struct object_id *repl = lookup_replace_object(the_repository, oid);\n \n \tif (buffer) {\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex f1cb45c227..41f2de37e4 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -87,7 +87,7 @@ static void name_rev(struct commit *commit,\n \tint parent_number = 1;\n \tchar *to_free = NULL;\n \n-\tparse_commit(commit);\n+\trepo_parse_commit(the_repository, commit);\n \n \tif (commit->date < cutoff)\n \t\treturn;\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex c05cd004ab..7ce3e50b45 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -124,7 +124,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid)\n {\n \tunsigned long size;\n \tenum object_type type;\n-\tchar *buf = read_object_file(oid, &type, &size);\n+\tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n \tif (buf) {\n \t\tif (size)\n \t\t\twrite_or_die(fd, buf, size);\n@@ -255,7 +255,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n \n \tif (get_oid(arg, &object))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), arg);\n-\tif (!(buf = read_object_file(&object, &type, &len))) {\n+\tif (!(buf = repo_read_object_file(the_repository, &object, &type, &len))) {\n \t\tfree(buf);\n \t\tdie(_(\"failed to read object '%s'.\"), arg);\n \t}\n@@ -610,7 +610,8 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \t\t/* Append buf to previous note contents */\n \t\tunsigned long size;\n \t\tenum object_type type;\n-\t\tchar *prev_buf = read_object_file(note, &type, &size);\n+\t\tchar *prev_buf = repo_read_object_file(the_repository, note,\n+\t\t\t\t\t\t       &type, &size);\n \n \t\tstrbuf_grow(&d.buf, size + 1);\n \t\tif (d.buf.len && prev_buf && size)\n@@ -714,7 +715,7 @@ static int merge_commit(struct notes_merge_options *o)\n \t\tdie(_(\"failed to read ref NOTES_MERGE_PARTIAL\"));\n \telse if (!(partial = lookup_commit_reference(the_repository, &oid)))\n \t\tdie(_(\"could not find commit from NOTES_MERGE_PARTIAL.\"));\n-\telse if (parse_commit(partial))\n+\telse if (repo_parse_commit(the_repository, partial))\n \t\tdie(_(\"could not parse commit from NOTES_MERGE_PARTIAL.\"));\n \n \tif (partial->parents)\n@@ -735,7 +736,8 @@ static int merge_commit(struct notes_merge_options *o)\n \n \t/* Reuse existing commit message in reflog message */\n \tmemset(&pretty_ctx, 0, sizeof(pretty_ctx));\n-\tformat_commit_message(partial, \"%s\", &msg, &pretty_ctx);\n+\trepo_format_commit_message(the_repository, partial, \"%s\", &msg,\n+\t\t\t\t   &pretty_ctx);\n \tstrbuf_trim(&msg);\n \tstrbuf_insert(&msg, 0, \"notes: \", 7);\n \tupdate_ref(msg.buf, o->local_ref, &oid,\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 3383ba43d0..2d55b64433 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -138,11 +138,13 @@ static void *get_delta(struct object_entry *entry)\n \tvoid *buf, *base_buf, *delta_buf;\n \tenum object_type type;\n \n-\tbuf = read_object_file(&entry->idx.oid, &type, &size);\n+\tbuf = repo_read_object_file(the_repository, &entry->idx.oid, &type,\n+\t\t\t\t    &size);\n \tif (!buf)\n \t\tdie(_(\"unable to read %s\"), oid_to_hex(&entry->idx.oid));\n-\tbase_buf = read_object_file(&DELTA(entry)->idx.oid, &type,\n-\t\t\t\t    &base_size);\n+\tbase_buf = repo_read_object_file(the_repository,\n+\t\t\t\t\t &DELTA(entry)->idx.oid, &type,\n+\t\t\t\t\t &base_size);\n \tif (!base_buf)\n \t\tdie(\"unable to read %s\",\n \t\t    oid_to_hex(&DELTA(entry)->idx.oid));\n@@ -292,7 +294,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent\n \t\t    (st = open_istream(&entry->idx.oid, &type, &size, NULL)) != NULL)\n \t\t\tbuf = NULL;\n \t\telse {\n-\t\t\tbuf = read_object_file(&entry->idx.oid, &type, &size);\n+\t\t\tbuf = repo_read_object_file(the_repository,\n+\t\t\t\t\t\t    &entry->idx.oid, &type,\n+\t\t\t\t\t\t    &size);\n \t\t\tif (!buf)\n \t\t\t\tdie(_(\"unable to read %s\"),\n \t\t\t\t    oid_to_hex(&entry->idx.oid));\n@@ -1218,7 +1222,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n \t/* Did not find one.  Either we got a bogus request or\n \t * we need to read and perhaps cache.\n \t */\n-\tdata = read_object_file(oid, &type, &size);\n+\tdata = repo_read_object_file(the_repository, oid, &type, &size);\n \tif (!data)\n \t\treturn NULL;\n \tif (type != OBJ_TREE) {\n@@ -1989,7 +1993,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t/* Load data if not already done */\n \tif (!trg->data) {\n \t\tread_lock();\n-\t\ttrg->data = read_object_file(&trg_entry->idx.oid, &type, &sz);\n+\t\ttrg->data = repo_read_object_file(the_repository,\n+\t\t\t\t\t\t  &trg_entry->idx.oid, &type,\n+\t\t\t\t\t\t  &sz);\n \t\tread_unlock();\n \t\tif (!trg->data)\n \t\t\tdie(_(\"object %s cannot be read\"),\n@@ -2002,7 +2008,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t}\n \tif (!src->data) {\n \t\tread_lock();\n-\t\tsrc->data = read_object_file(&src_entry->idx.oid, &type, &sz);\n+\t\tsrc->data = repo_read_object_file(the_repository,\n+\t\t\t\t\t\t  &src_entry->idx.oid, &type,\n+\t\t\t\t\t\t  &sz);\n \t\tread_unlock();\n \t\tif (!src->data) {\n \t\t\tif (src_entry->preferred_base) {\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex b5941c1ff3..53a7f0c8e5 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -77,7 +77,8 @@ static int tree_is_complete(const struct object_id *oid)\n \tif (!tree->buffer) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n-\t\tvoid *data = read_object_file(oid, &type, &size);\n+\t\tvoid *data = repo_read_object_file(the_repository, oid, &type,\n+\t\t\t\t\t\t   &size);\n \t\tif (!data) {\n \t\t\ttree->object.flags |= INCOMPLETE;\n \t\t\treturn 0;\n@@ -235,7 +236,7 @@ static void mark_reachable(struct expire_reflog_policy_cb *cb)\n \t\tstruct commit *commit = pop_commit(&pending);\n \t\tif (commit->object.flags & REACHABLE)\n \t\t\tcontinue;\n-\t\tif (parse_commit(commit))\n+\t\tif (repo_parse_commit(the_repository, commit))\n \t\t\tcontinue;\n \t\tcommit->object.flags |= REACHABLE;\n \t\tif (commit->date < expire_limit) {\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex e0b16ad44b..48b44dba3e 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -449,7 +449,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle)\n \n \tbuffer = get_commit_buffer(commit, &size);\n \tstrbuf_add(&buf, buffer, size);\n-\tunuse_commit_buffer(commit, buffer);\n+\trepo_unuse_commit_buffer(the_repository, commit, buffer);\n \n \tif (replace_parents(&buf, argc - 1, &argv[1]) < 0) {\n \t\tstrbuf_release(&buf);\ndiff --git a/builtin/shortlog.c b/builtin/shortlog.c\nindex 88f88e97b2..d46df5af34 100644\n--- a/builtin/shortlog.c\n+++ b/builtin/shortlog.c\n@@ -170,12 +170,13 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)\n \t\t(log->email ? \"%cN <%cE>\" : \"%cN\") :\n \t\t(log->email ? \"%aN <%aE>\" : \"%aN\");\n \n-\tformat_commit_message(commit, fmt, &author, &ctx);\n+\trepo_format_commit_message(the_repository, commit, fmt, &author, &ctx);\n \tif (!log->summary) {\n \t\tif (log->user_format)\n \t\t\tpretty_print_commit(&ctx, commit, &oneline);\n \t\telse\n-\t\t\tformat_commit_message(commit, \"%s\", &oneline, &ctx);\n+\t\t\trepo_format_commit_message(the_repository, commit,\n+\t\t\t\t\t\t   \"%s\", &oneline, &ctx);\n \t}\n \n \tinsert_one_record(log, author.buf, oneline.len ? oneline.buf : \"<none>\");\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 363cf8509a..d7e8d6f15c 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -238,7 +238,7 @@ static void join_revs(struct commit_list **list_p,\n \t\t\tparents = parents->next;\n \t\t\tif ((this_flag & flags) == flags)\n \t\t\t\tcontinue;\n-\t\t\tparse_commit(p);\n+\t\t\trepo_parse_commit(the_repository, p);\n \t\t\tif (mark_seen(p, seen_p) && !still_interesting)\n \t\t\t\textra--;\n \t\t\tp->object.flags |= flags;\n@@ -835,7 +835,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\tif (!commit)\n \t\t\tdie(_(\"cannot find commit %s (%s)\"),\n \t\t\t    ref_name[num_rev], oid_to_hex(&revkey));\n-\t\tparse_commit(commit);\n+\t\trepo_parse_commit(the_repository, commit);\n \t\tmark_seen(commit, &seen);\n \n \t\t/* rev#0 uses bit REV_SHIFT, rev#1 uses bit REV_SHIFT+1,\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 9a19ffb49f..3aa1ea7f15 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -169,7 +169,7 @@ static void write_tag_body(int fd, const struct object_id *oid)\n \tenum object_type type;\n \tchar *buf, *sp;\n \n-\tbuf = read_object_file(oid, &type, &size);\n+\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n \tif (!buf)\n \t\treturn;\n \t/* skip header */\n@@ -305,7 +305,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \t\tstrbuf_addstr(sb, \"object of unknown type\");\n \t\tbreak;\n \tcase OBJ_COMMIT:\n-\t\tif ((buf = read_object_file(oid, &type, &size)) != NULL) {\n+\t\tif ((buf = repo_read_object_file(the_repository, oid, &type, &size)) != NULL) {\n \t\t\tsubject_len = find_commit_subject(buf, &subject_start);\n \t\t\tstrbuf_insert(sb, sb->len, subject_start, subject_len);\n \t\t} else {\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex 58652229f2..df4a47bae7 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -10,7 +10,7 @@ static char *create_temp_file(struct object_id *oid)\n \tunsigned long size;\n \tint fd;\n \n-\tbuf = read_object_file(oid, &type, &size);\n+\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n \tif (!buf || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 30d9413b4b..1e2bc1be3a 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -425,7 +425,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \tif (resolve_against_held(nr, &base_oid, delta_data, delta_size))\n \t\treturn;\n \n-\tbase = read_object_file(&base_oid, &type, &base_size);\n+\tbase = repo_read_object_file(the_repository, &base_oid, &type,\n+\t\t\t\t     &base_size);\n \tif (!base) {\n \t\terror(\"failed to read delta-pack base object %s\",\n \t\t      oid_to_hex(&base_oid));\ndiff --git a/builtin/verify-commit.c b/builtin/verify-commit.c\nindex 7772c07ed7..3caa6cf8e9 100644\n--- a/builtin/verify-commit.c\n+++ b/builtin/verify-commit.c\n@@ -47,7 +47,7 @@ static int verify_commit(const char *name, unsigned flags)\n \tif (get_oid(name, &oid))\n \t\treturn error(\"commit '%s' not found.\", name);\n \n-\tbuf = read_object_file(&oid, &type, &size);\n+\tbuf = repo_read_object_file(the_repository, &oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"%s: unable to read file.\", name);\n \tif (type != OBJ_COMMIT)\ndiff --git a/bundle.c b/bundle.c\nindex a5a71d059e..8080cf1ed1 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -224,7 +224,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n \tif (revs->max_age == -1 && revs->min_age == -1)\n \t\tgoto out;\n \n-\tbuf = read_object_file(&tag->oid, &type, &size);\n+\tbuf = repo_read_object_file(the_repository, &tag->oid, &type, &size);\n \tif (!buf)\n \t\tgoto out;\n \tline = memmem(buf, size, \"\\ntagger \", 8);\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 41ab5b01de..5593052ae9 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -308,7 +308,7 @@ static char *grab_blob(struct repository *r,\n \t\t*size = fill_textconv(r, textconv, df, &blob);\n \t\tfree_filespec(df);\n \t} else {\n-\t\tblob = read_object_file(oid, &type, size);\n+\t\tblob = repo_read_object_file(the_repository, oid, &type, size);\n \t\tif (type != OBJ_BLOB)\n \t\t\tdie(\"object '%s' is not a blob!\", oid_to_hex(oid));\n \t}\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 8a1bec7b8a..fd2f5380e1 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -435,7 +435,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,\n \t\tint edge_value;\n \t\tuint32_t packedDate[2];\n \n-\t\tparse_commit(*list);\n+\t\trepo_parse_commit(the_repository, *list);\n \t\thashwrite(f, get_commit_tree_oid(*list)->hash, hash_len);\n \n \t\tparent = (*list)->parents;\n@@ -606,7 +606,7 @@ static void close_reachable(struct packed_oid_list *oids)\n \tfor (i = 0; i < oids->nr; i++) {\n \t\tcommit = lookup_commit(the_repository, &oids->list[i]);\n \n-\t\tif (commit && !parse_commit(commit))\n+\t\tif (commit && !repo_parse_commit(the_repository, commit))\n \t\t\tadd_missing_parents(oids, commit);\n \t}\n \n@@ -783,7 +783,7 @@ void write_commit_graph(const char *obj_dir,\n \t\t\tcontinue;\n \n \t\tcommits.list[commits.nr] = lookup_commit(the_repository, &oids.list[i]);\n-\t\tparse_commit(commits.list[commits.nr]);\n+\t\trepo_parse_commit(the_repository, commits.list[commits.nr]);\n \n \t\tfor (parent = commits.list[commits.nr]->parents;\n \t\t     parent; parent = parent->next)\n@@ -954,7 +954,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)\n \n \t\tgraph_commit = lookup_commit(r, &cur_oid);\n \t\todb_commit = (struct commit *)create_object(r, cur_oid.hash, alloc_commit_node(r));\n-\t\tif (parse_commit_internal(odb_commit, 0, 0)) {\n+\t\tif (repo_parse_commit_internal(the_repository, odb_commit, 0, 0)) {\n \t\t\tgraph_report(\"failed to parse %s from object database\",\n \t\t\t\t     oid_to_hex(&cur_oid));\n \t\t\tcontinue;\ndiff --git a/commit.c b/commit.c\nindex 526b33758d..e86241b802 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -70,7 +70,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)\n \tif (get_oid_committish(name, &oid))\n \t\treturn NULL;\n \tcommit = lookup_commit_reference(the_repository, &oid);\n-\tif (parse_commit(commit))\n+\tif (repo_parse_commit(the_repository, commit))\n \t\treturn NULL;\n \treturn commit;\n }\n@@ -491,7 +491,7 @@ int repo_parse_commit_gently(struct repository *r,\n \n void parse_commit_or_die(struct commit *item)\n {\n-\tif (parse_commit(item))\n+\tif (repo_parse_commit(the_repository, item))\n \t\tdie(\"unable to parse commit %s\",\n \t\t    item ? oid_to_hex(&item->object.oid) : \"(null)\");\n }\n@@ -596,7 +596,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,\n \n \twhile (parents) {\n \t\tstruct commit *commit = parents->item;\n-\t\tif (!parse_commit(commit) && !(commit->object.flags & mark)) {\n+\t\tif (!repo_parse_commit(the_repository, commit) && !(commit->object.flags & mark)) {\n \t\t\tcommit->object.flags |= mark;\n \t\t\tcommit_list_insert_by_date(commit, list);\n \t\t}\n@@ -689,7 +689,7 @@ static void record_author_date(struct author_date_slab *author_date,\n \t*(author_date_slab_at(author_date, commit)) = date;\n \n fail_exit:\n-\tunuse_commit_buffer(commit, buffer);\n+\trepo_unuse_commit_buffer(the_repository, commit, buffer);\n }\n \n static int compare_commits_by_author_date(const void *a_, const void *b_,\n@@ -1302,7 +1302,7 @@ int parse_signed_commit(const struct commit *commit,\n \t\t}\n \t\tline = next;\n \t}\n-\tunuse_commit_buffer(commit, buffer);\n+\trepo_unuse_commit_buffer(the_repository, commit, buffer);\n \treturn saw_signature;\n }\n \n@@ -1351,7 +1351,8 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header\n \tdesc = merge_remote_util(parent);\n \tif (!desc || !desc->obj)\n \t\treturn;\n-\tbuf = read_object_file(&desc->obj->oid, &type, &size);\n+\tbuf = repo_read_object_file(the_repository, &desc->obj->oid, &type,\n+\t\t\t\t    &size);\n \tif (!buf || type != OBJ_TAG)\n \t\tgoto free_return;\n \tlen = parse_signature(buf, size);\n@@ -1429,7 +1430,7 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,\n \tunsigned long size;\n \tconst char *buffer = get_commit_buffer(commit, &size);\n \textra = read_commit_extra_header_lines(buffer, size, exclude);\n-\tunuse_commit_buffer(commit, buffer);\n+\trepo_unuse_commit_buffer(the_repository, commit, buffer);\n \treturn extra;\n }\n \ndiff --git a/config.c b/config.c\nindex 3461993f0a..e2b72403a6 100644\n--- a/config.c\n+++ b/config.c\n@@ -1605,7 +1605,7 @@ int git_config_from_blob_oid(config_fn_t fn,\n \tunsigned long size;\n \tint ret;\n \n-\tbuf = read_object_file(oid, &type, &size);\n+\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n \tif (!buf)\n \t\treturn error(_(\"unable to load config blob object '%s'\"), name);\n \tif (type != OBJ_BLOB) {\ndiff --git a/diff.c b/diff.c\nindex c5b5e7ac41..ab16d6dcad 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3939,7 +3939,8 @@ int diff_populate_filespec(struct repository *r,\n \t\t\t\treturn 0;\n \t\t\t}\n \t\t}\n-\t\ts->data = read_object_file(&s->oid, &type, &s->size);\n+\t\ts->data = repo_read_object_file(the_repository, &s->oid,\n+\t\t\t\t\t\t&type, &s->size);\n \t\tif (!s->data)\n \t\t\tdie(\"unable to read %s\", oid_to_hex(&s->oid));\n \t\ts->should_free = 1;\ndiff --git a/dir.c b/dir.c\nindex aceb0d4869..8722b1e5d5 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -245,7 +245,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,\n \t*size_out = 0;\n \t*data_out = NULL;\n \n-\tdata = read_object_file(oid, &type, &sz);\n+\tdata = repo_read_object_file(the_repository, oid, &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn -1;\ndiff --git a/entry.c b/entry.c\nindex 2a2ab6c839..45723fc958 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -86,7 +86,8 @@ static int create_file(const char *path, unsigned int mode)\n static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size)\n {\n \tenum object_type type;\n-\tvoid *blob_data = read_object_file(&ce->oid, &type, size);\n+\tvoid *blob_data = repo_read_object_file(the_repository, &ce->oid,\n+\t\t\t\t\t\t&type, size);\n \n \tif (blob_data) {\n \t\tif (type == OBJ_BLOB)\ndiff --git a/fast-import.c b/fast-import.c\nindex 89bb0c9db3..879b1fbf56 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1371,7 +1371,7 @@ static void load_tree(struct tree_entry *root)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t} else {\n \t\tenum object_type type;\n-\t\tbuf = read_object_file(oid, &type, &size);\n+\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n \t\tif (!buf || type != OBJ_TREE)\n \t\t\tdie(\"Can't load tree %s\", oid_to_hex(oid));\n \t}\n@@ -2931,7 +2931,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)\n \tchar *buf;\n \n \tif (!oe || oe->pack_id == MAX_PACK_ID) {\n-\t\tbuf = read_object_file(oid, &type, &size);\n+\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n \t} else {\n \t\ttype = oe->type;\n \t\tbuf = gfi_unpack_entry(oe, &size);\n@@ -3037,7 +3037,8 @@ static struct object_entry *dereference(struct object_entry *oe,\n \t\tbuf = gfi_unpack_entry(oe, &size);\n \t} else {\n \t\tenum object_type unused;\n-\t\tbuf = read_object_file(oid, &unused, &size);\n+\t\tbuf = repo_read_object_file(the_repository, oid, &unused,\n+\t\t\t\t\t    &size);\n \t}\n \tif (!buf)\n \t\tdie(\"Can't load object %s\", oid_to_hex(oid));\ndiff --git a/fsck.c b/fsck.c\nindex a0cee0be59..0d3e8886e2 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -447,7 +447,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio\n \tint result;\n \tconst char *name;\n \n-\tif (parse_commit(commit))\n+\tif (repo_parse_commit(the_repository, commit))\n \t\treturn -1;\n \n \tname = get_object_name(options, &commit->object);\n@@ -859,7 +859,7 @@ static int fsck_commit(struct commit *commit, const char *data,\n \tconst char *buffer = data ?  data : get_commit_buffer(commit, &size);\n \tint ret = fsck_commit_buffer(commit, buffer, size, options);\n \tif (!data)\n-\t\tunuse_commit_buffer(commit, buffer);\n+\t\trepo_unuse_commit_buffer(the_repository, commit, buffer);\n \treturn ret;\n }\n \n@@ -879,7 +879,8 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,\n \t\tenum object_type type;\n \n \t\tbuffer = to_free =\n-\t\t\tread_object_file(&tag->object.oid, &type, &size);\n+\t\t\trepo_read_object_file(the_repository,\n+\t\t\t\t\t      &tag->object.oid, &type, &size);\n \t\tif (!buffer)\n \t\t\treturn report(options, &tag->object,\n \t\t\t\tFSCK_MSG_MISSING_TAG_OBJECT,\n@@ -1091,7 +1092,7 @@ int fsck_finish(struct fsck_options *options)\n \t\t\tcontinue;\n \t\t}\n \n-\t\tbuf = read_object_file(oid, &type, &size);\n+\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n \t\tif (!buf) {\n \t\t\tif (is_promisor_object(&blob->object.oid))\n \t\t\t\tcontinue;\ndiff --git a/grep.c b/grep.c\nindex f6bd89e40b..216c38a0d5 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -2112,7 +2112,8 @@ static int grep_source_load_oid(struct grep_source *gs)\n \tenum object_type type;\n \n \tgrep_read_lock();\n-\tgs->buf = read_object_file(gs->identifier, &type, &gs->size);\n+\tgs->buf = repo_read_object_file(the_repository, gs->identifier, &type,\n+\t\t\t\t\t&gs->size);\n \tgrep_read_unlock();\n \n \tif (!gs->buf)\ndiff --git a/http-push.c b/http-push.c\nindex df504ab6a3..c6206838ed 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -364,7 +364,8 @@ static void start_put(struct transfer_request *request)\n \tssize_t size;\n \tgit_zstream stream;\n \n-\tunpacked = read_object_file(&request->obj->oid, &type, &len);\n+\tunpacked = repo_read_object_file(the_repository, &request->obj->oid,\n+\t\t\t\t\t &type, &len);\n \thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %lu\", type_name(type), len) + 1;\n \n \t/* Set it up */\ndiff --git a/log-tree.c b/log-tree.c\nindex 7443e5fcc7..360dd0b4e6 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -332,7 +332,8 @@ void fmt_output_commit(struct strbuf *filename,\n \tstruct pretty_print_context ctx = {0};\n \tstruct strbuf subject = STRBUF_INIT;\n \n-\tformat_commit_message(commit, \"%f\", &subject, &ctx);\n+\trepo_format_commit_message(the_repository, commit, \"%f\", &subject,\n+\t\t\t\t   &ctx);\n \tfmt_output_subject(filename, subject.buf, info);\n \tstrbuf_release(&subject);\n }\ndiff --git a/mailmap.c b/mailmap.c\nindex 962fd86d6d..f3ffea0e17 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -225,7 +225,7 @@ static int read_mailmap_blob(struct string_list *map,\n \tif (get_oid(name, &oid) < 0)\n \t\treturn 0;\n \n-\tbuf = read_object_file(&oid, &type, &size);\n+\tbuf = repo_read_object_file(the_repository, &oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"unable to read mailmap object at %s\", name);\n \tif (type != OBJ_BLOB)\ndiff --git a/match-trees.c b/match-trees.c\nindex 37653308d3..3fb649ad08 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -55,7 +55,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc,\n \tenum object_type type;\n \tunsigned long size;\n \n-\tbuffer = read_object_file(hash, &type, &size);\n+\tbuffer = repo_read_object_file(the_repository, hash, &type, &size);\n \tif (!buffer)\n \t\tdie(\"unable to read tree (%s)\", oid_to_hex(hash));\n \tif (type != OBJ_TREE)\n@@ -190,7 +190,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,\n \tif (*subpath)\n \t\tsubpath++;\n \n-\tbuf = read_object_file(oid1, &type, &sz);\n+\tbuf = repo_read_object_file(the_repository, oid1, &type, &sz);\n \tif (!buf)\n \t\tdie(\"cannot read tree %s\", oid_to_hex(oid1));\n \tinit_tree_desc(&desc, buf, sz);\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex ee0a0e90c9..757e338715 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -12,7 +12,8 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n \tunsigned long size;\n \tenum object_type type;\n \n-\tbuf = read_object_file(&obj->object.oid, &type, &size);\n+\tbuf = repo_read_object_file(the_repository, &obj->object.oid, &type,\n+\t\t\t\t    &size);\n \tif (!buf)\n \t\treturn -1;\n \tif (type != OBJ_BLOB) {\n@@ -75,7 +76,8 @@ void *merge_blobs(struct index_state *istate, const char *path,\n \t\t\treturn NULL;\n \t\tif (!our)\n \t\t\tour = their;\n-\t\treturn read_object_file(&our->object.oid, &type, size);\n+\t\treturn repo_read_object_file(the_repository, &our->object.oid,\n+\t\t\t\t\t     &type, size);\n \t}\n \n \tif (fill_mmfile_blob(&f1, our) < 0)\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 82e9f1d24a..646e265625 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -299,7 +299,7 @@ static void output_commit_title(struct merge_options *o, struct commit *commit)\n \t\tstrbuf_add_unique_abbrev(&o->obuf, &commit->object.oid,\n \t\t\t\t\t DEFAULT_ABBREV);\n \t\tstrbuf_addch(&o->obuf, ' ');\n-\t\tif (parse_commit(commit) != 0)\n+\t\tif (repo_parse_commit(the_repository, commit) != 0)\n \t\t\tstrbuf_addstr(&o->obuf, _(\"(bad commit)\\n\"));\n \t\telse {\n \t\t\tconst char *title;\n@@ -307,7 +307,7 @@ static void output_commit_title(struct merge_options *o, struct commit *commit)\n \t\t\tint len = find_commit_subject(msg, &title);\n \t\t\tif (len)\n \t\t\t\tstrbuf_addf(&o->obuf, \"%.*s\\n\", len, title);\n-\t\t\tunuse_commit_buffer(commit, msg);\n+\t\t\trepo_unuse_commit_buffer(the_repository, commit, msg);\n \t\t}\n \t}\n \tflush_output(o);\n@@ -957,7 +957,7 @@ static int update_file_flags(struct merge_options *o,\n \t\t\tgoto update_index;\n \t\t}\n \n-\t\tbuf = read_object_file(oid, &type, &size);\n+\t\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n \t\tif (!buf)\n \t\t\treturn err(o, _(\"cannot read object %s '%s'\"), oid_to_hex(oid), path);\n \t\tif (type != OBJ_BLOB) {\n@@ -1160,7 +1160,8 @@ static void print_commit(struct commit *commit)\n \tstruct strbuf sb = STRBUF_INIT;\n \tstruct pretty_print_context ctx = {0};\n \tctx.date_mode.type = DATE_NORMAL;\n-\tformat_commit_message(commit, \" %h: %m %s\", &sb, &ctx);\n+\trepo_format_commit_message(the_repository, commit, \" %h: %m %s\", &sb,\n+\t\t\t\t   &ctx);\n \tfprintf(stderr, \"%s\\n\", sb.buf);\n \tstrbuf_release(&sb);\n }\n@@ -2944,7 +2945,7 @@ static int read_oid_strbuf(struct merge_options *o,\n \tvoid *buf;\n \tenum object_type type;\n \tunsigned long size;\n-\tbuf = read_object_file(oid, &type, &size);\n+\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n \tif (!buf)\n \t\treturn err(o, _(\"cannot read object %s\"), oid_to_hex(oid));\n \tif (type != OBJ_BLOB) {\n@@ -3522,7 +3523,7 @@ static struct commit *get_ref(const struct object_id *oid, const char *name)\n \t\treturn make_virtual_commit((struct tree*)object, name);\n \tif (object->type != OBJ_COMMIT)\n \t\treturn NULL;\n-\tif (parse_commit((struct commit *)object))\n+\tif (repo_parse_commit(the_repository, (struct commit *)object))\n \t\treturn NULL;\n \treturn (struct commit *)object;\n }\ndiff --git a/negotiator/default.c b/negotiator/default.c\nindex 4b78f6bf36..19071a97df 100644\n--- a/negotiator/default.c\n+++ b/negotiator/default.c\n@@ -25,7 +25,7 @@ static void rev_list_push(struct negotiation_state *ns,\n \tif (!(commit->object.flags & mark)) {\n \t\tcommit->object.flags |= mark;\n \n-\t\tif (parse_commit(commit))\n+\t\tif (repo_parse_commit(the_repository, commit))\n \t\t\treturn;\n \n \t\tprio_queue_put(&ns->rev_list, commit);\n@@ -68,7 +68,7 @@ static void mark_common(struct negotiation_state *ns, struct commit *commit,\n \t\t\tif (!ancestors_only && !(o->flags & POPPED))\n \t\t\t\tns->non_common_revs--;\n \t\t\tif (!o->parsed && !dont_parse)\n-\t\t\t\tif (parse_commit(commit))\n+\t\t\t\tif (repo_parse_commit(the_repository, commit))\n \t\t\t\t\treturn;\n \n \t\t\tfor (parents = commit->parents;\n@@ -95,7 +95,7 @@ static const struct object_id *get_rev(struct negotiation_state *ns)\n \t\t\treturn NULL;\n \n \t\tcommit = prio_queue_get(&ns->rev_list);\n-\t\tparse_commit(commit);\n+\t\trepo_parse_commit(the_repository, commit);\n \t\tparents = commit->parents;\n \n \t\tcommit->object.flags |= POPPED;\ndiff --git a/negotiator/skipping.c b/negotiator/skipping.c\nindex dffbc76c49..9b76f95654 100644\n--- a/negotiator/skipping.c\n+++ b/negotiator/skipping.c\n@@ -177,7 +177,7 @@ static const struct object_id *get_rev(struct data *data)\n \t\tif (!(commit->object.flags & COMMON) && !entry->ttl)\n \t\t\tto_send = commit;\n \n-\t\tparse_commit(commit);\n+\t\trepo_parse_commit(the_repository, commit);\n \t\tfor (p = commit->parents; p; p = p->next)\n \t\t\tparent_pushed |= push_parent(data, entry, p->item);\n \ndiff --git a/notes-cache.c b/notes-cache.c\nindex d87e7ca91c..94196ef0f6 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -21,7 +21,8 @@ static int notes_cache_match_validity(const char *ref, const char *validity)\n \t\treturn 0;\n \n \tmemset(&pretty_ctx, 0, sizeof(pretty_ctx));\n-\tformat_commit_message(commit, \"%s\", &msg, &pretty_ctx);\n+\trepo_format_commit_message(the_repository, commit, \"%s\", &msg,\n+\t\t\t\t   &pretty_ctx);\n \tstrbuf_trim(&msg);\n \n \tret = !strcmp(msg.buf, validity);\n@@ -79,7 +80,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \tvalue_oid = get_note(&c->tree, key_oid);\n \tif (!value_oid)\n \t\treturn NULL;\n-\tvalue = read_object_file(value_oid, &type, &size);\n+\tvalue = repo_read_object_file(the_repository, value_oid, &type, &size);\n \n \t*outsize = size;\n \treturn value;\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 13dd9ba158..af1f5306dd 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -324,7 +324,7 @@ static void write_note_to_worktree(const struct object_id *obj,\n {\n \tenum object_type type;\n \tunsigned long size;\n-\tvoid *buf = read_object_file(note, &type, &size);\n+\tvoid *buf = repo_read_object_file(the_repository, note, &type, &size);\n \n \tif (!buf)\n \t\tdie(\"cannot read note %s for object %s\",\n@@ -723,7 +723,7 @@ int notes_merge_commit(struct notes_merge_options *o,\n \n \tcreate_notes_commit(partial_tree, partial_commit->parents, msg,\n \t\t\t    strlen(msg), result_oid);\n-\tunuse_commit_buffer(partial_commit, buffer);\n+\trepo_unuse_commit_buffer(the_repository, partial_commit, buffer);\n \tif (o->verbosity >= 4)\n \t\tprintf(\"Finalized notes merge commit: %s\\n\",\n \t\t\toid_to_hex(result_oid));\ndiff --git a/notes-utils.c b/notes-utils.c\nindex 14ea03178e..f25ef54a77 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -22,7 +22,7 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,\n \t\tif (!read_ref(t->ref, &parent_oid)) {\n \t\t\tstruct commit *parent = lookup_commit(the_repository,\n \t\t\t\t\t\t\t      &parent_oid);\n-\t\t\tif (parse_commit(parent))\n+\t\t\tif (repo_parse_commit(the_repository, parent))\n \t\t\t\tdie(\"Failed to find/parse commit %s\", t->ref);\n \t\t\tcommit_list_insert(parent, &parents);\n \t\t}\ndiff --git a/notes.c b/notes.c\nindex 32d3dbcc1e..766d540dd1 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -797,13 +797,15 @@ int combine_notes_concatenate(struct object_id *cur_oid,\n \n \t/* read in both note blob objects */\n \tif (!is_null_oid(new_oid))\n-\t\tnew_msg = read_object_file(new_oid, &new_type, &new_len);\n+\t\tnew_msg = repo_read_object_file(the_repository, new_oid,\n+\t\t\t\t\t\t&new_type, &new_len);\n \tif (!new_msg || !new_len || new_type != OBJ_BLOB) {\n \t\tfree(new_msg);\n \t\treturn 0;\n \t}\n \tif (!is_null_oid(cur_oid))\n-\t\tcur_msg = read_object_file(cur_oid, &cur_type, &cur_len);\n+\t\tcur_msg = repo_read_object_file(the_repository, cur_oid,\n+\t\t\t\t\t\t&cur_type, &cur_len);\n \tif (!cur_msg || !cur_len || cur_type != OBJ_BLOB) {\n \t\tfree(cur_msg);\n \t\tfree(new_msg);\n@@ -859,7 +861,7 @@ static int string_list_add_note_lines(struct string_list *list,\n \t\treturn 0;\n \n \t/* read_sha1_file NUL-terminates */\n-\tdata = read_object_file(oid, &t, &len);\n+\tdata = repo_read_object_file(the_repository, oid, &t, &len);\n \tif (t != OBJ_BLOB || !data || !len) {\n \t\tfree(data);\n \t\treturn t != OBJ_BLOB || !data;\n@@ -1218,7 +1220,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n \tif (!oid)\n \t\treturn;\n \n-\tif (!(msg = read_object_file(oid, &type, &msglen)) || type != OBJ_BLOB) {\n+\tif (!(msg = repo_read_object_file(the_repository, oid, &type, &msglen)) || type != OBJ_BLOB) {\n \t\tfree(msg);\n \t\treturn;\n \t}\ndiff --git a/pretty.c b/pretty.c\nindex 948f5346cf..4ab5b44da0 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1799,7 +1799,8 @@ void pretty_print_commit(struct pretty_print_context *pp,\n \tint need_8bit_cte = pp->need_8bit_cte;\n \n \tif (pp->fmt == CMIT_FMT_USERFORMAT) {\n-\t\tformat_commit_message(commit, user_format, sb, pp);\n+\t\trepo_format_commit_message(the_repository, commit,\n+\t\t\t\t\t   user_format, sb, pp);\n \t\treturn;\n \t}\n \n@@ -1861,7 +1862,7 @@ void pretty_print_commit(struct pretty_print_context *pp,\n \tif (cmit_fmt_is_mail(pp->fmt) && sb->len <= beginning_of_body)\n \t\tstrbuf_addch(sb, '\\n');\n \n-\tunuse_commit_buffer(commit, reencoded);\n+\trepo_unuse_commit_buffer(the_repository, commit, reencoded);\n }\n \n void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,\ndiff --git a/read-cache.c b/read-cache.c\nindex b707edd044..e0669b174e 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -232,7 +232,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)\n \tif (strbuf_readlink(&sb, ce->name, expected_size))\n \t\treturn -1;\n \n-\tbuffer = read_object_file(&ce->oid, &type, &size);\n+\tbuffer = repo_read_object_file(the_repository, &ce->oid, &type, &size);\n \tif (buffer) {\n \t\tif (size == sb.len)\n \t\t\tmatch = memcmp(buffer, sb.buf, size);\n@@ -2901,7 +2901,8 @@ void *read_blob_data_from_index(const struct index_state *istate,\n \t}\n \tif (pos < 0)\n \t\treturn NULL;\n-\tdata = read_object_file(&istate->cache[pos]->oid, &type, &sz);\n+\tdata = repo_read_object_file(the_repository, &istate->cache[pos]->oid,\n+\t\t\t\t     &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn NULL;\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex 3af708c5b6..c846c9ee3b 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -62,7 +62,7 @@ static char *read_ref_note(const struct object_id *oid)\n \tinit_notes(NULL, notes_ref, NULL, 0);\n \tif (!(note_oid = get_note(NULL, oid)))\n \t\treturn NULL;\t/* note tree not found */\n-\tif (!(msg = read_object_file(note_oid, &type, &msglen)))\n+\tif (!(msg = repo_read_object_file(the_repository, note_oid, &type, &msglen)))\n \t\terror(\"Empty notes tree. %s\", notes_ref);\n \telse if (!msglen || type != OBJ_BLOB) {\n \t\terror(\"Note contains unusable content. \"\n@@ -109,7 +109,7 @@ static int note2mark_cb(const struct object_id *object_oid,\n \tenum object_type type;\n \tstruct rev_note note;\n \n-\tif (!(msg = read_object_file(note_oid, &type, &msglen)) ||\n+\tif (!(msg = repo_read_object_file(the_repository, note_oid, &type, &msglen)) ||\n \t\t\t!msglen || type != OBJ_BLOB) {\n \t\tfree(msg);\n \t\treturn 1;\ndiff --git a/remote.c b/remote.c\nindex 348417f0a7..e16e8e002f 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1822,7 +1822,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)\n \t\treturn 0;\n \tnew_commit = (struct commit *) o;\n \n-\tif (parse_commit(new_commit) < 0)\n+\tif (repo_parse_commit(the_repository, new_commit) < 0)\n \t\treturn 0;\n \n \tused = list = NULL;\ndiff --git a/rerere.c b/rerere.c\nindex 8d4ac8426b..084bedfe55 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -988,8 +988,9 @@ static int handle_cache(struct index_state *istate, const char *path,\n \t\t\tbreak;\n \t\ti = ce_stage(ce) - 1;\n \t\tif (!mmfile[i].ptr) {\n-\t\t\tmmfile[i].ptr = read_object_file(&ce->oid, &type,\n-\t\t\t\t\t\t\t &size);\n+\t\t\tmmfile[i].ptr = repo_read_object_file(the_repository,\n+\t\t\t\t\t\t\t      &ce->oid, &type,\n+\t\t\t\t\t\t\t      &size);\n \t\t\tmmfile[i].size = size;\n \t\t}\n \t}\ndiff --git a/revision.c b/revision.c\nindex 28366eaccf..01c11107b8 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -274,7 +274,7 @@ static struct commit *handle_commit(struct rev_info *revs,\n \tif (object->type == OBJ_COMMIT) {\n \t\tstruct commit *commit = (struct commit *)object;\n \n-\t\tif (parse_commit(commit) < 0)\n+\t\tif (repo_parse_commit(the_repository, commit) < 0)\n \t\t\tdie(\"unable to parse commit %s\", name);\n \t\tif (flags & UNINTERESTING) {\n \t\t\tmark_parents_uninteresting(commit);\n@@ -688,7 +688,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)\n \t\t\t\t\tts->treesame[0] = 1;\n \t\t\t}\n \t\t}\n-\t\tif (parse_commit(p) < 0)\n+\t\tif (repo_parse_commit(the_repository, p) < 0)\n \t\t\tdie(\"cannot simplify commit %s (because of %s)\",\n \t\t\t    oid_to_hex(&commit->object.oid),\n \t\t\t    oid_to_hex(&p->object.oid));\n@@ -721,7 +721,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)\n \t\t\t\t * IOW, we pretend this parent is a\n \t\t\t\t * \"root\" commit.\n \t\t\t\t */\n-\t\t\t\tif (parse_commit(p) < 0)\n+\t\t\t\tif (repo_parse_commit(the_repository, p) < 0)\n \t\t\t\t\tdie(\"cannot simplify commit %s (invalid %s)\",\n \t\t\t\t\t    oid_to_hex(&commit->object.oid),\n \t\t\t\t\t    oid_to_hex(&p->object.oid));\n@@ -800,7 +800,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,\n \t\t\tparent = parent->next;\n \t\t\tif (p)\n \t\t\t\tp->object.flags |= UNINTERESTING;\n-\t\t\tif (parse_commit_gently(p, 1) < 0)\n+\t\t\tif (repo_parse_commit_gently(the_repository, p, 1) < 0)\n \t\t\t\tcontinue;\n \t\t\tif (p->parents)\n \t\t\t\tmark_parents_uninteresting(p);\n@@ -828,7 +828,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,\n \t\tstruct commit *p = parent->item;\n \t\tint gently = revs->ignore_missing_links ||\n \t\t\t     revs->exclude_promisor_objects;\n-\t\tif (parse_commit_gently(p, gently) < 0) {\n+\t\tif (repo_parse_commit_gently(the_repository, p, gently) < 0) {\n \t\t\tif (revs->exclude_promisor_objects &&\n \t\t\t    is_promisor_object(&p->object.oid)) {\n \t\t\t\tif (revs->first_parent_only)\n@@ -3095,7 +3095,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt)\n \t\tretval = grep_buffer(&opt->grep_filter,\n \t\t\t\t     (char *)message, strlen(message));\n \tstrbuf_release(&buf);\n-\tunuse_commit_buffer(commit, message);\n+\trepo_unuse_commit_buffer(the_repository, commit, message);\n \treturn opt->invert_grep ? !retval : retval;\n }\n \ndiff --git a/sequencer.c b/sequencer.c\nindex da4e727cc3..5d612831e9 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -344,7 +344,7 @@ static void free_message(struct commit *commit, struct commit_message *msg)\n \tfree(msg->parent_label);\n \tfree(msg->label);\n \tfree(msg->subject);\n-\tunuse_commit_buffer(commit, msg->message);\n+\trepo_unuse_commit_buffer(the_repository, commit, msg->message);\n }\n \n static void print_advice(int show_hint, struct replay_opts *opts)\n@@ -604,7 +604,7 @@ static int is_index_unchanged(void)\n \t * the commit is invalid, parse_commit() will complain.  So\n \t * there is nothing for us to say here.  Just return failure.\n \t */\n-\tif (parse_commit(head_commit))\n+\tif (repo_parse_commit(the_repository, head_commit))\n \t\treturn -1;\n \n \tif (!(cache_tree_oid = get_cache_tree_oid()))\n@@ -1142,13 +1142,15 @@ void print_commit_summary(const char *prefix, const struct object_id *oid,\n \tcommit = lookup_commit(the_repository, oid);\n \tif (!commit)\n \t\tdie(_(\"couldn't look up newly created commit\"));\n-\tif (parse_commit(commit))\n+\tif (repo_parse_commit(the_repository, commit))\n \t\tdie(_(\"could not parse newly created commit\"));\n \n \tstrbuf_addstr(&format, \"format:%h] %s\");\n \n-\tformat_commit_message(commit, \"%an <%ae>\", &author_ident, &pctx);\n-\tformat_commit_message(commit, \"%cn <%ce>\", &committer_ident, &pctx);\n+\trepo_format_commit_message(the_repository, commit, \"%an <%ae>\",\n+\t\t\t\t   &author_ident, &pctx);\n+\trepo_format_commit_message(the_repository, commit, \"%cn <%ce>\",\n+\t\t\t\t   &committer_ident, &pctx);\n \tif (strbuf_cmp(&author_ident, &committer_ident)) {\n \t\tstrbuf_addstr(&format, \"\\n Author: \");\n \t\tstrbuf_addbuf_percentquote(&format, &author_ident);\n@@ -1156,7 +1158,8 @@ void print_commit_summary(const char *prefix, const struct object_id *oid,\n \tif (flags & SUMMARY_SHOW_AUTHOR_DATE) {\n \t\tstruct strbuf date = STRBUF_INIT;\n \n-\t\tformat_commit_message(commit, \"%ad\", &date, &pctx);\n+\t\trepo_format_commit_message(the_repository, commit, \"%ad\",\n+\t\t\t\t\t   &date, &pctx);\n \t\tstrbuf_addstr(&format, \"\\n Date: \");\n \t\tstrbuf_addbuf_percentquote(&format, &date);\n \t\tstrbuf_release(&date);\n@@ -1221,7 +1224,7 @@ static int parse_head(struct commit **head)\n \t\t\twarning(_(\"HEAD %s is not a commit!\"),\n \t\t\t\toid_to_hex(&oid));\n \t\t}\n-\t\tif (parse_commit(current_head))\n+\t\tif (repo_parse_commit(the_repository, current_head))\n \t\t\treturn error(_(\"could not parse HEAD commit\"));\n \t}\n \t*head = current_head;\n@@ -1271,7 +1274,8 @@ static int try_to_commit(struct strbuf *msg, const char *author,\n \t\t\thook_commit = \"HEAD\";\n \t\t}\n \t\tauthor = amend_author = get_author(message);\n-\t\tunuse_commit_buffer(current_head, message);\n+\t\trepo_unuse_commit_buffer(the_repository, current_head,\n+\t\t\t\t\t message);\n \t\tif (!author) {\n \t\t\tres = error(_(\"unable to parse commit author\"));\n \t\t\tgoto out;\n@@ -1381,12 +1385,12 @@ static int is_original_commit_empty(struct commit *commit)\n {\n \tconst struct object_id *ptree_oid;\n \n-\tif (parse_commit(commit))\n+\tif (repo_parse_commit(the_repository, commit))\n \t\treturn error(_(\"could not parse commit %s\"),\n \t\t\t     oid_to_hex(&commit->object.oid));\n \tif (commit->parents) {\n \t\tstruct commit *parent = commit->parents->item;\n-\t\tif (parse_commit(parent))\n+\t\tif (repo_parse_commit(the_repository, parent))\n \t\t\treturn error(_(\"could not parse parent commit %s\"),\n \t\t\t\toid_to_hex(&parent->object.oid));\n \t\tptree_oid = get_commit_tree_oid(parent);\n@@ -1557,7 +1561,8 @@ static int update_squash_messages(enum todo_command command,\n \t\tfind_commit_subject(head_message, &body);\n \t\tif (write_message(body, strlen(body),\n \t\t\t\t  rebase_path_fixup_msg(), 0)) {\n-\t\t\tunuse_commit_buffer(head_commit, head_message);\n+\t\t\trepo_unuse_commit_buffer(the_repository, head_commit,\n+\t\t\t\t\t\t head_message);\n \t\t\treturn error(_(\"cannot write '%s'\"),\n \t\t\t\t     rebase_path_fixup_msg());\n \t\t}\n@@ -1569,7 +1574,8 @@ static int update_squash_messages(enum todo_command command,\n \t\tstrbuf_addstr(&buf, \"\\n\\n\");\n \t\tstrbuf_addstr(&buf, body);\n \n-\t\tunuse_commit_buffer(head_commit, head_message);\n+\t\trepo_unuse_commit_buffer(the_repository, head_commit,\n+\t\t\t\t\t head_message);\n \t}\n \n \tif (!(message = get_commit_buffer(commit, NULL)))\n@@ -1592,7 +1598,7 @@ static int update_squash_messages(enum todo_command command,\n \t\tstrbuf_add_commented_lines(&buf, body, strlen(body));\n \t} else\n \t\treturn error(_(\"unknown command: %d\"), command);\n-\tunuse_commit_buffer(commit, message);\n+\trepo_unuse_commit_buffer(the_repository, commit, message);\n \n \tres = write_message(buf.buf, buf.len, rebase_path_squash_msg(), 0);\n \tstrbuf_release(&buf);\n@@ -1729,7 +1735,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\tmsg_file = NULL;\n \t\tgoto fast_forward_edit;\n \t}\n-\tif (parent && parse_commit(parent) < 0)\n+\tif (parent && repo_parse_commit(the_repository, parent) < 0)\n \t\t/* TRANSLATORS: The first %s will be a \"todo\" command like\n \t\t   \"revert\" or \"pick\", the second %s a SHA1. */\n \t\treturn error(_(\"%s: cannot parse parent commit %s\"),\n@@ -2357,7 +2363,8 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,\n \t\tsubject_len = find_commit_subject(commit_buffer, &subject);\n \t\tstrbuf_addf(&todo_list->buf, \"%s %s %.*s\\n\", command_string,\n \t\t\tshort_commit_name(commit), subject_len, subject);\n-\t\tunuse_commit_buffer(commit, commit_buffer);\n+\t\trepo_unuse_commit_buffer(the_repository, commit,\n+\t\t\t\t\t commit_buffer);\n \t}\n \n \tif (!todo_list->nr)\n@@ -2616,7 +2623,8 @@ static int make_patch(struct commit *commit, struct replay_opts *opts)\n \t\tconst char *commit_buffer = get_commit_buffer(commit, NULL);\n \t\tfind_commit_subject(commit_buffer, &subject);\n \t\tres |= write_message(subject, strlen(subject), buf.buf, 1);\n-\t\tunuse_commit_buffer(commit, commit_buffer);\n+\t\trepo_unuse_commit_buffer(the_repository, commit,\n+\t\t\t\t\t commit_buffer);\n \t}\n \tstrbuf_release(&buf);\n \n@@ -3013,7 +3021,7 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,\n \t\tfind_commit_subject(message, &body);\n \t\tlen = strlen(body);\n \t\tret = write_message(body, len, git_path_merge_msg(the_repository), 0);\n-\t\tunuse_commit_buffer(commit, message);\n+\t\trepo_unuse_commit_buffer(the_repository, commit, message);\n \t\tif (ret) {\n \t\t\terror_errno(_(\"could not write '%s'\"),\n \t\t\t\t    git_path_merge_msg(the_repository));\n@@ -3658,11 +3666,13 @@ static int commit_staged_changes(struct replay_opts *opts,\n \t\t\t\tif (parse_head(&commit) ||\n \t\t\t\t    !(p = get_commit_buffer(commit, NULL)) ||\n \t\t\t\t    write_message(p, strlen(p), path, 0)) {\n-\t\t\t\t\tunuse_commit_buffer(commit, p);\n+\t\t\t\t\trepo_unuse_commit_buffer(the_repository,\n+\t\t\t\t\t\t\t\t commit, p);\n \t\t\t\t\treturn error(_(\"could not write file: \"\n \t\t\t\t\t\t       \"'%s'\"), path);\n \t\t\t\t}\n-\t\t\t\tunuse_commit_buffer(commit, p);\n+\t\t\t\trepo_unuse_commit_buffer(the_repository,\n+\t\t\t\t\t\t\t commit, p);\n \t\t\t}\n \t\t}\n \n@@ -4564,7 +4574,7 @@ int skip_unnecessary_picks(void)\n \t\t\tcontinue;\n \t\tif (item->command != TODO_PICK)\n \t\t\tbreak;\n-\t\tif (parse_commit(item->commit)) {\n+\t\tif (repo_parse_commit(the_repository, item->commit)) {\n \t\t\ttodo_list_release(&todo_list);\n \t\t\treturn error(_(\"could not parse commit '%s'\"),\n \t\t\t\toid_to_hex(&item->commit->object.oid));\n@@ -4691,12 +4701,13 @@ int rearrange_squash(void)\n \n \t\t*commit_todo_item_at(&commit_todo, item->commit) = item;\n \n-\t\tparse_commit(item->commit);\n+\t\trepo_parse_commit(the_repository, item->commit);\n \t\tcommit_buffer = get_commit_buffer(item->commit, NULL);\n \t\tfind_commit_subject(commit_buffer, &subject);\n \t\tformat_subject(&buf, subject, \" \");\n \t\tsubject = subjects[i] = strbuf_detach(&buf, &subject_len);\n-\t\tunuse_commit_buffer(item->commit, commit_buffer);\n+\t\trepo_unuse_commit_buffer(the_repository, item->commit,\n+\t\t\t\t\t commit_buffer);\n \t\tif ((skip_prefix(subject, \"fixup! \", &p) ||\n \t\t     skip_prefix(subject, \"squash! \", &p))) {\n \t\t\tstruct commit *commit2;\ndiff --git a/sha1-file.c b/sha1-file.c\nindex ce47524679..4f86034d25 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -1456,7 +1456,8 @@ void *read_object_with_reference(const struct object_id *oid,\n \t\tint ref_length = -1;\n \t\tconst char *ref_type = NULL;\n \n-\t\tbuffer = read_object_file(&actual_oid, &type, &isize);\n+\t\tbuffer = repo_read_object_file(the_repository, &actual_oid,\n+\t\t\t\t\t       &type, &isize);\n \t\tif (!buffer)\n \t\t\treturn NULL;\n \t\tif (type == required_type) {\ndiff --git a/sha1-name.c b/sha1-name.c\nindex c9cc1318b7..71e6bb7a9a 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -357,7 +357,8 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)\n \t\tif (commit) {\n \t\t\tstruct pretty_print_context pp = {0};\n \t\t\tpp.date_mode.type = DATE_SHORT;\n-\t\t\tformat_commit_message(commit, \" %ad - %s\", &desc, &pp);\n+\t\t\trepo_format_commit_message(the_repository, commit,\n+\t\t\t\t\t\t   \" %ad - %s\", &desc, &pp);\n \t\t}\n \t} else if (type == OBJ_TAG) {\n \t\tstruct tag *tag = lookup_tag(the_repository, oid);\n@@ -849,7 +850,7 @@ static int get_parent(const char *name, int len,\n \tif (ret)\n \t\treturn ret;\n \tcommit = lookup_commit_reference(the_repository, &oid);\n-\tif (parse_commit(commit))\n+\tif (repo_parse_commit(the_repository, commit))\n \t\treturn -1;\n \tif (!idx) {\n \t\toidcpy(result, &commit->object.oid);\n@@ -881,7 +882,7 @@ static int get_nth_ancestor(const char *name, int len,\n \t\treturn -1;\n \n \twhile (generation--) {\n-\t\tif (parse_commit(commit) || !commit->parents)\n+\t\tif (repo_parse_commit(the_repository, commit) || !commit->parents)\n \t\t\treturn -1;\n \t\tcommit = commit->parents->item;\n \t}\n@@ -1152,7 +1153,7 @@ static int get_oid_oneline(const char *prefix, struct object_id *oid,\n \t\tbuf = get_commit_buffer(commit, NULL);\n \t\tp = strstr(buf, \"\\n\\n\");\n \t\tmatches = negative ^ (p && !regexec(&regex, p + 2, 0, NULL, 0));\n-\t\tunuse_commit_buffer(commit, buf);\n+\t\trepo_unuse_commit_buffer(the_repository, commit, buf);\n \n \t\tif (matches) {\n \t\t\toidcpy(oid, &commit->object.oid);\ndiff --git a/shallow.c b/shallow.c\nindex e656ce8b9c..124c03f003 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -210,7 +210,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,\n \t\tstruct commit *c = p->item;\n \t\tstruct commit_list *parent;\n \n-\t\tif (parse_commit(c))\n+\t\tif (repo_parse_commit(the_repository, c))\n \t\t\tdie(\"unable to parse commit %s\",\n \t\t\t    oid_to_hex(&c->object.oid));\n \n@@ -533,7 +533,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,\n \t\tif (c->object.flags & BOTTOM)\n \t\t\tcontinue;\n \n-\t\tif (parse_commit(c))\n+\t\tif (repo_parse_commit(the_repository, c))\n \t\t\tdie(\"unable to parse commit %s\",\n \t\t\t    oid_to_hex(&c->object.oid));\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex fc2c41b947..4b2104979b 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -552,7 +552,8 @@ static const struct submodule *config_from(struct submodule_cache *cache,\n \tif (submodule)\n \t\tgoto out;\n \n-\tconfig = read_object_file(&oid, &type, &config_size);\n+\tconfig = repo_read_object_file(the_repository, &oid, &type,\n+\t\t\t\t       &config_size);\n \tif (!config || type != OBJ_BLOB)\n \t\tgoto out;\n \ndiff --git a/t/helper/test-revision-walking.c b/t/helper/test-revision-walking.c\nindex 625b2dbf82..a03cfcdae1 100644\n--- a/t/helper/test-revision-walking.c\n+++ b/t/helper/test-revision-walking.c\n@@ -19,7 +19,8 @@ static void print_commit(struct commit *commit)\n \tstruct strbuf sb = STRBUF_INIT;\n \tstruct pretty_print_context ctx = {0};\n \tctx.date_mode.type = DATE_NORMAL;\n-\tformat_commit_message(commit, \" %m %s\", &sb, &ctx);\n+\trepo_format_commit_message(the_repository, commit, \" %m %s\", &sb,\n+\t\t\t\t   &ctx);\n \tprintf(\"%s\\n\", sb.buf);\n \tstrbuf_release(&sb);\n }\ndiff --git a/tag.c b/tag.c\nindex 1db663d716..b5a5a4c152 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -52,7 +52,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n \t\t\t\tfind_unique_abbrev(oid, DEFAULT_ABBREV),\n \t\t\t\ttype_name(type));\n \n-\tbuf = read_object_file(oid, &type, &size);\n+\tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n \tif (!buf)\n \t\treturn error(\"%s: unable to read file.\",\n \t\t\t\tname_to_report ?\n@@ -200,7 +200,8 @@ int parse_tag(struct tag *item)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tdata = read_object_file(&item->object.oid, &type, &size);\n+\tdata = repo_read_object_file(the_repository, &item->object.oid, &type,\n+\t\t\t\t     &size);\n \tif (!data)\n \t\treturn error(\"Could not read %s\",\n \t\t\t     oid_to_hex(&item->object.oid));\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 77b37f36fa..ec6045828b 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -715,8 +715,10 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(struct object_id *tre\n \t\t\t */\n \t\t\tretval = DANGLING_SYMLINK;\n \n-\t\t\tcontents = read_object_file(&current_tree_oid, &type,\n-\t\t\t\t\t\t    &link_len);\n+\t\t\tcontents = repo_read_object_file(the_repository,\n+\t\t\t\t\t\t\t &current_tree_oid,\n+\t\t\t\t\t\t\t &type,\n+\t\t\t\t\t\t\t &link_len);\n \n \t\t\tif (!contents)\n \t\t\t\tgoto done;\ndiff --git a/tree.c b/tree.c\nindex 215d3fdc7c..e741180482 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -105,7 +105,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,\n \t\t\t\t    oid_to_hex(entry.oid),\n \t\t\t\t    base->buf, entry.path);\n \n-\t\t\tif (parse_commit(commit))\n+\t\t\tif (repo_parse_commit(the_repository, commit))\n \t\t\t\tdie(\"Invalid commit %s in submodule path %s%s\",\n \t\t\t\t    oid_to_hex(entry.oid),\n \t\t\t\t    base->buf, entry.path);\n@@ -221,7 +221,8 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)\n \n \tif (item->object.parsed)\n \t\treturn 0;\n-\tbuffer = read_object_file(&item->object.oid, &type, &size);\n+\tbuffer = repo_read_object_file(the_repository, &item->object.oid,\n+\t\t\t\t       &type, &size);\n \tif (!buffer)\n \t\treturn quiet_on_missing ? -1 :\n \t\t\terror(\"Could not read %s\",\ndiff --git a/walker.c b/walker.c\nindex 96990d84da..3e398cd485 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -78,7 +78,7 @@ static int process_commit(struct walker *walker, struct commit *commit)\n {\n \tstruct commit_list *parents;\n \n-\tif (parse_commit(commit))\n+\tif (repo_parse_commit(the_repository, commit))\n \t\treturn -1;\n \n \twhile (complete && complete->item->date >= commit->date) {\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex ec6e574e4a..742553de49 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -192,7 +192,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n \t\treturn;\n \t}\n \n-\tptr->ptr = read_object_file(oid, &type, &size);\n+\tptr->ptr = repo_read_object_file(the_repository, oid, &type, &size);\n \tif (!ptr->ptr || type != OBJ_BLOB)\n \t\tdie(\"unable to read blob object %s\", oid_to_hex(oid));\n \tptr->size = size;\n-- \n2.19.0\n\n"},{"id":"360231","messageId":"20181011215823.182711-1-jonathantanmy@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-4-sbeller@google.com","subject":"Re: [PATCH 03/19] object-store: allow read_object_file_extended to read from arbitrary repositories","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-10-11T21:58:23Z","receivedAt":"2018-10-11T21:58:37Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"> @@ -1413,10 +1414,10 @@ void *read_object_file_extended(const struct object_id *oid,\n>  \tconst char *path;\n>  \tstruct stat st;\n>  \tconst struct object_id *repl = lookup_replace ?\n> -\t\tlookup_replace_object(the_repository, oid) : oid;\n> +\t\tlookup_replace_object(r, oid) : oid;\n\nFirstly, patches 1 and 2 are obviously correct.\n\nThis lookup_replace_object() is a bit tricky in that at 'master',\nregister_replace_ref() (indirectly called by lookup_replace_object())\ndid not handle arbitrary repositories correctly, but 'next' has a patch\nthat solves this, so this shouldn't be an issue. The other function\nchanges look fine. So this patch looks correct too.\n"},{"id":"360232","messageId":"20181011220147.183266-1-jonathantanmy@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-5-sbeller@google.com","subject":"Re: [PATCH 04/19] object-store: prepare read_object_file to deal with arbitrary repositories","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-10-11T22:01:47Z","receivedAt":"2018-10-11T22:01:52Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"> Introduce repo_read_object_file which takes the repository argument, and\n> hide the original read_object_file as a macro behind\n> NO_THE_REPOSITORY_COMPATIBILITY_MACROS, which we planned for in\n> e675765235 (diff.c: remove implicit dependency on the_index, 2018-09-21)\n\nThat commit didn't seem to plan for anything - it just seems to add a\nnew function with the name \"repo_\" preprended and define a macro if\nNO_THE_REPOSITORY_COMPATIBILITY_MACROS is not set, just like this patch.\nMaybe s/which we planned for in/just like in/.\n\nThe patch itself looks good.\n"},{"id":"360233","messageId":"CAGZ79ka7Kv51SpqiGdZTr4fA7iAJ1aw-h41NuQPqLutBGaTSfw@mail.gmail.com","threadId":"49542","inReplyTo":"20181011220147.183266-1-jonathantanmy@google.com","subject":"Re: [PATCH 04/19] object-store: prepare read_object_file to deal with arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T22:02:49Z","receivedAt":"2018-10-11T22:03:03Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Oct 11, 2018 at 3:01 PM Jonathan Tan <jonathantanmy@google.com> wrote:\n>\n> > Introduce repo_read_object_file which takes the repository argument, and\n> > hide the original read_object_file as a macro behind\n> > NO_THE_REPOSITORY_COMPATIBILITY_MACROS, which we planned for in\n> > e675765235 (diff.c: remove implicit dependency on the_index, 2018-09-21)\n>\n> That commit didn't seem to plan for anything - it just seems to add a\n> new function with the name \"repo_\" preprended and define a macro if\n> NO_THE_REPOSITORY_COMPATIBILITY_MACROS is not set, just like this patch.\n> Maybe s/which we planned for in/just like in/.\n\nI was reading too much into\n\n    The plan is these macros will always be defined for all library files\n    and the macros are only accessible in builtin/\n\nof that commit message.\n"},{"id":"360234","messageId":"20181011221114.186377-1-jonathantanmy@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-6-sbeller@google.com","subject":"Re: [PATCH 05/19] object: parse_object to honor its repository argument","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-10-11T22:11:14Z","receivedAt":"2018-10-11T22:11:21Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"> In 8e4b0b6047 (object.c: allow parse_object to handle\n> arbitrary repositories, 2018-06-28), we forgot to pass the\n> repository down to the read_object_file.\n\n[snip]\n\n> @@ -270,7 +270,7 @@ struct object *parse_object(struct repository *r, const struct object_id *oid)\n>  \t\treturn lookup_object(r, oid->hash);\n>  \t}\n>  \n> -\tbuffer = read_object_file(oid, &type, &size);\n> +\tbuffer = repo_read_object_file(r, oid, &type, &size);\n\nThere is still the matter of the 2 invocations of has_object_file()\nearlier in this function. The first one probably can be replaced with\noid_object_info_extended() (see the definition of\nhas_sha1_file_with_flags() to see how to do it), and the second one\nlooks redundant to me and can be removed. Apart from that, I don't see\nany other invocations that need to be converted, so parse_object() will\nindeed fully honor its repository argument.\n"},{"id":"360236","messageId":"20181011222204.187928-1-jonathantanmy@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-17-sbeller@google.com","subject":"Re: [PATCH 16/19] pretty: prepare format_commit_message to handle arbitrary repositories","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-10-11T22:22:04Z","receivedAt":"2018-10-11T22:22:10Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"Patches 6-16 are all quite straightforward, and are reviewed-by: me.\n"},{"id":"360239","messageId":"20181011224052.191281-1-jonathantanmy@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-18-sbeller@google.com","subject":"Re: [PATCH 17/19] submodule: use submodule repos for object lookup","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-10-11T22:40:52Z","receivedAt":"2018-10-11T22:41:05Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"> +/*\n> + * Initialize 'out' based on the provided submodule path.\n> + *\n> + * Unlike repo_submodule_init, this tolerates submodules not present\n> + * in .gitmodules. NEEDSWORK: The repo_submodule_init behavior is\n> + * preferrable. This function exists only to preserve historical behavior.\n\nWhat do you mean by \"The repo_submodule_init behavior is preferable\"? If\nwe need to preserve historical behavior, then it seems that the most\npreferable one is something that meets our needs (like open_submodule()\nin this patch).\n\n> +static int open_submodule(struct repository *out, const char *path)\n> +{\n> +\tstruct strbuf sb = STRBUF_INIT;\n> +\n> +\tif (submodule_to_gitdir(&sb, path) || repo_init(out, sb.buf, NULL)) {\n> +\t\tstrbuf_release(&sb);\n> +\t\treturn -1;\n> +\t}\n> +\n> +\tout->submodule_prefix = xstrdup(path);\n\nDo we need to set submodule_prefix?\n\n> @@ -507,7 +533,7 @@ static void show_submodule_header(struct diff_options *o, const char *path,\n>  \telse if (is_null_oid(two))\n>  \t\tmessage = \"(submodule deleted)\";\n>  \n> -\tif (add_submodule_odb(path)) {\n> +\tif (open_submodule(sub, path) < 0) {\n\nThis function, as a side effect, writes the open repository to \"sub\" for\nits caller to use. I think it's better if its callers open \"sub\" and\nthen pass it to show_submodule_header() if successful. If opening the\nsubmodule is expected to fail sometimes (like it seems here), then we\ncan allow callers to also pass NULL, and document what happens when NULL\nis passed.\n\nAlso, repositories open in this way should also be freed.\n"},{"id":"360246","messageId":"20181011230028.200488-1-jonathantanmy@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-19-sbeller@google.com","subject":"Re: [PATCH 18/19] submodule: don't add submodule as odb for push","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-10-11T23:00:28Z","receivedAt":"2018-10-11T23:00:40Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"> The submodule was added as an alternative in eb21c732d6 (push: teach\n> --recurse-submodules the on-demand option, 2012-03-29), but was\n> not explained, why.\n> \n> In similar code, submodule_has_commits, the submodule is added as an\n> alternative to perform a quick check if we need to dive into the submodule.\n> \n> However in push_submodule\n> (a) for_each_remote_ref_submodule will also provide the quick check and\n> (b) after that we don't need to have submodule objects around, as all\n>     further code is to spawn a separate process.\n\nAfter some investigation, I think I understand. I would explain it this\nway:\n\n  In push_submodule(), because we do not actually need access to objects\n  in the submodule, do not invoke add_submodule_odb().\n  (for_each_remote_ref_submodule() does not require access to those\n  objects, and the actual push is done by spawning another process,\n  which handles object access by itself.)\n\nI'm not sure if it's worth mentioning the commit in which the call was\nintroduced, since nothing seems to have changed between then and now\n(the same bug is present when it was introduced, and now).\n\nI also checked the users of push_submodule() (transport_push()) and\nindeed it doesn't seem to make use of the additional objects brought in\nby add_submodule_odb().\n\nDo you know if pushing of submodules is exercised by any test?\n\nOther than that, the code itself looks good.\n"},{"id":"360249","messageId":"20181011230748.201450-1-jonathantanmy@google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"Re: [RFC PATCH 00/19] Bring more repository handles into our code base","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-10-11T23:07:48Z","receivedAt":"2018-10-11T23:07:53Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"> This series takes another approach as it doesn't change the signature of\n> functions, but introduces new functions that can deal with arbitrary \n> repositories, keeping the old function signature around using a shallow wrapper.\n> \n> Additionally each patch adds a semantic patch, that would port from the old to\n> the new function. These semantic patches are all applied in the very last patch,\n> but we could omit applying the last patch if it causes too many merge conflicts\n> and trickl in the semantic patches over time when there are no merge conflicts.\n\nThanks, this looks like a good plan.\n\nOne concern is that if we leave 2 versions of functions around, it will\nbe difficult to look at a function and see if it's truly\nmulti-repository-compatible (or making a call to a function that\ninternally uses the_repository, and is thus wrong). But with the plan\nStefan quoted [1], mentioned in commit e675765235 (\"diff.c: remove\nimplicit dependency on the_index\", 2018-09-21):\n\n  The plan is these macros will always be defined for all library files\n  and the macros are only accessible in builtin/\n\n(The macros include NO_THE_REPOSITORY_COMPATIBILITY_MACROS, which\ndisables the single-repository function-like macros.) This mitigates the\nconcern somewhat.\n\n[1] https://public-inbox.org/git/20181011211754.31369-1-sbeller@google.com/\n"},{"id":"360254","messageId":"CAGZ79kZx+3Qwx8-is4Bbrrf_FdwUqQGkS+BuVu9QeNK6OLFBFQ@mail.gmail.com","threadId":"49542","inReplyTo":"20181011230028.200488-1-jonathantanmy@google.com","subject":"Re: [PATCH 18/19] submodule: don't add submodule as odb for push","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-11T23:09:56Z","receivedAt":"2018-10-11T23:10:10Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"> Do you know if pushing of submodules is exercised by any test?\n\nt5531-deep-submodule-push.sh (all of them)\nt5545-push-options.sh (ok 4 - push options and submodules)\n"},{"id":"360257","messageId":"xmqqr2gwdprf.fsf@gitster-ct.c.googlers.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"Re: [RFC PATCH 00/19] Bring more repository handles into our code base","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-10-11T23:31:32Z","receivedAt":"2018-10-11T23:31:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> Additionally each patch adds a semantic patch, that would port from the old to\n> the new function. These semantic patches are all applied in the very last patch,\n> but we could omit applying the last patch if it causes too many merge conflicts\n> and trickl in the semantic patches over time when there are no merge conflicts.\n\nThat's an interesting approach ;-)\n\n> The original goal of all these refactoring series was to remove add_submodule_odb \n> in submodule.c, which was partially reached with this series.\n\nYup, that is a very good goalpost to keep in mind.\n\n> remaining calls in another series, but it shows we're close to be done with these\n> large refactorings as far as I am concerned.\n\nNice.\n"},{"id":"360334","messageId":"20181012185037.GA52080@aiede.svl.corp.google.com","threadId":"49542","inReplyTo":"20181011211754.31369-1-sbeller@google.com","subject":"Re: [RFC PATCH 00/19] Bring more repository handles into our code base","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2018-10-12T18:50:37Z","receivedAt":"2018-10-12T18:50:42Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nStefan Beller wrote:\n\n> This applies on nd/the-index (b3c7eef9b05) and is the logical continuation of\n> the object store series, which I sent over the last year.\n>\n> The previous series did take a very slow and pedantic approach,\n> using a #define trick, see cfc62fc98c for details, but it turns out,\n> that it doesn't work:\n\nThanks for the heads up --- this will remind me to review this new\nseries more carefully, since it differs from what was reviewed before.\n\nI think this will be easiest to review with --function-context.  I can\ngenerate that diff locally, so no need to resend.\n\n>    When changing the signature of widely used functions, it burdens the\n>    maintainer in resolving the semantic conflicts.\n>\n>    In the orginal approach this was called a feature, as then we can ensure\n>    that not bugs creep into the code base during the merge window (while such\n>    a refactoring series wanders from pu to master). It turns out this\n>    was not well received and was just burdensome.\n\nI don't agree with this characterization.\n\nThe question of who resolves conflicts is separate from the question\nof whether conflicts appear, which is in turn separate from the\nquestion of whether the build breaks.\n\nI consider making the build break when a caller tries to use a\nhalf-converted function too early to be a very useful feature.  There\nis a way to do that in C++ that allows decoupled conversions, but the\nC version forced an ordering of the conversions.  It seems that the\npain was caused by the combination of\n\n 1. that coupling, which forced an ordering on the conversions and\n    prevented us from ordering the patches in an order based on\n    convenience of integration (unlike e.g. the \"struct object_id\"\n    series which was able to proceed by taking a batch covering a\n    quiet area of the tree at a time)\n\n 2. as you mentioned, removal of old API at the same time of addition\n of new API forced callers across the tree to update at once\n\n 3. the lack of having decided how to handle the anticipated churn\n\nNow most of the conversions are done (thanks much for that) so the\nordering (1) is not the main remaining pain point.  Thanks for\ntackling the other two in this series.\n\nI want future API changes to be easier.  That means tackling the\nfollowing questions up front:\n\n i. Where does this fit in Rusty's API rating scheme\n    <http://sweng.the-davies.net/Home/rustys-api-design-manifesto>?\n    Does misuse (or misconverted callers) break the build, break\n    visibly at runtime, or are the effects more subtle?\n\n ii. Is there good test coverage for the new API?  Are there tests\n     that need to be migrated?\n\n iii. Is there a way to automatically migrate callers, or does this\n      require manual, error-prone work (thanks for tackling that in\n      this one.)\n\n iv. How are we planning to handle multiple patches in flight?  Will\n     the change produce merge conflicts?  How can others on the list\n     help the maintainer with integrating this set of changes?\n\n iv. Is the ending point cleaner than where we started?\n\nThe #define trick you're referring to was a way of addressing (i).\n\n[...]\n>  79 files changed, 571 insertions(+), 278 deletions(-)\n\nMost of the increase is in the coccinelle file and in improved\ndocumentation.\n\nIt appears that some patches use a the_index-style\nNO_THE_REPOSITORY_COMPATIBILITY_MACROS backward compatibility synonym\nand others don't.  Can you say a little more about this aspect of the\napproach?  Would the compatibility macros go away eventually?\n\nThanks,\nJonathan\n"},{"id":"360367","messageId":"CAGZ79kbr-K3OARrn=3dGTmeMUUVVHPw3fp9zX=vy3pJrv8g2Tg@mail.gmail.com","threadId":"49542","inReplyTo":"20181011221114.186377-1-jonathantanmy@google.com","subject":"Re: [PATCH 05/19] object: parse_object to honor its repository argument","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-13T00:00:55Z","receivedAt":"2018-10-13T00:01:09Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Oct 11, 2018 at 3:11 PM Jonathan Tan <jonathantanmy@google.com> wrote:\n>\n> > In 8e4b0b6047 (object.c: allow parse_object to handle\n> > arbitrary repositories, 2018-06-28), we forgot to pass the\n> > repository down to the read_object_file.\n>\n> [snip]\n>\n> > @@ -270,7 +270,7 @@ struct object *parse_object(struct repository *r, const struct object_id *oid)\n> >               return lookup_object(r, oid->hash);\n> >       }\n> >\n> > -     buffer = read_object_file(oid, &type, &size);\n> > +     buffer = repo_read_object_file(r, oid, &type, &size);\n>\n> There is still the matter of the 2 invocations of has_object_file()\n> earlier in this function. The first one probably can be replaced with\n> oid_object_info_extended() (see the definition of\n> has_sha1_file_with_flags() to see how to do it), and the second one\n> looks redundant to me and can be removed. Apart from that, I don't see\n> any other invocations that need to be converted, so parse_object() will\n> indeed fully honor its repository argument.\n\nI will convert the has_{sha1, object}_file[_with_flags] functions\nbefore this patch in a resend and just pass along the repository.\n\nI'll defer the change of logic to another patch to be followed up later.\n"},{"id":"360368","messageId":"CAGZ79kZTxoNMUyX+EHg0q3Ss2M-Etkf0yiw3E40U3VCt4QMwrQ@mail.gmail.com","threadId":"49542","inReplyTo":"20181011224052.191281-1-jonathantanmy@google.com","subject":"Re: [PATCH 17/19] submodule: use submodule repos for object lookup","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-13T00:20:44Z","receivedAt":"2018-10-13T00:20:59Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Oct 11, 2018 at 3:41 PM Jonathan Tan <jonathantanmy@google.com> wrote:\n>\n> > +/*\n> > + * Initialize 'out' based on the provided submodule path.\n> > + *\n> > + * Unlike repo_submodule_init, this tolerates submodules not present\n> > + * in .gitmodules. NEEDSWORK: The repo_submodule_init behavior is\n> > + * preferrable. This function exists only to preserve historical behavior.\n>\n> What do you mean by \"The repo_submodule_init behavior is preferable\"?\n\nPreferable in the sense that it follows the definition of a submodule, but this\nhere works for \"any repo\" that happens to be at the gitlink.\n\n>  If\n> we need to preserve historical behavior, then it seems that the most\n> preferable one is something that meets our needs (like open_submodule()\n> in this patch).\n\nYes, I'll reword to drop the preferrable, but still state the difference.\n\nI wonder if instead we'd want to introduce a\n\n    repo_submodule_init(struct repository *submodule \\\n        struct repository *superproject \\\n        const char *path, \\\n        int tolerate_lookalikes)\n\nAnother patch proposes to replace the path\nby a struct submodule, but for lookalikes, we do not have\na struct submodule to begin with (though in the other\npatches we cook up a fake entry in the submodule config)\n\n> > +static int open_submodule(struct repository *out, const char *path)\n> > +{\n> > +     struct strbuf sb = STRBUF_INIT;\n> > +\n> > +     if (submodule_to_gitdir(&sb, path) || repo_init(out, sb.buf, NULL)) {\n> > +             strbuf_release(&sb);\n> > +             return -1;\n> > +     }\n> > +\n> > +     out->submodule_prefix = xstrdup(path);\n>\n> Do we need to set submodule_prefix?\n\nGood point! Thanks for catching this.\n\n>\n> > @@ -507,7 +533,7 @@ static void show_submodule_header(struct diff_options *o, const char *path,\n> >       else if (is_null_oid(two))\n> >               message = \"(submodule deleted)\";\n> >\n> > -     if (add_submodule_odb(path)) {\n> > +     if (open_submodule(sub, path) < 0) {\n>\n> This function, as a side effect, writes the open repository to \"sub\" for\n> its caller to use. I think it's better if its callers open \"sub\" and\n> then pass it to show_submodule_header() if successful. If opening the\n> submodule is expected to fail sometimes (like it seems here), then we\n> can allow callers to also pass NULL, and document what happens when NULL\n> is passed.\n\nThat looks intriguing, I'll take a look. Note that we also pass\nin **left and **right to have it assigned in there.\n\n>\n> Also, repositories open in this way should also be freed.\n\nYes, thanks!\n"},{"id":"360369","messageId":"CAGZ79ka9L+s8PdREL04MOag-x68SzCc4xHn-JShVFPest6YxZg@mail.gmail.com","threadId":"49542","inReplyTo":"20181012185037.GA52080@aiede.svl.corp.google.com","subject":"Re: [RFC PATCH 00/19] Bring more repository handles into our code base","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-13T00:30:03Z","receivedAt":"2018-10-13T00:30:18Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Fri, Oct 12, 2018 at 11:50 AM Jonathan Nieder <jrnieder@gmail.com> wrote:\n\n>\n> It appears that some patches use a the_index-style\n> NO_THE_REPOSITORY_COMPATIBILITY_MACROS backward compatibility synonym\n> and others don't.  Can you say a little more about this aspect of the\n> approach?  Would the compatibility macros go away eventually?\n\nI use the macro only when not doing the whole conversion in the patch\n(i.e. there is a coccinelle patch IFF there is the macro and vice versa).\n\nIt's quite frankly a judgement call what I would convert as a whole\nand what not, it depends on the usage of the functions and if I know\nseries that are in flight using it. The full conversion is easy to write if\nthere are less than a hand full of callers, so for the \"small case\", I just\ndid it, hoping it won't break other topics in flight.\n"},{"id":"360659","messageId":"CAGZ79kYS7at89igHdg163mcZGmsOXO1jj6iBqSZF_VuMEh=g9A@mail.gmail.com","threadId":"49542","inReplyTo":"20181011224052.191281-1-jonathantanmy@google.com","subject":"Re: [PATCH 17/19] submodule: use submodule repos for object lookup","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-16T19:30:09Z","receivedAt":"2018-10-16T19:30:24Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Oct 11, 2018 at 3:41 PM Jonathan Tan <jonathantanmy@google.com> wrote:\n>\n> > +/*\n> > + * Initialize 'out' based on the provided submodule path.\n> > + *\n> > + * Unlike repo_submodule_init, this tolerates submodules not present\n> > + * in .gitmodules. NEEDSWORK: The repo_submodule_init behavior is\n> > + * preferrable. This function exists only to preserve historical behavior.\n>\n> What do you mean by \"The repo_submodule_init behavior is preferable\"? If\n> we need to preserve historical behavior, then it seems that the most\n> preferable one is something that meets our needs (like open_submodule()\n> in this patch).\n>\n> > +static int open_submodule(struct repository *out, const char *path)\n> > +{\n> > +     struct strbuf sb = STRBUF_INIT;\n> > +\n> > +     if (submodule_to_gitdir(&sb, path) || repo_init(out, sb.buf, NULL)) {\n> > +             strbuf_release(&sb);\n> > +             return -1;\n> > +     }\n> > +\n> > +     out->submodule_prefix = xstrdup(path);\n>\n> Do we need to set submodule_prefix?\n>\n> > @@ -507,7 +533,7 @@ static void show_submodule_header(struct diff_options *o, const char *path,\n> >       else if (is_null_oid(two))\n> >               message = \"(submodule deleted)\";\n> >\n> > -     if (add_submodule_odb(path)) {\n> > +     if (open_submodule(sub, path) < 0) {\n>\n> This function, as a side effect, writes the open repository to \"sub\" for\n> its caller to use. I think it's better if its callers open \"sub\" and\n> then pass it to show_submodule_header() if successful. If opening the\n> submodule is expected to fail sometimes (like it seems here), then we\n> can allow callers to also pass NULL, and document what happens when NULL\n> is passed.\n\nThanks for the review of the whole series!\n\nI have redone this series, addressing all your comments. I addressed\nthis comment differently than suggested, and put the submodule\nrepository argument at the end of the parameter list, such that it\ngoes with all the other arguments to be filled in.\n\nI was about to resend the series, but test-merged with the other\nsubmodule series in flight (origin/sb/submodule-recursive-fetch-gets-the-tip)\nwhich had some conflicts that I can easily resolve by rebasing on top.\n\nIt conflicts a lot when merging to next, due to the latest patch\n(\"Apply semantic patches from previous patches\"), so I am not sure\nhow to proceed properly. Maybe we'd omit that patch and\nrun 'make coccicheck' on next to apply the semantic patches\nthere instead.\n"},{"id":"360694","messageId":"20181016231343.189184-1-jonathantanmy@google.com","threadId":"49542","inReplyTo":"CAGZ79kYS7at89igHdg163mcZGmsOXO1jj6iBqSZF_VuMEh=g9A@mail.gmail.com","subject":"Re: [PATCH 17/19] submodule: use submodule repos for object lookup","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2018-10-16T23:13:43Z","receivedAt":"2018-10-16T23:13:50Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"> Thanks for the review of the whole series!\n> \n> I have redone this series, addressing all your comments. I addressed\n> this comment differently than suggested, and put the submodule\n> repository argument at the end of the parameter list, such that it\n> goes with all the other arguments to be filled in.\n\nSounds good.\n\n> I was about to resend the series, but test-merged with the other\n> submodule series in flight (origin/sb/submodule-recursive-fetch-gets-the-tip)\n> which had some conflicts that I can easily resolve by rebasing on top.\n\nI presume you are talking about [1]? Maybe consider rebasing that one on\ntop of this instead, since this is just a refactoring whereas\nsubmodule-recursive-fetch-gets-the-tip changes functionality, from what\nI understand of patches 8 and 9.\n\n[1] https://public-inbox.org/git/20181016181327.107186-1-sbeller@google.com/\n\n> It conflicts a lot when merging to next, due to the latest patch\n> (\"Apply semantic patches from previous patches\"), so I am not sure\n> how to proceed properly. Maybe we'd omit that patch and\n> run 'make coccicheck' on next to apply the semantic patches\n> there instead.\n\nOmitting the patch sounds good to me. For me, just stating that you have\nexcluded any coccinelle-generated patches in order to ease merging into\nthe various branches is sufficient, and people can test the coccinelle\npatches included by running \"make coccicheck\" then \"patch -p1\n<contrib/coccinelle/the_repository.cocci.patch\".\n"},{"id":"360695","messageId":"CAGZ79kbNybApS60pvusO0OiLVca+JtN=X3vTG3dHiRDSfoy4yA@mail.gmail.com","threadId":"49542","inReplyTo":"20181016231343.189184-1-jonathantanmy@google.com","subject":"Re: [PATCH 17/19] submodule: use submodule repos for object lookup","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-16T23:16:49Z","receivedAt":"2018-10-16T23:17:04Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Oct 16, 2018 at 4:13 PM Jonathan Tan <jonathantanmy@google.com> wrote:\n>\n> > Thanks for the review of the whole series!\n> >\n> > I have redone this series, addressing all your comments. I addressed\n> > this comment differently than suggested, and put the submodule\n> > repository argument at the end of the parameter list, such that it\n> > goes with all the other arguments to be filled in.\n>\n> Sounds good.\n\nActually I changed my mind on that after figuring out how to free\nthe submodule repository appropriately and went with your original suggestion.\n\n>\n> > I was about to resend the series, but test-merged with the other\n> > submodule series in flight (origin/sb/submodule-recursive-fetch-gets-the-tip)\n> > which had some conflicts that I can easily resolve by rebasing on top.\n>\n> I presume you are talking about [1]? Maybe consider rebasing that one on\n> top of this instead, since this is just a refactoring whereas\n> submodule-recursive-fetch-gets-the-tip changes functionality, from what\n> I understand of patches 8 and 9.\n\nFrom my understanding, that series is further along than this one,\nso I would not want to mix up their order.\n\nCurrently I am rebasing this on top of select topics from next,\n(ds/reachable) as that are the other conflicts that I'd have to deal with.\n\n> [1] https://public-inbox.org/git/20181016181327.107186-1-sbeller@google.com/\n>\n> > It conflicts a lot when merging to next, due to the latest patch\n> > (\"Apply semantic patches from previous patches\"), so I am not sure\n> > how to proceed properly. Maybe we'd omit that patch and\n> > run 'make coccicheck' on next to apply the semantic patches\n> > there instead.\n>\n> Omitting the patch sounds good to me. For me, just stating that you have\n> excluded any coccinelle-generated patches in order to ease merging into\n> the various branches is sufficient, and people can test the coccinelle\n> patches included by running \"make coccicheck\" then \"patch -p1\n> <contrib/coccinelle/the_repository.cocci.patch\".\n\nok.\n\nThanks,\nStefan\n"}]}