{"thread":{"id":"48501","subject":"[RFC PATCH 00/19] object store: grafts and shallow.","startedAt":"2018-05-15T23:42:41Z","lastAt":"2018-05-17T22:53:13Z","messageCount":40,"participants":["Stefan Beller"],"isPatch":true,"patchVersion":1,"patchTotal":19},"messages":[{"id":"347723","messageId":"20180515234233.143708-1-sbeller@google.com","threadId":"48501","inReplyTo":null,"subject":"[RFC PATCH 00/19] object store: grafts and shallow.","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:14Z","receivedAt":"2018-05-15T23:42:41Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This applies on top of sb/object-store-alloc[1], and is the next part of the\nobject store series. \n\nI think we're getting close to actually being done in the object store series,\nas the next series to build on top of this will convert the\nlookup_{object, commit, ...} functions.\n\nHowever I marked this series as RFC, as I expect heavy conflicts with the\ncode base. sb/object-store-alloc builds on an older base of the code base\nand there have been some series that will conflict with this one.\nFor example the patch to migrate path functions into a repository world\nwill collide with one of Dschos series as he added another path helper\nfunction there. I am happy to reroll on top of that, but for now I chose\nsb/object-store-alloc to keep the momentum in the object-store series'.\n\nThere is another object store series that is not part of the critical path:\nThere is a mem leak in the pack files stored in the raw object store.\nUpon free'ing the repository we do not free its pack files. We cannot\nfree the packfiles, as otherwise the bitmap code would have dangling\npointers into packfiles that no longer exists, leading to segfaults.\nSo we'll need to have an object store series covering the bitmap code.\nI have something local, which I'll send out shortly.\n\nThanks,\nStefan\n\n[1] with the latest patch replaced as in\n    https://public-inbox.org/git/20180515214842.108713-1-sbeller@google.com/\n\nBrandon Williams (3):\n  commit: convert commit_graft_pos() to handle arbitrary repositories\n  commit: convert register_commit_graft to handle arbitrary repositories\n  commit: convert read_graft_file to handle arbitrary repositories\n\nJonathan Nieder (6):\n  object: move grafts to object parser\n  commit: add repository argument to commit_graft_pos\n  commit: add repository argument to register_commit_graft\n  commit: add repository argument to read_graft_file\n  commit: add repository argument to prepare_commit_graft\n  commit: add repository argument to lookup_commit_graft\n\nStefan Beller (10):\n  object-store: move object access functions to object-store.h\n  shallow: add repository argument to set_alternate_shallow_file\n  shallow: add repository argument to register_shallow\n  shallow: add repository argument to check_shallow_file_for_update\n  shallow: add repository argument to is_repository_shallow\n  cache: convert get_graft_file to handle arbitrary repositories\n  path.c: migrate git_path_ to take a repository argument\n  shallow: migrate shallow information into the object parser\n  commit: allow prepare_commit_graft to handle arbitrary repositories\n  commit: allow lookup_commit_graft to handle arbitrary repositories\n\n apply.c                  |   1 +\n archive-tar.c            |   1 +\n archive-zip.c            |   1 +\n archive.c                |   1 +\n blame.c                  |   9 ++-\n branch.c                 |  14 ++---\n builtin/blame.c          |   4 +-\n builtin/cat-file.c       |   1 +\n builtin/checkout.c       |   1 +\n builtin/clone.c          |   1 +\n builtin/commit-tree.c    |   1 +\n builtin/commit.c         |  38 ++++++-------\n builtin/describe.c       |   1 +\n builtin/difftool.c       |   1 +\n builtin/fast-export.c    |   1 +\n builtin/fetch.c          |   7 ++-\n builtin/fmt-merge-msg.c  |   1 +\n builtin/hash-object.c    |   1 +\n builtin/log.c            |   1 +\n builtin/ls-tree.c        |   1 +\n builtin/merge-tree.c     |   1 +\n builtin/merge.c          |  37 ++++++------\n builtin/mktag.c          |   1 +\n builtin/mktree.c         |   1 +\n builtin/notes.c          |   1 +\n builtin/pack-objects.c   |   6 +-\n builtin/prune.c          |   3 +-\n builtin/pull.c           |   4 +-\n builtin/receive-pack.c   |   3 +-\n builtin/reflog.c         |   1 +\n builtin/remote.c         |   1 +\n builtin/reset.c          |   2 +-\n builtin/rev-list.c       |   1 +\n builtin/rev-parse.c      |   3 +-\n builtin/show-ref.c       |   1 +\n builtin/tag.c            |   1 +\n builtin/unpack-file.c    |   1 +\n builtin/unpack-objects.c |   1 +\n builtin/verify-commit.c  |   1 +\n bulk-checkin.c           |   1 +\n bundle.c                 |   1 +\n cache-tree.c             |   1 +\n cache.h                  | 119 +--------------------------------------\n combine-diff.c           |   1 +\n commit.c                 |  77 +++++++++++++------------\n commit.h                 |  10 ++--\n config.c                 |   1 +\n convert.c                |   1 +\n diff.c                   |   1 +\n diffcore-rename.c        |   1 +\n dir.c                    |   1 +\n entry.c                  |   1 +\n environment.c            |   8 +--\n fetch-pack.c             |   9 +--\n fsck.c                   |   3 +-\n git.c                    |   2 +-\n grep.c                   |   1 +\n list-objects-filter.c    |   1 +\n list-objects.c           |   1 +\n log-tree.c               |   1 +\n mailmap.c                |   1 +\n match-trees.c            |   1 +\n merge-blobs.c            |   1 +\n merge-recursive.c        |   1 +\n notes-cache.c            |   1 +\n notes-merge.c            |   1 +\n notes.c                  |   1 +\n object-store.h           | 117 ++++++++++++++++++++++++++++++++++++++\n object.c                 |   4 ++\n object.h                 |  10 ++++\n pack-bitmap-write.c      |   1 +\n packfile.h               |   5 ++\n path.c                   |  18 +++---\n path.h                   |  40 ++++++++++---\n read-cache.c             |   1 +\n ref-filter.c             |   1 +\n refs.c                   |   1 +\n remote-testsvn.c         |   1 +\n remote.c                 |   1 +\n repository.h             |   5 ++\n rerere.c                 |   8 ++-\n revision.c               |   1 +\n send-pack.c              |   7 ++-\n sequencer.c              |  38 +++++++------\n shallow.c                |  74 ++++++++++++------------\n submodule-config.c       |   1 +\n tag.c                    |   1 +\n tree-walk.c              |   1 +\n tree.c                   |   1 +\n unpack-trees.c           |   1 +\n upload-pack.c            |  10 ++--\n walker.c                 |   1 +\n wt-status.c              |   8 +--\n xdiff-interface.c        |   1 +\n 94 files changed, 450 insertions(+), 314 deletions(-)\n\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347724","messageId":"20180515234233.143708-3-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 02/19] object: move grafts to object parser","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:16Z","receivedAt":"2018-05-15T23:42:46Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nGrafts are only meaningful in the context of a single repository.\nTherefore they cannot be global.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n commit.c | 42 +++++++++++++++++++++++-------------------\n object.h |  4 ++++\n 2 files changed, 27 insertions(+), 19 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex b053f07f305..a0c9eb05c82 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"tag.h\"\n #include \"commit.h\"\n+#include \"repository.h\"\n #include \"object-store.h\"\n #include \"pkt-line.h\"\n #include \"utf8.h\"\n@@ -97,9 +98,6 @@ static timestamp_t parse_commit_date(const char *buf, const char *tail)\n \treturn parse_timestamp(dateptr, NULL, 10);\n }\n \n-static struct commit_graft **commit_graft;\n-static int commit_graft_alloc, commit_graft_nr;\n-\n static const unsigned char *commit_graft_sha1_access(size_t index, void *table)\n {\n \tstruct commit_graft **commit_graft_table = table;\n@@ -108,7 +106,8 @@ static const unsigned char *commit_graft_sha1_access(size_t index, void *table)\n \n static int commit_graft_pos(const unsigned char *sha1)\n {\n-\treturn sha1_pos(sha1, commit_graft, commit_graft_nr,\n+\treturn sha1_pos(sha1, the_repository->parsed_objects->grafts,\n+\t\t\tthe_repository->parsed_objects->grafts_nr,\n \t\t\tcommit_graft_sha1_access);\n }\n \n@@ -120,18 +119,22 @@ int register_commit_graft(struct commit_graft *graft, int ignore_dups)\n \t\tif (ignore_dups)\n \t\t\tfree(graft);\n \t\telse {\n-\t\t\tfree(commit_graft[pos]);\n-\t\t\tcommit_graft[pos] = graft;\n+\t\t\tfree(the_repository->parsed_objects->grafts[pos]);\n+\t\t\tthe_repository->parsed_objects->grafts[pos] = graft;\n \t\t}\n \t\treturn 1;\n \t}\n \tpos = -pos - 1;\n-\tALLOC_GROW(commit_graft, commit_graft_nr + 1, commit_graft_alloc);\n-\tcommit_graft_nr++;\n-\tif (pos < commit_graft_nr)\n-\t\tMOVE_ARRAY(commit_graft + pos + 1, commit_graft + pos,\n-\t\t\t   commit_graft_nr - pos - 1);\n-\tcommit_graft[pos] = graft;\n+\tALLOC_GROW(the_repository->parsed_objects->grafts,\n+\t\t   the_repository->parsed_objects->grafts_nr + 1,\n+\t\t   the_repository->parsed_objects->grafts_alloc);\n+\tthe_repository->parsed_objects->grafts_nr++;\n+\tif (pos < the_repository->parsed_objects->grafts_nr)\n+\t\tmemmove(the_repository->parsed_objects->grafts + pos + 1,\n+\t\t\tthe_repository->parsed_objects->grafts + pos,\n+\t\t\t(the_repository->parsed_objects->grafts_nr - pos - 1) *\n+\t\t\tsizeof(*the_repository->parsed_objects->grafts));\n+\tthe_repository->parsed_objects->grafts[pos] = graft;\n \treturn 0;\n }\n \n@@ -213,14 +216,14 @@ struct commit_graft *lookup_commit_graft(const struct object_id *oid)\n \tpos = commit_graft_pos(oid->hash);\n \tif (pos < 0)\n \t\treturn NULL;\n-\treturn commit_graft[pos];\n+\treturn the_repository->parsed_objects->grafts[pos];\n }\n \n int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data)\n {\n \tint i, ret;\n-\tfor (i = ret = 0; i < commit_graft_nr && !ret; i++)\n-\t\tret = fn(commit_graft[i], cb_data);\n+\tfor (i = ret = 0; i < the_repository->parsed_objects->grafts_nr && !ret; i++)\n+\t\tret = fn(the_repository->parsed_objects->grafts[i], cb_data);\n \treturn ret;\n }\n \n@@ -229,10 +232,11 @@ int unregister_shallow(const struct object_id *oid)\n \tint pos = commit_graft_pos(oid->hash);\n \tif (pos < 0)\n \t\treturn -1;\n-\tif (pos + 1 < commit_graft_nr)\n-\t\tMOVE_ARRAY(commit_graft + pos, commit_graft + pos + 1,\n-\t\t\t   commit_graft_nr - pos - 1);\n-\tcommit_graft_nr--;\n+\tif (pos + 1 < the_repository->parsed_objects->grafts_nr)\n+\t\tMOVE_ARRAY(the_repository->parsed_objects->grafts + pos,\n+\t\t\t   the_repository->parsed_objects->grafts + pos + 1,\n+\t\t\t   the_repository->parsed_objects->grafts_nr - pos - 1);\n+\tthe_repository->parsed_objects->grafts_nr--;\n \treturn 0;\n }\n \ndiff --git a/object.h b/object.h\nindex 7916edb4edf..ec908f9bcc1 100644\n--- a/object.h\n+++ b/object.h\n@@ -12,6 +12,10 @@ struct parsed_object_pool {\n \tstruct alloc_state *tag_state;\n \tstruct alloc_state *object_state;\n \tunsigned commit_count;\n+\n+\t/* parent substitutions from .git/info/grafts and .git/shallow */\n+\tstruct commit_graft **grafts;\n+\tint grafts_alloc, grafts_nr;\n };\n \n struct parsed_object_pool *parsed_object_pool_new(void);\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347725","messageId":"20180515234233.143708-6-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 05/19] commit: add repository argument to read_graft_file","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:19Z","receivedAt":"2018-05-15T23:42:48Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nAdd a repository argument to allow the caller of read_graft_file to be\nmore specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 4e8d3488425..b5c0aec24a0 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -177,7 +177,8 @@ struct commit_graft *read_graft_line(struct strbuf *line)\n \treturn NULL;\n }\n \n-static int read_graft_file(const char *graft_file)\n+#define read_graft_file(r, f) read_graft_file_##r(f)\n+static int read_graft_file_the_repository(const char *graft_file)\n {\n \tFILE *fp = fopen_or_warn(graft_file, \"r\");\n \tstruct strbuf buf = STRBUF_INIT;\n@@ -204,7 +205,7 @@ static void prepare_commit_graft(void)\n \tif (commit_graft_prepared)\n \t\treturn;\n \tgraft_file = get_graft_file();\n-\tread_graft_file(graft_file);\n+\tread_graft_file(the_repository, graft_file);\n \t/* make sure shallows are read */\n \tis_repository_shallow();\n \tcommit_graft_prepared = 1;\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347726","messageId":"20180515234233.143708-7-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 06/19] commit: add repository argument to prepare_commit_graft","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:20Z","receivedAt":"2018-05-15T23:42:51Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nAdd a repository argument to allow the caller of prepare_commit_graft\nto be more specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex b5c0aec24a0..a0400b93a1e 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -197,7 +197,8 @@ static int read_graft_file_the_repository(const char *graft_file)\n \treturn 0;\n }\n \n-static void prepare_commit_graft(void)\n+#define prepare_commit_graft(r) prepare_commit_graft_##r()\n+static void prepare_commit_graft_the_repository(void)\n {\n \tstatic int commit_graft_prepared;\n \tchar *graft_file;\n@@ -214,7 +215,7 @@ static void prepare_commit_graft(void)\n struct commit_graft *lookup_commit_graft(const struct object_id *oid)\n {\n \tint pos;\n-\tprepare_commit_graft();\n+\tprepare_commit_graft(the_repository);\n \tpos = commit_graft_pos(the_repository, oid->hash);\n \tif (pos < 0)\n \t\treturn NULL;\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347727","messageId":"20180515234233.143708-10-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 09/19] shallow: add repository argument to register_shallow","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:23Z","receivedAt":"2018-05-15T23:42:54Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/pack-objects.c | 2 +-\n builtin/receive-pack.c | 2 +-\n commit.h               | 3 ++-\n fetch-pack.c           | 2 +-\n shallow.c              | 4 ++--\n upload-pack.c          | 7 ++++---\n 6 files changed, 11 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex d65eb4a9478..97a5963efb6 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2875,7 +2875,7 @@ static void get_object_list(int ac, const char **av)\n \t\t\t\tstruct object_id oid;\n \t\t\t\tif (get_oid_hex(line + 10, &oid))\n \t\t\t\t\tdie(\"not an SHA-1 '%s'\", line + 10);\n-\t\t\t\tregister_shallow(&oid);\n+\t\t\t\tregister_shallow(the_repository, &oid);\n \t\t\t\tuse_bitmap_index = 0;\n \t\t\t\tcontinue;\n \t\t\t}\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 36906fd5e98..c666820b69a 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -906,7 +906,7 @@ static int update_shallow_ref(struct command *cmd, struct shallow_info *si)\n \t * not lose these new roots..\n \t */\n \tfor (i = 0; i < extra.nr; i++)\n-\t\tregister_shallow(&extra.oid[i]);\n+\t\tregister_shallow(the_repository, &extra.oid[i]);\n \n \tsi->shallow_ref[cmd->index] = 0;\n \toid_array_clear(&extra);\ndiff --git a/commit.h b/commit.h\nindex f88c854e2f6..59346de5512 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -191,7 +191,8 @@ extern struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n,\n \n struct oid_array;\n struct ref;\n-extern int register_shallow(const struct object_id *oid);\n+#define register_shallow(r, o) register_shallow_##r(o);\n+extern int register_shallow_the_repository(const struct object_id *oid);\n extern int unregister_shallow(const struct object_id *oid);\n extern int for_each_commit_graft(each_commit_graft_fn, void *);\n extern int is_repository_shallow(void);\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex a1535b37b9b..e3e99e44962 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -428,7 +428,7 @@ static int find_common(struct fetch_pack_args *args,\n \t\t\tif (skip_prefix(line, \"shallow \", &arg)) {\n \t\t\t\tif (get_oid_hex(arg, &oid))\n \t\t\t\t\tdie(_(\"invalid shallow line: %s\"), line);\n-\t\t\t\tregister_shallow(&oid);\n+\t\t\t\tregister_shallow(the_repository, &oid);\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (skip_prefix(line, \"unshallow \", &arg)) {\ndiff --git a/shallow.c b/shallow.c\nindex 73cb11a9162..0fadd5330d2 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -29,7 +29,7 @@ void set_alternate_shallow_file_the_repository(const char *path, int override)\n \talternate_shallow_file = xstrdup_or_null(path);\n }\n \n-int register_shallow(const struct object_id *oid)\n+int register_shallow_the_repository(const struct object_id *oid)\n {\n \tstruct commit_graft *graft =\n \t\txmalloc(sizeof(struct commit_graft));\n@@ -70,7 +70,7 @@ int is_repository_shallow(void)\n \t\tstruct object_id oid;\n \t\tif (get_oid_hex(buf, &oid))\n \t\t\tdie(\"bad shallow line: %s\", buf);\n-\t\tregister_shallow(&oid);\n+\t\tregister_shallow(the_repository, &oid);\n \t}\n \tfclose(fp);\n \treturn is_shallow;\ndiff --git a/upload-pack.c b/upload-pack.c\nindex a11c6d192ce..4e4ac0f0d95 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -663,7 +663,7 @@ static void send_shallow(struct commit_list *result)\n \t\tif (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {\n \t\t\tpacket_write_fmt(1, \"shallow %s\",\n \t\t\t\t\t oid_to_hex(&object->oid));\n-\t\t\tregister_shallow(&object->oid);\n+\t\t\tregister_shallow(the_repository, &object->oid);\n \t\t\tshallow_nr++;\n \t\t}\n \t\tresult = result->next;\n@@ -700,7 +700,7 @@ static void send_unshallow(const struct object_array *shallows)\n \t\t\tadd_object_array(object, NULL, &extra_edge_obj);\n \t\t}\n \t\t/* make sure commit traversal conforms to client */\n-\t\tregister_shallow(&object->oid);\n+\t\tregister_shallow(the_repository, &object->oid);\n \t}\n }\n \n@@ -912,7 +912,8 @@ static void receive_needs(void)\n \t\tif (shallows.nr > 0) {\n \t\t\tint i;\n \t\t\tfor (i = 0; i < shallows.nr; i++)\n-\t\t\t\tregister_shallow(&shallows.objects[i].item->oid);\n+\t\t\t\tregister_shallow(the_repository,\n+\t\t\t\t\t\t &shallows.objects[i].item->oid);\n \t\t}\n \n \tshallow_nr += shallows.nr;\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347728","messageId":"20180515234233.143708-12-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 11/19] shallow: add repository argument to is_repository_shallow","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:25Z","receivedAt":"2018-05-15T23:42:58Z","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 builtin/fetch.c        | 2 +-\n builtin/pack-objects.c | 4 ++--\n builtin/prune.c        | 2 +-\n builtin/rev-parse.c    | 3 ++-\n commit.c               | 2 +-\n commit.h               | 3 ++-\n fetch-pack.c           | 4 ++--\n send-pack.c            | 6 +++---\n shallow.c              | 8 ++++----\n upload-pack.c          | 2 +-\n 10 files changed, 19 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex c1f2df97965..55140671ef3 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -1445,7 +1445,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)\n \tif (unshallow) {\n \t\tif (depth)\n \t\t\tdie(_(\"--depth and --unshallow cannot be used together\"));\n-\t\telse if (!is_repository_shallow())\n+\t\telse if (!is_repository_shallow(the_repository))\n \t\t\tdie(_(\"--unshallow on a complete repository does not make sense\"));\n \t\telse\n \t\t\tdepth = xstrfmt(\"%d\", INFINITE_DEPTH);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 97a5963efb6..0f1eec2eecd 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2857,7 +2857,7 @@ static void get_object_list(int ac, const char **av)\n \tsetup_revisions(ac, av, &revs, NULL);\n \n \t/* make sure shallows are read */\n-\tis_repository_shallow();\n+\tis_repository_shallow(the_repository);\n \n \twhile (fgets(line, sizeof(line), stdin) != NULL) {\n \t\tint len = strlen(line);\n@@ -3142,7 +3142,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \t\tuse_bitmap_index = use_bitmap_index_default;\n \n \t/* \"hard\" reasons not to use bitmaps; these just won't work at all */\n-\tif (!use_internal_rev_list || (!pack_to_stdout && write_bitmap_index) || is_repository_shallow())\n+\tif (!use_internal_rev_list || (!pack_to_stdout && write_bitmap_index) || is_repository_shallow(the_repository))\n \t\tuse_bitmap_index = 0;\n \n \tif (pack_to_stdout || !rev_list_all)\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 8cc8659612f..70ec35aa058 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -160,7 +160,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)\n \tremove_temporary_files(s);\n \tfree(s);\n \n-\tif (is_repository_shallow())\n+\tif (is_repository_shallow(the_repository))\n \t\tprune_shallow(show_only);\n \n \treturn 0;\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex 36b20877828..a8a9b506ff6 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -879,7 +879,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--is-shallow-repository\")) {\n-\t\t\t\tprintf(\"%s\\n\", is_repository_shallow() ? \"true\"\n+\t\t\t\tprintf(\"%s\\n\",\n+\t\t\t\t\t\tis_repository_shallow(the_repository) ? \"true\"\n \t\t\t\t\t\t: \"false\");\n \t\t\t\tcontinue;\n \t\t\t}\ndiff --git a/commit.c b/commit.c\nindex c832133f055..684eeaa2ccd 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -208,7 +208,7 @@ static void prepare_commit_graft_the_repository(void)\n \tgraft_file = get_graft_file();\n \tread_graft_file(the_repository, graft_file);\n \t/* make sure shallows are read */\n-\tis_repository_shallow();\n+\tis_repository_shallow(the_repository);\n \tcommit_graft_prepared = 1;\n }\n \ndiff --git a/commit.h b/commit.h\nindex 59346de5512..c7f25d6490a 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -195,7 +195,8 @@ struct ref;\n extern int register_shallow_the_repository(const struct object_id *oid);\n extern int unregister_shallow(const struct object_id *oid);\n extern int for_each_commit_graft(each_commit_graft_fn, void *);\n-extern int is_repository_shallow(void);\n+#define is_repository_shallow(r) is_repository_shallow_##r()\n+extern int is_repository_shallow_the_repository(void);\n extern struct commit_list *get_shallow_commits(struct object_array *heads,\n \t\tint depth, int shallow_flag, int not_shallow_flag);\n extern struct commit_list *get_shallow_commits_by_rev_list(\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex e3e99e44962..90befd370fe 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -397,7 +397,7 @@ static int find_common(struct fetch_pack_args *args,\n \t\treturn 1;\n \t}\n \n-\tif (is_repository_shallow())\n+\tif (is_repository_shallow(the_repository))\n \t\twrite_shallow_commits(&req_buf, 1, NULL);\n \tif (args->depth > 0)\n \t\tpacket_buf_write(&req_buf, \"deepen %d\", args->depth);\n@@ -986,7 +986,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,\n \tsort_ref_list(&ref, ref_compare_name);\n \tQSORT(sought, nr_sought, cmp_ref_by_name);\n \n-\tif ((args->depth > 0 || is_repository_shallow()) && !server_supports(\"shallow\"))\n+\tif ((args->depth > 0 || is_repository_shallow(the_repository)) && !server_supports(\"shallow\"))\n \t\tdie(_(\"Server does not support shallow clients\"));\n \tif (args->depth > 0 || args->deepen_since || args->deepen_not)\n \t\targs->deepen = 1;\ndiff --git a/send-pack.c b/send-pack.c\nindex 71600028cdd..e920ca57df4 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -76,7 +76,7 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc\n \t\targv_array_push(&po.args, \"-q\");\n \tif (args->progress)\n \t\targv_array_push(&po.args, \"--progress\");\n-\tif (is_repository_shallow())\n+\tif (is_repository_shallow(the_repository))\n \t\targv_array_push(&po.args, \"--shallow\");\n \tpo.in = -1;\n \tpo.out = args->stateless_rpc ? -1 : fd;\n@@ -221,7 +221,7 @@ static int advertise_shallow_grafts_cb(const struct commit_graft *graft, void *c\n \n static void advertise_shallow_grafts_buf(struct strbuf *sb)\n {\n-\tif (!is_repository_shallow())\n+\tif (!is_repository_shallow(the_repository))\n \t\treturn;\n \tfor_each_commit_graft(advertise_shallow_grafts_cb, sb);\n }\n@@ -538,7 +538,7 @@ int send_pack(struct send_pack_args *args,\n \t}\n \n \tif (args->stateless_rpc) {\n-\t\tif (!args->dry_run && (cmds_sent || is_repository_shallow())) {\n+\t\tif (!args->dry_run && (cmds_sent || is_repository_shallow(the_repository))) {\n \t\t\tpacket_buf_flush(&req_buf);\n \t\t\tsend_sideband(out, -1, req_buf.buf, req_buf.len, LARGE_PACKET_MAX);\n \t\t}\ndiff --git a/shallow.c b/shallow.c\nindex 0028e4ea776..e903651202b 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -42,7 +42,7 @@ int register_shallow_the_repository(const struct object_id *oid)\n \treturn register_commit_graft(the_repository, graft, 0);\n }\n \n-int is_repository_shallow(void)\n+int is_repository_shallow_the_repository(void)\n {\n \tFILE *fp;\n \tchar buf[1024];\n@@ -108,7 +108,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,\n \t\tparse_commit_or_die(commit);\n \t\tcur_depth++;\n \t\tif ((depth != INFINITE_DEPTH && cur_depth >= depth) ||\n-\t\t    (is_repository_shallow() && !commit->parents &&\n+\t\t    (is_repository_shallow(the_repository) && !commit->parents &&\n \t\t     (graft = lookup_commit_graft(the_repository, &commit->object.oid)) != NULL &&\n \t\t     graft->nr_parent < 0)) {\n \t\t\tcommit_list_insert(commit, &result);\n@@ -167,7 +167,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,\n \t */\n \tclear_object_flags(both_flags);\n \n-\tis_repository_shallow(); /* make sure shallows are read */\n+\tis_repository_shallow(the_repository); /* make sure shallows are read */\n \n \tinit_revisions(&revs, NULL);\n \tsave_commit_buffer = 0;\n@@ -345,7 +345,7 @@ static int advertise_shallow_grafts_cb(const struct commit_graft *graft, void *c\n \n void advertise_shallow_grafts(int fd)\n {\n-\tif (!is_repository_shallow())\n+\tif (!is_repository_shallow(the_repository))\n \t\treturn;\n \tfor_each_commit_graft(advertise_shallow_grafts_cb, &fd);\n }\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 4e4ac0f0d95..51b9038111e 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -707,7 +707,7 @@ static void send_unshallow(const struct object_array *shallows)\n static void deepen(int depth, int deepen_relative,\n \t\t   struct object_array *shallows)\n {\n-\tif (depth == INFINITE_DEPTH && !is_repository_shallow()) {\n+\tif (depth == INFINITE_DEPTH && !is_repository_shallow(the_repository)) {\n \t\tint i;\n \n \t\tfor (i = 0; i < shallows->nr; i++) {\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347729","messageId":"20180515234233.143708-14-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 13/19] commit: convert register_commit_graft to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:27Z","receivedAt":"2018-05-15T23:42:59Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Brandon Williams <bmwill@google.com>\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 29 +++++++++++++++--------------\n commit.h |  3 +--\n 2 files changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 0ec3d22813a..8a2ab53fc67 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -111,30 +111,31 @@ static int commit_graft_pos(struct repository *r, const unsigned char *sha1)\n \t\t\tcommit_graft_sha1_access);\n }\n \n-int register_commit_graft_the_repository(struct commit_graft *graft, int ignore_dups)\n+int register_commit_graft(struct repository *r, struct commit_graft *graft,\n+\t\t\t  int ignore_dups)\n {\n-\tint pos = commit_graft_pos(the_repository, graft->oid.hash);\n+\tint pos = commit_graft_pos(r, graft->oid.hash);\n \n \tif (0 <= pos) {\n \t\tif (ignore_dups)\n \t\t\tfree(graft);\n \t\telse {\n-\t\t\tfree(the_repository->parsed_objects->grafts[pos]);\n-\t\t\tthe_repository->parsed_objects->grafts[pos] = graft;\n+\t\t\tfree(r->parsed_objects->grafts[pos]);\n+\t\t\tr->parsed_objects->grafts[pos] = graft;\n \t\t}\n \t\treturn 1;\n \t}\n \tpos = -pos - 1;\n-\tALLOC_GROW(the_repository->parsed_objects->grafts,\n-\t\t   the_repository->parsed_objects->grafts_nr + 1,\n-\t\t   the_repository->parsed_objects->grafts_alloc);\n-\tthe_repository->parsed_objects->grafts_nr++;\n-\tif (pos < the_repository->parsed_objects->grafts_nr)\n-\t\tmemmove(the_repository->parsed_objects->grafts + pos + 1,\n-\t\t\tthe_repository->parsed_objects->grafts + pos,\n-\t\t\t(the_repository->parsed_objects->grafts_nr - pos - 1) *\n-\t\t\tsizeof(*the_repository->parsed_objects->grafts));\n-\tthe_repository->parsed_objects->grafts[pos] = graft;\n+\tALLOC_GROW(r->parsed_objects->grafts,\n+\t\t   r->parsed_objects->grafts_nr + 1,\n+\t\t   r->parsed_objects->grafts_alloc);\n+\tr->parsed_objects->grafts_nr++;\n+\tif (pos < r->parsed_objects->grafts_nr)\n+\t\tmemmove(r->parsed_objects->grafts + pos + 1,\n+\t\t\tr->parsed_objects->grafts + pos,\n+\t\t\t(r->parsed_objects->grafts_nr - pos - 1) *\n+\t\t\tsizeof(*r->parsed_objects->grafts));\n+\tr->parsed_objects->grafts[pos] = graft;\n \treturn 0;\n }\n \ndiff --git a/commit.h b/commit.h\nindex c7f25d6490a..d04bbed81cf 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -174,8 +174,7 @@ struct commit_graft {\n typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *);\n \n struct commit_graft *read_graft_line(struct strbuf *line);\n-#define register_commit_graft(r, g, i) register_commit_graft_##r(g, i)\n-int register_commit_graft_the_repository(struct commit_graft *, int);\n+int register_commit_graft(struct repository *r, struct commit_graft *, int);\n #define lookup_commit_graft(r, o) lookup_commit_graft_##r(o)\n struct commit_graft *lookup_commit_graft_the_repository(const struct object_id *oid);\n \n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347730","messageId":"20180515234233.143708-16-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 15/19] cache: convert get_graft_file to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:29Z","receivedAt":"2018-05-15T23:43:02Z","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 cache.h       | 2 +-\n commit.c      | 2 +-\n environment.c | 6 +++---\n 3 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex ab716011b7e..cb1aeb1dcbf 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -476,7 +476,7 @@ extern const char *get_git_dir(void);\n extern const char *get_git_common_dir(void);\n extern char *get_object_directory(void);\n extern char *get_index_file(void);\n-extern char *get_graft_file(void);\n+extern char *get_graft_file(struct repository *r);\n extern int set_git_dir(const char *path);\n extern int get_common_dir_noenv(struct strbuf *sb, const char *gitdir);\n extern int get_common_dir(struct strbuf *sb, const char *gitdir);\ndiff --git a/commit.c b/commit.c\nindex 3fcb2fd66ce..24028fd257a 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -204,7 +204,7 @@ static void prepare_commit_graft_the_repository(void)\n \n \tif (commit_graft_prepared)\n \t\treturn;\n-\tgraft_file = get_graft_file();\n+\tgraft_file = get_graft_file(the_repository);\n \tread_graft_file(the_repository, graft_file);\n \t/* make sure shallows are read */\n \tis_repository_shallow(the_repository);\ndiff --git a/environment.c b/environment.c\nindex 87d9e52ffde..ab42346e563 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -316,11 +316,11 @@ char *get_index_file(void)\n \treturn the_repository->index_file;\n }\n \n-char *get_graft_file(void)\n+char *get_graft_file(struct repository *r)\n {\n-\tif (!the_repository->graft_file)\n+\tif (!r->graft_file)\n \t\tBUG(\"git environment hasn't been setup\");\n-\treturn the_repository->graft_file;\n+\treturn r->graft_file;\n }\n \n int set_git_dir(const char *path)\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347731","messageId":"20180515234233.143708-17-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 16/19] path.c: migrate git_path_ to take a repository argument","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:30Z","receivedAt":"2018-05-15T23:43:05Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n blame.c          |  8 +++++---\n branch.c         | 14 +++++++-------\n builtin/commit.c | 38 +++++++++++++++++++-------------------\n builtin/fetch.c  |  4 ++--\n builtin/merge.c  | 37 +++++++++++++++++++------------------\n builtin/pull.c   |  4 ++--\n builtin/reset.c  |  2 +-\n fetch-pack.c     |  2 +-\n path.c           | 18 +++++++++---------\n path.h           | 40 +++++++++++++++++++++++++++++++---------\n repository.h     |  5 +++++\n rerere.c         |  7 ++++---\n sequencer.c      | 37 +++++++++++++++++++------------------\n shallow.c        | 12 +++++++-----\n wt-status.c      |  8 ++++----\n 15 files changed, 135 insertions(+), 101 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex f689bde31cd..c22184c2dad 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -112,17 +112,19 @@ static void append_merge_parents(struct commit_list **tail)\n \tint merge_head;\n \tstruct strbuf line = STRBUF_INIT;\n \n-\tmerge_head = open(git_path_merge_head(), O_RDONLY);\n+\tmerge_head = open(git_path_merge_head(the_repository), O_RDONLY);\n \tif (merge_head < 0) {\n \t\tif (errno == ENOENT)\n \t\t\treturn;\n-\t\tdie(\"cannot open '%s' for reading\", git_path_merge_head());\n+\t\tdie(\"cannot open '%s' for reading\",\n+\t\t    git_path_merge_head(the_repository));\n \t}\n \n \twhile (!strbuf_getwholeline_fd(&line, merge_head, '\\n')) {\n \t\tstruct object_id oid;\n \t\tif (line.len < GIT_SHA1_HEXSZ || get_oid_hex(line.buf, &oid))\n-\t\t\tdie(\"unknown line in '%s': %s\", git_path_merge_head(), line.buf);\n+\t\t\tdie(\"unknown line in '%s': %s\",\n+\t\t\t    git_path_merge_head(the_repository), line.buf);\n \t\ttail = append_parent(tail, &oid);\n \t}\n \tclose(merge_head);\ndiff --git a/branch.c b/branch.c\nindex 2672054f0b5..9b2742de32a 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -339,13 +339,13 @@ void create_branch(const char *name, const char *start_name,\n \n void remove_branch_state(void)\n {\n-\tunlink(git_path_cherry_pick_head());\n-\tunlink(git_path_revert_head());\n-\tunlink(git_path_merge_head());\n-\tunlink(git_path_merge_rr());\n-\tunlink(git_path_merge_msg());\n-\tunlink(git_path_merge_mode());\n-\tunlink(git_path_squash_msg());\n+\tunlink(git_path_cherry_pick_head(the_repository));\n+\tunlink(git_path_revert_head(the_repository));\n+\tunlink(git_path_merge_head(the_repository));\n+\tunlink(git_path_merge_rr(the_repository));\n+\tunlink(git_path_merge_msg(the_repository));\n+\tunlink(git_path_merge_mode(the_repository));\n+\tunlink(git_path_squash_msg(the_repository));\n }\n \n void die_if_checked_out(const char *branch, int ignore_current_worktree)\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 37fcb55ab0a..7c22879777d 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -145,9 +145,9 @@ static int opt_parse_m(const struct option *opt, const char *arg, int unset)\n \n static void determine_whence(struct wt_status *s)\n {\n-\tif (file_exists(git_path_merge_head()))\n+\tif (file_exists(git_path_merge_head(the_repository)))\n \t\twhence = FROM_MERGE;\n-\telse if (file_exists(git_path_cherry_pick_head())) {\n+\telse if (file_exists(git_path_cherry_pick_head(the_repository))) {\n \t\twhence = FROM_CHERRY_PICK;\n \t\tif (file_exists(git_path_seq_dir()))\n \t\t\tsequencer_in_use = 1;\n@@ -696,21 +696,21 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\tif (have_option_m)\n \t\t\tstrbuf_addbuf(&sb, &message);\n \t\thook_arg1 = \"message\";\n-\t} else if (!stat(git_path_merge_msg(), &statbuf)) {\n+\t} else if (!stat(git_path_merge_msg(the_repository), &statbuf)) {\n \t\t/*\n \t\t * prepend SQUASH_MSG here if it exists and a\n \t\t * \"merge --squash\" was originally performed\n \t\t */\n-\t\tif (!stat(git_path_squash_msg(), &statbuf)) {\n-\t\t\tif (strbuf_read_file(&sb, git_path_squash_msg(), 0) < 0)\n+\t\tif (!stat(git_path_squash_msg(the_repository), &statbuf)) {\n+\t\t\tif (strbuf_read_file(&sb, git_path_squash_msg(the_repository), 0) < 0)\n \t\t\t\tdie_errno(_(\"could not read SQUASH_MSG\"));\n \t\t\thook_arg1 = \"squash\";\n \t\t} else\n \t\t\thook_arg1 = \"merge\";\n-\t\tif (strbuf_read_file(&sb, git_path_merge_msg(), 0) < 0)\n+\t\tif (strbuf_read_file(&sb, git_path_merge_msg(the_repository), 0) < 0)\n \t\t\tdie_errno(_(\"could not read MERGE_MSG\"));\n-\t} else if (!stat(git_path_squash_msg(), &statbuf)) {\n-\t\tif (strbuf_read_file(&sb, git_path_squash_msg(), 0) < 0)\n+\t} else if (!stat(git_path_squash_msg(the_repository), &statbuf)) {\n+\t\tif (strbuf_read_file(&sb, git_path_squash_msg(the_repository), 0) < 0)\n \t\t\tdie_errno(_(\"could not read SQUASH_MSG\"));\n \t\thook_arg1 = \"squash\";\n \t} else if (template_file) {\n@@ -791,8 +791,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\t\t\t\"\t%s\\n\"\n \t\t\t\t\t\"and try again.\\n\"),\n \t\t\t\twhence == FROM_MERGE ?\n-\t\t\t\t\tgit_path_merge_head() :\n-\t\t\t\t\tgit_path_cherry_pick_head());\n+\t\t\t\t\tgit_path_merge_head(the_repository) :\n+\t\t\t\t\tgit_path_cherry_pick_head(the_repository));\n \t\t}\n \n \t\tfprintf(s->fp, \"\\n\");\n@@ -1523,7 +1523,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tif (!reflog_msg)\n \t\t\treflog_msg = \"commit (merge)\";\n \t\tpptr = commit_list_append(current_head, pptr);\n-\t\tfp = xfopen(git_path_merge_head(), \"r\");\n+\t\tfp = xfopen(git_path_merge_head(the_repository), \"r\");\n \t\twhile (strbuf_getline_lf(&m, fp) != EOF) {\n \t\t\tstruct commit *parent;\n \n@@ -1534,8 +1534,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tfclose(fp);\n \t\tstrbuf_release(&m);\n-\t\tif (!stat(git_path_merge_mode(), &statbuf)) {\n-\t\t\tif (strbuf_read_file(&sb, git_path_merge_mode(), 0) < 0)\n+\t\tif (!stat(git_path_merge_mode(the_repository), &statbuf)) {\n+\t\t\tif (strbuf_read_file(&sb, git_path_merge_mode(the_repository), 0) < 0)\n \t\t\t\tdie_errno(_(\"could not read MERGE_MODE\"));\n \t\t\tif (!strcmp(sb.buf, \"no-ff\"))\n \t\t\t\tallow_fast_forward = 0;\n@@ -1598,12 +1598,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tdie(\"%s\", err.buf);\n \t}\n \n-\tunlink(git_path_cherry_pick_head());\n-\tunlink(git_path_revert_head());\n-\tunlink(git_path_merge_head());\n-\tunlink(git_path_merge_msg());\n-\tunlink(git_path_merge_mode());\n-\tunlink(git_path_squash_msg());\n+\tunlink(git_path_cherry_pick_head(the_repository));\n+\tunlink(git_path_revert_head(the_repository));\n+\tunlink(git_path_merge_head(the_repository));\n+\tunlink(git_path_merge_msg(the_repository));\n+\tunlink(git_path_merge_mode(the_repository));\n+\tunlink(git_path_squash_msg(the_repository));\n \n \tif (commit_index_files())\n \t\tdie (_(\"Repository has been updated, but unable to write\\n\"\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 55140671ef3..41d74c7e8d3 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -767,7 +767,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \tconst char *what, *kind;\n \tstruct ref *rm;\n \tchar *url;\n-\tconst char *filename = dry_run ? \"/dev/null\" : git_path_fetch_head();\n+\tconst char *filename = dry_run ? \"/dev/null\" : git_path_fetch_head(the_repository);\n \tint want_status;\n \tint summary_width = transport_summary_width(ref_map);\n \n@@ -1019,7 +1019,7 @@ static void check_not_current_branch(struct ref *ref_map)\n \n static int truncate_fetch_head(void)\n {\n-\tconst char *filename = git_path_fetch_head();\n+\tconst char *filename = git_path_fetch_head(the_repository);\n \tFILE *fp = fopen_for_writing(filename);\n \n \tif (!fp)\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 9db5a2cf16e..e9057c1657b 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -245,9 +245,9 @@ static struct option builtin_merge_options[] = {\n /* Cleans up metadata that is uninteresting after a succeeded merge. */\n static void drop_save(void)\n {\n-\tunlink(git_path_merge_head());\n-\tunlink(git_path_merge_msg());\n-\tunlink(git_path_merge_mode());\n+\tunlink(git_path_merge_head(the_repository));\n+\tunlink(git_path_merge_msg(the_repository));\n+\tunlink(git_path_merge_mode(the_repository));\n }\n \n static int save_state(struct object_id *stash)\n@@ -380,7 +380,7 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead\n \t\t\toid_to_hex(&commit->object.oid));\n \t\tpretty_print_commit(&ctx, commit, &out);\n \t}\n-\twrite_file_buf(git_path_squash_msg(), out.buf, out.len);\n+\twrite_file_buf(git_path_squash_msg(the_repository), out.buf, out.len);\n \tstrbuf_release(&out);\n }\n \n@@ -741,7 +741,7 @@ static void add_strategies(const char *string, unsigned attr)\n \n static void read_merge_msg(struct strbuf *msg)\n {\n-\tconst char *filename = git_path_merge_msg();\n+\tconst char *filename = git_path_merge_msg(the_repository);\n \tstrbuf_reset(msg);\n \tif (strbuf_read_file(msg, filename, 0) < 0)\n \t\tdie_errno(_(\"Could not read from '%s'\"), filename);\n@@ -778,18 +778,18 @@ static void prepare_to_commit(struct commit_list *remoteheads)\n \tif (signoff)\n \t\tappend_signoff(&msg, ignore_non_trailer(msg.buf, msg.len), 0);\n \twrite_merge_heads(remoteheads);\n-\twrite_file_buf(git_path_merge_msg(), msg.buf, msg.len);\n+\twrite_file_buf(git_path_merge_msg(the_repository), msg.buf, msg.len);\n \tif (run_commit_hook(0 < option_edit, get_index_file(), \"prepare-commit-msg\",\n-\t\t\t    git_path_merge_msg(), \"merge\", NULL))\n+\t\t\t    git_path_merge_msg(the_repository), \"merge\", NULL))\n \t\tabort_commit(remoteheads, NULL);\n \tif (0 < option_edit) {\n-\t\tif (launch_editor(git_path_merge_msg(), NULL, NULL))\n+\t\tif (launch_editor(git_path_merge_msg(the_repository), NULL, NULL))\n \t\t\tabort_commit(remoteheads, NULL);\n \t}\n \n \tif (verify_msg && run_commit_hook(0 < option_edit, get_index_file(),\n \t\t\t\t\t  \"commit-msg\",\n-\t\t\t\t\t  git_path_merge_msg(), NULL))\n+\t\t\t\t\t  git_path_merge_msg(the_repository), NULL))\n \t\tabort_commit(remoteheads, NULL);\n \n \tread_merge_msg(&msg);\n@@ -859,7 +859,7 @@ static int suggest_conflicts(void)\n \tFILE *fp;\n \tstruct strbuf msgbuf = STRBUF_INIT;\n \n-\tfilename = git_path_merge_msg();\n+\tfilename = git_path_merge_msg(the_repository);\n \tfp = xfopen(filename, \"a\");\n \n \tappend_conflicts_hint(&msgbuf);\n@@ -939,12 +939,12 @@ static void write_merge_heads(struct commit_list *remoteheads)\n \t\t}\n \t\tstrbuf_addf(&buf, \"%s\\n\", oid_to_hex(oid));\n \t}\n-\twrite_file_buf(git_path_merge_head(), buf.buf, buf.len);\n+\twrite_file_buf(git_path_merge_head(the_repository), buf.buf, buf.len);\n \n \tstrbuf_reset(&buf);\n \tif (fast_forward == FF_NO)\n \t\tstrbuf_addstr(&buf, \"no-ff\");\n-\twrite_file_buf(git_path_merge_mode(), buf.buf, buf.len);\n+\twrite_file_buf(git_path_merge_mode(the_repository), buf.buf, buf.len);\n \tstrbuf_release(&buf);\n }\n \n@@ -952,7 +952,8 @@ static void write_merge_state(struct commit_list *remoteheads)\n {\n \twrite_merge_heads(remoteheads);\n \tstrbuf_addch(&merge_msg, '\\n');\n-\twrite_file_buf(git_path_merge_msg(), merge_msg.buf, merge_msg.len);\n+\twrite_file_buf(git_path_merge_msg(the_repository), merge_msg.buf,\n+\t\t       merge_msg.len);\n }\n \n static int default_edit_option(void)\n@@ -1035,7 +1036,7 @@ static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge\n \tif (!merge_names)\n \t\tmerge_names = &fetch_head_file;\n \n-\tfilename = git_path_fetch_head();\n+\tfilename = git_path_fetch_head(the_repository);\n \tfd = open(filename, O_RDONLY);\n \tif (fd < 0)\n \t\tdie_errno(_(\"could not open '%s' for reading\"), filename);\n@@ -1209,7 +1210,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\t\tusage_msg_opt(_(\"--abort expects no arguments\"),\n \t\t\t      builtin_merge_usage, builtin_merge_options);\n \n-\t\tif (!file_exists(git_path_merge_head()))\n+\t\tif (!file_exists(git_path_merge_head(the_repository)))\n \t\t\tdie(_(\"There is no merge to abort (MERGE_HEAD missing).\"));\n \n \t\t/* Invoke 'git reset --merge' */\n@@ -1225,7 +1226,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\t\tusage_msg_opt(_(\"--continue expects no arguments\"),\n \t\t\t      builtin_merge_usage, builtin_merge_options);\n \n-\t\tif (!file_exists(git_path_merge_head()))\n+\t\tif (!file_exists(git_path_merge_head(the_repository)))\n \t\t\tdie(_(\"There is no merge in progress (MERGE_HEAD missing).\"));\n \n \t\t/* Invoke 'git commit' */\n@@ -1236,7 +1237,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \tif (read_cache_unmerged())\n \t\tdie_resolve_conflict(\"merge\");\n \n-\tif (file_exists(git_path_merge_head())) {\n+\tif (file_exists(git_path_merge_head(the_repository))) {\n \t\t/*\n \t\t * There is no unmerged entry, don't advise 'git\n \t\t * add/rm <file>', just 'git commit'.\n@@ -1247,7 +1248,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\telse\n \t\t\tdie(_(\"You have not concluded your merge (MERGE_HEAD exists).\"));\n \t}\n-\tif (file_exists(git_path_cherry_pick_head())) {\n+\tif (file_exists(git_path_cherry_pick_head(the_repository))) {\n \t\tif (advice_resolve_conflict)\n \t\t\tdie(_(\"You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\\n\"\n \t\t\t    \"Please, commit your changes before you merge.\"));\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex e32d6cd5b4c..d21239cd9f3 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -351,7 +351,7 @@ static int git_pull_config(const char *var, const char *value, void *cb)\n  */\n static void get_merge_heads(struct oid_array *merge_heads)\n {\n-\tconst char *filename = git_path_fetch_head();\n+\tconst char *filename = git_path_fetch_head(the_repository);\n \tFILE *fp;\n \tstruct strbuf sb = STRBUF_INIT;\n \tstruct object_id oid;\n@@ -857,7 +857,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)\n \tif (read_cache_unmerged())\n \t\tdie_resolve_conflict(\"pull\");\n \n-\tif (file_exists(git_path_merge_head()))\n+\tif (file_exists(git_path_merge_head(the_repository)))\n \t\tdie_conclude_merge();\n \n \tif (get_oid(\"HEAD\", &orig_head))\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 7f1c3f02a30..a9136a163c0 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -39,7 +39,7 @@ static const char *reset_type_names[] = {\n \n static inline int is_merge(void)\n {\n-\treturn !access(git_path_merge_head(), F_OK);\n+\treturn !access(git_path_merge_head(the_repository), F_OK);\n }\n \n static int reset_index(const struct object_id *oid, int reset_type, int quiet)\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 90befd370fe..8f3aacaaaa2 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -1136,7 +1136,7 @@ static void update_shallow(struct fetch_pack_args *args,\n \n \tif (args->deepen && alternate_shallow_file) {\n \t\tif (*alternate_shallow_file == '\\0') { /* --unshallow */\n-\t\t\tunlink_or_warn(git_path_shallow());\n+\t\t\tunlink_or_warn(git_path_shallow(the_repository));\n \t\t\trollback_lock_file(&shallow_lock);\n \t\t} else\n \t\t\tcommit_lock_file(&shallow_lock);\ndiff --git a/path.c b/path.c\nindex 3308b7b9582..e2745bfd02e 100644\n--- a/path.c\n+++ b/path.c\n@@ -1358,12 +1358,12 @@ char *xdg_cache_home(const char *filename)\n \treturn NULL;\n }\n \n-GIT_PATH_FUNC(git_path_cherry_pick_head, \"CHERRY_PICK_HEAD\")\n-GIT_PATH_FUNC(git_path_revert_head, \"REVERT_HEAD\")\n-GIT_PATH_FUNC(git_path_squash_msg, \"SQUASH_MSG\")\n-GIT_PATH_FUNC(git_path_merge_msg, \"MERGE_MSG\")\n-GIT_PATH_FUNC(git_path_merge_rr, \"MERGE_RR\")\n-GIT_PATH_FUNC(git_path_merge_mode, \"MERGE_MODE\")\n-GIT_PATH_FUNC(git_path_merge_head, \"MERGE_HEAD\")\n-GIT_PATH_FUNC(git_path_fetch_head, \"FETCH_HEAD\")\n-GIT_PATH_FUNC(git_path_shallow, \"shallow\")\n+REPO_GIT_PATH_FUNC(path_cherry_pick_head, \"CHERRY_PICK_HEAD\")\n+REPO_GIT_PATH_FUNC(path_revert_head, \"REVERT_HEAD\")\n+REPO_GIT_PATH_FUNC(path_squash_msg, \"SQUASH_MSG\")\n+REPO_GIT_PATH_FUNC(path_merge_msg, \"MERGE_MSG\")\n+REPO_GIT_PATH_FUNC(path_merge_rr, \"MERGE_RR\")\n+REPO_GIT_PATH_FUNC(path_merge_mode, \"MERGE_MODE\")\n+REPO_GIT_PATH_FUNC(path_merge_head, \"MERGE_HEAD\")\n+REPO_GIT_PATH_FUNC(path_fetch_head, \"FETCH_HEAD\")\n+REPO_GIT_PATH_FUNC(path_shallow, \"shallow\")\ndiff --git a/path.h b/path.h\nindex 1ccd0373c9d..0fa6172f96f 100644\n--- a/path.h\n+++ b/path.h\n@@ -160,14 +160,36 @@ extern void report_linked_checkout_garbage(void);\n \t\treturn ret; \\\n \t}\n \n-const char *git_path_cherry_pick_head(void);\n-const char *git_path_revert_head(void);\n-const char *git_path_squash_msg(void);\n-const char *git_path_merge_msg(void);\n-const char *git_path_merge_rr(void);\n-const char *git_path_merge_mode(void);\n-const char *git_path_merge_head(void);\n-const char *git_path_fetch_head(void);\n-const char *git_path_shallow(void);\n+#define REPO_GIT_PATH_FUNC(var, filename) \\\n+\tconst char *git_##var(struct repository *r) \\\n+\t{ \\\n+\t\tif (!r->cached_paths.var) \\\n+\t\t\tr->cached_paths.var = git_pathdup(filename); \\\n+\t\treturn r->cached_paths.var; \\\n+\t}\n+\n+struct path_cache {\n+\tconst char *path_cherry_pick_head;\n+\tconst char *path_revert_head;\n+\tconst char *path_squash_msg;\n+\tconst char *path_merge_msg;\n+\tconst char *path_merge_rr;\n+\tconst char *path_merge_mode;\n+\tconst char *path_merge_head;\n+\tconst char *path_fetch_head;\n+\tconst char *path_shallow;\n+};\n+\n+#define PATH_CACHE_INIT { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }\n+\n+const char *git_path_cherry_pick_head(struct repository *r);\n+const char *git_path_revert_head(struct repository *r);\n+const char *git_path_squash_msg(struct repository *r);\n+const char *git_path_merge_msg(struct repository *r);\n+const char *git_path_merge_rr(struct repository *r);\n+const char *git_path_merge_mode(struct repository *r);\n+const char *git_path_merge_head(struct repository *r);\n+const char *git_path_fetch_head(struct repository *r);\n+const char *git_path_shallow(struct repository *r);\n \n #endif /* PATH_H */\ndiff --git a/repository.h b/repository.h\nindex 6d199819905..83f9ef15103 100644\n--- a/repository.h\n+++ b/repository.h\n@@ -38,6 +38,11 @@ struct repository {\n \t/* The store in which the refs are held. */\n \tstruct ref_store *refs;\n \n+\t/*\n+\t * Contains path to often used file names.\n+\t */\n+\tstruct path_cache cached_paths;\n+\n \t/*\n \t * Path to the repository's graft file.\n \t * Cannot be NULL after initialization.\ndiff --git a/rerere.c b/rerere.c\nindex fcb99cc9542..a3af88939a2 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -201,7 +201,7 @@ static struct rerere_id *new_rerere_id(unsigned char *sha1)\n static void read_rr(struct string_list *rr)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n-\tFILE *in = fopen_or_warn(git_path_merge_rr(), \"r\");\n+\tFILE *in = fopen_or_warn(git_path_merge_rr(the_repository), \"r\");\n \n \tif (!in)\n \t\treturn;\n@@ -897,7 +897,8 @@ int setup_rerere(struct string_list *merge_rr, int flags)\n \tif (flags & RERERE_READONLY)\n \t\tfd = 0;\n \telse\n-\t\tfd = hold_lock_file_for_update(&write_lock, git_path_merge_rr(),\n+\t\tfd = hold_lock_file_for_update(&write_lock,\n+\t\t\t\t\t       git_path_merge_rr(the_repository),\n \t\t\t\t\t       LOCK_DIE_ON_ERROR);\n \tread_rr(merge_rr);\n \treturn fd;\n@@ -1247,6 +1248,6 @@ void rerere_clear(struct string_list *merge_rr)\n \t\t\trmdir(rerere_path(id, NULL));\n \t\t}\n \t}\n-\tunlink_or_warn(git_path_merge_rr());\n+\tunlink_or_warn(git_path_merge_rr(the_repository));\n \trollback_lock_file(&write_lock);\n }\ndiff --git a/sequencer.c b/sequencer.c\nindex cf6456ab75d..eb0bef45e2a 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -322,7 +322,7 @@ static void print_advice(int show_hint, struct replay_opts *opts)\n \t\t * (typically rebase --interactive) wants to take care\n \t\t * of the commit itself so remove CHERRY_PICK_HEAD\n \t\t */\n-\t\tunlink(git_path_cherry_pick_head());\n+\t\tunlink(git_path_cherry_pick_head(the_repository));\n \t\treturn;\n \t}\n \n@@ -1191,8 +1191,8 @@ static int do_commit(const char *msg_file, const char *author,\n \t\t\t\t    &oid);\n \t\tstrbuf_release(&sb);\n \t\tif (!res) {\n-\t\t\tunlink(git_path_cherry_pick_head());\n-\t\t\tunlink(git_path_merge_msg());\n+\t\t\tunlink(git_path_cherry_pick_head(the_repository));\n+\t\t\tunlink(git_path_merge_msg(the_repository));\n \t\t\tif (!is_rebase_i(opts))\n \t\t\t\tprint_commit_summary(NULL, &oid,\n \t\t\t\t\t\tSUMMARY_SHOW_AUTHOR_DATE);\n@@ -1459,7 +1459,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\tstruct replay_opts *opts, int final_fixup)\n {\n \tunsigned int flags = opts->edit ? EDIT_MSG : 0;\n-\tconst char *msg_file = opts->edit ? NULL : git_path_merge_msg();\n+\tconst char *msg_file = opts->edit ? NULL : git_path_merge_msg(the_repository);\n \tstruct object_id head;\n \tstruct commit *base, *next, *parent;\n \tconst char *base_label, *next_label;\n@@ -1594,12 +1594,12 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\t\tflags |= CLEANUP_MSG;\n \t\t\tmsg_file = rebase_path_fixup_msg();\n \t\t} else {\n-\t\t\tconst char *dest = git_path_squash_msg();\n+\t\t\tconst char *dest = git_path_squash_msg(the_repository);\n \t\t\tunlink(dest);\n \t\t\tif (copy_file(dest, rebase_path_squash_msg(), 0666))\n \t\t\t\treturn error(_(\"could not rename '%s' to '%s'\"),\n \t\t\t\t\t     rebase_path_squash_msg(), dest);\n-\t\t\tunlink(git_path_merge_msg());\n+\t\t\tunlink(git_path_merge_msg(the_repository));\n \t\t\tmsg_file = dest;\n \t\t\tflags |= EDIT_MSG;\n \t\t}\n@@ -1616,13 +1616,13 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\tif (res < 0)\n \t\t\treturn res;\n \t\tres |= write_message(msgbuf.buf, msgbuf.len,\n-\t\t\t\t     git_path_merge_msg(), 0);\n+\t\t\t\t     git_path_merge_msg(the_repository), 0);\n \t} else {\n \t\tstruct commit_list *common = NULL;\n \t\tstruct commit_list *remotes = NULL;\n \n \t\tres = write_message(msgbuf.buf, msgbuf.len,\n-\t\t\t\t    git_path_merge_msg(), 0);\n+\t\t\t\t    git_path_merge_msg(the_repository), 0);\n \n \t\tcommit_list_insert(base, &common);\n \t\tcommit_list_insert(next, &remotes);\n@@ -2168,8 +2168,8 @@ static int rollback_single_pick(void)\n {\n \tstruct object_id head_oid;\n \n-\tif (!file_exists(git_path_cherry_pick_head()) &&\n-\t    !file_exists(git_path_revert_head()))\n+\tif (!file_exists(git_path_cherry_pick_head(the_repository)) &&\n+\t    !file_exists(git_path_revert_head(the_repository)))\n \t\treturn error(_(\"no cherry-pick or revert in progress\"));\n \tif (read_ref_full(\"HEAD\", 0, &head_oid, NULL))\n \t\treturn error(_(\"cannot resolve HEAD\"));\n@@ -2397,10 +2397,11 @@ static int error_failed_squash(struct commit *commit,\n \t\treturn error(_(\"could not rename '%s' to '%s'\"),\n \t\t\trebase_path_squash_msg(), rebase_path_message());\n \tunlink(rebase_path_fixup_msg());\n-\tunlink(git_path_merge_msg());\n-\tif (copy_file(git_path_merge_msg(), rebase_path_message(), 0666))\n+\tunlink(git_path_merge_msg(the_repository));\n+\tif (copy_file(git_path_merge_msg(the_repository), rebase_path_message(), 0666))\n \t\treturn error(_(\"could not copy '%s' to '%s'\"),\n-\t\t\t     rebase_path_message(), git_path_merge_msg());\n+\t\t\t     rebase_path_message(),\n+\t\t\t     git_path_merge_msg(the_repository));\n \treturn error_with_patch(commit, subject, subject_len, opts, 1, 0);\n }\n \n@@ -2756,8 +2757,8 @@ static int continue_single_pick(void)\n {\n \tconst char *argv[] = { \"commit\", NULL };\n \n-\tif (!file_exists(git_path_cherry_pick_head()) &&\n-\t    !file_exists(git_path_revert_head()))\n+\tif (!file_exists(git_path_cherry_pick_head(the_repository)) &&\n+\t    !file_exists(git_path_revert_head(the_repository)))\n \t\treturn error(_(\"no cherry-pick or revert in progress\"));\n \treturn run_command_v_opt(argv, RUN_GIT_CMD);\n }\n@@ -2769,7 +2770,7 @@ static int commit_staged_changes(struct replay_opts *opts)\n \tif (has_unstaged_changes(1))\n \t\treturn error(_(\"cannot rebase: You have unstaged changes.\"));\n \tif (!has_uncommitted_changes(0)) {\n-\t\tconst char *cherry_pick_head = git_path_cherry_pick_head();\n+\t\tconst char *cherry_pick_head = git_path_cherry_pick_head(the_repository);\n \n \t\tif (file_exists(cherry_pick_head) && unlink(cherry_pick_head))\n \t\t\treturn error(_(\"could not remove CHERRY_PICK_HEAD\"));\n@@ -2823,8 +2824,8 @@ int sequencer_continue(struct replay_opts *opts)\n \n \tif (!is_rebase_i(opts)) {\n \t\t/* Verify that the conflict has been resolved */\n-\t\tif (file_exists(git_path_cherry_pick_head()) ||\n-\t\t    file_exists(git_path_revert_head())) {\n+\t\tif (file_exists(git_path_cherry_pick_head(the_repository)) ||\n+\t\t    file_exists(git_path_revert_head(the_repository))) {\n \t\t\tres = continue_single_pick();\n \t\t\tif (res)\n \t\t\t\tgoto release_todo_list;\ndiff --git a/shallow.c b/shallow.c\nindex e903651202b..a0e338459f9 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -52,7 +52,7 @@ int is_repository_shallow_the_repository(void)\n \t\treturn is_shallow;\n \n \tif (!path)\n-\t\tpath = git_path_shallow();\n+\t\tpath = git_path_shallow(the_repository);\n \t/*\n \t * fetch-pack sets '--shallow-file \"\"' as an indicator that no\n \t * shallow file should be used. We could just open it and it\n@@ -223,7 +223,7 @@ static void check_shallow_file_for_update_the_repository(void)\n \tif (is_shallow == -1)\n \t\tdie(\"BUG: shallow must be initialized by now\");\n \n-\tif (!stat_validity_check(&shallow_stat, git_path_shallow()))\n+\tif (!stat_validity_check(&shallow_stat, git_path_shallow(the_repository)))\n \t\tdie(\"shallow file has changed since we read it\");\n }\n \n@@ -318,7 +318,8 @@ void setup_alternate_shallow(struct lock_file *shallow_lock,\n \tstruct strbuf sb = STRBUF_INIT;\n \tint fd;\n \n-\tfd = hold_lock_file_for_update(shallow_lock, git_path_shallow(),\n+\tfd = hold_lock_file_for_update(shallow_lock,\n+\t\t\t\t       git_path_shallow(the_repository),\n \t\t\t\t       LOCK_DIE_ON_ERROR);\n \tcheck_shallow_file_for_update(the_repository);\n \tif (write_shallow_commits(&sb, 0, extra)) {\n@@ -365,7 +366,8 @@ void prune_shallow(int show_only)\n \t\tstrbuf_release(&sb);\n \t\treturn;\n \t}\n-\tfd = hold_lock_file_for_update(&shallow_lock, git_path_shallow(),\n+\tfd = hold_lock_file_for_update(&shallow_lock,\n+\t\t\t\t       git_path_shallow(the_repository),\n \t\t\t\t       LOCK_DIE_ON_ERROR);\n \tcheck_shallow_file_for_update(the_repository);\n \tif (write_shallow_commits_1(&sb, 0, NULL, SEEN_ONLY)) {\n@@ -374,7 +376,7 @@ void prune_shallow(int show_only)\n \t\t\t\t  get_lock_file_path(&shallow_lock));\n \t\tcommit_lock_file(&shallow_lock);\n \t} else {\n-\t\tunlink(git_path_shallow());\n+\t\tunlink(git_path_shallow(the_repository));\n \t\trollback_lock_file(&shallow_lock);\n \t}\n \tstrbuf_release(&sb);\ndiff --git a/wt-status.c b/wt-status.c\nindex 50815e5faff..e35cdfeb4be 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1309,7 +1309,7 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (use \\\"git rebase --abort\\\" to check out the original branch)\"));\n \t\t}\n-\t} else if (state->rebase_in_progress || !stat(git_path_merge_msg(), &st)) {\n+\t} else if (state->rebase_in_progress || !stat(git_path_merge_msg(the_repository), &st)) {\n \t\tprint_rebase_state(s, state, color);\n \t\tif (s->hints)\n \t\t\tstatus_printf_ln(s, color,\n@@ -1544,17 +1544,17 @@ void wt_status_get_state(struct wt_status_state *state,\n \tstruct stat st;\n \tstruct object_id oid;\n \n-\tif (!stat(git_path_merge_head(), &st)) {\n+\tif (!stat(git_path_merge_head(the_repository), &st)) {\n \t\tstate->merge_in_progress = 1;\n \t} else if (wt_status_check_rebase(NULL, state)) {\n \t\t;\t\t/* all set */\n-\t} else if (!stat(git_path_cherry_pick_head(), &st) &&\n+\t} else if (!stat(git_path_cherry_pick_head(the_repository), &st) &&\n \t\t\t!get_oid(\"CHERRY_PICK_HEAD\", &oid)) {\n \t\tstate->cherry_pick_in_progress = 1;\n \t\toidcpy(&state->cherry_pick_head_oid, &oid);\n \t}\n \twt_status_check_bisect(NULL, state);\n-\tif (!stat(git_path_revert_head(), &st) &&\n+\tif (!stat(git_path_revert_head(the_repository), &st) &&\n \t    !get_oid(\"REVERT_HEAD\", &oid)) {\n \t\tstate->revert_in_progress = 1;\n \t\toidcpy(&state->revert_head_oid, &oid);\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347732","messageId":"20180515234233.143708-20-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 19/19] commit: allow lookup_commit_graft to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:33Z","receivedAt":"2018-05-15T23:43:09Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 8 ++++----\n commit.h | 3 +--\n 2 files changed, 5 insertions(+), 6 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex eef1675d692..b01cc0c3e0c 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -209,14 +209,14 @@ static void prepare_commit_graft(struct repository *r)\n \tr->parsed_objects->commit_graft_prepared = 1;\n }\n \n-struct commit_graft *lookup_commit_graft_the_repository(const struct object_id *oid)\n+struct commit_graft *lookup_commit_graft(struct repository *r, const struct object_id *oid)\n {\n \tint pos;\n-\tprepare_commit_graft(the_repository);\n-\tpos = commit_graft_pos(the_repository, oid->hash);\n+\tprepare_commit_graft(r);\n+\tpos = commit_graft_pos(r, oid->hash);\n \tif (pos < 0)\n \t\treturn NULL;\n-\treturn the_repository->parsed_objects->grafts[pos];\n+\treturn r->parsed_objects->grafts[pos];\n }\n \n int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data)\ndiff --git a/commit.h b/commit.h\nindex 45114a95b25..6de6f10cd04 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -175,8 +175,7 @@ typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *);\n \n struct commit_graft *read_graft_line(struct strbuf *line);\n int register_commit_graft(struct repository *r, struct commit_graft *, int);\n-#define lookup_commit_graft(r, o) lookup_commit_graft_##r(o)\n-struct commit_graft *lookup_commit_graft_the_repository(const struct object_id *oid);\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-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347733","messageId":"20180515234233.143708-19-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 18/19] commit: allow prepare_commit_graft to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:32Z","receivedAt":"2018-05-15T23:43:11Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 14 ++++++--------\n object.h |  2 ++\n 2 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 24028fd257a..eef1675d692 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -196,19 +196,17 @@ static int read_graft_file(struct repository *r, const char *graft_file)\n \treturn 0;\n }\n \n-#define prepare_commit_graft(r) prepare_commit_graft_##r()\n-static void prepare_commit_graft_the_repository(void)\n+static void prepare_commit_graft(struct repository *r)\n {\n-\tstatic int commit_graft_prepared;\n \tchar *graft_file;\n \n-\tif (commit_graft_prepared)\n+\tif (r->parsed_objects->commit_graft_prepared)\n \t\treturn;\n-\tgraft_file = get_graft_file(the_repository);\n-\tread_graft_file(the_repository, graft_file);\n+\tgraft_file = get_graft_file(r);\n+\tread_graft_file(r, graft_file);\n \t/* make sure shallows are read */\n-\tis_repository_shallow(the_repository);\n-\tcommit_graft_prepared = 1;\n+\tis_repository_shallow(r);\n+\tr->parsed_objects->commit_graft_prepared = 1;\n }\n \n struct commit_graft *lookup_commit_graft_the_repository(const struct object_id *oid)\ndiff --git a/object.h b/object.h\nindex a314331acaf..4af499ab03e 100644\n--- a/object.h\n+++ b/object.h\n@@ -20,6 +20,8 @@ struct parsed_object_pool {\n \tint is_shallow;\n \tstruct stat_validity *shallow_stat;\n \tchar *alternate_shallow_file;\n+\n+\tint commit_graft_prepared;\n };\n \n struct parsed_object_pool *parsed_object_pool_new(void);\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347734","messageId":"20180515234233.143708-13-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 12/19] commit: convert commit_graft_pos() to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:26Z","receivedAt":"2018-05-15T23:43:17Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Brandon Williams <bmwill@google.com>\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 7 +++----\n 1 file changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 684eeaa2ccd..0ec3d22813a 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -104,11 +104,10 @@ static const unsigned char *commit_graft_sha1_access(size_t index, void *table)\n \treturn commit_graft_table[index]->oid.hash;\n }\n \n-#define commit_graft_pos(r, s) commit_graft_pos_##r(s)\n-static int commit_graft_pos_the_repository(const unsigned char *sha1)\n+static int commit_graft_pos(struct repository *r, const unsigned char *sha1)\n {\n-\treturn sha1_pos(sha1, the_repository->parsed_objects->grafts,\n-\t\t\tthe_repository->parsed_objects->grafts_nr,\n+\treturn sha1_pos(sha1, r->parsed_objects->grafts,\n+\t\t\tr->parsed_objects->grafts_nr,\n \t\t\tcommit_graft_sha1_access);\n }\n \n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347735","messageId":"20180515234233.143708-15-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 14/19] commit: convert read_graft_file to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:28Z","receivedAt":"2018-05-15T23:43:20Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Brandon Williams <bmwill@google.com>\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 8a2ab53fc67..3fcb2fd66ce 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -177,8 +177,7 @@ struct commit_graft *read_graft_line(struct strbuf *line)\n \treturn NULL;\n }\n \n-#define read_graft_file(r, f) read_graft_file_##r(f)\n-static int read_graft_file_the_repository(const char *graft_file)\n+static int read_graft_file(struct repository *r, const char *graft_file)\n {\n \tFILE *fp = fopen_or_warn(graft_file, \"r\");\n \tstruct strbuf buf = STRBUF_INIT;\n@@ -189,7 +188,7 @@ static int read_graft_file_the_repository(const char *graft_file)\n \t\tstruct commit_graft *graft = read_graft_line(&buf);\n \t\tif (!graft)\n \t\t\tcontinue;\n-\t\tif (register_commit_graft(the_repository, graft, 1))\n+\t\tif (register_commit_graft(r, graft, 1))\n \t\t\terror(\"duplicate graft data: %s\", buf.buf);\n \t}\n \tfclose(fp);\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347736","messageId":"20180515234233.143708-18-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 17/19] shallow: migrate shallow information into the object parser","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:31Z","receivedAt":"2018-05-15T23:43: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.h  |  9 +++------\n object.c  |  3 +++\n object.h  |  4 ++++\n shallow.c | 50 ++++++++++++++++++++++++--------------------------\n 4 files changed, 34 insertions(+), 32 deletions(-)\n\ndiff --git a/commit.h b/commit.h\nindex d04bbed81cf..45114a95b25 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -190,18 +190,15 @@ extern struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n,\n \n struct oid_array;\n struct ref;\n-#define register_shallow(r, o) register_shallow_##r(o);\n-extern int register_shallow_the_repository(const struct object_id *oid);\n+extern int register_shallow(struct repository *r, const struct object_id *oid);\n extern int unregister_shallow(const struct object_id *oid);\n extern int for_each_commit_graft(each_commit_graft_fn, void *);\n-#define is_repository_shallow(r) is_repository_shallow_##r()\n-extern int is_repository_shallow_the_repository(void);\n+extern int is_repository_shallow(struct repository *r);\n extern struct commit_list *get_shallow_commits(struct object_array *heads,\n \t\tint depth, int shallow_flag, int not_shallow_flag);\n extern struct commit_list *get_shallow_commits_by_rev_list(\n \t\tint ac, const char **av, int shallow_flag, int not_shallow_flag);\n-#define set_alternate_shallow_file(r, p, o) set_alternate_shallow_file_##r(p, o)\n-extern void set_alternate_shallow_file_the_repository(const char *path, int override);\n+extern void set_alternate_shallow_file(struct repository *r, const char *path, int override);\n extern int write_shallow_commits(struct strbuf *out, int use_pack_protocol,\n \t\t\t\t const struct oid_array *extra);\n extern void setup_alternate_shallow(struct lock_file *shallow_lock,\ndiff --git a/object.c b/object.c\nindex 0116ed6529a..30b8a721cf6 100644\n--- a/object.c\n+++ b/object.c\n@@ -464,6 +464,9 @@ struct parsed_object_pool *parsed_object_pool_new(void)\n \to->tag_state = allocate_alloc_state();\n \to->object_state = allocate_alloc_state();\n \n+\to->is_shallow = -1;\n+\to->shallow_stat = xcalloc(1, sizeof(*o->shallow_stat));\n+\n \treturn o;\n }\n \ndiff --git a/object.h b/object.h\nindex ec908f9bcc1..a314331acaf 100644\n--- a/object.h\n+++ b/object.h\n@@ -16,6 +16,10 @@ struct parsed_object_pool {\n \t/* parent substitutions from .git/info/grafts and .git/shallow */\n \tstruct commit_graft **grafts;\n \tint grafts_alloc, grafts_nr;\n+\n+\tint is_shallow;\n+\tstruct stat_validity *shallow_stat;\n+\tchar *alternate_shallow_file;\n };\n \n struct parsed_object_pool *parsed_object_pool_new(void);\ndiff --git a/shallow.c b/shallow.c\nindex a0e338459f9..560329d53a8 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -14,22 +14,21 @@\n #include \"commit-slab.h\"\n #include \"revision.h\"\n #include \"list-objects.h\"\n+#include \"repository.h\"\n \n-static int is_shallow = -1;\n-static struct stat_validity shallow_stat;\n-static char *alternate_shallow_file;\n+struct stat_validity the_repository_shallow_stat;\n \n-void set_alternate_shallow_file_the_repository(const char *path, int override)\n+void set_alternate_shallow_file(struct repository *r, const char *path, int override)\n {\n-\tif (is_shallow != -1)\n+\tif (r->parsed_objects->is_shallow != -1)\n \t\tdie(\"BUG: is_repository_shallow must not be called before set_alternate_shallow_file\");\n-\tif (alternate_shallow_file && !override)\n+\tif (r->parsed_objects->alternate_shallow_file && !override)\n \t\treturn;\n-\tfree(alternate_shallow_file);\n-\talternate_shallow_file = xstrdup_or_null(path);\n+\tfree(r->parsed_objects->alternate_shallow_file);\n+\tr->parsed_objects->alternate_shallow_file = xstrdup_or_null(path);\n }\n \n-int register_shallow_the_repository(const struct object_id *oid)\n+int register_shallow(struct repository *r, const struct object_id *oid)\n {\n \tstruct commit_graft *graft =\n \t\txmalloc(sizeof(struct commit_graft));\n@@ -39,41 +38,41 @@ int register_shallow_the_repository(const struct object_id *oid)\n \tgraft->nr_parent = -1;\n \tif (commit && commit->object.parsed)\n \t\tcommit->parents = NULL;\n-\treturn register_commit_graft(the_repository, graft, 0);\n+\treturn register_commit_graft(r, graft, 0);\n }\n \n-int is_repository_shallow_the_repository(void)\n+int is_repository_shallow(struct repository *r)\n {\n \tFILE *fp;\n \tchar buf[1024];\n-\tconst char *path = alternate_shallow_file;\n+\tconst char *path = r->parsed_objects->alternate_shallow_file;\n \n-\tif (is_shallow >= 0)\n-\t\treturn is_shallow;\n+\tif (r->parsed_objects->is_shallow >= 0)\n+\t\treturn r->parsed_objects->is_shallow;\n \n \tif (!path)\n-\t\tpath = git_path_shallow(the_repository);\n+\t\tpath = git_path_shallow(r);\n \t/*\n \t * fetch-pack sets '--shallow-file \"\"' as an indicator that no\n \t * shallow file should be used. We could just open it and it\n \t * will likely fail. But let's do an explicit check instead.\n \t */\n \tif (!*path || (fp = fopen(path, \"r\")) == NULL) {\n-\t\tstat_validity_clear(&shallow_stat);\n-\t\tis_shallow = 0;\n-\t\treturn is_shallow;\n+\t\tstat_validity_clear(r->parsed_objects->shallow_stat);\n+\t\tr->parsed_objects->is_shallow = 0;\n+\t\treturn r->parsed_objects->is_shallow;\n \t}\n-\tstat_validity_update(&shallow_stat, fileno(fp));\n-\tis_shallow = 1;\n+\tstat_validity_update(r->parsed_objects->shallow_stat, fileno(fp));\n+\tr->parsed_objects->is_shallow = 1;\n \n \twhile (fgets(buf, sizeof(buf), fp)) {\n \t\tstruct object_id oid;\n \t\tif (get_oid_hex(buf, &oid))\n \t\t\tdie(\"bad shallow line: %s\", buf);\n-\t\tregister_shallow(the_repository, &oid);\n+\t\tregister_shallow(r, &oid);\n \t}\n \tfclose(fp);\n-\treturn is_shallow;\n+\treturn r->parsed_objects->is_shallow;\n }\n \n struct commit_list *get_shallow_commits(struct object_array *heads, int depth,\n@@ -217,13 +216,12 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,\n \treturn result;\n }\n \n-#define check_shallow_file_for_update(r) check_shallow_file_for_update_##r()\n-static void check_shallow_file_for_update_the_repository(void)\n+static void check_shallow_file_for_update(struct repository *r)\n {\n-\tif (is_shallow == -1)\n+\tif (r->parsed_objects->is_shallow == -1)\n \t\tdie(\"BUG: shallow must be initialized by now\");\n \n-\tif (!stat_validity_check(&shallow_stat, git_path_shallow(the_repository)))\n+\tif (!stat_validity_check(r->parsed_objects->shallow_stat, git_path_shallow(the_repository)))\n \t\tdie(\"shallow file has changed since we read it\");\n }\n \n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347737","messageId":"20180515234233.143708-8-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 07/19] commit: add repository argument to lookup_commit_graft","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:21Z","receivedAt":"2018-05-15T23:43:24Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nAdd a repository argument to allow callers of lookup_commit_graft to\nbe more specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nThe included coccinelle semantic patch will adapt any new callers in\nthe diff produced by `make coccicheck`.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c  | 4 ++--\n commit.h  | 3 ++-\n fsck.c    | 2 +-\n shallow.c | 5 +++--\n 4 files changed, 8 insertions(+), 6 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex a0400b93a1e..c832133f055 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -212,7 +212,7 @@ static void prepare_commit_graft_the_repository(void)\n \tcommit_graft_prepared = 1;\n }\n \n-struct commit_graft *lookup_commit_graft(const struct object_id *oid)\n+struct commit_graft *lookup_commit_graft_the_repository(const struct object_id *oid)\n {\n \tint pos;\n \tprepare_commit_graft(the_repository);\n@@ -359,7 +359,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s\n \tbufptr += tree_entry_len + 1; /* \"tree \" + \"hex sha1\" + \"\\n\" */\n \tpptr = &item->parents;\n \n-\tgraft = lookup_commit_graft(&item->object.oid);\n+\tgraft = lookup_commit_graft(the_repository, &item->object.oid);\n \twhile (bufptr + parent_entry_len < tail && !memcmp(bufptr, \"parent \", 7)) {\n \t\tstruct commit *new_parent;\n \ndiff --git a/commit.h b/commit.h\nindex 40a5b5e2585..f6746125766 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -176,7 +176,8 @@ typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *);\n struct commit_graft *read_graft_line(struct strbuf *line);\n #define register_commit_graft(r, g, i) register_commit_graft_##r(g, i)\n int register_commit_graft_the_repository(struct commit_graft *, int);\n-struct commit_graft *lookup_commit_graft(const struct object_id *oid);\n+#define lookup_commit_graft(r, o) lookup_commit_graft_##r(o)\n+struct commit_graft *lookup_commit_graft_the_repository(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);\ndiff --git a/fsck.c b/fsck.c\nindex 59b0c7d640e..104c3c0a434 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -738,7 +738,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,\n \t\tbuffer += 41;\n \t\tparent_line_count++;\n \t}\n-\tgraft = lookup_commit_graft(&commit->object.oid);\n+\tgraft = lookup_commit_graft(the_repository, &commit->object.oid);\n \tparent_count = commit_list_count(commit->parents);\n \tif (graft) {\n \t\tif (graft->nr_parent == -1 && !parent_count)\ndiff --git a/shallow.c b/shallow.c\nindex ef802deed41..ca360c700c5 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -109,7 +109,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,\n \t\tcur_depth++;\n \t\tif ((depth != INFINITE_DEPTH && cur_depth >= depth) ||\n \t\t    (is_repository_shallow() && !commit->parents &&\n-\t\t     (graft = lookup_commit_graft(&commit->object.oid)) != NULL &&\n+\t\t     (graft = lookup_commit_graft(the_repository, &commit->object.oid)) != NULL &&\n \t\t     graft->nr_parent < 0)) {\n \t\t\tcommit_list_insert(commit, &result);\n \t\t\tcommit->object.flags |= shallow_flag;\n@@ -398,7 +398,8 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)\n \tfor (i = 0; i < sa->nr; i++) {\n \t\tif (has_object_file(sa->oid + i)) {\n \t\t\tstruct commit_graft *graft;\n-\t\t\tgraft = lookup_commit_graft(&sa->oid[i]);\n+\t\t\tgraft = lookup_commit_graft(the_repository,\n+\t\t\t\t\t\t    &sa->oid[i]);\n \t\t\tif (graft && graft->nr_parent < 0)\n \t\t\t\tcontinue;\n \t\t\tinfo->ours[info->nr_ours++] = i;\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347738","messageId":"20180515234233.143708-11-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 10/19] shallow: add repository argument to check_shallow_file_for_update","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:24Z","receivedAt":"2018-05-15T23:43:25Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n shallow.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/shallow.c b/shallow.c\nindex 0fadd5330d2..0028e4ea776 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -217,7 +217,8 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,\n \treturn result;\n }\n \n-static void check_shallow_file_for_update(void)\n+#define check_shallow_file_for_update(r) check_shallow_file_for_update_##r()\n+static void check_shallow_file_for_update_the_repository(void)\n {\n \tif (is_shallow == -1)\n \t\tdie(\"BUG: shallow must be initialized by now\");\n@@ -319,7 +320,7 @@ void setup_alternate_shallow(struct lock_file *shallow_lock,\n \n \tfd = hold_lock_file_for_update(shallow_lock, git_path_shallow(),\n \t\t\t\t       LOCK_DIE_ON_ERROR);\n-\tcheck_shallow_file_for_update();\n+\tcheck_shallow_file_for_update(the_repository);\n \tif (write_shallow_commits(&sb, 0, extra)) {\n \t\tif (write_in_full(fd, sb.buf, sb.len) < 0)\n \t\t\tdie_errno(\"failed to write to %s\",\n@@ -366,7 +367,7 @@ void prune_shallow(int show_only)\n \t}\n \tfd = hold_lock_file_for_update(&shallow_lock, git_path_shallow(),\n \t\t\t\t       LOCK_DIE_ON_ERROR);\n-\tcheck_shallow_file_for_update();\n+\tcheck_shallow_file_for_update(the_repository);\n \tif (write_shallow_commits_1(&sb, 0, NULL, SEEN_ONLY)) {\n \t\tif (write_in_full(fd, sb.buf, sb.len) < 0)\n \t\t\tdie_errno(\"failed to write to %s\",\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347739","messageId":"20180515234233.143708-9-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 08/19] shallow: add repository argument to set_alternate_shallow_file","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:22Z","receivedAt":"2018-05-15T23:43: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.h      | 3 ++-\n environment.c | 2 +-\n git.c         | 2 +-\n shallow.c     | 2 +-\n 4 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/commit.h b/commit.h\nindex f6746125766..f88c854e2f6 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -199,7 +199,8 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads,\n \t\tint depth, int shallow_flag, int not_shallow_flag);\n extern struct commit_list *get_shallow_commits_by_rev_list(\n \t\tint ac, const char **av, int shallow_flag, int not_shallow_flag);\n-extern void set_alternate_shallow_file(const char *path, int override);\n+#define set_alternate_shallow_file(r, p, o) set_alternate_shallow_file_##r(p, o)\n+extern void set_alternate_shallow_file_the_repository(const char *path, int override);\n extern int write_shallow_commits(struct strbuf *out, int use_pack_protocol,\n \t\t\t\t const struct oid_array *extra);\n extern void setup_alternate_shallow(struct lock_file *shallow_lock,\ndiff --git a/environment.c b/environment.c\nindex b991fc0a87c..87d9e52ffde 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -189,7 +189,7 @@ void setup_git_env(const char *git_dir)\n \tgit_namespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT));\n \tshallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT);\n \tif (shallow_file)\n-\t\tset_alternate_shallow_file(shallow_file, 0);\n+\t\tset_alternate_shallow_file(the_repository, shallow_file, 0);\n }\n \n int is_bare_repository(void)\ndiff --git a/git.c b/git.c\nindex 3a89893712e..5e8903681e6 100644\n--- a/git.c\n+++ b/git.c\n@@ -207,7 +207,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t} else if (!strcmp(cmd, \"--shallow-file\")) {\n \t\t\t(*argv)++;\n \t\t\t(*argc)--;\n-\t\t\tset_alternate_shallow_file((*argv)[0], 1);\n+\t\t\tset_alternate_shallow_file(the_repository, (*argv)[0], 1);\n \t\t\tif (envchanged)\n \t\t\t\t*envchanged = 1;\n \t\t} else if (!strcmp(cmd, \"-C\")) {\ndiff --git a/shallow.c b/shallow.c\nindex ca360c700c5..73cb11a9162 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -19,7 +19,7 @@ static int is_shallow = -1;\n static struct stat_validity shallow_stat;\n static char *alternate_shallow_file;\n \n-void set_alternate_shallow_file(const char *path, int override)\n+void set_alternate_shallow_file_the_repository(const char *path, int override)\n {\n \tif (is_shallow != -1)\n \t\tdie(\"BUG: is_repository_shallow must not be called before set_alternate_shallow_file\");\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347740","messageId":"20180515234233.143708-4-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 03/19] commit: add repository argument to commit_graft_pos","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:17Z","receivedAt":"2018-05-15T23:43:32Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nAdd a repository argument to allow callers of commit_graft_pos to be\nmore specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex a0c9eb05c82..2cd5b8a0b96 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -104,7 +104,8 @@ static const unsigned char *commit_graft_sha1_access(size_t index, void *table)\n \treturn commit_graft_table[index]->oid.hash;\n }\n \n-static int commit_graft_pos(const unsigned char *sha1)\n+#define commit_graft_pos(r, s) commit_graft_pos_##r(s)\n+static int commit_graft_pos_the_repository(const unsigned char *sha1)\n {\n \treturn sha1_pos(sha1, the_repository->parsed_objects->grafts,\n \t\t\tthe_repository->parsed_objects->grafts_nr,\n@@ -113,7 +114,7 @@ static int commit_graft_pos(const unsigned char *sha1)\n \n int register_commit_graft(struct commit_graft *graft, int ignore_dups)\n {\n-\tint pos = commit_graft_pos(graft->oid.hash);\n+\tint pos = commit_graft_pos(the_repository, graft->oid.hash);\n \n \tif (0 <= pos) {\n \t\tif (ignore_dups)\n@@ -213,7 +214,7 @@ struct commit_graft *lookup_commit_graft(const struct object_id *oid)\n {\n \tint pos;\n \tprepare_commit_graft();\n-\tpos = commit_graft_pos(oid->hash);\n+\tpos = commit_graft_pos(the_repository, oid->hash);\n \tif (pos < 0)\n \t\treturn NULL;\n \treturn the_repository->parsed_objects->grafts[pos];\n@@ -229,7 +230,7 @@ int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data)\n \n int unregister_shallow(const struct object_id *oid)\n {\n-\tint pos = commit_graft_pos(oid->hash);\n+\tint pos = commit_graft_pos(the_repository, oid->hash);\n \tif (pos < 0)\n \t\treturn -1;\n \tif (pos + 1 < the_repository->parsed_objects->grafts_nr)\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347741","messageId":"20180515234233.143708-5-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 04/19] commit: add repository argument to register_commit_graft","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:18Z","receivedAt":"2018-05-15T23:43:36Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nAdd a repository argument to allow callers of register_commit_graft to\nbe more specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/blame.c | 3 ++-\n commit.c        | 4 ++--\n commit.h        | 3 ++-\n shallow.c       | 3 ++-\n 4 files changed, 8 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 0ffd1d443ea..7a07bff2423 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -8,6 +8,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"builtin.h\"\n+#include \"repository.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n #include \"revision.h\"\n@@ -491,7 +492,7 @@ static int read_ancestry(const char *graft_file)\n \t\t/* The format is just \"Commit Parent1 Parent2 ...\\n\" */\n \t\tstruct commit_graft *graft = read_graft_line(&buf);\n \t\tif (graft)\n-\t\t\tregister_commit_graft(graft, 0);\n+\t\t\tregister_commit_graft(the_repository, graft, 0);\n \t}\n \tfclose(fp);\n \tstrbuf_release(&buf);\ndiff --git a/commit.c b/commit.c\nindex 2cd5b8a0b96..4e8d3488425 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -112,7 +112,7 @@ static int commit_graft_pos_the_repository(const unsigned char *sha1)\n \t\t\tcommit_graft_sha1_access);\n }\n \n-int register_commit_graft(struct commit_graft *graft, int ignore_dups)\n+int register_commit_graft_the_repository(struct commit_graft *graft, int ignore_dups)\n {\n \tint pos = commit_graft_pos(the_repository, graft->oid.hash);\n \n@@ -188,7 +188,7 @@ static int read_graft_file(const char *graft_file)\n \t\tstruct commit_graft *graft = read_graft_line(&buf);\n \t\tif (!graft)\n \t\t\tcontinue;\n-\t\tif (register_commit_graft(graft, 1))\n+\t\tif (register_commit_graft(the_repository, graft, 1))\n \t\t\terror(\"duplicate graft data: %s\", buf.buf);\n \t}\n \tfclose(fp);\ndiff --git a/commit.h b/commit.h\nindex 2d764ab7d8e..40a5b5e2585 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -174,7 +174,8 @@ struct commit_graft {\n typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *);\n \n struct commit_graft *read_graft_line(struct strbuf *line);\n-int register_commit_graft(struct commit_graft *, int);\n+#define register_commit_graft(r, g, i) register_commit_graft_##r(g, i)\n+int register_commit_graft_the_repository(struct commit_graft *, int);\n struct commit_graft *lookup_commit_graft(const struct object_id *oid);\n \n extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2);\ndiff --git a/shallow.c b/shallow.c\nindex c2f81a5a5a8..ef802deed41 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"repository.h\"\n #include \"tempfile.h\"\n #include \"lockfile.h\"\n #include \"object-store.h\"\n@@ -38,7 +39,7 @@ int register_shallow(const struct object_id *oid)\n \tgraft->nr_parent = -1;\n \tif (commit && commit->object.parsed)\n \t\tcommit->parents = NULL;\n-\treturn register_commit_graft(graft, 0);\n+\treturn register_commit_graft(the_repository, graft, 0);\n }\n \n int is_repository_shallow(void)\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347742","messageId":"20180515234233.143708-2-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 01/19] object-store: move object access functions to object-store.h","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-15T23:42:15Z","receivedAt":"2018-05-15T23:43:38Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This should make these functions easier to find and cache.h less\noverwhelming to read.\n\nIn particular, this moves:\n- read_object_file\n- oid_object_info\n- write_object_file\n\nAs a result, most of the codebase needs to #include object-store.h.\nIn this patch the #include is only added to files that would fail to\ncompile otherwise.  It would be better to #include wherever\nidentifiers from the header are used.  That can happen later\nwhen we have better tooling for it.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n apply.c                  |   1 +\n archive-tar.c            |   1 +\n archive-zip.c            |   1 +\n archive.c                |   1 +\n blame.c                  |   1 +\n builtin/blame.c          |   1 +\n builtin/cat-file.c       |   1 +\n builtin/checkout.c       |   1 +\n builtin/clone.c          |   1 +\n builtin/commit-tree.c    |   1 +\n builtin/describe.c       |   1 +\n builtin/difftool.c       |   1 +\n builtin/fast-export.c    |   1 +\n builtin/fetch.c          |   1 +\n builtin/fmt-merge-msg.c  |   1 +\n builtin/hash-object.c    |   1 +\n builtin/log.c            |   1 +\n builtin/ls-tree.c        |   1 +\n builtin/merge-tree.c     |   1 +\n builtin/mktag.c          |   1 +\n builtin/mktree.c         |   1 +\n builtin/notes.c          |   1 +\n builtin/prune.c          |   1 +\n builtin/receive-pack.c   |   1 +\n builtin/reflog.c         |   1 +\n builtin/remote.c         |   1 +\n builtin/rev-list.c       |   1 +\n builtin/show-ref.c       |   1 +\n builtin/tag.c            |   1 +\n builtin/unpack-file.c    |   1 +\n builtin/unpack-objects.c |   1 +\n builtin/verify-commit.c  |   1 +\n bulk-checkin.c           |   1 +\n bundle.c                 |   1 +\n cache-tree.c             |   1 +\n cache.h                  | 117 ---------------------------------------\n combine-diff.c           |   1 +\n commit.c                 |   1 +\n config.c                 |   1 +\n convert.c                |   1 +\n diff.c                   |   1 +\n diffcore-rename.c        |   1 +\n dir.c                    |   1 +\n entry.c                  |   1 +\n fetch-pack.c             |   1 +\n fsck.c                   |   1 +\n grep.c                   |   1 +\n list-objects-filter.c    |   1 +\n list-objects.c           |   1 +\n log-tree.c               |   1 +\n mailmap.c                |   1 +\n match-trees.c            |   1 +\n merge-blobs.c            |   1 +\n merge-recursive.c        |   1 +\n notes-cache.c            |   1 +\n notes-merge.c            |   1 +\n notes.c                  |   1 +\n object-store.h           | 117 +++++++++++++++++++++++++++++++++++++++\n object.c                 |   1 +\n pack-bitmap-write.c      |   1 +\n packfile.h               |   5 ++\n read-cache.c             |   1 +\n ref-filter.c             |   1 +\n refs.c                   |   1 +\n remote-testsvn.c         |   1 +\n remote.c                 |   1 +\n rerere.c                 |   1 +\n revision.c               |   1 +\n send-pack.c              |   1 +\n sequencer.c              |   1 +\n shallow.c                |   1 +\n submodule-config.c       |   1 +\n tag.c                    |   1 +\n tree-walk.c              |   1 +\n tree.c                   |   1 +\n unpack-trees.c           |   1 +\n upload-pack.c            |   1 +\n walker.c                 |   1 +\n xdiff-interface.c        |   1 +\n 79 files changed, 198 insertions(+), 117 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 7e5792c996f..cbc45fa1b0e 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -9,6 +9,7 @@\n \n #include \"cache.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"delta.h\"\n #include \"diff.h\"\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f93409324f9..e38435eb4ef 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -5,6 +5,7 @@\n #include \"config.h\"\n #include \"tar.h\"\n #include \"archive.h\"\n+#include \"object-store.h\"\n #include \"streaming.h\"\n #include \"run-command.h\"\n \ndiff --git a/archive-zip.c b/archive-zip.c\nindex 74f3fe91034..abc556e5a75 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -6,6 +6,7 @@\n #include \"archive.h\"\n #include \"streaming.h\"\n #include \"utf8.h\"\n+#include \"object-store.h\"\n #include \"userdiff.h\"\n #include \"xdiff-interface.h\"\n \ndiff --git a/archive.c b/archive.c\nindex 93ab175b0b4..9da1e3664a6 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tree-walk.h\"\n #include \"attr.h\"\ndiff --git a/blame.c b/blame.c\nindex 3a11f1ce52b..f689bde31cd 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"cache-tree.h\"\n #include \"mergesort.h\"\n #include \"diff.h\"\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex bfdf7cc1325..0ffd1d443ea 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -22,6 +22,7 @@\n #include \"line-log.h\"\n #include \"dir.h\"\n #include \"progress.h\"\n+#include \"object-store.h\"\n #include \"blame.h\"\n \n static char blame_usage[] = N_(\"git blame [<options>] [<rev-opts>] [<rev>] [--] <file>\");\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex b8ecbea98e9..91e7764243e 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -13,6 +13,7 @@\n #include \"tree-walk.h\"\n #include \"sha1-array.h\"\n #include \"packfile.h\"\n+#include \"object-store.h\"\n \n struct batch_options {\n \tint enabled;\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex b49b5820718..105e07981ff 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -4,6 +4,7 @@\n #include \"lockfile.h\"\n #include \"parse-options.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 7df5932b855..29998c02ece 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -14,6 +14,7 @@\n #include \"parse-options.h\"\n #include \"fetch-pack.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"unpack-trees.h\"\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex ecf42191da1..9fbd3529fb1 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -5,6 +5,7 @@\n  */\n #include \"cache.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"builtin.h\"\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 66c497f7896..65b0edc473c 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -13,6 +13,7 @@\n #include \"hashmap.h\"\n #include \"argv-array.h\"\n #include \"run-command.h\"\n+#include \"object-store.h\"\n #include \"revision.h\"\n #include \"list-objects.h\"\n \ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex ee8dce019e1..df7e75f797b 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -20,6 +20,7 @@\n #include \"argv-array.h\"\n #include \"strbuf.h\"\n #include \"lockfile.h\"\n+#include \"object-store.h\"\n #include \"dir.h\"\n \n static char *diff_gui_tool;\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 373c794873e..f593e57b9d4 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -7,6 +7,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"object.h\"\n #include \"tag.h\"\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 73be393b2ea..c1f2df97965 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -5,6 +5,7 @@\n #include \"config.h\"\n #include \"repository.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"builtin.h\"\n #include \"string-list.h\"\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex bd680be6874..1b526adb3a9 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -2,6 +2,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex 526da5c1856..d5c018eabd5 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -6,6 +6,7 @@\n  */\n #include \"builtin.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"quote.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 71f68a3e4f5..9656578f58e 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -7,6 +7,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"color.h\"\n #include \"commit.h\"\n #include \"diff.h\"\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 409da4e8351..fe3b952cb30 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -5,6 +5,7 @@\n  */\n #include \"cache.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"tree.h\"\n #include \"commit.h\"\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 32736e0b101..1b702d44c9f 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -1,6 +1,7 @@\n #include \"builtin.h\"\n #include \"tree-walk.h\"\n #include \"xdiff-interface.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"exec_cmd.h\"\n #include \"merge-blobs.h\"\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 82a6e860775..6fb7dc8578d 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -1,6 +1,7 @@\n #include \"builtin.h\"\n #include \"tag.h\"\n #include \"replace-object.h\"\n+#include \"object-store.h\"\n \n /*\n  * A signature file has a very simple fixed format: four lines\ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex bb76b469fd1..2dc4ad6ba8f 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -7,6 +7,7 @@\n #include \"quote.h\"\n #include \"tree.h\"\n #include \"parse-options.h\"\n+#include \"object-store.h\"\n \n static struct treeent {\n \tunsigned mode;\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 921e08d5bf5..73b680ee13a 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -11,6 +11,7 @@\n #include \"config.h\"\n #include \"builtin.h\"\n #include \"notes.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"pretty.h\"\n #include \"refs.h\"\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 518ffbea139..8cc8659612f 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -6,6 +6,7 @@\n #include \"reachable.h\"\n #include \"parse-options.h\"\n #include \"progress.h\"\n+#include \"object-store.h\"\n \n static const char * const prune_usage[] = {\n \tN_(\"git prune [-n] [-v] [--progress] [--expire <time>] [--] [<head>...]\"),\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex c4272fbc96d..36906fd5e98 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -25,6 +25,7 @@\n #include \"tmp-objdir.h\"\n #include \"oidset.h\"\n #include \"packfile.h\"\n+#include \"object-store.h\"\n #include \"protocol.h\"\n \n static const char * const receive_pack_usage[] = {\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex a89bd1dd252..bee4795a936 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -1,6 +1,7 @@\n #include \"builtin.h\"\n #include \"config.h\"\n #include \"lockfile.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"refs.h\"\n #include \"dir.h\"\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 805ffc05cdb..9487c019092 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -7,6 +7,7 @@\n #include \"strbuf.h\"\n #include \"run-command.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"argv-array.h\"\n \n static const char * const builtin_remote_usage[] = {\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex fadd3ec14cb..e9bd4e378ad 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -6,6 +6,7 @@\n #include \"list-objects.h\"\n #include \"list-objects-filter.h\"\n #include \"list-objects-filter-options.h\"\n+#include \"object-store.h\"\n #include \"pack.h\"\n #include \"pack-bitmap.h\"\n #include \"builtin.h\"\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex f2eb1a77240..2f13f1316fa 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -1,6 +1,7 @@\n #include \"builtin.h\"\n #include \"cache.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"object.h\"\n #include \"tag.h\"\n #include \"string-list.h\"\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 26d7729f57b..f872f14f65e 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -10,6 +10,7 @@\n #include \"config.h\"\n #include \"builtin.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"tag.h\"\n #include \"run-command.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex 300eb59657e..58652229f27 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -1,5 +1,6 @@\n #include \"builtin.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n \n static char *create_temp_file(struct object_id *oid)\n {\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex cfe9019f800..ded798b72ff 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -1,6 +1,7 @@\n #include \"builtin.h\"\n #include \"cache.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"object.h\"\n #include \"delta.h\"\n #include \"pack.h\"\ndiff --git a/builtin/verify-commit.c b/builtin/verify-commit.c\nindex dcdaada1110..f6922da16d6 100644\n--- a/builtin/verify-commit.c\n+++ b/builtin/verify-commit.c\n@@ -8,6 +8,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"builtin.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"run-command.h\"\n #include <signal.h>\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex de1f4040c78..918d58a7ebf 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -8,6 +8,7 @@\n #include \"pack.h\"\n #include \"strbuf.h\"\n #include \"packfile.h\"\n+#include \"object-store.h\"\n \n static struct bulk_checkin_state {\n \tunsigned plugged:1;\ndiff --git a/bundle.c b/bundle.c\nindex 902c9b54485..00ada05f46c 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"lockfile.h\"\n #include \"bundle.h\"\n+#include \"object-store.h\"\n #include \"object.h\"\n #include \"commit.h\"\n #include \"diff.h\"\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 6a555f4d431..1c338c41f3a 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -3,6 +3,7 @@\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"cache-tree.h\"\n+#include \"object-store.h\"\n \n #ifndef DEBUG\n #define DEBUG 0\ndiff --git a/cache.h b/cache.h\nindex c75559b7d38..ab716011b7e 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1183,32 +1183,6 @@ extern char *xdg_config_home(const char *filename);\n  */\n extern char *xdg_cache_home(const char *filename);\n \n-extern void *read_object_file_extended(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-}\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-\n-extern int hash_object_file(const void *buf, unsigned long len,\n-\t\t\t    const char *type, struct object_id *oid);\n-\n-extern int write_object_file(const void *buf, unsigned long len,\n-\t\t\t     const char *type, struct object_id *oid);\n-\n-extern int hash_object_file_literally(const void *buf, unsigned long len,\n-\t\t\t\t      const char *type, struct object_id *oid,\n-\t\t\t\t      unsigned flags);\n-\n-extern int pretend_object_file(void *, unsigned long, enum object_type,\n-\t\t\t       struct object_id *oid);\n-\n-extern int force_object_loose(const struct object_id *oid, time_t mtime);\n-\n extern int git_open_cloexec(const char *name, int flags);\n #define git_open(name) git_open_cloexec(name, O_RDONLY)\n extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);\n@@ -1218,43 +1192,6 @@ extern int check_object_signature(const struct object_id *oid, void *buf, unsign\n \n extern int finalize_object_file(const char *tmpfile, const char *filename);\n \n-/*\n- * Open the loose object at path, check its hash, and return the contents,\n- * type, and size. If the object is a blob, then \"contents\" may return NULL,\n- * to allow streaming of large blobs.\n- *\n- * Returns 0 on success, negative on error (details may be written to stderr).\n- */\n-int read_loose_object(const char *path,\n-\t\t      const struct object_id *expected_oid,\n-\t\t      enum object_type *type,\n-\t\t      unsigned long *size,\n-\t\t      void **contents);\n-\n-/*\n- * Convenience for sha1_object_info_extended() with a NULL struct\n- * object_info. OBJECT_INFO_SKIP_CACHED is automatically set; pass\n- * nonzero flags to also set other flags.\n- */\n-extern int has_sha1_file_with_flags(const unsigned char *sha1, int flags);\n-static inline int has_sha1_file(const unsigned char *sha1)\n-{\n-\treturn has_sha1_file_with_flags(sha1, 0);\n-}\n-\n-/* Same as the above, except for struct object_id. */\n-extern int has_object_file(const struct object_id *oid);\n-extern int has_object_file_with_flags(const struct object_id *oid, int flags);\n-\n-/*\n- * Return true iff an alternate object database has a loose object\n- * with the specified name.  This function does not respect replace\n- * references.\n- */\n-extern int has_loose_object_nonlocal(const unsigned char *sha1);\n-\n-extern void assert_oid_type(const struct object_id *oid, enum object_type expect);\n-\n /* Helper to check and \"touch\" a file */\n extern int check_and_freshen_file(const char *fn, int freshen);\n \n@@ -1624,60 +1561,6 @@ int for_each_loose_file_in_objdir_buf(struct strbuf *path,\n #define FOR_EACH_OBJECT_LOCAL_ONLY 0x1\n extern int for_each_loose_object(each_loose_object_fn, void *, unsigned flags);\n \n-struct object_info {\n-\t/* Request */\n-\tenum object_type *typep;\n-\tunsigned long *sizep;\n-\toff_t *disk_sizep;\n-\tunsigned char *delta_base_sha1;\n-\tstruct strbuf *type_name;\n-\tvoid **contentp;\n-\n-\t/* Response */\n-\tenum {\n-\t\tOI_CACHED,\n-\t\tOI_LOOSE,\n-\t\tOI_PACKED,\n-\t\tOI_DBCACHED\n-\t} whence;\n-\tunion {\n-\t\t/*\n-\t\t * struct {\n-\t\t * \t... Nothing to expose in this case\n-\t\t * } cached;\n-\t\t * struct {\n-\t\t * \t... Nothing to expose in this case\n-\t\t * } loose;\n-\t\t */\n-\t\tstruct {\n-\t\t\tstruct packed_git *pack;\n-\t\t\toff_t offset;\n-\t\t\tunsigned int is_delta;\n-\t\t} packed;\n-\t} u;\n-};\n-\n-/*\n- * Initializer for a \"struct object_info\" that wants no items. You may\n- * also memset() the memory to all-zeroes.\n- */\n-#define OBJECT_INFO_INIT {NULL}\n-\n-/* Invoke lookup_replace_object() on the given hash */\n-#define OBJECT_INFO_LOOKUP_REPLACE 1\n-/* Allow reading from a loose object file of unknown/bogus type */\n-#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2\n-/* Do not check cached storage */\n-#define OBJECT_INFO_SKIP_CACHED 4\n-/* Do not retry packed storage after checking packed and loose storage */\n-#define OBJECT_INFO_QUICK 8\n-/* Do not check loose object */\n-#define OBJECT_INFO_IGNORE_LOOSE 16\n-\n-int oid_object_info_extended(struct repository *r,\n-\t\t\t     const struct object_id *,\n-\t\t\t     struct object_info *, unsigned flags);\n-\n /*\n  * Set this to 0 to prevent sha1_object_info_extended() from fetching missing\n  * blobs. This has a difference only if extensions.partialClone is set.\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 2ef495963fc..de7695e7282 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"blob.h\"\n #include \"diff.h\"\ndiff --git a/commit.c b/commit.c\nindex 5eb4d2f08f8..b053f07f305 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"tag.h\"\n #include \"commit.h\"\n+#include \"object-store.h\"\n #include \"pkt-line.h\"\n #include \"utf8.h\"\n #include \"diff.h\"\ndiff --git a/config.c b/config.c\nindex c698988f5e1..041db3ce7d4 100644\n--- a/config.c\n+++ b/config.c\n@@ -14,6 +14,7 @@\n #include \"quote.h\"\n #include \"hashmap.h\"\n #include \"string-list.h\"\n+#include \"object-store.h\"\n #include \"utf8.h\"\n #include \"dir.h\"\n \ndiff --git a/convert.c b/convert.c\nindex c480097a2a0..7f5afd6dd66 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -1,6 +1,7 @@\n #define NO_THE_INDEX_COMPATIBILITY_MACROS\n #include \"cache.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"attr.h\"\n #include \"run-command.h\"\n #include \"quote.h\"\ndiff --git a/diff.c b/diff.c\nindex 4753170fe12..18d478c5190 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -13,6 +13,7 @@\n #include \"attr.h\"\n #include \"run-command.h\"\n #include \"utf8.h\"\n+#include \"object-store.h\"\n #include \"userdiff.h\"\n #include \"submodule-config.h\"\n #include \"submodule.h\"\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex 0b7e4989a87..d775183c2fd 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -4,6 +4,7 @@\n #include \"cache.h\"\n #include \"diff.h\"\n #include \"diffcore.h\"\n+#include \"object-store.h\"\n #include \"hashmap.h\"\n #include \"progress.h\"\n \ndiff --git a/dir.c b/dir.c\nindex 63a917be45d..9e7c90cf50b 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -11,6 +11,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"dir.h\"\n+#include \"object-store.h\"\n #include \"attr.h\"\n #include \"refs.h\"\n #include \"wildmatch.h\"\ndiff --git a/entry.c b/entry.c\nindex 2101201a111..b5d1d3cf231 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"blob.h\"\n+#include \"object-store.h\"\n #include \"dir.h\"\n #include \"streaming.h\"\n #include \"submodule.h\"\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex adc1b68dd3a..a1535b37b9b 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -19,6 +19,7 @@\n #include \"sha1-array.h\"\n #include \"oidset.h\"\n #include \"packfile.h\"\n+#include \"object-store.h\"\n \n static int transfer_unpack_limit = -1;\n static int fetch_unpack_limit = -1;\ndiff --git a/fsck.c b/fsck.c\nindex 9218c2a643b..59b0c7d640e 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"object-store.h\"\n #include \"object.h\"\n #include \"blob.h\"\n #include \"tree.h\"\ndiff --git a/grep.c b/grep.c\nindex 65b90c10a38..438987220ea 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"grep.h\"\n+#include \"object-store.h\"\n #include \"userdiff.h\"\n #include \"xdiff-interface.h\"\n #include \"diff.h\"\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex ea94fe8af28..44b3a49bdb3 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -11,6 +11,7 @@\n #include \"list-objects-filter.h\"\n #include \"list-objects-filter-options.h\"\n #include \"oidset.h\"\n+#include \"object-store.h\"\n \n /* Remember to update object flag allocation in object.h */\n /*\ndiff --git a/list-objects.c b/list-objects.c\nindex 168bef688a8..7ae0eb8ebc7 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -10,6 +10,7 @@\n #include \"list-objects-filter.h\"\n #include \"list-objects-filter-options.h\"\n #include \"packfile.h\"\n+#include \"object-store.h\"\n \n static void process_blob(struct rev_info *revs,\n \t\t\t struct blob *blob,\ndiff --git a/log-tree.c b/log-tree.c\nindex d1c0bedf244..5660ee7c785 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"diff.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"graph.h\"\ndiff --git a/mailmap.c b/mailmap.c\nindex 13f0d2884e2..962fd86d6d7 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"string-list.h\"\n #include \"mailmap.h\"\n+#include \"object-store.h\"\n \n #define DEBUG_MAILMAP 0\n #if DEBUG_MAILMAP\ndiff --git a/match-trees.c b/match-trees.c\nindex 72cc2baa3f9..4cdeff53e1e 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\n+#include \"object-store.h\"\n \n static int score_missing(unsigned mode, const char *path)\n {\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex fa49c17287f..fabb8c19ce9 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -4,6 +4,7 @@\n #include \"ll-merge.h\"\n #include \"blob.h\"\n #include \"merge-blobs.h\"\n+#include \"object-store.h\"\n \n static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n {\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex cbded673c28..455f59d21ac 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -8,6 +8,7 @@\n #include \"advice.h\"\n #include \"lockfile.h\"\n #include \"cache-tree.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"blob.h\"\n #include \"builtin.h\"\ndiff --git a/notes-cache.c b/notes-cache.c\nindex e61988e503b..d5770031776 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"notes-cache.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"refs.h\"\n \ndiff --git a/notes-merge.c b/notes-merge.c\nindex 8e0726a9418..fd96c5ab3d6 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"commit.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"diff.h\"\n #include \"diffcore.h\"\n #include \"xdiff-interface.h\"\ndiff --git a/notes.c b/notes.c\nindex a386d450c4c..32d3dbcc1e7 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"notes.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"tree.h\"\n #include \"utf8.h\"\ndiff --git a/object-store.h b/object-store.h\nindex 1ff862c7f93..695266891bf 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -137,4 +137,121 @@ 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+\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+}\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+\n+extern int hash_object_file(const void *buf, unsigned long len,\n+\t\t\t    const char *type, struct object_id *oid);\n+\n+extern int write_object_file(const void *buf, unsigned long len,\n+\t\t\t     const char *type, struct object_id *oid);\n+\n+extern int hash_object_file_literally(const void *buf, unsigned long len,\n+\t\t\t\t      const char *type, struct object_id *oid,\n+\t\t\t\t      unsigned flags);\n+\n+extern int pretend_object_file(void *, unsigned long, enum object_type,\n+\t\t\t       struct object_id *oid);\n+\n+extern int force_object_loose(const struct object_id *oid, time_t mtime);\n+\n+/*\n+ * Open the loose object at path, check its hash, and return the contents,\n+ * type, and size. If the object is a blob, then \"contents\" may return NULL,\n+ * to allow streaming of large blobs.\n+ *\n+ * Returns 0 on success, negative on error (details may be written to stderr).\n+ */\n+int read_loose_object(const char *path,\n+\t\t      const struct object_id *expected_oid,\n+\t\t      enum object_type *type,\n+\t\t      unsigned long *size,\n+\t\t      void **contents);\n+\n+/*\n+ * Convenience for sha1_object_info_extended() with a NULL struct\n+ * object_info. OBJECT_INFO_SKIP_CACHED is automatically set; pass\n+ * nonzero flags to also set other flags.\n+ */\n+extern int has_sha1_file_with_flags(const unsigned char *sha1, int flags);\n+static inline int has_sha1_file(const unsigned char *sha1)\n+{\n+\treturn has_sha1_file_with_flags(sha1, 0);\n+}\n+\n+/* Same as the above, except for struct object_id. */\n+extern int has_object_file(const struct object_id *oid);\n+extern int has_object_file_with_flags(const struct object_id *oid, int flags);\n+\n+/*\n+ * Return true iff an alternate object database has a loose object\n+ * with the specified name.  This function does not respect replace\n+ * references.\n+ */\n+extern int has_loose_object_nonlocal(const unsigned char *sha1);\n+\n+extern void assert_oid_type(const struct object_id *oid, enum object_type expect);\n+\n+struct object_info {\n+\t/* Request */\n+\tenum object_type *typep;\n+\tunsigned long *sizep;\n+\toff_t *disk_sizep;\n+\tunsigned char *delta_base_sha1;\n+\tstruct strbuf *type_name;\n+\tvoid **contentp;\n+\n+\t/* Response */\n+\tenum {\n+\t\tOI_CACHED,\n+\t\tOI_LOOSE,\n+\t\tOI_PACKED,\n+\t\tOI_DBCACHED\n+\t} whence;\n+\tunion {\n+\t\t/*\n+\t\t * struct {\n+\t\t * \t... Nothing to expose in this case\n+\t\t * } cached;\n+\t\t * struct {\n+\t\t * \t... Nothing to expose in this case\n+\t\t * } loose;\n+\t\t */\n+\t\tstruct {\n+\t\t\tstruct packed_git *pack;\n+\t\t\toff_t offset;\n+\t\t\tunsigned int is_delta;\n+\t\t} packed;\n+\t} u;\n+};\n+\n+/*\n+ * Initializer for a \"struct object_info\" that wants no items. You may\n+ * also memset() the memory to all-zeroes.\n+ */\n+#define OBJECT_INFO_INIT {NULL}\n+\n+/* Invoke lookup_replace_object() on the given hash */\n+#define OBJECT_INFO_LOOKUP_REPLACE 1\n+/* Allow reading from a loose object file of unknown/bogus type */\n+#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2\n+/* Do not check cached storage */\n+#define OBJECT_INFO_SKIP_CACHED 4\n+/* Do not retry packed storage after checking packed and loose storage */\n+#define OBJECT_INFO_QUICK 8\n+/* Do not check loose object */\n+#define OBJECT_INFO_IGNORE_LOOSE 16\n+\n+int oid_object_info_extended(struct repository *r,\n+\t\t\t     const struct object_id *,\n+\t\t\t     struct object_info *, unsigned flags);\n+\n #endif /* OBJECT_STORE_H */\ndiff --git a/object.c b/object.c\nindex 8e29f63bf23..0116ed6529a 100644\n--- a/object.c\n+++ b/object.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"object.h\"\n #include \"replace-object.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"tree.h\"\n #include \"commit.h\"\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex cd1903e717a..f7fac9d0f24 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"diff.h\"\ndiff --git a/packfile.h b/packfile.h\nindex fdfddb89b53..1abbc2c07c8 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -3,6 +3,11 @@\n \n #include \"oidset.h\"\n \n+/* in object-store.h */\n+struct packed_git;\n+struct object_info;\n+enum object_type;\n+\n /*\n  * Generate the filename to be used for a pack file with checksum \"sha1\" and\n  * extension \"ext\". The result is written into the strbuf \"buf\", overwriting\ndiff --git a/read-cache.c b/read-cache.c\nindex 10f1c6bb8a3..7f10d9ffff9 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -11,6 +11,7 @@\n #include \"cache-tree.h\"\n #include \"refs.h\"\n #include \"dir.h\"\n+#include \"object-store.h\"\n #include \"tree.h\"\n #include \"commit.h\"\n #include \"blob.h\"\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 9a333e21b51..e2ae1f47fee 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -3,6 +3,7 @@\n #include \"parse-options.h\"\n #include \"refs.h\"\n #include \"wildmatch.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"remote.h\"\n #include \"color.h\"\ndiff --git a/refs.c b/refs.c\nindex 27c88ba7689..2361ba9c6ee 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -9,6 +9,7 @@\n #include \"iterator.h\"\n #include \"refs.h\"\n #include \"refs/refs-internal.h\"\n+#include \"object-store.h\"\n #include \"object.h\"\n #include \"tag.h\"\n #include \"submodule.h\"\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex c4bb9a8ba92..515b922b503 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"refs.h\"\n #include \"remote.h\"\n+#include \"object-store.h\"\n #include \"strbuf.h\"\n #include \"url.h\"\n #include \"exec_cmd.h\"\ndiff --git a/remote.c b/remote.c\nindex 481bf933f39..db438cfbc56 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -2,6 +2,7 @@\n #include \"config.h\"\n #include \"remote.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/rerere.c b/rerere.c\nindex 18cae2d11c9..fcb99cc9542 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -9,6 +9,7 @@\n #include \"ll-merge.h\"\n #include \"attr.h\"\n #include \"pathspec.h\"\n+#include \"object-store.h\"\n #include \"sha1-lookup.h\"\n \n #define RESOLVED 0\ndiff --git a/revision.c b/revision.c\nindex 1cff11833e7..260b9c276c7 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"object-store.h\"\n #include \"tag.h\"\n #include \"blob.h\"\n #include \"tree.h\"\ndiff --git a/send-pack.c b/send-pack.c\nindex 19025a7aca8..71600028cdd 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -2,6 +2,7 @@\n #include \"config.h\"\n #include \"commit.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n #include \"run-command.h\"\ndiff --git a/sequencer.c b/sequencer.c\nindex 44f0518b9c4..cf6456ab75d 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2,6 +2,7 @@\n #include \"config.h\"\n #include \"lockfile.h\"\n #include \"dir.h\"\n+#include \"object-store.h\"\n #include \"object.h\"\n #include \"commit.h\"\n #include \"sequencer.h\"\ndiff --git a/shallow.c b/shallow.c\nindex df4d44ea7a3..c2f81a5a5a8 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"tempfile.h\"\n #include \"lockfile.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"pkt-line.h\"\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 3f2075764fe..a1e57c33339 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -4,6 +4,7 @@\n #include \"submodule-config.h\"\n #include \"submodule.h\"\n #include \"strbuf.h\"\n+#include \"object-store.h\"\n #include \"parse-options.h\"\n \n /*\ndiff --git a/tag.c b/tag.c\nindex 7c12426b4ea..3be7206e920 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"tag.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"blob.h\"\ndiff --git a/tree-walk.c b/tree-walk.c\nindex e11b3063afa..cd428a1ee53 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -2,6 +2,7 @@\n #include \"tree-walk.h\"\n #include \"unpack-trees.h\"\n #include \"dir.h\"\n+#include \"object-store.h\"\n #include \"tree.h\"\n #include \"pathspec.h\"\n \ndiff --git a/tree.c b/tree.c\nindex 8f8ef3189af..dc20a2693fd 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -2,6 +2,7 @@\n #include \"cache.h\"\n #include \"cache-tree.h\"\n #include \"tree.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"commit.h\"\n #include \"tag.h\"\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex e73745051e5..e3f95cc6f95 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -15,6 +15,7 @@\n #include \"submodule.h\"\n #include \"submodule-config.h\"\n #include \"fsmonitor.h\"\n+#include \"object-store.h\"\n #include \"fetch-object.h\"\n \n /*\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 4a82602be5d..a11c6d192ce 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -3,6 +3,7 @@\n #include \"refs.h\"\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n+#include \"object-store.h\"\n #include \"tag.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/walker.c b/walker.c\nindex dffb9c8e37c..3fb5fb2a0be 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"walker.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 9315bc0ede1..ec6e574e4aa 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"xdiff-interface.h\"\n #include \"xdiff/xtypes.h\"\n #include \"xdiff/xdiffi.h\"\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347940","messageId":"20180517225154.9200-1-sbeller@google.com","threadId":"48501","inReplyTo":"20180515234233.143708-1-sbeller@google.com","subject":"[PATCH 00/19] object store: grafts and shallow.","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:35Z","receivedAt":"2018-05-17T22:52:13Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"v1:\n\nThis reroll:\n* includes the fixup by Ramsay\n  http://public-inbox.org/git/ae96f1c4-add2-d9d8-f08b-a765fe277232@ramsayjones.plus.com\n* fixes commit messages\n* changes the macro for the global git_path definitions such that we need fewer\n  characters (omits the duplicates \"path_\" that were the same for every function)\n* the range diff is below\n  (per https://public-inbox.org/git/20180508034815.GB7242@sigill.intra.peff.net/)\n\nThanks,\nStefan\n\nv0/RFC:\nThis applies on top of sb/object-store-alloc[1], and is the next part of the\nobject store series. \n\nI think we're getting close to actually being done in the object store series,\nas the next series to build on top of this will convert the\nlookup_{object, commit, ...} functions.\n\nHowever I marked this series as RFC, as I expect heavy conflicts with the\ncode base. sb/object-store-alloc builds on an older base of the code base\nand there have been some series that will conflict with this one.\nFor example the patch to migrate path functions into a repository world\nwill collide with one of Dschos series as he added another path helper\nfunction there. I am happy to reroll on top of that, but for now I chose\nsb/object-store-alloc to keep the momentum in the object-store series'.\n\nThere is another object store series that is not part of the critical path:\nThere is a mem leak in the pack files stored in the raw object store.\nUpon free'ing the repository we do not free its pack files. We cannot\nfree the packfiles, as otherwise the bitmap code would have dangling\npointers into packfiles that no longer exists, leading to segfaults.\nSo we'll need to have an object store series covering the bitmap code.\nI have something local, which I'll send out shortly.\n\nThanks,\nStefan\n\n[1] with the latest patch replaced as in\n    https://public-inbox.org/git/20180515214842.108713-1-sbeller@google.com/\n\nBrandon Williams (3):\n  commit: convert commit_graft_pos() to handle arbitrary repositories\n  commit: convert register_commit_graft to handle arbitrary repositories\n  commit: convert read_graft_file to handle arbitrary repositories\n\nJonathan Nieder (6):\n  object: move grafts to object parser\n  commit: add repository argument to commit_graft_pos\n  commit: add repository argument to register_commit_graft\n  commit: add repository argument to read_graft_file\n  commit: add repository argument to prepare_commit_graft\n  commit: add repository argument to lookup_commit_graft\n\nStefan Beller (10):\n  object-store: move object access functions to object-store.h\n  shallow: add repository argument to set_alternate_shallow_file\n  shallow: add repository argument to register_shallow\n  shallow: add repository argument to check_shallow_file_for_update\n  shallow: add repository argument to is_repository_shallow\n  cache: convert get_graft_file to handle arbitrary repositories\n  path.c: migrate global git_path_* to take a repository argument\n  shallow: migrate shallow information into the object parser\n  commit: allow prepare_commit_graft to handle arbitrary repositories\n  commit: allow lookup_commit_graft to handle arbitrary repositories\n\n apply.c                  |   1 +\n archive-tar.c            |   1 +\n archive-zip.c            |   1 +\n archive.c                |   1 +\n blame.c                  |   9 ++-\n branch.c                 |  14 ++---\n builtin/blame.c          |   4 +-\n builtin/cat-file.c       |   1 +\n builtin/checkout.c       |   1 +\n builtin/clone.c          |   1 +\n builtin/commit-tree.c    |   1 +\n builtin/commit.c         |  38 ++++++-------\n builtin/describe.c       |   1 +\n builtin/difftool.c       |   1 +\n builtin/fast-export.c    |   1 +\n builtin/fetch.c          |   7 ++-\n builtin/fmt-merge-msg.c  |   1 +\n builtin/hash-object.c    |   1 +\n builtin/log.c            |   1 +\n builtin/ls-tree.c        |   1 +\n builtin/merge-tree.c     |   1 +\n builtin/merge.c          |  37 ++++++------\n builtin/mktag.c          |   1 +\n builtin/mktree.c         |   1 +\n builtin/notes.c          |   1 +\n builtin/pack-objects.c   |   6 +-\n builtin/prune.c          |   3 +-\n builtin/pull.c           |   4 +-\n builtin/receive-pack.c   |   3 +-\n builtin/reflog.c         |   1 +\n builtin/remote.c         |   1 +\n builtin/reset.c          |   2 +-\n builtin/rev-list.c       |   1 +\n builtin/rev-parse.c      |   3 +-\n builtin/show-ref.c       |   1 +\n builtin/tag.c            |   1 +\n builtin/unpack-file.c    |   1 +\n builtin/unpack-objects.c |   1 +\n builtin/verify-commit.c  |   1 +\n bulk-checkin.c           |   1 +\n bundle.c                 |   1 +\n cache-tree.c             |   1 +\n cache.h                  | 119 +--------------------------------------\n combine-diff.c           |   1 +\n commit.c                 |  77 +++++++++++++------------\n commit.h                 |  10 ++--\n config.c                 |   1 +\n convert.c                |   1 +\n diff.c                   |   1 +\n diffcore-rename.c        |   1 +\n dir.c                    |   1 +\n entry.c                  |   1 +\n environment.c            |   8 +--\n fetch-pack.c             |   9 +--\n fsck.c                   |   3 +-\n git.c                    |   2 +-\n grep.c                   |   1 +\n list-objects-filter.c    |   1 +\n list-objects.c           |   1 +\n log-tree.c               |   1 +\n mailmap.c                |   1 +\n match-trees.c            |   1 +\n merge-blobs.c            |   1 +\n merge-recursive.c        |   1 +\n notes-cache.c            |   1 +\n notes-merge.c            |   1 +\n notes.c                  |   1 +\n object-store.h           | 117 ++++++++++++++++++++++++++++++++++++++\n object.c                 |   4 ++\n object.h                 |  10 ++++\n pack-bitmap-write.c      |   1 +\n packfile.h               |   5 ++\n path.c                   |  18 +++---\n path.h                   |  40 ++++++++++---\n read-cache.c             |   1 +\n ref-filter.c             |   1 +\n refs.c                   |   1 +\n remote-testsvn.c         |   1 +\n remote.c                 |   1 +\n repository.h             |   5 ++\n rerere.c                 |   8 ++-\n revision.c               |   1 +\n send-pack.c              |   7 ++-\n sequencer.c              |  38 +++++++------\n shallow.c                |  74 ++++++++++++------------\n submodule-config.c       |   1 +\n tag.c                    |   1 +\n tree-walk.c              |   1 +\n tree.c                   |   1 +\n unpack-trees.c           |   1 +\n upload-pack.c            |  10 ++--\n walker.c                 |   1 +\n wt-status.c              |   8 +--\n xdiff-interface.c        |   1 +\n 94 files changed, 449 insertions(+), 315 deletions(-)\n\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n1:  cbd53a2193d = 1:  20b6bef31b7 object-store: move object access functions to object-store.h\n2:  6a1a79fd146 = 2:  6855b203842 object: move grafts to object parser\n3:  be479e801da = 3:  0afdfac30da commit: add repository argument to commit_graft_pos\n4:  3f5787f8066 = 4:  af84c3bc1dd commit: add repository argument to register_commit_graft\n5:  02ba3e1a057 = 5:  154ec8bacc1 commit: add repository argument to read_graft_file\n6:  3ee37656ee6 = 6:  c12bd3a7870 commit: add repository argument to prepare_commit_graft\n7:  e6c898f460c ! 7:  aef9cd4ffba commit: add repository argument to lookup_commit_graft\n    @@ -10,9 +10,6 @@\n         As with the previous commits, use a macro to catch callers passing a\n         repository other than the_repository at compile time.\n     \n    -    The included coccinelle semantic patch will adapt any new callers in\n    -    the diff produced by `make coccicheck`.\n    -\n         Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n         Signed-off-by: Stefan Beller <sbeller@google.com>\n         Signed-off-by: Junio C Hamano <gitster@pobox.com>\n8:  f95ee308eb7 ! 8:  0025ae11097 shallow: add repository argument to set_alternate_shallow_file\n    @@ -2,8 +2,15 @@\n     \n         shallow: add repository argument to set_alternate_shallow_file\n     \n    +    Add a repository argument to allow callers of set_alternate_shallow_file\n    +    to be more specific about which repository to handle. This is a small\n    +    mechanical change; it doesn't change the implementation to handle\n    +    repositories other than the_repository yet.\n    +\n    +    As with the previous commits, use a macro to catch callers passing a\n    +    repository other than the_repository at compile time.\n    +\n         Signed-off-by: Stefan Beller <sbeller@google.com>\n    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n     \n     diff --git a/commit.h b/commit.h\n     --- a/commit.h\n9:  11948c4278a ! 9:  3ee6c801d16 shallow: add repository argument to register_shallow\n    @@ -2,8 +2,15 @@\n     \n         shallow: add repository argument to register_shallow\n     \n    +    Add a repository argument to allow callers of register_shallow\n    +    to be more specific about which repository to handle. This is a small\n    +    mechanical change; it doesn't change the implementation to handle\n    +    repositories other than the_repository yet.\n    +\n    +    As with the previous commits, use a macro to catch callers passing a\n    +    repository other than the_repository at compile time.\n    +\n         Signed-off-by: Stefan Beller <sbeller@google.com>\n    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n     \n     diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\n     --- a/builtin/pack-objects.c\n10:  c69182008bd ! 10:  f0d9eb428ef shallow: add repository argument to check_shallow_file_for_update\n    @@ -2,8 +2,15 @@\n     \n         shallow: add repository argument to check_shallow_file_for_update\n     \n    +    Add a repository argument to allow callers of check_shallow_file_for_update\n    +    to be more specific about which repository to handle. This is a small\n    +    mechanical change; it doesn't change the implementation to handle\n    +    repositories other than the_repository yet.\n    +\n    +    As with the previous commits, use a macro to catch callers passing a\n    +    repository other than the_repository at compile time.\n    +\n         Signed-off-by: Stefan Beller <sbeller@google.com>\n    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n     \n     diff --git a/shallow.c b/shallow.c\n     --- a/shallow.c\n11:  2194490111e ! 11:  5ba578b5386 shallow: add repository argument to is_repository_shallow\n    @@ -2,8 +2,15 @@\n     \n         shallow: add repository argument to is_repository_shallow\n     \n    +    Add a repository argument to allow callers of is_repository_shallow\n    +    to be more specific about which repository to handle. This is a small\n    +    mechanical change; it doesn't change the implementation to handle\n    +    repositories other than the_repository yet.\n    +\n    +    As with the previous commits, use a macro to catch callers passing a\n    +    repository other than the_repository at compile time.\n    +\n         Signed-off-by: Stefan Beller <sbeller@google.com>\n    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n     \n     diff --git a/builtin/fetch.c b/builtin/fetch.c\n     --- a/builtin/fetch.c\n12:  7560733756e ! 12:  8432e847c05 commit: convert commit_graft_pos() to handle arbitrary repositories\n    @@ -4,7 +4,6 @@\n     \n         Signed-off-by: Brandon Williams <bmwill@google.com>\n         Signed-off-by: Stefan Beller <sbeller@google.com>\n    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n     \n     diff --git a/commit.c b/commit.c\n     --- a/commit.c\n13:  12a4071c6a5 ! 13:  8763c86af52 commit: convert register_commit_graft to handle arbitrary repositories\n    @@ -4,7 +4,6 @@\n     \n         Signed-off-by: Brandon Williams <bmwill@google.com>\n         Signed-off-by: Stefan Beller <sbeller@google.com>\n    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n     \n     diff --git a/commit.c b/commit.c\n     --- a/commit.c\n14:  a333e619158 ! 14:  2eea80787c6 commit: convert read_graft_file to handle arbitrary repositories\n    @@ -4,7 +4,6 @@\n     \n         Signed-off-by: Brandon Williams <bmwill@google.com>\n         Signed-off-by: Stefan Beller <sbeller@google.com>\n    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n     \n     diff --git a/commit.c b/commit.c\n     --- a/commit.c\n15:  5c8f9317393 ! 15:  4f41b5cc4e8 cache: convert get_graft_file to handle arbitrary repositories\n    @@ -2,6 +2,10 @@\n     \n         cache: convert get_graft_file to handle arbitrary repositories\n     \n    +    This conversion was done without the #define trick used in the earlier\n    +    series refactoring to have better repository access, because this function\n    +    is easy to review, as all lines are converted and it has only one caller.\n    +\n         Signed-off-by: Stefan Beller <sbeller@google.com>\n         Signed-off-by: Junio C Hamano <gitster@pobox.com>\n     \n16:  adbe83bff1f ! 16:  77cc05fde8a path.c: migrate git_path_ to take a repository argument\n    @@ -1,6 +1,14 @@\n     Author: Stefan Beller <sbeller@google.com>\n     \n    -    path.c: migrate git_path_ to take a repository argument\n    +    path.c: migrate global git_path_* to take a repository argument\n    +\n    +    Migrate all git_path_* functions that are defined in path.c to take a\n    +    repository argument. Unlike other patches in this series, do not use the\n    +     #define trick, as we rewrite the whole function, which is rather small.\n    +\n    +    This doesn't migrate all the functions, as other builtins have their own\n    +    local path functions defined using GIT_PATH_FUNC. So keep that macro\n    +    around to serve the other locations.\n     \n         Signed-off-by: Stefan Beller <sbeller@google.com>\n         Signed-off-by: Junio C Hamano <gitster@pobox.com>\n    @@ -374,15 +382,15 @@\n     -GIT_PATH_FUNC(git_path_merge_head, \"MERGE_HEAD\")\n     -GIT_PATH_FUNC(git_path_fetch_head, \"FETCH_HEAD\")\n     -GIT_PATH_FUNC(git_path_shallow, \"shallow\")\n    -+REPO_GIT_PATH_FUNC(path_cherry_pick_head, \"CHERRY_PICK_HEAD\")\n    -+REPO_GIT_PATH_FUNC(path_revert_head, \"REVERT_HEAD\")\n    -+REPO_GIT_PATH_FUNC(path_squash_msg, \"SQUASH_MSG\")\n    -+REPO_GIT_PATH_FUNC(path_merge_msg, \"MERGE_MSG\")\n    -+REPO_GIT_PATH_FUNC(path_merge_rr, \"MERGE_RR\")\n    -+REPO_GIT_PATH_FUNC(path_merge_mode, \"MERGE_MODE\")\n    -+REPO_GIT_PATH_FUNC(path_merge_head, \"MERGE_HEAD\")\n    -+REPO_GIT_PATH_FUNC(path_fetch_head, \"FETCH_HEAD\")\n    -+REPO_GIT_PATH_FUNC(path_shallow, \"shallow\")\n    ++REPO_GIT_PATH_FUNC(cherry_pick_head, \"CHERRY_PICK_HEAD\")\n    ++REPO_GIT_PATH_FUNC(revert_head, \"REVERT_HEAD\")\n    ++REPO_GIT_PATH_FUNC(squash_msg, \"SQUASH_MSG\")\n    ++REPO_GIT_PATH_FUNC(merge_msg, \"MERGE_MSG\")\n    ++REPO_GIT_PATH_FUNC(merge_rr, \"MERGE_RR\")\n    ++REPO_GIT_PATH_FUNC(merge_mode, \"MERGE_MODE\")\n    ++REPO_GIT_PATH_FUNC(merge_head, \"MERGE_HEAD\")\n    ++REPO_GIT_PATH_FUNC(fetch_head, \"FETCH_HEAD\")\n    ++REPO_GIT_PATH_FUNC(shallow, \"shallow\")\n     \n     diff --git a/path.h b/path.h\n     --- a/path.h\n    @@ -401,7 +409,7 @@\n     -const char *git_path_fetch_head(void);\n     -const char *git_path_shallow(void);\n     +#define REPO_GIT_PATH_FUNC(var, filename) \\\n    -+\tconst char *git_##var(struct repository *r) \\\n    ++\tconst char *git_path_##var(struct repository *r) \\\n     +\t{ \\\n     +\t\tif (!r->cached_paths.var) \\\n     +\t\t\tr->cached_paths.var = git_pathdup(filename); \\\n    @@ -409,15 +417,15 @@\n     +\t}\n     +\n     +struct path_cache {\n    -+\tconst char *path_cherry_pick_head;\n    -+\tconst char *path_revert_head;\n    -+\tconst char *path_squash_msg;\n    -+\tconst char *path_merge_msg;\n    -+\tconst char *path_merge_rr;\n    -+\tconst char *path_merge_mode;\n    -+\tconst char *path_merge_head;\n    -+\tconst char *path_fetch_head;\n    -+\tconst char *path_shallow;\n    ++\tconst char *cherry_pick_head;\n    ++\tconst char *revert_head;\n    ++\tconst char *squash_msg;\n    ++\tconst char *merge_msg;\n    ++\tconst char *merge_rr;\n    ++\tconst char *merge_mode;\n    ++\tconst char *merge_head;\n    ++\tconst char *fetch_head;\n    ++\tconst char *shallow;\n     +};\n     +\n     +#define PATH_CACHE_INIT { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }\n17:  d73b49b7078 ! 17:  d9b50420d32 shallow: migrate shallow information into the object parser\n    @@ -2,8 +2,10 @@\n     \n         shallow: migrate shallow information into the object parser\n     \n    +    We need to convert the shallow functions all at the same time\n    +    as we move the data structures they operate on into the repository.\n    +\n         Signed-off-by: Stefan Beller <sbeller@google.com>\n    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n     \n     diff --git a/commit.h b/commit.h\n     --- a/commit.h\n    @@ -72,8 +74,7 @@\n     -static int is_shallow = -1;\n     -static struct stat_validity shallow_stat;\n     -static char *alternate_shallow_file;\n    -+struct stat_validity the_repository_shallow_stat;\n    - \n    +-\n     -void set_alternate_shallow_file_the_repository(const char *path, int override)\n     +void set_alternate_shallow_file(struct repository *r, const char *path, int override)\n      {\n18:  cede061c90f ! 18:  0458d3b9fac commit: allow prepare_commit_graft to handle arbitrary repositories\n    @@ -2,8 +2,11 @@\n     \n         commit: allow prepare_commit_graft to handle arbitrary repositories\n     \n    +    Move the global variable 'commit_graft_prepared' into the object\n    +    pool and convert the function prepare_commit_graft to work\n    +    an arbitrary repositories.\n    +\n         Signed-off-by: Stefan Beller <sbeller@google.com>\n    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n     \n     diff --git a/commit.c b/commit.c\n     --- a/commit.c\n19:  7dc1693a492 ! 19:  39c2ddce2e1 commit: allow lookup_commit_graft to handle arbitrary repositories\n    @@ -3,7 +3,6 @@\n         commit: allow lookup_commit_graft to handle arbitrary repositories\n     \n         Signed-off-by: Stefan Beller <sbeller@google.com>\n    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n     \n     diff --git a/commit.c b/commit.c\n     --- a/commit.c\n"},{"id":"347941","messageId":"20180517225154.9200-3-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 02/19] object: move grafts to object parser","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:37Z","receivedAt":"2018-05-17T22:52:18Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nGrafts are only meaningful in the context of a single repository.\nTherefore they cannot be global.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n commit.c | 42 +++++++++++++++++++++++-------------------\n object.h |  4 ++++\n 2 files changed, 27 insertions(+), 19 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex b053f07f305..a0c9eb05c82 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"tag.h\"\n #include \"commit.h\"\n+#include \"repository.h\"\n #include \"object-store.h\"\n #include \"pkt-line.h\"\n #include \"utf8.h\"\n@@ -97,9 +98,6 @@ static timestamp_t parse_commit_date(const char *buf, const char *tail)\n \treturn parse_timestamp(dateptr, NULL, 10);\n }\n \n-static struct commit_graft **commit_graft;\n-static int commit_graft_alloc, commit_graft_nr;\n-\n static const unsigned char *commit_graft_sha1_access(size_t index, void *table)\n {\n \tstruct commit_graft **commit_graft_table = table;\n@@ -108,7 +106,8 @@ static const unsigned char *commit_graft_sha1_access(size_t index, void *table)\n \n static int commit_graft_pos(const unsigned char *sha1)\n {\n-\treturn sha1_pos(sha1, commit_graft, commit_graft_nr,\n+\treturn sha1_pos(sha1, the_repository->parsed_objects->grafts,\n+\t\t\tthe_repository->parsed_objects->grafts_nr,\n \t\t\tcommit_graft_sha1_access);\n }\n \n@@ -120,18 +119,22 @@ int register_commit_graft(struct commit_graft *graft, int ignore_dups)\n \t\tif (ignore_dups)\n \t\t\tfree(graft);\n \t\telse {\n-\t\t\tfree(commit_graft[pos]);\n-\t\t\tcommit_graft[pos] = graft;\n+\t\t\tfree(the_repository->parsed_objects->grafts[pos]);\n+\t\t\tthe_repository->parsed_objects->grafts[pos] = graft;\n \t\t}\n \t\treturn 1;\n \t}\n \tpos = -pos - 1;\n-\tALLOC_GROW(commit_graft, commit_graft_nr + 1, commit_graft_alloc);\n-\tcommit_graft_nr++;\n-\tif (pos < commit_graft_nr)\n-\t\tMOVE_ARRAY(commit_graft + pos + 1, commit_graft + pos,\n-\t\t\t   commit_graft_nr - pos - 1);\n-\tcommit_graft[pos] = graft;\n+\tALLOC_GROW(the_repository->parsed_objects->grafts,\n+\t\t   the_repository->parsed_objects->grafts_nr + 1,\n+\t\t   the_repository->parsed_objects->grafts_alloc);\n+\tthe_repository->parsed_objects->grafts_nr++;\n+\tif (pos < the_repository->parsed_objects->grafts_nr)\n+\t\tmemmove(the_repository->parsed_objects->grafts + pos + 1,\n+\t\t\tthe_repository->parsed_objects->grafts + pos,\n+\t\t\t(the_repository->parsed_objects->grafts_nr - pos - 1) *\n+\t\t\tsizeof(*the_repository->parsed_objects->grafts));\n+\tthe_repository->parsed_objects->grafts[pos] = graft;\n \treturn 0;\n }\n \n@@ -213,14 +216,14 @@ struct commit_graft *lookup_commit_graft(const struct object_id *oid)\n \tpos = commit_graft_pos(oid->hash);\n \tif (pos < 0)\n \t\treturn NULL;\n-\treturn commit_graft[pos];\n+\treturn the_repository->parsed_objects->grafts[pos];\n }\n \n int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data)\n {\n \tint i, ret;\n-\tfor (i = ret = 0; i < commit_graft_nr && !ret; i++)\n-\t\tret = fn(commit_graft[i], cb_data);\n+\tfor (i = ret = 0; i < the_repository->parsed_objects->grafts_nr && !ret; i++)\n+\t\tret = fn(the_repository->parsed_objects->grafts[i], cb_data);\n \treturn ret;\n }\n \n@@ -229,10 +232,11 @@ int unregister_shallow(const struct object_id *oid)\n \tint pos = commit_graft_pos(oid->hash);\n \tif (pos < 0)\n \t\treturn -1;\n-\tif (pos + 1 < commit_graft_nr)\n-\t\tMOVE_ARRAY(commit_graft + pos, commit_graft + pos + 1,\n-\t\t\t   commit_graft_nr - pos - 1);\n-\tcommit_graft_nr--;\n+\tif (pos + 1 < the_repository->parsed_objects->grafts_nr)\n+\t\tMOVE_ARRAY(the_repository->parsed_objects->grafts + pos,\n+\t\t\t   the_repository->parsed_objects->grafts + pos + 1,\n+\t\t\t   the_repository->parsed_objects->grafts_nr - pos - 1);\n+\tthe_repository->parsed_objects->grafts_nr--;\n \treturn 0;\n }\n \ndiff --git a/object.h b/object.h\nindex 7916edb4edf..ec908f9bcc1 100644\n--- a/object.h\n+++ b/object.h\n@@ -12,6 +12,10 @@ struct parsed_object_pool {\n \tstruct alloc_state *tag_state;\n \tstruct alloc_state *object_state;\n \tunsigned commit_count;\n+\n+\t/* parent substitutions from .git/info/grafts and .git/shallow */\n+\tstruct commit_graft **grafts;\n+\tint grafts_alloc, grafts_nr;\n };\n \n struct parsed_object_pool *parsed_object_pool_new(void);\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347942","messageId":"20180517225154.9200-5-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 04/19] commit: add repository argument to register_commit_graft","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:39Z","receivedAt":"2018-05-17T22:52:23Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nAdd a repository argument to allow callers of register_commit_graft to\nbe more specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/blame.c | 3 ++-\n commit.c        | 4 ++--\n commit.h        | 3 ++-\n shallow.c       | 3 ++-\n 4 files changed, 8 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 0ffd1d443ea..7a07bff2423 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -8,6 +8,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"builtin.h\"\n+#include \"repository.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n #include \"revision.h\"\n@@ -491,7 +492,7 @@ static int read_ancestry(const char *graft_file)\n \t\t/* The format is just \"Commit Parent1 Parent2 ...\\n\" */\n \t\tstruct commit_graft *graft = read_graft_line(&buf);\n \t\tif (graft)\n-\t\t\tregister_commit_graft(graft, 0);\n+\t\t\tregister_commit_graft(the_repository, graft, 0);\n \t}\n \tfclose(fp);\n \tstrbuf_release(&buf);\ndiff --git a/commit.c b/commit.c\nindex 2cd5b8a0b96..4e8d3488425 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -112,7 +112,7 @@ static int commit_graft_pos_the_repository(const unsigned char *sha1)\n \t\t\tcommit_graft_sha1_access);\n }\n \n-int register_commit_graft(struct commit_graft *graft, int ignore_dups)\n+int register_commit_graft_the_repository(struct commit_graft *graft, int ignore_dups)\n {\n \tint pos = commit_graft_pos(the_repository, graft->oid.hash);\n \n@@ -188,7 +188,7 @@ static int read_graft_file(const char *graft_file)\n \t\tstruct commit_graft *graft = read_graft_line(&buf);\n \t\tif (!graft)\n \t\t\tcontinue;\n-\t\tif (register_commit_graft(graft, 1))\n+\t\tif (register_commit_graft(the_repository, graft, 1))\n \t\t\terror(\"duplicate graft data: %s\", buf.buf);\n \t}\n \tfclose(fp);\ndiff --git a/commit.h b/commit.h\nindex 2d764ab7d8e..40a5b5e2585 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -174,7 +174,8 @@ struct commit_graft {\n typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *);\n \n struct commit_graft *read_graft_line(struct strbuf *line);\n-int register_commit_graft(struct commit_graft *, int);\n+#define register_commit_graft(r, g, i) register_commit_graft_##r(g, i)\n+int register_commit_graft_the_repository(struct commit_graft *, int);\n struct commit_graft *lookup_commit_graft(const struct object_id *oid);\n \n extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2);\ndiff --git a/shallow.c b/shallow.c\nindex c2f81a5a5a8..ef802deed41 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"repository.h\"\n #include \"tempfile.h\"\n #include \"lockfile.h\"\n #include \"object-store.h\"\n@@ -38,7 +39,7 @@ int register_shallow(const struct object_id *oid)\n \tgraft->nr_parent = -1;\n \tif (commit && commit->object.parsed)\n \t\tcommit->parents = NULL;\n-\treturn register_commit_graft(graft, 0);\n+\treturn register_commit_graft(the_repository, graft, 0);\n }\n \n int is_repository_shallow(void)\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347943","messageId":"20180517225154.9200-8-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 07/19] commit: add repository argument to lookup_commit_graft","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:42Z","receivedAt":"2018-05-17T22:52:25Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nAdd a repository argument to allow callers of lookup_commit_graft to\nbe more specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n commit.c  | 4 ++--\n commit.h  | 3 ++-\n fsck.c    | 2 +-\n shallow.c | 5 +++--\n 4 files changed, 8 insertions(+), 6 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex a0400b93a1e..c832133f055 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -212,7 +212,7 @@ static void prepare_commit_graft_the_repository(void)\n \tcommit_graft_prepared = 1;\n }\n \n-struct commit_graft *lookup_commit_graft(const struct object_id *oid)\n+struct commit_graft *lookup_commit_graft_the_repository(const struct object_id *oid)\n {\n \tint pos;\n \tprepare_commit_graft(the_repository);\n@@ -359,7 +359,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s\n \tbufptr += tree_entry_len + 1; /* \"tree \" + \"hex sha1\" + \"\\n\" */\n \tpptr = &item->parents;\n \n-\tgraft = lookup_commit_graft(&item->object.oid);\n+\tgraft = lookup_commit_graft(the_repository, &item->object.oid);\n \twhile (bufptr + parent_entry_len < tail && !memcmp(bufptr, \"parent \", 7)) {\n \t\tstruct commit *new_parent;\n \ndiff --git a/commit.h b/commit.h\nindex 40a5b5e2585..f6746125766 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -176,7 +176,8 @@ typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *);\n struct commit_graft *read_graft_line(struct strbuf *line);\n #define register_commit_graft(r, g, i) register_commit_graft_##r(g, i)\n int register_commit_graft_the_repository(struct commit_graft *, int);\n-struct commit_graft *lookup_commit_graft(const struct object_id *oid);\n+#define lookup_commit_graft(r, o) lookup_commit_graft_##r(o)\n+struct commit_graft *lookup_commit_graft_the_repository(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);\ndiff --git a/fsck.c b/fsck.c\nindex 59b0c7d640e..104c3c0a434 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -738,7 +738,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,\n \t\tbuffer += 41;\n \t\tparent_line_count++;\n \t}\n-\tgraft = lookup_commit_graft(&commit->object.oid);\n+\tgraft = lookup_commit_graft(the_repository, &commit->object.oid);\n \tparent_count = commit_list_count(commit->parents);\n \tif (graft) {\n \t\tif (graft->nr_parent == -1 && !parent_count)\ndiff --git a/shallow.c b/shallow.c\nindex ef802deed41..ca360c700c5 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -109,7 +109,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,\n \t\tcur_depth++;\n \t\tif ((depth != INFINITE_DEPTH && cur_depth >= depth) ||\n \t\t    (is_repository_shallow() && !commit->parents &&\n-\t\t     (graft = lookup_commit_graft(&commit->object.oid)) != NULL &&\n+\t\t     (graft = lookup_commit_graft(the_repository, &commit->object.oid)) != NULL &&\n \t\t     graft->nr_parent < 0)) {\n \t\t\tcommit_list_insert(commit, &result);\n \t\t\tcommit->object.flags |= shallow_flag;\n@@ -398,7 +398,8 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)\n \tfor (i = 0; i < sa->nr; i++) {\n \t\tif (has_object_file(sa->oid + i)) {\n \t\t\tstruct commit_graft *graft;\n-\t\t\tgraft = lookup_commit_graft(&sa->oid[i]);\n+\t\t\tgraft = lookup_commit_graft(the_repository,\n+\t\t\t\t\t\t    &sa->oid[i]);\n \t\t\tif (graft && graft->nr_parent < 0)\n \t\t\t\tcontinue;\n \t\t\tinfo->ours[info->nr_ours++] = i;\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347944","messageId":"20180517225154.9200-9-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 08/19] shallow: add repository argument to set_alternate_shallow_file","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:43Z","receivedAt":"2018-05-17T22:52:28Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow callers of set_alternate_shallow_file\nto be more specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.h      | 3 ++-\n environment.c | 2 +-\n git.c         | 2 +-\n shallow.c     | 2 +-\n 4 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/commit.h b/commit.h\nindex f6746125766..f88c854e2f6 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -199,7 +199,8 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads,\n \t\tint depth, int shallow_flag, int not_shallow_flag);\n extern struct commit_list *get_shallow_commits_by_rev_list(\n \t\tint ac, const char **av, int shallow_flag, int not_shallow_flag);\n-extern void set_alternate_shallow_file(const char *path, int override);\n+#define set_alternate_shallow_file(r, p, o) set_alternate_shallow_file_##r(p, o)\n+extern void set_alternate_shallow_file_the_repository(const char *path, int override);\n extern int write_shallow_commits(struct strbuf *out, int use_pack_protocol,\n \t\t\t\t const struct oid_array *extra);\n extern void setup_alternate_shallow(struct lock_file *shallow_lock,\ndiff --git a/environment.c b/environment.c\nindex b991fc0a87c..87d9e52ffde 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -189,7 +189,7 @@ void setup_git_env(const char *git_dir)\n \tgit_namespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT));\n \tshallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT);\n \tif (shallow_file)\n-\t\tset_alternate_shallow_file(shallow_file, 0);\n+\t\tset_alternate_shallow_file(the_repository, shallow_file, 0);\n }\n \n int is_bare_repository(void)\ndiff --git a/git.c b/git.c\nindex 3a89893712e..5e8903681e6 100644\n--- a/git.c\n+++ b/git.c\n@@ -207,7 +207,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t} else if (!strcmp(cmd, \"--shallow-file\")) {\n \t\t\t(*argv)++;\n \t\t\t(*argc)--;\n-\t\t\tset_alternate_shallow_file((*argv)[0], 1);\n+\t\t\tset_alternate_shallow_file(the_repository, (*argv)[0], 1);\n \t\t\tif (envchanged)\n \t\t\t\t*envchanged = 1;\n \t\t} else if (!strcmp(cmd, \"-C\")) {\ndiff --git a/shallow.c b/shallow.c\nindex ca360c700c5..73cb11a9162 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -19,7 +19,7 @@ static int is_shallow = -1;\n static struct stat_validity shallow_stat;\n static char *alternate_shallow_file;\n \n-void set_alternate_shallow_file(const char *path, int override)\n+void set_alternate_shallow_file_the_repository(const char *path, int override)\n {\n \tif (is_shallow != -1)\n \t\tdie(\"BUG: is_repository_shallow must not be called before set_alternate_shallow_file\");\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347945","messageId":"20180517225154.9200-10-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 09/19] shallow: add repository argument to register_shallow","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:44Z","receivedAt":"2018-05-17T22:52:31Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow callers of register_shallow\nto be more specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/pack-objects.c | 2 +-\n builtin/receive-pack.c | 2 +-\n commit.h               | 3 ++-\n fetch-pack.c           | 2 +-\n shallow.c              | 4 ++--\n upload-pack.c          | 7 ++++---\n 6 files changed, 11 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex d65eb4a9478..97a5963efb6 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2875,7 +2875,7 @@ static void get_object_list(int ac, const char **av)\n \t\t\t\tstruct object_id oid;\n \t\t\t\tif (get_oid_hex(line + 10, &oid))\n \t\t\t\t\tdie(\"not an SHA-1 '%s'\", line + 10);\n-\t\t\t\tregister_shallow(&oid);\n+\t\t\t\tregister_shallow(the_repository, &oid);\n \t\t\t\tuse_bitmap_index = 0;\n \t\t\t\tcontinue;\n \t\t\t}\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 36906fd5e98..c666820b69a 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -906,7 +906,7 @@ static int update_shallow_ref(struct command *cmd, struct shallow_info *si)\n \t * not lose these new roots..\n \t */\n \tfor (i = 0; i < extra.nr; i++)\n-\t\tregister_shallow(&extra.oid[i]);\n+\t\tregister_shallow(the_repository, &extra.oid[i]);\n \n \tsi->shallow_ref[cmd->index] = 0;\n \toid_array_clear(&extra);\ndiff --git a/commit.h b/commit.h\nindex f88c854e2f6..59346de5512 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -191,7 +191,8 @@ extern struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n,\n \n struct oid_array;\n struct ref;\n-extern int register_shallow(const struct object_id *oid);\n+#define register_shallow(r, o) register_shallow_##r(o);\n+extern int register_shallow_the_repository(const struct object_id *oid);\n extern int unregister_shallow(const struct object_id *oid);\n extern int for_each_commit_graft(each_commit_graft_fn, void *);\n extern int is_repository_shallow(void);\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex a1535b37b9b..e3e99e44962 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -428,7 +428,7 @@ static int find_common(struct fetch_pack_args *args,\n \t\t\tif (skip_prefix(line, \"shallow \", &arg)) {\n \t\t\t\tif (get_oid_hex(arg, &oid))\n \t\t\t\t\tdie(_(\"invalid shallow line: %s\"), line);\n-\t\t\t\tregister_shallow(&oid);\n+\t\t\t\tregister_shallow(the_repository, &oid);\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (skip_prefix(line, \"unshallow \", &arg)) {\ndiff --git a/shallow.c b/shallow.c\nindex 73cb11a9162..0fadd5330d2 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -29,7 +29,7 @@ void set_alternate_shallow_file_the_repository(const char *path, int override)\n \talternate_shallow_file = xstrdup_or_null(path);\n }\n \n-int register_shallow(const struct object_id *oid)\n+int register_shallow_the_repository(const struct object_id *oid)\n {\n \tstruct commit_graft *graft =\n \t\txmalloc(sizeof(struct commit_graft));\n@@ -70,7 +70,7 @@ int is_repository_shallow(void)\n \t\tstruct object_id oid;\n \t\tif (get_oid_hex(buf, &oid))\n \t\t\tdie(\"bad shallow line: %s\", buf);\n-\t\tregister_shallow(&oid);\n+\t\tregister_shallow(the_repository, &oid);\n \t}\n \tfclose(fp);\n \treturn is_shallow;\ndiff --git a/upload-pack.c b/upload-pack.c\nindex a11c6d192ce..4e4ac0f0d95 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -663,7 +663,7 @@ static void send_shallow(struct commit_list *result)\n \t\tif (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {\n \t\t\tpacket_write_fmt(1, \"shallow %s\",\n \t\t\t\t\t oid_to_hex(&object->oid));\n-\t\t\tregister_shallow(&object->oid);\n+\t\t\tregister_shallow(the_repository, &object->oid);\n \t\t\tshallow_nr++;\n \t\t}\n \t\tresult = result->next;\n@@ -700,7 +700,7 @@ static void send_unshallow(const struct object_array *shallows)\n \t\t\tadd_object_array(object, NULL, &extra_edge_obj);\n \t\t}\n \t\t/* make sure commit traversal conforms to client */\n-\t\tregister_shallow(&object->oid);\n+\t\tregister_shallow(the_repository, &object->oid);\n \t}\n }\n \n@@ -912,7 +912,8 @@ static void receive_needs(void)\n \t\tif (shallows.nr > 0) {\n \t\t\tint i;\n \t\t\tfor (i = 0; i < shallows.nr; i++)\n-\t\t\t\tregister_shallow(&shallows.objects[i].item->oid);\n+\t\t\t\tregister_shallow(the_repository,\n+\t\t\t\t\t\t &shallows.objects[i].item->oid);\n \t\t}\n \n \tshallow_nr += shallows.nr;\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347946","messageId":"20180517225154.9200-11-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 10/19] shallow: add repository argument to check_shallow_file_for_update","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:45Z","receivedAt":"2018-05-17T22:52:32Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow callers of check_shallow_file_for_update\nto be more specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n shallow.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/shallow.c b/shallow.c\nindex 0fadd5330d2..0028e4ea776 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -217,7 +217,8 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,\n \treturn result;\n }\n \n-static void check_shallow_file_for_update(void)\n+#define check_shallow_file_for_update(r) check_shallow_file_for_update_##r()\n+static void check_shallow_file_for_update_the_repository(void)\n {\n \tif (is_shallow == -1)\n \t\tdie(\"BUG: shallow must be initialized by now\");\n@@ -319,7 +320,7 @@ void setup_alternate_shallow(struct lock_file *shallow_lock,\n \n \tfd = hold_lock_file_for_update(shallow_lock, git_path_shallow(),\n \t\t\t\t       LOCK_DIE_ON_ERROR);\n-\tcheck_shallow_file_for_update();\n+\tcheck_shallow_file_for_update(the_repository);\n \tif (write_shallow_commits(&sb, 0, extra)) {\n \t\tif (write_in_full(fd, sb.buf, sb.len) < 0)\n \t\t\tdie_errno(\"failed to write to %s\",\n@@ -366,7 +367,7 @@ void prune_shallow(int show_only)\n \t}\n \tfd = hold_lock_file_for_update(&shallow_lock, git_path_shallow(),\n \t\t\t\t       LOCK_DIE_ON_ERROR);\n-\tcheck_shallow_file_for_update();\n+\tcheck_shallow_file_for_update(the_repository);\n \tif (write_shallow_commits_1(&sb, 0, NULL, SEEN_ONLY)) {\n \t\tif (write_in_full(fd, sb.buf, sb.len) < 0)\n \t\t\tdie_errno(\"failed to write to %s\",\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347947","messageId":"20180517225154.9200-13-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 12/19] commit: convert commit_graft_pos() to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:47Z","receivedAt":"2018-05-17T22:52:33Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Brandon Williams <bmwill@google.com>\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 7 +++----\n 1 file changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 684eeaa2ccd..0ec3d22813a 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -104,11 +104,10 @@ static const unsigned char *commit_graft_sha1_access(size_t index, void *table)\n \treturn commit_graft_table[index]->oid.hash;\n }\n \n-#define commit_graft_pos(r, s) commit_graft_pos_##r(s)\n-static int commit_graft_pos_the_repository(const unsigned char *sha1)\n+static int commit_graft_pos(struct repository *r, const unsigned char *sha1)\n {\n-\treturn sha1_pos(sha1, the_repository->parsed_objects->grafts,\n-\t\t\tthe_repository->parsed_objects->grafts_nr,\n+\treturn sha1_pos(sha1, r->parsed_objects->grafts,\n+\t\t\tr->parsed_objects->grafts_nr,\n \t\t\tcommit_graft_sha1_access);\n }\n \n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347948","messageId":"20180517225154.9200-15-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 14/19] commit: convert read_graft_file to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:49Z","receivedAt":"2018-05-17T22:52:36Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Brandon Williams <bmwill@google.com>\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 8a2ab53fc67..3fcb2fd66ce 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -177,8 +177,7 @@ struct commit_graft *read_graft_line(struct strbuf *line)\n \treturn NULL;\n }\n \n-#define read_graft_file(r, f) read_graft_file_##r(f)\n-static int read_graft_file_the_repository(const char *graft_file)\n+static int read_graft_file(struct repository *r, const char *graft_file)\n {\n \tFILE *fp = fopen_or_warn(graft_file, \"r\");\n \tstruct strbuf buf = STRBUF_INIT;\n@@ -189,7 +188,7 @@ static int read_graft_file_the_repository(const char *graft_file)\n \t\tstruct commit_graft *graft = read_graft_line(&buf);\n \t\tif (!graft)\n \t\t\tcontinue;\n-\t\tif (register_commit_graft(the_repository, graft, 1))\n+\t\tif (register_commit_graft(r, graft, 1))\n \t\t\terror(\"duplicate graft data: %s\", buf.buf);\n \t}\n \tfclose(fp);\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347949","messageId":"20180517225154.9200-16-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 15/19] cache: convert get_graft_file to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:50Z","receivedAt":"2018-05-17T22:52:40Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This conversion was done without the #define trick used in the earlier\nseries refactoring to have better repository access, because this function\nis easy to review, as all lines are converted and it has only one caller.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n cache.h       | 2 +-\n commit.c      | 2 +-\n environment.c | 6 +++---\n 3 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex ab716011b7e..cb1aeb1dcbf 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -476,7 +476,7 @@ extern const char *get_git_dir(void);\n extern const char *get_git_common_dir(void);\n extern char *get_object_directory(void);\n extern char *get_index_file(void);\n-extern char *get_graft_file(void);\n+extern char *get_graft_file(struct repository *r);\n extern int set_git_dir(const char *path);\n extern int get_common_dir_noenv(struct strbuf *sb, const char *gitdir);\n extern int get_common_dir(struct strbuf *sb, const char *gitdir);\ndiff --git a/commit.c b/commit.c\nindex 3fcb2fd66ce..24028fd257a 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -204,7 +204,7 @@ static void prepare_commit_graft_the_repository(void)\n \n \tif (commit_graft_prepared)\n \t\treturn;\n-\tgraft_file = get_graft_file();\n+\tgraft_file = get_graft_file(the_repository);\n \tread_graft_file(the_repository, graft_file);\n \t/* make sure shallows are read */\n \tis_repository_shallow(the_repository);\ndiff --git a/environment.c b/environment.c\nindex 87d9e52ffde..ab42346e563 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -316,11 +316,11 @@ char *get_index_file(void)\n \treturn the_repository->index_file;\n }\n \n-char *get_graft_file(void)\n+char *get_graft_file(struct repository *r)\n {\n-\tif (!the_repository->graft_file)\n+\tif (!r->graft_file)\n \t\tBUG(\"git environment hasn't been setup\");\n-\treturn the_repository->graft_file;\n+\treturn r->graft_file;\n }\n \n int set_git_dir(const char *path)\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347950","messageId":"20180517225154.9200-20-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 19/19] commit: allow lookup_commit_graft to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:54Z","receivedAt":"2018-05-17T22:52:42Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 8 ++++----\n commit.h | 3 +--\n 2 files changed, 5 insertions(+), 6 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex eef1675d692..b01cc0c3e0c 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -209,14 +209,14 @@ static void prepare_commit_graft(struct repository *r)\n \tr->parsed_objects->commit_graft_prepared = 1;\n }\n \n-struct commit_graft *lookup_commit_graft_the_repository(const struct object_id *oid)\n+struct commit_graft *lookup_commit_graft(struct repository *r, const struct object_id *oid)\n {\n \tint pos;\n-\tprepare_commit_graft(the_repository);\n-\tpos = commit_graft_pos(the_repository, oid->hash);\n+\tprepare_commit_graft(r);\n+\tpos = commit_graft_pos(r, oid->hash);\n \tif (pos < 0)\n \t\treturn NULL;\n-\treturn the_repository->parsed_objects->grafts[pos];\n+\treturn r->parsed_objects->grafts[pos];\n }\n \n int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data)\ndiff --git a/commit.h b/commit.h\nindex 45114a95b25..6de6f10cd04 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -175,8 +175,7 @@ typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *);\n \n struct commit_graft *read_graft_line(struct strbuf *line);\n int register_commit_graft(struct repository *r, struct commit_graft *, int);\n-#define lookup_commit_graft(r, o) lookup_commit_graft_##r(o)\n-struct commit_graft *lookup_commit_graft_the_repository(const struct object_id *oid);\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-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347951","messageId":"20180517225154.9200-18-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 17/19] shallow: migrate shallow information into the object parser","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:52Z","receivedAt":"2018-05-17T22:52:44Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"We need to convert the shallow functions all at the same time\nas we move the data structures they operate on into the repository.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.h  |  9 +++------\n object.c  |  3 +++\n object.h  |  4 ++++\n shallow.c | 50 +++++++++++++++++++++++---------------------------\n 4 files changed, 33 insertions(+), 33 deletions(-)\n\ndiff --git a/commit.h b/commit.h\nindex d04bbed81cf..45114a95b25 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -190,18 +190,15 @@ extern struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n,\n \n struct oid_array;\n struct ref;\n-#define register_shallow(r, o) register_shallow_##r(o);\n-extern int register_shallow_the_repository(const struct object_id *oid);\n+extern int register_shallow(struct repository *r, const struct object_id *oid);\n extern int unregister_shallow(const struct object_id *oid);\n extern int for_each_commit_graft(each_commit_graft_fn, void *);\n-#define is_repository_shallow(r) is_repository_shallow_##r()\n-extern int is_repository_shallow_the_repository(void);\n+extern int is_repository_shallow(struct repository *r);\n extern struct commit_list *get_shallow_commits(struct object_array *heads,\n \t\tint depth, int shallow_flag, int not_shallow_flag);\n extern struct commit_list *get_shallow_commits_by_rev_list(\n \t\tint ac, const char **av, int shallow_flag, int not_shallow_flag);\n-#define set_alternate_shallow_file(r, p, o) set_alternate_shallow_file_##r(p, o)\n-extern void set_alternate_shallow_file_the_repository(const char *path, int override);\n+extern void set_alternate_shallow_file(struct repository *r, const char *path, int override);\n extern int write_shallow_commits(struct strbuf *out, int use_pack_protocol,\n \t\t\t\t const struct oid_array *extra);\n extern void setup_alternate_shallow(struct lock_file *shallow_lock,\ndiff --git a/object.c b/object.c\nindex 0116ed6529a..30b8a721cf6 100644\n--- a/object.c\n+++ b/object.c\n@@ -464,6 +464,9 @@ struct parsed_object_pool *parsed_object_pool_new(void)\n \to->tag_state = allocate_alloc_state();\n \to->object_state = allocate_alloc_state();\n \n+\to->is_shallow = -1;\n+\to->shallow_stat = xcalloc(1, sizeof(*o->shallow_stat));\n+\n \treturn o;\n }\n \ndiff --git a/object.h b/object.h\nindex ec908f9bcc1..a314331acaf 100644\n--- a/object.h\n+++ b/object.h\n@@ -16,6 +16,10 @@ struct parsed_object_pool {\n \t/* parent substitutions from .git/info/grafts and .git/shallow */\n \tstruct commit_graft **grafts;\n \tint grafts_alloc, grafts_nr;\n+\n+\tint is_shallow;\n+\tstruct stat_validity *shallow_stat;\n+\tchar *alternate_shallow_file;\n };\n \n struct parsed_object_pool *parsed_object_pool_new(void);\ndiff --git a/shallow.c b/shallow.c\nindex a0e338459f9..9f6ee351319 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -14,22 +14,19 @@\n #include \"commit-slab.h\"\n #include \"revision.h\"\n #include \"list-objects.h\"\n+#include \"repository.h\"\n \n-static int is_shallow = -1;\n-static struct stat_validity shallow_stat;\n-static char *alternate_shallow_file;\n-\n-void set_alternate_shallow_file_the_repository(const char *path, int override)\n+void set_alternate_shallow_file(struct repository *r, const char *path, int override)\n {\n-\tif (is_shallow != -1)\n+\tif (r->parsed_objects->is_shallow != -1)\n \t\tdie(\"BUG: is_repository_shallow must not be called before set_alternate_shallow_file\");\n-\tif (alternate_shallow_file && !override)\n+\tif (r->parsed_objects->alternate_shallow_file && !override)\n \t\treturn;\n-\tfree(alternate_shallow_file);\n-\talternate_shallow_file = xstrdup_or_null(path);\n+\tfree(r->parsed_objects->alternate_shallow_file);\n+\tr->parsed_objects->alternate_shallow_file = xstrdup_or_null(path);\n }\n \n-int register_shallow_the_repository(const struct object_id *oid)\n+int register_shallow(struct repository *r, const struct object_id *oid)\n {\n \tstruct commit_graft *graft =\n \t\txmalloc(sizeof(struct commit_graft));\n@@ -39,41 +36,41 @@ int register_shallow_the_repository(const struct object_id *oid)\n \tgraft->nr_parent = -1;\n \tif (commit && commit->object.parsed)\n \t\tcommit->parents = NULL;\n-\treturn register_commit_graft(the_repository, graft, 0);\n+\treturn register_commit_graft(r, graft, 0);\n }\n \n-int is_repository_shallow_the_repository(void)\n+int is_repository_shallow(struct repository *r)\n {\n \tFILE *fp;\n \tchar buf[1024];\n-\tconst char *path = alternate_shallow_file;\n+\tconst char *path = r->parsed_objects->alternate_shallow_file;\n \n-\tif (is_shallow >= 0)\n-\t\treturn is_shallow;\n+\tif (r->parsed_objects->is_shallow >= 0)\n+\t\treturn r->parsed_objects->is_shallow;\n \n \tif (!path)\n-\t\tpath = git_path_shallow(the_repository);\n+\t\tpath = git_path_shallow(r);\n \t/*\n \t * fetch-pack sets '--shallow-file \"\"' as an indicator that no\n \t * shallow file should be used. We could just open it and it\n \t * will likely fail. But let's do an explicit check instead.\n \t */\n \tif (!*path || (fp = fopen(path, \"r\")) == NULL) {\n-\t\tstat_validity_clear(&shallow_stat);\n-\t\tis_shallow = 0;\n-\t\treturn is_shallow;\n+\t\tstat_validity_clear(r->parsed_objects->shallow_stat);\n+\t\tr->parsed_objects->is_shallow = 0;\n+\t\treturn r->parsed_objects->is_shallow;\n \t}\n-\tstat_validity_update(&shallow_stat, fileno(fp));\n-\tis_shallow = 1;\n+\tstat_validity_update(r->parsed_objects->shallow_stat, fileno(fp));\n+\tr->parsed_objects->is_shallow = 1;\n \n \twhile (fgets(buf, sizeof(buf), fp)) {\n \t\tstruct object_id oid;\n \t\tif (get_oid_hex(buf, &oid))\n \t\t\tdie(\"bad shallow line: %s\", buf);\n-\t\tregister_shallow(the_repository, &oid);\n+\t\tregister_shallow(r, &oid);\n \t}\n \tfclose(fp);\n-\treturn is_shallow;\n+\treturn r->parsed_objects->is_shallow;\n }\n \n struct commit_list *get_shallow_commits(struct object_array *heads, int depth,\n@@ -217,13 +214,12 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,\n \treturn result;\n }\n \n-#define check_shallow_file_for_update(r) check_shallow_file_for_update_##r()\n-static void check_shallow_file_for_update_the_repository(void)\n+static void check_shallow_file_for_update(struct repository *r)\n {\n-\tif (is_shallow == -1)\n+\tif (r->parsed_objects->is_shallow == -1)\n \t\tdie(\"BUG: shallow must be initialized by now\");\n \n-\tif (!stat_validity_check(&shallow_stat, git_path_shallow(the_repository)))\n+\tif (!stat_validity_check(r->parsed_objects->shallow_stat, git_path_shallow(the_repository)))\n \t\tdie(\"shallow file has changed since we read it\");\n }\n \n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347952","messageId":"20180517225154.9200-17-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 16/19] path.c: migrate global git_path_* to take a repository argument","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:51Z","receivedAt":"2018-05-17T22:52:47Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Migrate all git_path_* functions that are defined in path.c to take a\nrepository argument. Unlike other patches in this series, do not use the\n #define trick, as we rewrite the whole function, which is rather small.\n\nThis doesn't migrate all the functions, as other builtins have their own\nlocal path functions defined using GIT_PATH_FUNC. So keep that macro\naround to serve the other locations.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n blame.c          |  8 +++++---\n branch.c         | 14 +++++++-------\n builtin/commit.c | 38 +++++++++++++++++++-------------------\n builtin/fetch.c  |  4 ++--\n builtin/merge.c  | 37 +++++++++++++++++++------------------\n builtin/pull.c   |  4 ++--\n builtin/reset.c  |  2 +-\n fetch-pack.c     |  2 +-\n path.c           | 18 +++++++++---------\n path.h           | 40 +++++++++++++++++++++++++++++++---------\n repository.h     |  5 +++++\n rerere.c         |  7 ++++---\n sequencer.c      | 37 +++++++++++++++++++------------------\n shallow.c        | 12 +++++++-----\n wt-status.c      |  8 ++++----\n 15 files changed, 135 insertions(+), 101 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex f689bde31cd..c22184c2dad 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -112,17 +112,19 @@ static void append_merge_parents(struct commit_list **tail)\n \tint merge_head;\n \tstruct strbuf line = STRBUF_INIT;\n \n-\tmerge_head = open(git_path_merge_head(), O_RDONLY);\n+\tmerge_head = open(git_path_merge_head(the_repository), O_RDONLY);\n \tif (merge_head < 0) {\n \t\tif (errno == ENOENT)\n \t\t\treturn;\n-\t\tdie(\"cannot open '%s' for reading\", git_path_merge_head());\n+\t\tdie(\"cannot open '%s' for reading\",\n+\t\t    git_path_merge_head(the_repository));\n \t}\n \n \twhile (!strbuf_getwholeline_fd(&line, merge_head, '\\n')) {\n \t\tstruct object_id oid;\n \t\tif (line.len < GIT_SHA1_HEXSZ || get_oid_hex(line.buf, &oid))\n-\t\t\tdie(\"unknown line in '%s': %s\", git_path_merge_head(), line.buf);\n+\t\t\tdie(\"unknown line in '%s': %s\",\n+\t\t\t    git_path_merge_head(the_repository), line.buf);\n \t\ttail = append_parent(tail, &oid);\n \t}\n \tclose(merge_head);\ndiff --git a/branch.c b/branch.c\nindex 2672054f0b5..9b2742de32a 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -339,13 +339,13 @@ void create_branch(const char *name, const char *start_name,\n \n void remove_branch_state(void)\n {\n-\tunlink(git_path_cherry_pick_head());\n-\tunlink(git_path_revert_head());\n-\tunlink(git_path_merge_head());\n-\tunlink(git_path_merge_rr());\n-\tunlink(git_path_merge_msg());\n-\tunlink(git_path_merge_mode());\n-\tunlink(git_path_squash_msg());\n+\tunlink(git_path_cherry_pick_head(the_repository));\n+\tunlink(git_path_revert_head(the_repository));\n+\tunlink(git_path_merge_head(the_repository));\n+\tunlink(git_path_merge_rr(the_repository));\n+\tunlink(git_path_merge_msg(the_repository));\n+\tunlink(git_path_merge_mode(the_repository));\n+\tunlink(git_path_squash_msg(the_repository));\n }\n \n void die_if_checked_out(const char *branch, int ignore_current_worktree)\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 37fcb55ab0a..7c22879777d 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -145,9 +145,9 @@ static int opt_parse_m(const struct option *opt, const char *arg, int unset)\n \n static void determine_whence(struct wt_status *s)\n {\n-\tif (file_exists(git_path_merge_head()))\n+\tif (file_exists(git_path_merge_head(the_repository)))\n \t\twhence = FROM_MERGE;\n-\telse if (file_exists(git_path_cherry_pick_head())) {\n+\telse if (file_exists(git_path_cherry_pick_head(the_repository))) {\n \t\twhence = FROM_CHERRY_PICK;\n \t\tif (file_exists(git_path_seq_dir()))\n \t\t\tsequencer_in_use = 1;\n@@ -696,21 +696,21 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\tif (have_option_m)\n \t\t\tstrbuf_addbuf(&sb, &message);\n \t\thook_arg1 = \"message\";\n-\t} else if (!stat(git_path_merge_msg(), &statbuf)) {\n+\t} else if (!stat(git_path_merge_msg(the_repository), &statbuf)) {\n \t\t/*\n \t\t * prepend SQUASH_MSG here if it exists and a\n \t\t * \"merge --squash\" was originally performed\n \t\t */\n-\t\tif (!stat(git_path_squash_msg(), &statbuf)) {\n-\t\t\tif (strbuf_read_file(&sb, git_path_squash_msg(), 0) < 0)\n+\t\tif (!stat(git_path_squash_msg(the_repository), &statbuf)) {\n+\t\t\tif (strbuf_read_file(&sb, git_path_squash_msg(the_repository), 0) < 0)\n \t\t\t\tdie_errno(_(\"could not read SQUASH_MSG\"));\n \t\t\thook_arg1 = \"squash\";\n \t\t} else\n \t\t\thook_arg1 = \"merge\";\n-\t\tif (strbuf_read_file(&sb, git_path_merge_msg(), 0) < 0)\n+\t\tif (strbuf_read_file(&sb, git_path_merge_msg(the_repository), 0) < 0)\n \t\t\tdie_errno(_(\"could not read MERGE_MSG\"));\n-\t} else if (!stat(git_path_squash_msg(), &statbuf)) {\n-\t\tif (strbuf_read_file(&sb, git_path_squash_msg(), 0) < 0)\n+\t} else if (!stat(git_path_squash_msg(the_repository), &statbuf)) {\n+\t\tif (strbuf_read_file(&sb, git_path_squash_msg(the_repository), 0) < 0)\n \t\t\tdie_errno(_(\"could not read SQUASH_MSG\"));\n \t\thook_arg1 = \"squash\";\n \t} else if (template_file) {\n@@ -791,8 +791,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\t\t\t\"\t%s\\n\"\n \t\t\t\t\t\"and try again.\\n\"),\n \t\t\t\twhence == FROM_MERGE ?\n-\t\t\t\t\tgit_path_merge_head() :\n-\t\t\t\t\tgit_path_cherry_pick_head());\n+\t\t\t\t\tgit_path_merge_head(the_repository) :\n+\t\t\t\t\tgit_path_cherry_pick_head(the_repository));\n \t\t}\n \n \t\tfprintf(s->fp, \"\\n\");\n@@ -1523,7 +1523,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tif (!reflog_msg)\n \t\t\treflog_msg = \"commit (merge)\";\n \t\tpptr = commit_list_append(current_head, pptr);\n-\t\tfp = xfopen(git_path_merge_head(), \"r\");\n+\t\tfp = xfopen(git_path_merge_head(the_repository), \"r\");\n \t\twhile (strbuf_getline_lf(&m, fp) != EOF) {\n \t\t\tstruct commit *parent;\n \n@@ -1534,8 +1534,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tfclose(fp);\n \t\tstrbuf_release(&m);\n-\t\tif (!stat(git_path_merge_mode(), &statbuf)) {\n-\t\t\tif (strbuf_read_file(&sb, git_path_merge_mode(), 0) < 0)\n+\t\tif (!stat(git_path_merge_mode(the_repository), &statbuf)) {\n+\t\t\tif (strbuf_read_file(&sb, git_path_merge_mode(the_repository), 0) < 0)\n \t\t\t\tdie_errno(_(\"could not read MERGE_MODE\"));\n \t\t\tif (!strcmp(sb.buf, \"no-ff\"))\n \t\t\t\tallow_fast_forward = 0;\n@@ -1598,12 +1598,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tdie(\"%s\", err.buf);\n \t}\n \n-\tunlink(git_path_cherry_pick_head());\n-\tunlink(git_path_revert_head());\n-\tunlink(git_path_merge_head());\n-\tunlink(git_path_merge_msg());\n-\tunlink(git_path_merge_mode());\n-\tunlink(git_path_squash_msg());\n+\tunlink(git_path_cherry_pick_head(the_repository));\n+\tunlink(git_path_revert_head(the_repository));\n+\tunlink(git_path_merge_head(the_repository));\n+\tunlink(git_path_merge_msg(the_repository));\n+\tunlink(git_path_merge_mode(the_repository));\n+\tunlink(git_path_squash_msg(the_repository));\n \n \tif (commit_index_files())\n \t\tdie (_(\"Repository has been updated, but unable to write\\n\"\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 55140671ef3..41d74c7e8d3 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -767,7 +767,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \tconst char *what, *kind;\n \tstruct ref *rm;\n \tchar *url;\n-\tconst char *filename = dry_run ? \"/dev/null\" : git_path_fetch_head();\n+\tconst char *filename = dry_run ? \"/dev/null\" : git_path_fetch_head(the_repository);\n \tint want_status;\n \tint summary_width = transport_summary_width(ref_map);\n \n@@ -1019,7 +1019,7 @@ static void check_not_current_branch(struct ref *ref_map)\n \n static int truncate_fetch_head(void)\n {\n-\tconst char *filename = git_path_fetch_head();\n+\tconst char *filename = git_path_fetch_head(the_repository);\n \tFILE *fp = fopen_for_writing(filename);\n \n \tif (!fp)\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 9db5a2cf16e..e9057c1657b 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -245,9 +245,9 @@ static struct option builtin_merge_options[] = {\n /* Cleans up metadata that is uninteresting after a succeeded merge. */\n static void drop_save(void)\n {\n-\tunlink(git_path_merge_head());\n-\tunlink(git_path_merge_msg());\n-\tunlink(git_path_merge_mode());\n+\tunlink(git_path_merge_head(the_repository));\n+\tunlink(git_path_merge_msg(the_repository));\n+\tunlink(git_path_merge_mode(the_repository));\n }\n \n static int save_state(struct object_id *stash)\n@@ -380,7 +380,7 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead\n \t\t\toid_to_hex(&commit->object.oid));\n \t\tpretty_print_commit(&ctx, commit, &out);\n \t}\n-\twrite_file_buf(git_path_squash_msg(), out.buf, out.len);\n+\twrite_file_buf(git_path_squash_msg(the_repository), out.buf, out.len);\n \tstrbuf_release(&out);\n }\n \n@@ -741,7 +741,7 @@ static void add_strategies(const char *string, unsigned attr)\n \n static void read_merge_msg(struct strbuf *msg)\n {\n-\tconst char *filename = git_path_merge_msg();\n+\tconst char *filename = git_path_merge_msg(the_repository);\n \tstrbuf_reset(msg);\n \tif (strbuf_read_file(msg, filename, 0) < 0)\n \t\tdie_errno(_(\"Could not read from '%s'\"), filename);\n@@ -778,18 +778,18 @@ static void prepare_to_commit(struct commit_list *remoteheads)\n \tif (signoff)\n \t\tappend_signoff(&msg, ignore_non_trailer(msg.buf, msg.len), 0);\n \twrite_merge_heads(remoteheads);\n-\twrite_file_buf(git_path_merge_msg(), msg.buf, msg.len);\n+\twrite_file_buf(git_path_merge_msg(the_repository), msg.buf, msg.len);\n \tif (run_commit_hook(0 < option_edit, get_index_file(), \"prepare-commit-msg\",\n-\t\t\t    git_path_merge_msg(), \"merge\", NULL))\n+\t\t\t    git_path_merge_msg(the_repository), \"merge\", NULL))\n \t\tabort_commit(remoteheads, NULL);\n \tif (0 < option_edit) {\n-\t\tif (launch_editor(git_path_merge_msg(), NULL, NULL))\n+\t\tif (launch_editor(git_path_merge_msg(the_repository), NULL, NULL))\n \t\t\tabort_commit(remoteheads, NULL);\n \t}\n \n \tif (verify_msg && run_commit_hook(0 < option_edit, get_index_file(),\n \t\t\t\t\t  \"commit-msg\",\n-\t\t\t\t\t  git_path_merge_msg(), NULL))\n+\t\t\t\t\t  git_path_merge_msg(the_repository), NULL))\n \t\tabort_commit(remoteheads, NULL);\n \n \tread_merge_msg(&msg);\n@@ -859,7 +859,7 @@ static int suggest_conflicts(void)\n \tFILE *fp;\n \tstruct strbuf msgbuf = STRBUF_INIT;\n \n-\tfilename = git_path_merge_msg();\n+\tfilename = git_path_merge_msg(the_repository);\n \tfp = xfopen(filename, \"a\");\n \n \tappend_conflicts_hint(&msgbuf);\n@@ -939,12 +939,12 @@ static void write_merge_heads(struct commit_list *remoteheads)\n \t\t}\n \t\tstrbuf_addf(&buf, \"%s\\n\", oid_to_hex(oid));\n \t}\n-\twrite_file_buf(git_path_merge_head(), buf.buf, buf.len);\n+\twrite_file_buf(git_path_merge_head(the_repository), buf.buf, buf.len);\n \n \tstrbuf_reset(&buf);\n \tif (fast_forward == FF_NO)\n \t\tstrbuf_addstr(&buf, \"no-ff\");\n-\twrite_file_buf(git_path_merge_mode(), buf.buf, buf.len);\n+\twrite_file_buf(git_path_merge_mode(the_repository), buf.buf, buf.len);\n \tstrbuf_release(&buf);\n }\n \n@@ -952,7 +952,8 @@ static void write_merge_state(struct commit_list *remoteheads)\n {\n \twrite_merge_heads(remoteheads);\n \tstrbuf_addch(&merge_msg, '\\n');\n-\twrite_file_buf(git_path_merge_msg(), merge_msg.buf, merge_msg.len);\n+\twrite_file_buf(git_path_merge_msg(the_repository), merge_msg.buf,\n+\t\t       merge_msg.len);\n }\n \n static int default_edit_option(void)\n@@ -1035,7 +1036,7 @@ static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge\n \tif (!merge_names)\n \t\tmerge_names = &fetch_head_file;\n \n-\tfilename = git_path_fetch_head();\n+\tfilename = git_path_fetch_head(the_repository);\n \tfd = open(filename, O_RDONLY);\n \tif (fd < 0)\n \t\tdie_errno(_(\"could not open '%s' for reading\"), filename);\n@@ -1209,7 +1210,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\t\tusage_msg_opt(_(\"--abort expects no arguments\"),\n \t\t\t      builtin_merge_usage, builtin_merge_options);\n \n-\t\tif (!file_exists(git_path_merge_head()))\n+\t\tif (!file_exists(git_path_merge_head(the_repository)))\n \t\t\tdie(_(\"There is no merge to abort (MERGE_HEAD missing).\"));\n \n \t\t/* Invoke 'git reset --merge' */\n@@ -1225,7 +1226,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\t\tusage_msg_opt(_(\"--continue expects no arguments\"),\n \t\t\t      builtin_merge_usage, builtin_merge_options);\n \n-\t\tif (!file_exists(git_path_merge_head()))\n+\t\tif (!file_exists(git_path_merge_head(the_repository)))\n \t\t\tdie(_(\"There is no merge in progress (MERGE_HEAD missing).\"));\n \n \t\t/* Invoke 'git commit' */\n@@ -1236,7 +1237,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \tif (read_cache_unmerged())\n \t\tdie_resolve_conflict(\"merge\");\n \n-\tif (file_exists(git_path_merge_head())) {\n+\tif (file_exists(git_path_merge_head(the_repository))) {\n \t\t/*\n \t\t * There is no unmerged entry, don't advise 'git\n \t\t * add/rm <file>', just 'git commit'.\n@@ -1247,7 +1248,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\telse\n \t\t\tdie(_(\"You have not concluded your merge (MERGE_HEAD exists).\"));\n \t}\n-\tif (file_exists(git_path_cherry_pick_head())) {\n+\tif (file_exists(git_path_cherry_pick_head(the_repository))) {\n \t\tif (advice_resolve_conflict)\n \t\t\tdie(_(\"You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\\n\"\n \t\t\t    \"Please, commit your changes before you merge.\"));\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex e32d6cd5b4c..d21239cd9f3 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -351,7 +351,7 @@ static int git_pull_config(const char *var, const char *value, void *cb)\n  */\n static void get_merge_heads(struct oid_array *merge_heads)\n {\n-\tconst char *filename = git_path_fetch_head();\n+\tconst char *filename = git_path_fetch_head(the_repository);\n \tFILE *fp;\n \tstruct strbuf sb = STRBUF_INIT;\n \tstruct object_id oid;\n@@ -857,7 +857,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)\n \tif (read_cache_unmerged())\n \t\tdie_resolve_conflict(\"pull\");\n \n-\tif (file_exists(git_path_merge_head()))\n+\tif (file_exists(git_path_merge_head(the_repository)))\n \t\tdie_conclude_merge();\n \n \tif (get_oid(\"HEAD\", &orig_head))\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 7f1c3f02a30..a9136a163c0 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -39,7 +39,7 @@ static const char *reset_type_names[] = {\n \n static inline int is_merge(void)\n {\n-\treturn !access(git_path_merge_head(), F_OK);\n+\treturn !access(git_path_merge_head(the_repository), F_OK);\n }\n \n static int reset_index(const struct object_id *oid, int reset_type, int quiet)\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 90befd370fe..8f3aacaaaa2 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -1136,7 +1136,7 @@ static void update_shallow(struct fetch_pack_args *args,\n \n \tif (args->deepen && alternate_shallow_file) {\n \t\tif (*alternate_shallow_file == '\\0') { /* --unshallow */\n-\t\t\tunlink_or_warn(git_path_shallow());\n+\t\t\tunlink_or_warn(git_path_shallow(the_repository));\n \t\t\trollback_lock_file(&shallow_lock);\n \t\t} else\n \t\t\tcommit_lock_file(&shallow_lock);\ndiff --git a/path.c b/path.c\nindex 3308b7b9582..3c06e258b4c 100644\n--- a/path.c\n+++ b/path.c\n@@ -1358,12 +1358,12 @@ char *xdg_cache_home(const char *filename)\n \treturn NULL;\n }\n \n-GIT_PATH_FUNC(git_path_cherry_pick_head, \"CHERRY_PICK_HEAD\")\n-GIT_PATH_FUNC(git_path_revert_head, \"REVERT_HEAD\")\n-GIT_PATH_FUNC(git_path_squash_msg, \"SQUASH_MSG\")\n-GIT_PATH_FUNC(git_path_merge_msg, \"MERGE_MSG\")\n-GIT_PATH_FUNC(git_path_merge_rr, \"MERGE_RR\")\n-GIT_PATH_FUNC(git_path_merge_mode, \"MERGE_MODE\")\n-GIT_PATH_FUNC(git_path_merge_head, \"MERGE_HEAD\")\n-GIT_PATH_FUNC(git_path_fetch_head, \"FETCH_HEAD\")\n-GIT_PATH_FUNC(git_path_shallow, \"shallow\")\n+REPO_GIT_PATH_FUNC(cherry_pick_head, \"CHERRY_PICK_HEAD\")\n+REPO_GIT_PATH_FUNC(revert_head, \"REVERT_HEAD\")\n+REPO_GIT_PATH_FUNC(squash_msg, \"SQUASH_MSG\")\n+REPO_GIT_PATH_FUNC(merge_msg, \"MERGE_MSG\")\n+REPO_GIT_PATH_FUNC(merge_rr, \"MERGE_RR\")\n+REPO_GIT_PATH_FUNC(merge_mode, \"MERGE_MODE\")\n+REPO_GIT_PATH_FUNC(merge_head, \"MERGE_HEAD\")\n+REPO_GIT_PATH_FUNC(fetch_head, \"FETCH_HEAD\")\n+REPO_GIT_PATH_FUNC(shallow, \"shallow\")\ndiff --git a/path.h b/path.h\nindex 1ccd0373c9d..5263f40519a 100644\n--- a/path.h\n+++ b/path.h\n@@ -160,14 +160,36 @@ extern void report_linked_checkout_garbage(void);\n \t\treturn ret; \\\n \t}\n \n-const char *git_path_cherry_pick_head(void);\n-const char *git_path_revert_head(void);\n-const char *git_path_squash_msg(void);\n-const char *git_path_merge_msg(void);\n-const char *git_path_merge_rr(void);\n-const char *git_path_merge_mode(void);\n-const char *git_path_merge_head(void);\n-const char *git_path_fetch_head(void);\n-const char *git_path_shallow(void);\n+#define REPO_GIT_PATH_FUNC(var, filename) \\\n+\tconst char *git_path_##var(struct repository *r) \\\n+\t{ \\\n+\t\tif (!r->cached_paths.var) \\\n+\t\t\tr->cached_paths.var = git_pathdup(filename); \\\n+\t\treturn r->cached_paths.var; \\\n+\t}\n+\n+struct path_cache {\n+\tconst char *cherry_pick_head;\n+\tconst char *revert_head;\n+\tconst char *squash_msg;\n+\tconst char *merge_msg;\n+\tconst char *merge_rr;\n+\tconst char *merge_mode;\n+\tconst char *merge_head;\n+\tconst char *fetch_head;\n+\tconst char *shallow;\n+};\n+\n+#define PATH_CACHE_INIT { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }\n+\n+const char *git_path_cherry_pick_head(struct repository *r);\n+const char *git_path_revert_head(struct repository *r);\n+const char *git_path_squash_msg(struct repository *r);\n+const char *git_path_merge_msg(struct repository *r);\n+const char *git_path_merge_rr(struct repository *r);\n+const char *git_path_merge_mode(struct repository *r);\n+const char *git_path_merge_head(struct repository *r);\n+const char *git_path_fetch_head(struct repository *r);\n+const char *git_path_shallow(struct repository *r);\n \n #endif /* PATH_H */\ndiff --git a/repository.h b/repository.h\nindex 6d199819905..83f9ef15103 100644\n--- a/repository.h\n+++ b/repository.h\n@@ -38,6 +38,11 @@ struct repository {\n \t/* The store in which the refs are held. */\n \tstruct ref_store *refs;\n \n+\t/*\n+\t * Contains path to often used file names.\n+\t */\n+\tstruct path_cache cached_paths;\n+\n \t/*\n \t * Path to the repository's graft file.\n \t * Cannot be NULL after initialization.\ndiff --git a/rerere.c b/rerere.c\nindex fcb99cc9542..a3af88939a2 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -201,7 +201,7 @@ static struct rerere_id *new_rerere_id(unsigned char *sha1)\n static void read_rr(struct string_list *rr)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n-\tFILE *in = fopen_or_warn(git_path_merge_rr(), \"r\");\n+\tFILE *in = fopen_or_warn(git_path_merge_rr(the_repository), \"r\");\n \n \tif (!in)\n \t\treturn;\n@@ -897,7 +897,8 @@ int setup_rerere(struct string_list *merge_rr, int flags)\n \tif (flags & RERERE_READONLY)\n \t\tfd = 0;\n \telse\n-\t\tfd = hold_lock_file_for_update(&write_lock, git_path_merge_rr(),\n+\t\tfd = hold_lock_file_for_update(&write_lock,\n+\t\t\t\t\t       git_path_merge_rr(the_repository),\n \t\t\t\t\t       LOCK_DIE_ON_ERROR);\n \tread_rr(merge_rr);\n \treturn fd;\n@@ -1247,6 +1248,6 @@ void rerere_clear(struct string_list *merge_rr)\n \t\t\trmdir(rerere_path(id, NULL));\n \t\t}\n \t}\n-\tunlink_or_warn(git_path_merge_rr());\n+\tunlink_or_warn(git_path_merge_rr(the_repository));\n \trollback_lock_file(&write_lock);\n }\ndiff --git a/sequencer.c b/sequencer.c\nindex cf6456ab75d..eb0bef45e2a 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -322,7 +322,7 @@ static void print_advice(int show_hint, struct replay_opts *opts)\n \t\t * (typically rebase --interactive) wants to take care\n \t\t * of the commit itself so remove CHERRY_PICK_HEAD\n \t\t */\n-\t\tunlink(git_path_cherry_pick_head());\n+\t\tunlink(git_path_cherry_pick_head(the_repository));\n \t\treturn;\n \t}\n \n@@ -1191,8 +1191,8 @@ static int do_commit(const char *msg_file, const char *author,\n \t\t\t\t    &oid);\n \t\tstrbuf_release(&sb);\n \t\tif (!res) {\n-\t\t\tunlink(git_path_cherry_pick_head());\n-\t\t\tunlink(git_path_merge_msg());\n+\t\t\tunlink(git_path_cherry_pick_head(the_repository));\n+\t\t\tunlink(git_path_merge_msg(the_repository));\n \t\t\tif (!is_rebase_i(opts))\n \t\t\t\tprint_commit_summary(NULL, &oid,\n \t\t\t\t\t\tSUMMARY_SHOW_AUTHOR_DATE);\n@@ -1459,7 +1459,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\tstruct replay_opts *opts, int final_fixup)\n {\n \tunsigned int flags = opts->edit ? EDIT_MSG : 0;\n-\tconst char *msg_file = opts->edit ? NULL : git_path_merge_msg();\n+\tconst char *msg_file = opts->edit ? NULL : git_path_merge_msg(the_repository);\n \tstruct object_id head;\n \tstruct commit *base, *next, *parent;\n \tconst char *base_label, *next_label;\n@@ -1594,12 +1594,12 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\t\tflags |= CLEANUP_MSG;\n \t\t\tmsg_file = rebase_path_fixup_msg();\n \t\t} else {\n-\t\t\tconst char *dest = git_path_squash_msg();\n+\t\t\tconst char *dest = git_path_squash_msg(the_repository);\n \t\t\tunlink(dest);\n \t\t\tif (copy_file(dest, rebase_path_squash_msg(), 0666))\n \t\t\t\treturn error(_(\"could not rename '%s' to '%s'\"),\n \t\t\t\t\t     rebase_path_squash_msg(), dest);\n-\t\t\tunlink(git_path_merge_msg());\n+\t\t\tunlink(git_path_merge_msg(the_repository));\n \t\t\tmsg_file = dest;\n \t\t\tflags |= EDIT_MSG;\n \t\t}\n@@ -1616,13 +1616,13 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\tif (res < 0)\n \t\t\treturn res;\n \t\tres |= write_message(msgbuf.buf, msgbuf.len,\n-\t\t\t\t     git_path_merge_msg(), 0);\n+\t\t\t\t     git_path_merge_msg(the_repository), 0);\n \t} else {\n \t\tstruct commit_list *common = NULL;\n \t\tstruct commit_list *remotes = NULL;\n \n \t\tres = write_message(msgbuf.buf, msgbuf.len,\n-\t\t\t\t    git_path_merge_msg(), 0);\n+\t\t\t\t    git_path_merge_msg(the_repository), 0);\n \n \t\tcommit_list_insert(base, &common);\n \t\tcommit_list_insert(next, &remotes);\n@@ -2168,8 +2168,8 @@ static int rollback_single_pick(void)\n {\n \tstruct object_id head_oid;\n \n-\tif (!file_exists(git_path_cherry_pick_head()) &&\n-\t    !file_exists(git_path_revert_head()))\n+\tif (!file_exists(git_path_cherry_pick_head(the_repository)) &&\n+\t    !file_exists(git_path_revert_head(the_repository)))\n \t\treturn error(_(\"no cherry-pick or revert in progress\"));\n \tif (read_ref_full(\"HEAD\", 0, &head_oid, NULL))\n \t\treturn error(_(\"cannot resolve HEAD\"));\n@@ -2397,10 +2397,11 @@ static int error_failed_squash(struct commit *commit,\n \t\treturn error(_(\"could not rename '%s' to '%s'\"),\n \t\t\trebase_path_squash_msg(), rebase_path_message());\n \tunlink(rebase_path_fixup_msg());\n-\tunlink(git_path_merge_msg());\n-\tif (copy_file(git_path_merge_msg(), rebase_path_message(), 0666))\n+\tunlink(git_path_merge_msg(the_repository));\n+\tif (copy_file(git_path_merge_msg(the_repository), rebase_path_message(), 0666))\n \t\treturn error(_(\"could not copy '%s' to '%s'\"),\n-\t\t\t     rebase_path_message(), git_path_merge_msg());\n+\t\t\t     rebase_path_message(),\n+\t\t\t     git_path_merge_msg(the_repository));\n \treturn error_with_patch(commit, subject, subject_len, opts, 1, 0);\n }\n \n@@ -2756,8 +2757,8 @@ static int continue_single_pick(void)\n {\n \tconst char *argv[] = { \"commit\", NULL };\n \n-\tif (!file_exists(git_path_cherry_pick_head()) &&\n-\t    !file_exists(git_path_revert_head()))\n+\tif (!file_exists(git_path_cherry_pick_head(the_repository)) &&\n+\t    !file_exists(git_path_revert_head(the_repository)))\n \t\treturn error(_(\"no cherry-pick or revert in progress\"));\n \treturn run_command_v_opt(argv, RUN_GIT_CMD);\n }\n@@ -2769,7 +2770,7 @@ static int commit_staged_changes(struct replay_opts *opts)\n \tif (has_unstaged_changes(1))\n \t\treturn error(_(\"cannot rebase: You have unstaged changes.\"));\n \tif (!has_uncommitted_changes(0)) {\n-\t\tconst char *cherry_pick_head = git_path_cherry_pick_head();\n+\t\tconst char *cherry_pick_head = git_path_cherry_pick_head(the_repository);\n \n \t\tif (file_exists(cherry_pick_head) && unlink(cherry_pick_head))\n \t\t\treturn error(_(\"could not remove CHERRY_PICK_HEAD\"));\n@@ -2823,8 +2824,8 @@ int sequencer_continue(struct replay_opts *opts)\n \n \tif (!is_rebase_i(opts)) {\n \t\t/* Verify that the conflict has been resolved */\n-\t\tif (file_exists(git_path_cherry_pick_head()) ||\n-\t\t    file_exists(git_path_revert_head())) {\n+\t\tif (file_exists(git_path_cherry_pick_head(the_repository)) ||\n+\t\t    file_exists(git_path_revert_head(the_repository))) {\n \t\t\tres = continue_single_pick();\n \t\t\tif (res)\n \t\t\t\tgoto release_todo_list;\ndiff --git a/shallow.c b/shallow.c\nindex e903651202b..a0e338459f9 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -52,7 +52,7 @@ int is_repository_shallow_the_repository(void)\n \t\treturn is_shallow;\n \n \tif (!path)\n-\t\tpath = git_path_shallow();\n+\t\tpath = git_path_shallow(the_repository);\n \t/*\n \t * fetch-pack sets '--shallow-file \"\"' as an indicator that no\n \t * shallow file should be used. We could just open it and it\n@@ -223,7 +223,7 @@ static void check_shallow_file_for_update_the_repository(void)\n \tif (is_shallow == -1)\n \t\tdie(\"BUG: shallow must be initialized by now\");\n \n-\tif (!stat_validity_check(&shallow_stat, git_path_shallow()))\n+\tif (!stat_validity_check(&shallow_stat, git_path_shallow(the_repository)))\n \t\tdie(\"shallow file has changed since we read it\");\n }\n \n@@ -318,7 +318,8 @@ void setup_alternate_shallow(struct lock_file *shallow_lock,\n \tstruct strbuf sb = STRBUF_INIT;\n \tint fd;\n \n-\tfd = hold_lock_file_for_update(shallow_lock, git_path_shallow(),\n+\tfd = hold_lock_file_for_update(shallow_lock,\n+\t\t\t\t       git_path_shallow(the_repository),\n \t\t\t\t       LOCK_DIE_ON_ERROR);\n \tcheck_shallow_file_for_update(the_repository);\n \tif (write_shallow_commits(&sb, 0, extra)) {\n@@ -365,7 +366,8 @@ void prune_shallow(int show_only)\n \t\tstrbuf_release(&sb);\n \t\treturn;\n \t}\n-\tfd = hold_lock_file_for_update(&shallow_lock, git_path_shallow(),\n+\tfd = hold_lock_file_for_update(&shallow_lock,\n+\t\t\t\t       git_path_shallow(the_repository),\n \t\t\t\t       LOCK_DIE_ON_ERROR);\n \tcheck_shallow_file_for_update(the_repository);\n \tif (write_shallow_commits_1(&sb, 0, NULL, SEEN_ONLY)) {\n@@ -374,7 +376,7 @@ void prune_shallow(int show_only)\n \t\t\t\t  get_lock_file_path(&shallow_lock));\n \t\tcommit_lock_file(&shallow_lock);\n \t} else {\n-\t\tunlink(git_path_shallow());\n+\t\tunlink(git_path_shallow(the_repository));\n \t\trollback_lock_file(&shallow_lock);\n \t}\n \tstrbuf_release(&sb);\ndiff --git a/wt-status.c b/wt-status.c\nindex 50815e5faff..e35cdfeb4be 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1309,7 +1309,7 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (use \\\"git rebase --abort\\\" to check out the original branch)\"));\n \t\t}\n-\t} else if (state->rebase_in_progress || !stat(git_path_merge_msg(), &st)) {\n+\t} else if (state->rebase_in_progress || !stat(git_path_merge_msg(the_repository), &st)) {\n \t\tprint_rebase_state(s, state, color);\n \t\tif (s->hints)\n \t\t\tstatus_printf_ln(s, color,\n@@ -1544,17 +1544,17 @@ void wt_status_get_state(struct wt_status_state *state,\n \tstruct stat st;\n \tstruct object_id oid;\n \n-\tif (!stat(git_path_merge_head(), &st)) {\n+\tif (!stat(git_path_merge_head(the_repository), &st)) {\n \t\tstate->merge_in_progress = 1;\n \t} else if (wt_status_check_rebase(NULL, state)) {\n \t\t;\t\t/* all set */\n-\t} else if (!stat(git_path_cherry_pick_head(), &st) &&\n+\t} else if (!stat(git_path_cherry_pick_head(the_repository), &st) &&\n \t\t\t!get_oid(\"CHERRY_PICK_HEAD\", &oid)) {\n \t\tstate->cherry_pick_in_progress = 1;\n \t\toidcpy(&state->cherry_pick_head_oid, &oid);\n \t}\n \twt_status_check_bisect(NULL, state);\n-\tif (!stat(git_path_revert_head(), &st) &&\n+\tif (!stat(git_path_revert_head(the_repository), &st) &&\n \t    !get_oid(\"REVERT_HEAD\", &oid)) {\n \t\tstate->revert_in_progress = 1;\n \t\toidcpy(&state->revert_head_oid, &oid);\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347953","messageId":"20180517225154.9200-12-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 11/19] shallow: add repository argument to is_repository_shallow","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:46Z","receivedAt":"2018-05-17T22:52:54Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Add a repository argument to allow callers of is_repository_shallow\nto be more specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/fetch.c        | 2 +-\n builtin/pack-objects.c | 4 ++--\n builtin/prune.c        | 2 +-\n builtin/rev-parse.c    | 3 ++-\n commit.c               | 2 +-\n commit.h               | 3 ++-\n fetch-pack.c           | 4 ++--\n send-pack.c            | 6 +++---\n shallow.c              | 8 ++++----\n upload-pack.c          | 2 +-\n 10 files changed, 19 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex c1f2df97965..55140671ef3 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -1445,7 +1445,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)\n \tif (unshallow) {\n \t\tif (depth)\n \t\t\tdie(_(\"--depth and --unshallow cannot be used together\"));\n-\t\telse if (!is_repository_shallow())\n+\t\telse if (!is_repository_shallow(the_repository))\n \t\t\tdie(_(\"--unshallow on a complete repository does not make sense\"));\n \t\telse\n \t\t\tdepth = xstrfmt(\"%d\", INFINITE_DEPTH);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 97a5963efb6..0f1eec2eecd 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2857,7 +2857,7 @@ static void get_object_list(int ac, const char **av)\n \tsetup_revisions(ac, av, &revs, NULL);\n \n \t/* make sure shallows are read */\n-\tis_repository_shallow();\n+\tis_repository_shallow(the_repository);\n \n \twhile (fgets(line, sizeof(line), stdin) != NULL) {\n \t\tint len = strlen(line);\n@@ -3142,7 +3142,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \t\tuse_bitmap_index = use_bitmap_index_default;\n \n \t/* \"hard\" reasons not to use bitmaps; these just won't work at all */\n-\tif (!use_internal_rev_list || (!pack_to_stdout && write_bitmap_index) || is_repository_shallow())\n+\tif (!use_internal_rev_list || (!pack_to_stdout && write_bitmap_index) || is_repository_shallow(the_repository))\n \t\tuse_bitmap_index = 0;\n \n \tif (pack_to_stdout || !rev_list_all)\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 8cc8659612f..70ec35aa058 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -160,7 +160,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)\n \tremove_temporary_files(s);\n \tfree(s);\n \n-\tif (is_repository_shallow())\n+\tif (is_repository_shallow(the_repository))\n \t\tprune_shallow(show_only);\n \n \treturn 0;\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex 36b20877828..a8a9b506ff6 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -879,7 +879,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--is-shallow-repository\")) {\n-\t\t\t\tprintf(\"%s\\n\", is_repository_shallow() ? \"true\"\n+\t\t\t\tprintf(\"%s\\n\",\n+\t\t\t\t\t\tis_repository_shallow(the_repository) ? \"true\"\n \t\t\t\t\t\t: \"false\");\n \t\t\t\tcontinue;\n \t\t\t}\ndiff --git a/commit.c b/commit.c\nindex c832133f055..684eeaa2ccd 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -208,7 +208,7 @@ static void prepare_commit_graft_the_repository(void)\n \tgraft_file = get_graft_file();\n \tread_graft_file(the_repository, graft_file);\n \t/* make sure shallows are read */\n-\tis_repository_shallow();\n+\tis_repository_shallow(the_repository);\n \tcommit_graft_prepared = 1;\n }\n \ndiff --git a/commit.h b/commit.h\nindex 59346de5512..c7f25d6490a 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -195,7 +195,8 @@ struct ref;\n extern int register_shallow_the_repository(const struct object_id *oid);\n extern int unregister_shallow(const struct object_id *oid);\n extern int for_each_commit_graft(each_commit_graft_fn, void *);\n-extern int is_repository_shallow(void);\n+#define is_repository_shallow(r) is_repository_shallow_##r()\n+extern int is_repository_shallow_the_repository(void);\n extern struct commit_list *get_shallow_commits(struct object_array *heads,\n \t\tint depth, int shallow_flag, int not_shallow_flag);\n extern struct commit_list *get_shallow_commits_by_rev_list(\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex e3e99e44962..90befd370fe 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -397,7 +397,7 @@ static int find_common(struct fetch_pack_args *args,\n \t\treturn 1;\n \t}\n \n-\tif (is_repository_shallow())\n+\tif (is_repository_shallow(the_repository))\n \t\twrite_shallow_commits(&req_buf, 1, NULL);\n \tif (args->depth > 0)\n \t\tpacket_buf_write(&req_buf, \"deepen %d\", args->depth);\n@@ -986,7 +986,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,\n \tsort_ref_list(&ref, ref_compare_name);\n \tQSORT(sought, nr_sought, cmp_ref_by_name);\n \n-\tif ((args->depth > 0 || is_repository_shallow()) && !server_supports(\"shallow\"))\n+\tif ((args->depth > 0 || is_repository_shallow(the_repository)) && !server_supports(\"shallow\"))\n \t\tdie(_(\"Server does not support shallow clients\"));\n \tif (args->depth > 0 || args->deepen_since || args->deepen_not)\n \t\targs->deepen = 1;\ndiff --git a/send-pack.c b/send-pack.c\nindex 71600028cdd..e920ca57df4 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -76,7 +76,7 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc\n \t\targv_array_push(&po.args, \"-q\");\n \tif (args->progress)\n \t\targv_array_push(&po.args, \"--progress\");\n-\tif (is_repository_shallow())\n+\tif (is_repository_shallow(the_repository))\n \t\targv_array_push(&po.args, \"--shallow\");\n \tpo.in = -1;\n \tpo.out = args->stateless_rpc ? -1 : fd;\n@@ -221,7 +221,7 @@ static int advertise_shallow_grafts_cb(const struct commit_graft *graft, void *c\n \n static void advertise_shallow_grafts_buf(struct strbuf *sb)\n {\n-\tif (!is_repository_shallow())\n+\tif (!is_repository_shallow(the_repository))\n \t\treturn;\n \tfor_each_commit_graft(advertise_shallow_grafts_cb, sb);\n }\n@@ -538,7 +538,7 @@ int send_pack(struct send_pack_args *args,\n \t}\n \n \tif (args->stateless_rpc) {\n-\t\tif (!args->dry_run && (cmds_sent || is_repository_shallow())) {\n+\t\tif (!args->dry_run && (cmds_sent || is_repository_shallow(the_repository))) {\n \t\t\tpacket_buf_flush(&req_buf);\n \t\t\tsend_sideband(out, -1, req_buf.buf, req_buf.len, LARGE_PACKET_MAX);\n \t\t}\ndiff --git a/shallow.c b/shallow.c\nindex 0028e4ea776..e903651202b 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -42,7 +42,7 @@ int register_shallow_the_repository(const struct object_id *oid)\n \treturn register_commit_graft(the_repository, graft, 0);\n }\n \n-int is_repository_shallow(void)\n+int is_repository_shallow_the_repository(void)\n {\n \tFILE *fp;\n \tchar buf[1024];\n@@ -108,7 +108,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,\n \t\tparse_commit_or_die(commit);\n \t\tcur_depth++;\n \t\tif ((depth != INFINITE_DEPTH && cur_depth >= depth) ||\n-\t\t    (is_repository_shallow() && !commit->parents &&\n+\t\t    (is_repository_shallow(the_repository) && !commit->parents &&\n \t\t     (graft = lookup_commit_graft(the_repository, &commit->object.oid)) != NULL &&\n \t\t     graft->nr_parent < 0)) {\n \t\t\tcommit_list_insert(commit, &result);\n@@ -167,7 +167,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,\n \t */\n \tclear_object_flags(both_flags);\n \n-\tis_repository_shallow(); /* make sure shallows are read */\n+\tis_repository_shallow(the_repository); /* make sure shallows are read */\n \n \tinit_revisions(&revs, NULL);\n \tsave_commit_buffer = 0;\n@@ -345,7 +345,7 @@ static int advertise_shallow_grafts_cb(const struct commit_graft *graft, void *c\n \n void advertise_shallow_grafts(int fd)\n {\n-\tif (!is_repository_shallow())\n+\tif (!is_repository_shallow(the_repository))\n \t\treturn;\n \tfor_each_commit_graft(advertise_shallow_grafts_cb, &fd);\n }\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 4e4ac0f0d95..51b9038111e 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -707,7 +707,7 @@ static void send_unshallow(const struct object_array *shallows)\n static void deepen(int depth, int deepen_relative,\n \t\t   struct object_array *shallows)\n {\n-\tif (depth == INFINITE_DEPTH && !is_repository_shallow()) {\n+\tif (depth == INFINITE_DEPTH && !is_repository_shallow(the_repository)) {\n \t\tint i;\n \n \t\tfor (i = 0; i < shallows->nr; i++) {\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347954","messageId":"20180517225154.9200-14-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 13/19] commit: convert register_commit_graft to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:48Z","receivedAt":"2018-05-17T22:52:55Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Brandon Williams <bmwill@google.com>\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 29 +++++++++++++++--------------\n commit.h |  3 +--\n 2 files changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 0ec3d22813a..8a2ab53fc67 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -111,30 +111,31 @@ static int commit_graft_pos(struct repository *r, const unsigned char *sha1)\n \t\t\tcommit_graft_sha1_access);\n }\n \n-int register_commit_graft_the_repository(struct commit_graft *graft, int ignore_dups)\n+int register_commit_graft(struct repository *r, struct commit_graft *graft,\n+\t\t\t  int ignore_dups)\n {\n-\tint pos = commit_graft_pos(the_repository, graft->oid.hash);\n+\tint pos = commit_graft_pos(r, graft->oid.hash);\n \n \tif (0 <= pos) {\n \t\tif (ignore_dups)\n \t\t\tfree(graft);\n \t\telse {\n-\t\t\tfree(the_repository->parsed_objects->grafts[pos]);\n-\t\t\tthe_repository->parsed_objects->grafts[pos] = graft;\n+\t\t\tfree(r->parsed_objects->grafts[pos]);\n+\t\t\tr->parsed_objects->grafts[pos] = graft;\n \t\t}\n \t\treturn 1;\n \t}\n \tpos = -pos - 1;\n-\tALLOC_GROW(the_repository->parsed_objects->grafts,\n-\t\t   the_repository->parsed_objects->grafts_nr + 1,\n-\t\t   the_repository->parsed_objects->grafts_alloc);\n-\tthe_repository->parsed_objects->grafts_nr++;\n-\tif (pos < the_repository->parsed_objects->grafts_nr)\n-\t\tmemmove(the_repository->parsed_objects->grafts + pos + 1,\n-\t\t\tthe_repository->parsed_objects->grafts + pos,\n-\t\t\t(the_repository->parsed_objects->grafts_nr - pos - 1) *\n-\t\t\tsizeof(*the_repository->parsed_objects->grafts));\n-\tthe_repository->parsed_objects->grafts[pos] = graft;\n+\tALLOC_GROW(r->parsed_objects->grafts,\n+\t\t   r->parsed_objects->grafts_nr + 1,\n+\t\t   r->parsed_objects->grafts_alloc);\n+\tr->parsed_objects->grafts_nr++;\n+\tif (pos < r->parsed_objects->grafts_nr)\n+\t\tmemmove(r->parsed_objects->grafts + pos + 1,\n+\t\t\tr->parsed_objects->grafts + pos,\n+\t\t\t(r->parsed_objects->grafts_nr - pos - 1) *\n+\t\t\tsizeof(*r->parsed_objects->grafts));\n+\tr->parsed_objects->grafts[pos] = graft;\n \treturn 0;\n }\n \ndiff --git a/commit.h b/commit.h\nindex c7f25d6490a..d04bbed81cf 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -174,8 +174,7 @@ struct commit_graft {\n typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *);\n \n struct commit_graft *read_graft_line(struct strbuf *line);\n-#define register_commit_graft(r, g, i) register_commit_graft_##r(g, i)\n-int register_commit_graft_the_repository(struct commit_graft *, int);\n+int register_commit_graft(struct repository *r, struct commit_graft *, int);\n #define lookup_commit_graft(r, o) lookup_commit_graft_##r(o)\n struct commit_graft *lookup_commit_graft_the_repository(const struct object_id *oid);\n \n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347955","messageId":"20180517225154.9200-19-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 18/19] commit: allow prepare_commit_graft to handle arbitrary repositories","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:53Z","receivedAt":"2018-05-17T22:52:58Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Move the global variable 'commit_graft_prepared' into the object\npool and convert the function prepare_commit_graft to work\nan arbitrary repositories.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n commit.c | 14 ++++++--------\n object.h |  2 ++\n 2 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 24028fd257a..eef1675d692 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -196,19 +196,17 @@ static int read_graft_file(struct repository *r, const char *graft_file)\n \treturn 0;\n }\n \n-#define prepare_commit_graft(r) prepare_commit_graft_##r()\n-static void prepare_commit_graft_the_repository(void)\n+static void prepare_commit_graft(struct repository *r)\n {\n-\tstatic int commit_graft_prepared;\n \tchar *graft_file;\n \n-\tif (commit_graft_prepared)\n+\tif (r->parsed_objects->commit_graft_prepared)\n \t\treturn;\n-\tgraft_file = get_graft_file(the_repository);\n-\tread_graft_file(the_repository, graft_file);\n+\tgraft_file = get_graft_file(r);\n+\tread_graft_file(r, graft_file);\n \t/* make sure shallows are read */\n-\tis_repository_shallow(the_repository);\n-\tcommit_graft_prepared = 1;\n+\tis_repository_shallow(r);\n+\tr->parsed_objects->commit_graft_prepared = 1;\n }\n \n struct commit_graft *lookup_commit_graft_the_repository(const struct object_id *oid)\ndiff --git a/object.h b/object.h\nindex a314331acaf..4af499ab03e 100644\n--- a/object.h\n+++ b/object.h\n@@ -20,6 +20,8 @@ struct parsed_object_pool {\n \tint is_shallow;\n \tstruct stat_validity *shallow_stat;\n \tchar *alternate_shallow_file;\n+\n+\tint commit_graft_prepared;\n };\n \n struct parsed_object_pool *parsed_object_pool_new(void);\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347956","messageId":"20180517225154.9200-2-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 01/19] object-store: move object access functions to object-store.h","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:36Z","receivedAt":"2018-05-17T22:53:04Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This should make these functions easier to find and cache.h less\noverwhelming to read.\n\nIn particular, this moves:\n- read_object_file\n- oid_object_info\n- write_object_file\n\nAs a result, most of the codebase needs to #include object-store.h.\nIn this patch the #include is only added to files that would fail to\ncompile otherwise.  It would be better to #include wherever\nidentifiers from the header are used.  That can happen later\nwhen we have better tooling for it.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n apply.c                  |   1 +\n archive-tar.c            |   1 +\n archive-zip.c            |   1 +\n archive.c                |   1 +\n blame.c                  |   1 +\n builtin/blame.c          |   1 +\n builtin/cat-file.c       |   1 +\n builtin/checkout.c       |   1 +\n builtin/clone.c          |   1 +\n builtin/commit-tree.c    |   1 +\n builtin/describe.c       |   1 +\n builtin/difftool.c       |   1 +\n builtin/fast-export.c    |   1 +\n builtin/fetch.c          |   1 +\n builtin/fmt-merge-msg.c  |   1 +\n builtin/hash-object.c    |   1 +\n builtin/log.c            |   1 +\n builtin/ls-tree.c        |   1 +\n builtin/merge-tree.c     |   1 +\n builtin/mktag.c          |   1 +\n builtin/mktree.c         |   1 +\n builtin/notes.c          |   1 +\n builtin/prune.c          |   1 +\n builtin/receive-pack.c   |   1 +\n builtin/reflog.c         |   1 +\n builtin/remote.c         |   1 +\n builtin/rev-list.c       |   1 +\n builtin/show-ref.c       |   1 +\n builtin/tag.c            |   1 +\n builtin/unpack-file.c    |   1 +\n builtin/unpack-objects.c |   1 +\n builtin/verify-commit.c  |   1 +\n bulk-checkin.c           |   1 +\n bundle.c                 |   1 +\n cache-tree.c             |   1 +\n cache.h                  | 117 ---------------------------------------\n combine-diff.c           |   1 +\n commit.c                 |   1 +\n config.c                 |   1 +\n convert.c                |   1 +\n diff.c                   |   1 +\n diffcore-rename.c        |   1 +\n dir.c                    |   1 +\n entry.c                  |   1 +\n fetch-pack.c             |   1 +\n fsck.c                   |   1 +\n grep.c                   |   1 +\n list-objects-filter.c    |   1 +\n list-objects.c           |   1 +\n log-tree.c               |   1 +\n mailmap.c                |   1 +\n match-trees.c            |   1 +\n merge-blobs.c            |   1 +\n merge-recursive.c        |   1 +\n notes-cache.c            |   1 +\n notes-merge.c            |   1 +\n notes.c                  |   1 +\n object-store.h           | 117 +++++++++++++++++++++++++++++++++++++++\n object.c                 |   1 +\n pack-bitmap-write.c      |   1 +\n packfile.h               |   5 ++\n read-cache.c             |   1 +\n ref-filter.c             |   1 +\n refs.c                   |   1 +\n remote-testsvn.c         |   1 +\n remote.c                 |   1 +\n rerere.c                 |   1 +\n revision.c               |   1 +\n send-pack.c              |   1 +\n sequencer.c              |   1 +\n shallow.c                |   1 +\n submodule-config.c       |   1 +\n tag.c                    |   1 +\n tree-walk.c              |   1 +\n tree.c                   |   1 +\n unpack-trees.c           |   1 +\n upload-pack.c            |   1 +\n walker.c                 |   1 +\n xdiff-interface.c        |   1 +\n 79 files changed, 198 insertions(+), 117 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 7e5792c996f..cbc45fa1b0e 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -9,6 +9,7 @@\n \n #include \"cache.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"delta.h\"\n #include \"diff.h\"\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f93409324f9..e38435eb4ef 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -5,6 +5,7 @@\n #include \"config.h\"\n #include \"tar.h\"\n #include \"archive.h\"\n+#include \"object-store.h\"\n #include \"streaming.h\"\n #include \"run-command.h\"\n \ndiff --git a/archive-zip.c b/archive-zip.c\nindex 74f3fe91034..abc556e5a75 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -6,6 +6,7 @@\n #include \"archive.h\"\n #include \"streaming.h\"\n #include \"utf8.h\"\n+#include \"object-store.h\"\n #include \"userdiff.h\"\n #include \"xdiff-interface.h\"\n \ndiff --git a/archive.c b/archive.c\nindex 93ab175b0b4..9da1e3664a6 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tree-walk.h\"\n #include \"attr.h\"\ndiff --git a/blame.c b/blame.c\nindex 3a11f1ce52b..f689bde31cd 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"cache-tree.h\"\n #include \"mergesort.h\"\n #include \"diff.h\"\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex bfdf7cc1325..0ffd1d443ea 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -22,6 +22,7 @@\n #include \"line-log.h\"\n #include \"dir.h\"\n #include \"progress.h\"\n+#include \"object-store.h\"\n #include \"blame.h\"\n \n static char blame_usage[] = N_(\"git blame [<options>] [<rev-opts>] [<rev>] [--] <file>\");\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex b8ecbea98e9..91e7764243e 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -13,6 +13,7 @@\n #include \"tree-walk.h\"\n #include \"sha1-array.h\"\n #include \"packfile.h\"\n+#include \"object-store.h\"\n \n struct batch_options {\n \tint enabled;\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex b49b5820718..105e07981ff 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -4,6 +4,7 @@\n #include \"lockfile.h\"\n #include \"parse-options.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 7df5932b855..29998c02ece 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -14,6 +14,7 @@\n #include \"parse-options.h\"\n #include \"fetch-pack.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"unpack-trees.h\"\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex ecf42191da1..9fbd3529fb1 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -5,6 +5,7 @@\n  */\n #include \"cache.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"builtin.h\"\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 66c497f7896..65b0edc473c 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -13,6 +13,7 @@\n #include \"hashmap.h\"\n #include \"argv-array.h\"\n #include \"run-command.h\"\n+#include \"object-store.h\"\n #include \"revision.h\"\n #include \"list-objects.h\"\n \ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex ee8dce019e1..df7e75f797b 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -20,6 +20,7 @@\n #include \"argv-array.h\"\n #include \"strbuf.h\"\n #include \"lockfile.h\"\n+#include \"object-store.h\"\n #include \"dir.h\"\n \n static char *diff_gui_tool;\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 373c794873e..f593e57b9d4 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -7,6 +7,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"object.h\"\n #include \"tag.h\"\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 73be393b2ea..c1f2df97965 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -5,6 +5,7 @@\n #include \"config.h\"\n #include \"repository.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"builtin.h\"\n #include \"string-list.h\"\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex bd680be6874..1b526adb3a9 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -2,6 +2,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex 526da5c1856..d5c018eabd5 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -6,6 +6,7 @@\n  */\n #include \"builtin.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"quote.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 71f68a3e4f5..9656578f58e 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -7,6 +7,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"color.h\"\n #include \"commit.h\"\n #include \"diff.h\"\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 409da4e8351..fe3b952cb30 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -5,6 +5,7 @@\n  */\n #include \"cache.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"tree.h\"\n #include \"commit.h\"\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 32736e0b101..1b702d44c9f 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -1,6 +1,7 @@\n #include \"builtin.h\"\n #include \"tree-walk.h\"\n #include \"xdiff-interface.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"exec_cmd.h\"\n #include \"merge-blobs.h\"\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 82a6e860775..6fb7dc8578d 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -1,6 +1,7 @@\n #include \"builtin.h\"\n #include \"tag.h\"\n #include \"replace-object.h\"\n+#include \"object-store.h\"\n \n /*\n  * A signature file has a very simple fixed format: four lines\ndiff --git a/builtin/mktree.c b/builtin/mktree.c\nindex bb76b469fd1..2dc4ad6ba8f 100644\n--- a/builtin/mktree.c\n+++ b/builtin/mktree.c\n@@ -7,6 +7,7 @@\n #include \"quote.h\"\n #include \"tree.h\"\n #include \"parse-options.h\"\n+#include \"object-store.h\"\n \n static struct treeent {\n \tunsigned mode;\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 921e08d5bf5..73b680ee13a 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -11,6 +11,7 @@\n #include \"config.h\"\n #include \"builtin.h\"\n #include \"notes.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"pretty.h\"\n #include \"refs.h\"\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex 518ffbea139..8cc8659612f 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -6,6 +6,7 @@\n #include \"reachable.h\"\n #include \"parse-options.h\"\n #include \"progress.h\"\n+#include \"object-store.h\"\n \n static const char * const prune_usage[] = {\n \tN_(\"git prune [-n] [-v] [--progress] [--expire <time>] [--] [<head>...]\"),\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex c4272fbc96d..36906fd5e98 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -25,6 +25,7 @@\n #include \"tmp-objdir.h\"\n #include \"oidset.h\"\n #include \"packfile.h\"\n+#include \"object-store.h\"\n #include \"protocol.h\"\n \n static const char * const receive_pack_usage[] = {\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex a89bd1dd252..bee4795a936 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -1,6 +1,7 @@\n #include \"builtin.h\"\n #include \"config.h\"\n #include \"lockfile.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"refs.h\"\n #include \"dir.h\"\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 805ffc05cdb..9487c019092 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -7,6 +7,7 @@\n #include \"strbuf.h\"\n #include \"run-command.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"argv-array.h\"\n \n static const char * const builtin_remote_usage[] = {\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex fadd3ec14cb..e9bd4e378ad 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -6,6 +6,7 @@\n #include \"list-objects.h\"\n #include \"list-objects-filter.h\"\n #include \"list-objects-filter-options.h\"\n+#include \"object-store.h\"\n #include \"pack.h\"\n #include \"pack-bitmap.h\"\n #include \"builtin.h\"\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex f2eb1a77240..2f13f1316fa 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -1,6 +1,7 @@\n #include \"builtin.h\"\n #include \"cache.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"object.h\"\n #include \"tag.h\"\n #include \"string-list.h\"\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 26d7729f57b..f872f14f65e 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -10,6 +10,7 @@\n #include \"config.h\"\n #include \"builtin.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"tag.h\"\n #include \"run-command.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex 300eb59657e..58652229f27 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -1,5 +1,6 @@\n #include \"builtin.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n \n static char *create_temp_file(struct object_id *oid)\n {\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex cfe9019f800..ded798b72ff 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -1,6 +1,7 @@\n #include \"builtin.h\"\n #include \"cache.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"object.h\"\n #include \"delta.h\"\n #include \"pack.h\"\ndiff --git a/builtin/verify-commit.c b/builtin/verify-commit.c\nindex dcdaada1110..f6922da16d6 100644\n--- a/builtin/verify-commit.c\n+++ b/builtin/verify-commit.c\n@@ -8,6 +8,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"builtin.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"run-command.h\"\n #include <signal.h>\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex de1f4040c78..918d58a7ebf 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -8,6 +8,7 @@\n #include \"pack.h\"\n #include \"strbuf.h\"\n #include \"packfile.h\"\n+#include \"object-store.h\"\n \n static struct bulk_checkin_state {\n \tunsigned plugged:1;\ndiff --git a/bundle.c b/bundle.c\nindex 902c9b54485..00ada05f46c 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"lockfile.h\"\n #include \"bundle.h\"\n+#include \"object-store.h\"\n #include \"object.h\"\n #include \"commit.h\"\n #include \"diff.h\"\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 6a555f4d431..1c338c41f3a 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -3,6 +3,7 @@\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"cache-tree.h\"\n+#include \"object-store.h\"\n \n #ifndef DEBUG\n #define DEBUG 0\ndiff --git a/cache.h b/cache.h\nindex c75559b7d38..ab716011b7e 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1183,32 +1183,6 @@ extern char *xdg_config_home(const char *filename);\n  */\n extern char *xdg_cache_home(const char *filename);\n \n-extern void *read_object_file_extended(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-}\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-\n-extern int hash_object_file(const void *buf, unsigned long len,\n-\t\t\t    const char *type, struct object_id *oid);\n-\n-extern int write_object_file(const void *buf, unsigned long len,\n-\t\t\t     const char *type, struct object_id *oid);\n-\n-extern int hash_object_file_literally(const void *buf, unsigned long len,\n-\t\t\t\t      const char *type, struct object_id *oid,\n-\t\t\t\t      unsigned flags);\n-\n-extern int pretend_object_file(void *, unsigned long, enum object_type,\n-\t\t\t       struct object_id *oid);\n-\n-extern int force_object_loose(const struct object_id *oid, time_t mtime);\n-\n extern int git_open_cloexec(const char *name, int flags);\n #define git_open(name) git_open_cloexec(name, O_RDONLY)\n extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);\n@@ -1218,43 +1192,6 @@ extern int check_object_signature(const struct object_id *oid, void *buf, unsign\n \n extern int finalize_object_file(const char *tmpfile, const char *filename);\n \n-/*\n- * Open the loose object at path, check its hash, and return the contents,\n- * type, and size. If the object is a blob, then \"contents\" may return NULL,\n- * to allow streaming of large blobs.\n- *\n- * Returns 0 on success, negative on error (details may be written to stderr).\n- */\n-int read_loose_object(const char *path,\n-\t\t      const struct object_id *expected_oid,\n-\t\t      enum object_type *type,\n-\t\t      unsigned long *size,\n-\t\t      void **contents);\n-\n-/*\n- * Convenience for sha1_object_info_extended() with a NULL struct\n- * object_info. OBJECT_INFO_SKIP_CACHED is automatically set; pass\n- * nonzero flags to also set other flags.\n- */\n-extern int has_sha1_file_with_flags(const unsigned char *sha1, int flags);\n-static inline int has_sha1_file(const unsigned char *sha1)\n-{\n-\treturn has_sha1_file_with_flags(sha1, 0);\n-}\n-\n-/* Same as the above, except for struct object_id. */\n-extern int has_object_file(const struct object_id *oid);\n-extern int has_object_file_with_flags(const struct object_id *oid, int flags);\n-\n-/*\n- * Return true iff an alternate object database has a loose object\n- * with the specified name.  This function does not respect replace\n- * references.\n- */\n-extern int has_loose_object_nonlocal(const unsigned char *sha1);\n-\n-extern void assert_oid_type(const struct object_id *oid, enum object_type expect);\n-\n /* Helper to check and \"touch\" a file */\n extern int check_and_freshen_file(const char *fn, int freshen);\n \n@@ -1624,60 +1561,6 @@ int for_each_loose_file_in_objdir_buf(struct strbuf *path,\n #define FOR_EACH_OBJECT_LOCAL_ONLY 0x1\n extern int for_each_loose_object(each_loose_object_fn, void *, unsigned flags);\n \n-struct object_info {\n-\t/* Request */\n-\tenum object_type *typep;\n-\tunsigned long *sizep;\n-\toff_t *disk_sizep;\n-\tunsigned char *delta_base_sha1;\n-\tstruct strbuf *type_name;\n-\tvoid **contentp;\n-\n-\t/* Response */\n-\tenum {\n-\t\tOI_CACHED,\n-\t\tOI_LOOSE,\n-\t\tOI_PACKED,\n-\t\tOI_DBCACHED\n-\t} whence;\n-\tunion {\n-\t\t/*\n-\t\t * struct {\n-\t\t * \t... Nothing to expose in this case\n-\t\t * } cached;\n-\t\t * struct {\n-\t\t * \t... Nothing to expose in this case\n-\t\t * } loose;\n-\t\t */\n-\t\tstruct {\n-\t\t\tstruct packed_git *pack;\n-\t\t\toff_t offset;\n-\t\t\tunsigned int is_delta;\n-\t\t} packed;\n-\t} u;\n-};\n-\n-/*\n- * Initializer for a \"struct object_info\" that wants no items. You may\n- * also memset() the memory to all-zeroes.\n- */\n-#define OBJECT_INFO_INIT {NULL}\n-\n-/* Invoke lookup_replace_object() on the given hash */\n-#define OBJECT_INFO_LOOKUP_REPLACE 1\n-/* Allow reading from a loose object file of unknown/bogus type */\n-#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2\n-/* Do not check cached storage */\n-#define OBJECT_INFO_SKIP_CACHED 4\n-/* Do not retry packed storage after checking packed and loose storage */\n-#define OBJECT_INFO_QUICK 8\n-/* Do not check loose object */\n-#define OBJECT_INFO_IGNORE_LOOSE 16\n-\n-int oid_object_info_extended(struct repository *r,\n-\t\t\t     const struct object_id *,\n-\t\t\t     struct object_info *, unsigned flags);\n-\n /*\n  * Set this to 0 to prevent sha1_object_info_extended() from fetching missing\n  * blobs. This has a difference only if extensions.partialClone is set.\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 2ef495963fc..de7695e7282 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"blob.h\"\n #include \"diff.h\"\ndiff --git a/commit.c b/commit.c\nindex 5eb4d2f08f8..b053f07f305 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"tag.h\"\n #include \"commit.h\"\n+#include \"object-store.h\"\n #include \"pkt-line.h\"\n #include \"utf8.h\"\n #include \"diff.h\"\ndiff --git a/config.c b/config.c\nindex c698988f5e1..041db3ce7d4 100644\n--- a/config.c\n+++ b/config.c\n@@ -14,6 +14,7 @@\n #include \"quote.h\"\n #include \"hashmap.h\"\n #include \"string-list.h\"\n+#include \"object-store.h\"\n #include \"utf8.h\"\n #include \"dir.h\"\n \ndiff --git a/convert.c b/convert.c\nindex c480097a2a0..7f5afd6dd66 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -1,6 +1,7 @@\n #define NO_THE_INDEX_COMPATIBILITY_MACROS\n #include \"cache.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"attr.h\"\n #include \"run-command.h\"\n #include \"quote.h\"\ndiff --git a/diff.c b/diff.c\nindex 4753170fe12..18d478c5190 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -13,6 +13,7 @@\n #include \"attr.h\"\n #include \"run-command.h\"\n #include \"utf8.h\"\n+#include \"object-store.h\"\n #include \"userdiff.h\"\n #include \"submodule-config.h\"\n #include \"submodule.h\"\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex 0b7e4989a87..d775183c2fd 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -4,6 +4,7 @@\n #include \"cache.h\"\n #include \"diff.h\"\n #include \"diffcore.h\"\n+#include \"object-store.h\"\n #include \"hashmap.h\"\n #include \"progress.h\"\n \ndiff --git a/dir.c b/dir.c\nindex 63a917be45d..9e7c90cf50b 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -11,6 +11,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"dir.h\"\n+#include \"object-store.h\"\n #include \"attr.h\"\n #include \"refs.h\"\n #include \"wildmatch.h\"\ndiff --git a/entry.c b/entry.c\nindex 2101201a111..b5d1d3cf231 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"blob.h\"\n+#include \"object-store.h\"\n #include \"dir.h\"\n #include \"streaming.h\"\n #include \"submodule.h\"\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex adc1b68dd3a..a1535b37b9b 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -19,6 +19,7 @@\n #include \"sha1-array.h\"\n #include \"oidset.h\"\n #include \"packfile.h\"\n+#include \"object-store.h\"\n \n static int transfer_unpack_limit = -1;\n static int fetch_unpack_limit = -1;\ndiff --git a/fsck.c b/fsck.c\nindex 9218c2a643b..59b0c7d640e 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"object-store.h\"\n #include \"object.h\"\n #include \"blob.h\"\n #include \"tree.h\"\ndiff --git a/grep.c b/grep.c\nindex 65b90c10a38..438987220ea 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"grep.h\"\n+#include \"object-store.h\"\n #include \"userdiff.h\"\n #include \"xdiff-interface.h\"\n #include \"diff.h\"\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex ea94fe8af28..44b3a49bdb3 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -11,6 +11,7 @@\n #include \"list-objects-filter.h\"\n #include \"list-objects-filter-options.h\"\n #include \"oidset.h\"\n+#include \"object-store.h\"\n \n /* Remember to update object flag allocation in object.h */\n /*\ndiff --git a/list-objects.c b/list-objects.c\nindex 168bef688a8..7ae0eb8ebc7 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -10,6 +10,7 @@\n #include \"list-objects-filter.h\"\n #include \"list-objects-filter-options.h\"\n #include \"packfile.h\"\n+#include \"object-store.h\"\n \n static void process_blob(struct rev_info *revs,\n \t\t\t struct blob *blob,\ndiff --git a/log-tree.c b/log-tree.c\nindex d1c0bedf244..5660ee7c785 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"diff.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"graph.h\"\ndiff --git a/mailmap.c b/mailmap.c\nindex 13f0d2884e2..962fd86d6d7 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"string-list.h\"\n #include \"mailmap.h\"\n+#include \"object-store.h\"\n \n #define DEBUG_MAILMAP 0\n #if DEBUG_MAILMAP\ndiff --git a/match-trees.c b/match-trees.c\nindex 72cc2baa3f9..4cdeff53e1e 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\n+#include \"object-store.h\"\n \n static int score_missing(unsigned mode, const char *path)\n {\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex fa49c17287f..fabb8c19ce9 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -4,6 +4,7 @@\n #include \"ll-merge.h\"\n #include \"blob.h\"\n #include \"merge-blobs.h\"\n+#include \"object-store.h\"\n \n static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n {\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex cbded673c28..455f59d21ac 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -8,6 +8,7 @@\n #include \"advice.h\"\n #include \"lockfile.h\"\n #include \"cache-tree.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"blob.h\"\n #include \"builtin.h\"\ndiff --git a/notes-cache.c b/notes-cache.c\nindex e61988e503b..d5770031776 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"notes-cache.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"refs.h\"\n \ndiff --git a/notes-merge.c b/notes-merge.c\nindex 8e0726a9418..fd96c5ab3d6 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"commit.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"diff.h\"\n #include \"diffcore.h\"\n #include \"xdiff-interface.h\"\ndiff --git a/notes.c b/notes.c\nindex a386d450c4c..32d3dbcc1e7 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"config.h\"\n #include \"notes.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"tree.h\"\n #include \"utf8.h\"\ndiff --git a/object-store.h b/object-store.h\nindex 1ff862c7f93..695266891bf 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -137,4 +137,121 @@ 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+\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+}\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+\n+extern int hash_object_file(const void *buf, unsigned long len,\n+\t\t\t    const char *type, struct object_id *oid);\n+\n+extern int write_object_file(const void *buf, unsigned long len,\n+\t\t\t     const char *type, struct object_id *oid);\n+\n+extern int hash_object_file_literally(const void *buf, unsigned long len,\n+\t\t\t\t      const char *type, struct object_id *oid,\n+\t\t\t\t      unsigned flags);\n+\n+extern int pretend_object_file(void *, unsigned long, enum object_type,\n+\t\t\t       struct object_id *oid);\n+\n+extern int force_object_loose(const struct object_id *oid, time_t mtime);\n+\n+/*\n+ * Open the loose object at path, check its hash, and return the contents,\n+ * type, and size. If the object is a blob, then \"contents\" may return NULL,\n+ * to allow streaming of large blobs.\n+ *\n+ * Returns 0 on success, negative on error (details may be written to stderr).\n+ */\n+int read_loose_object(const char *path,\n+\t\t      const struct object_id *expected_oid,\n+\t\t      enum object_type *type,\n+\t\t      unsigned long *size,\n+\t\t      void **contents);\n+\n+/*\n+ * Convenience for sha1_object_info_extended() with a NULL struct\n+ * object_info. OBJECT_INFO_SKIP_CACHED is automatically set; pass\n+ * nonzero flags to also set other flags.\n+ */\n+extern int has_sha1_file_with_flags(const unsigned char *sha1, int flags);\n+static inline int has_sha1_file(const unsigned char *sha1)\n+{\n+\treturn has_sha1_file_with_flags(sha1, 0);\n+}\n+\n+/* Same as the above, except for struct object_id. */\n+extern int has_object_file(const struct object_id *oid);\n+extern int has_object_file_with_flags(const struct object_id *oid, int flags);\n+\n+/*\n+ * Return true iff an alternate object database has a loose object\n+ * with the specified name.  This function does not respect replace\n+ * references.\n+ */\n+extern int has_loose_object_nonlocal(const unsigned char *sha1);\n+\n+extern void assert_oid_type(const struct object_id *oid, enum object_type expect);\n+\n+struct object_info {\n+\t/* Request */\n+\tenum object_type *typep;\n+\tunsigned long *sizep;\n+\toff_t *disk_sizep;\n+\tunsigned char *delta_base_sha1;\n+\tstruct strbuf *type_name;\n+\tvoid **contentp;\n+\n+\t/* Response */\n+\tenum {\n+\t\tOI_CACHED,\n+\t\tOI_LOOSE,\n+\t\tOI_PACKED,\n+\t\tOI_DBCACHED\n+\t} whence;\n+\tunion {\n+\t\t/*\n+\t\t * struct {\n+\t\t * \t... Nothing to expose in this case\n+\t\t * } cached;\n+\t\t * struct {\n+\t\t * \t... Nothing to expose in this case\n+\t\t * } loose;\n+\t\t */\n+\t\tstruct {\n+\t\t\tstruct packed_git *pack;\n+\t\t\toff_t offset;\n+\t\t\tunsigned int is_delta;\n+\t\t} packed;\n+\t} u;\n+};\n+\n+/*\n+ * Initializer for a \"struct object_info\" that wants no items. You may\n+ * also memset() the memory to all-zeroes.\n+ */\n+#define OBJECT_INFO_INIT {NULL}\n+\n+/* Invoke lookup_replace_object() on the given hash */\n+#define OBJECT_INFO_LOOKUP_REPLACE 1\n+/* Allow reading from a loose object file of unknown/bogus type */\n+#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2\n+/* Do not check cached storage */\n+#define OBJECT_INFO_SKIP_CACHED 4\n+/* Do not retry packed storage after checking packed and loose storage */\n+#define OBJECT_INFO_QUICK 8\n+/* Do not check loose object */\n+#define OBJECT_INFO_IGNORE_LOOSE 16\n+\n+int oid_object_info_extended(struct repository *r,\n+\t\t\t     const struct object_id *,\n+\t\t\t     struct object_info *, unsigned flags);\n+\n #endif /* OBJECT_STORE_H */\ndiff --git a/object.c b/object.c\nindex 8e29f63bf23..0116ed6529a 100644\n--- a/object.c\n+++ b/object.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"object.h\"\n #include \"replace-object.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"tree.h\"\n #include \"commit.h\"\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex cd1903e717a..f7fac9d0f24 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"diff.h\"\ndiff --git a/packfile.h b/packfile.h\nindex fdfddb89b53..1abbc2c07c8 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -3,6 +3,11 @@\n \n #include \"oidset.h\"\n \n+/* in object-store.h */\n+struct packed_git;\n+struct object_info;\n+enum object_type;\n+\n /*\n  * Generate the filename to be used for a pack file with checksum \"sha1\" and\n  * extension \"ext\". The result is written into the strbuf \"buf\", overwriting\ndiff --git a/read-cache.c b/read-cache.c\nindex 10f1c6bb8a3..7f10d9ffff9 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -11,6 +11,7 @@\n #include \"cache-tree.h\"\n #include \"refs.h\"\n #include \"dir.h\"\n+#include \"object-store.h\"\n #include \"tree.h\"\n #include \"commit.h\"\n #include \"blob.h\"\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 9a333e21b51..e2ae1f47fee 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -3,6 +3,7 @@\n #include \"parse-options.h\"\n #include \"refs.h\"\n #include \"wildmatch.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"remote.h\"\n #include \"color.h\"\ndiff --git a/refs.c b/refs.c\nindex 27c88ba7689..2361ba9c6ee 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -9,6 +9,7 @@\n #include \"iterator.h\"\n #include \"refs.h\"\n #include \"refs/refs-internal.h\"\n+#include \"object-store.h\"\n #include \"object.h\"\n #include \"tag.h\"\n #include \"submodule.h\"\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex c4bb9a8ba92..515b922b503 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"refs.h\"\n #include \"remote.h\"\n+#include \"object-store.h\"\n #include \"strbuf.h\"\n #include \"url.h\"\n #include \"exec_cmd.h\"\ndiff --git a/remote.c b/remote.c\nindex 481bf933f39..db438cfbc56 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -2,6 +2,7 @@\n #include \"config.h\"\n #include \"remote.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n #include \"revision.h\"\ndiff --git a/rerere.c b/rerere.c\nindex 18cae2d11c9..fcb99cc9542 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -9,6 +9,7 @@\n #include \"ll-merge.h\"\n #include \"attr.h\"\n #include \"pathspec.h\"\n+#include \"object-store.h\"\n #include \"sha1-lookup.h\"\n \n #define RESOLVED 0\ndiff --git a/revision.c b/revision.c\nindex 1cff11833e7..260b9c276c7 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"object-store.h\"\n #include \"tag.h\"\n #include \"blob.h\"\n #include \"tree.h\"\ndiff --git a/send-pack.c b/send-pack.c\nindex 19025a7aca8..71600028cdd 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -2,6 +2,7 @@\n #include \"config.h\"\n #include \"commit.h\"\n #include \"refs.h\"\n+#include \"object-store.h\"\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n #include \"run-command.h\"\ndiff --git a/sequencer.c b/sequencer.c\nindex 44f0518b9c4..cf6456ab75d 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2,6 +2,7 @@\n #include \"config.h\"\n #include \"lockfile.h\"\n #include \"dir.h\"\n+#include \"object-store.h\"\n #include \"object.h\"\n #include \"commit.h\"\n #include \"sequencer.h\"\ndiff --git a/shallow.c b/shallow.c\nindex df4d44ea7a3..c2f81a5a5a8 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"tempfile.h\"\n #include \"lockfile.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"pkt-line.h\"\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 3f2075764fe..a1e57c33339 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -4,6 +4,7 @@\n #include \"submodule-config.h\"\n #include \"submodule.h\"\n #include \"strbuf.h\"\n+#include \"object-store.h\"\n #include \"parse-options.h\"\n \n /*\ndiff --git a/tag.c b/tag.c\nindex 7c12426b4ea..3be7206e920 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"tag.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"blob.h\"\ndiff --git a/tree-walk.c b/tree-walk.c\nindex e11b3063afa..cd428a1ee53 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -2,6 +2,7 @@\n #include \"tree-walk.h\"\n #include \"unpack-trees.h\"\n #include \"dir.h\"\n+#include \"object-store.h\"\n #include \"tree.h\"\n #include \"pathspec.h\"\n \ndiff --git a/tree.c b/tree.c\nindex 8f8ef3189af..dc20a2693fd 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -2,6 +2,7 @@\n #include \"cache.h\"\n #include \"cache-tree.h\"\n #include \"tree.h\"\n+#include \"object-store.h\"\n #include \"blob.h\"\n #include \"commit.h\"\n #include \"tag.h\"\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex e73745051e5..e3f95cc6f95 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -15,6 +15,7 @@\n #include \"submodule.h\"\n #include \"submodule-config.h\"\n #include \"fsmonitor.h\"\n+#include \"object-store.h\"\n #include \"fetch-object.h\"\n \n /*\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 4a82602be5d..a11c6d192ce 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -3,6 +3,7 @@\n #include \"refs.h\"\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n+#include \"object-store.h\"\n #include \"tag.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/walker.c b/walker.c\nindex dffb9c8e37c..3fb5fb2a0be 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"walker.h\"\n+#include \"object-store.h\"\n #include \"commit.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 9315bc0ede1..ec6e574e4aa 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"config.h\"\n+#include \"object-store.h\"\n #include \"xdiff-interface.h\"\n #include \"xdiff/xtypes.h\"\n #include \"xdiff/xdiffi.h\"\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347957","messageId":"20180517225154.9200-7-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 06/19] commit: add repository argument to prepare_commit_graft","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:41Z","receivedAt":"2018-05-17T22:53:07Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nAdd a repository argument to allow the caller of prepare_commit_graft\nto be more specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n commit.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex b5c0aec24a0..a0400b93a1e 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -197,7 +197,8 @@ static int read_graft_file_the_repository(const char *graft_file)\n \treturn 0;\n }\n \n-static void prepare_commit_graft(void)\n+#define prepare_commit_graft(r) prepare_commit_graft_##r()\n+static void prepare_commit_graft_the_repository(void)\n {\n \tstatic int commit_graft_prepared;\n \tchar *graft_file;\n@@ -214,7 +215,7 @@ static void prepare_commit_graft(void)\n struct commit_graft *lookup_commit_graft(const struct object_id *oid)\n {\n \tint pos;\n-\tprepare_commit_graft();\n+\tprepare_commit_graft(the_repository);\n \tpos = commit_graft_pos(the_repository, oid->hash);\n \tif (pos < 0)\n \t\treturn NULL;\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347958","messageId":"20180517225154.9200-6-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 05/19] commit: add repository argument to read_graft_file","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:40Z","receivedAt":"2018-05-17T22:53:09Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nAdd a repository argument to allow the caller of read_graft_file to be\nmore specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n commit.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 4e8d3488425..b5c0aec24a0 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -177,7 +177,8 @@ struct commit_graft *read_graft_line(struct strbuf *line)\n \treturn NULL;\n }\n \n-static int read_graft_file(const char *graft_file)\n+#define read_graft_file(r, f) read_graft_file_##r(f)\n+static int read_graft_file_the_repository(const char *graft_file)\n {\n \tFILE *fp = fopen_or_warn(graft_file, \"r\");\n \tstruct strbuf buf = STRBUF_INIT;\n@@ -204,7 +205,7 @@ static void prepare_commit_graft(void)\n \tif (commit_graft_prepared)\n \t\treturn;\n \tgraft_file = get_graft_file();\n-\tread_graft_file(graft_file);\n+\tread_graft_file(the_repository, graft_file);\n \t/* make sure shallows are read */\n \tis_repository_shallow();\n \tcommit_graft_prepared = 1;\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"},{"id":"347959","messageId":"20180517225154.9200-4-sbeller@google.com","threadId":"48501","inReplyTo":"20180517225154.9200-1-sbeller@google.com","subject":"[PATCH 03/19] commit: add repository argument to commit_graft_pos","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-17T22:51:38Z","receivedAt":"2018-05-17T22:53:13Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nAdd a repository argument to allow callers of commit_graft_pos to be\nmore specific about which repository to handle. This is a small\nmechanical change; it doesn't change the implementation to handle\nrepositories other than the_repository yet.\n\nAs with the previous commits, use a macro to catch callers passing a\nrepository other than the_repository at compile time.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n commit.c | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex a0c9eb05c82..2cd5b8a0b96 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -104,7 +104,8 @@ static const unsigned char *commit_graft_sha1_access(size_t index, void *table)\n \treturn commit_graft_table[index]->oid.hash;\n }\n \n-static int commit_graft_pos(const unsigned char *sha1)\n+#define commit_graft_pos(r, s) commit_graft_pos_##r(s)\n+static int commit_graft_pos_the_repository(const unsigned char *sha1)\n {\n \treturn sha1_pos(sha1, the_repository->parsed_objects->grafts,\n \t\t\tthe_repository->parsed_objects->grafts_nr,\n@@ -113,7 +114,7 @@ static int commit_graft_pos(const unsigned char *sha1)\n \n int register_commit_graft(struct commit_graft *graft, int ignore_dups)\n {\n-\tint pos = commit_graft_pos(graft->oid.hash);\n+\tint pos = commit_graft_pos(the_repository, graft->oid.hash);\n \n \tif (0 <= pos) {\n \t\tif (ignore_dups)\n@@ -213,7 +214,7 @@ struct commit_graft *lookup_commit_graft(const struct object_id *oid)\n {\n \tint pos;\n \tprepare_commit_graft();\n-\tpos = commit_graft_pos(oid->hash);\n+\tpos = commit_graft_pos(the_repository, oid->hash);\n \tif (pos < 0)\n \t\treturn NULL;\n \treturn the_repository->parsed_objects->grafts[pos];\n@@ -229,7 +230,7 @@ int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data)\n \n int unregister_shallow(const struct object_id *oid)\n {\n-\tint pos = commit_graft_pos(oid->hash);\n+\tint pos = commit_graft_pos(the_repository, oid->hash);\n \tif (pos < 0)\n \t\treturn -1;\n \tif (pos + 1 < the_repository->parsed_objects->grafts_nr)\n-- \n2.17.0.582.gccdcbd54c44.dirty\n\n"}]}