cache: convert get_graft_file to handle arbitrary repositories

This conversion was done without the #define trick used in the earlier series refactoring to have better repository access, because this function is easy to review, as all lines are converted and it has only one caller. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed May 17, 2018 at 15:51 UTC 0437a2e365f3b9156097d029ca6f91cbb8bffd5e
3 files changed +5 -5
cache.h
+1 -1
@@ -476,7 +476,7 @@ extern const char *get_git_dir(void);
476 extern const char *get_git_common_dir(void);
477 extern char *get_object_directory(void);
478 extern char *get_index_file(void);
479 -extern char *get_graft_file(void);
479 +extern char *get_graft_file(struct repository *r);
480 extern int set_git_dir(const char *path);
481 extern int get_common_dir_noenv(struct strbuf *sb, const char *gitdir);
482 extern int get_common_dir(struct strbuf *sb, const char *gitdir);
commit.c
+1 -1
@@ -204,7 +204,7 @@ static void prepare_commit_graft_the_repository(void)
204
205 if (commit_graft_prepared)
206 return;
207 - graft_file = get_graft_file();
207 + graft_file = get_graft_file(the_repository);
208 read_graft_file(the_repository, graft_file);
209 /* make sure shallows are read */
210 is_repository_shallow(the_repository);
environment.c
+3 -3
@@ -316,11 +316,11 @@ char *get_index_file(void)
316 return the_repository->index_file;
317 }
318
319 -char *get_graft_file(void)
319 +char *get_graft_file(struct repository *r)
320 {
321 - if (!the_repository->graft_file)
321 + if (!r->graft_file)
322 BUG("git environment hasn't been setup");
323 - return the_repository->graft_file;
323 + return r->graft_file;
324 }
325
326 int set_git_dir(const char *path)