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>
This commit is contained in:
Stefan Beller 2018-05-17 15:51:50 -07:00 committed by Junio C Hamano
parent d0e5dd0ed4
commit 0437a2e365
3 changed files with 5 additions and 5 deletions

View File

@ -476,7 +476,7 @@ extern const char *get_git_dir(void);
extern const char *get_git_common_dir(void); extern const char *get_git_common_dir(void);
extern char *get_object_directory(void); extern char *get_object_directory(void);
extern char *get_index_file(void); extern char *get_index_file(void);
extern char *get_graft_file(void); extern char *get_graft_file(struct repository *r);
extern int set_git_dir(const char *path); extern int set_git_dir(const char *path);
extern int get_common_dir_noenv(struct strbuf *sb, const char *gitdir); extern int get_common_dir_noenv(struct strbuf *sb, const char *gitdir);
extern int get_common_dir(struct strbuf *sb, const char *gitdir); extern int get_common_dir(struct strbuf *sb, const char *gitdir);

View File

@ -204,7 +204,7 @@ static void prepare_commit_graft_the_repository(void)
if (commit_graft_prepared) if (commit_graft_prepared)
return; return;
graft_file = get_graft_file(); graft_file = get_graft_file(the_repository);
read_graft_file(the_repository, graft_file); read_graft_file(the_repository, graft_file);
/* make sure shallows are read */ /* make sure shallows are read */
is_repository_shallow(the_repository); is_repository_shallow(the_repository);

View File

@ -316,11 +316,11 @@ char *get_index_file(void)
return the_repository->index_file; return the_repository->index_file;
} }
char *get_graft_file(void) char *get_graft_file(struct repository *r)
{ {
if (!the_repository->graft_file) if (!r->graft_file)
BUG("git environment hasn't been setup"); BUG("git environment hasn't been setup");
return the_repository->graft_file; return r->graft_file;
} }
int set_git_dir(const char *path) int set_git_dir(const char *path)