Skip to content

Commit 0437a2e

Browse files
stefanbellergitster
authored andcommitted
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>
1 parent d0e5dd0 commit 0437a2e

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ extern const char *get_git_dir(void);
476476
extern const char *get_git_common_dir(void);
477477
extern char *get_object_directory(void);
478478
extern char *get_index_file(void);
479-
extern char *get_graft_file(void);
479+
extern char *get_graft_file(struct repository *r);
480480
extern int set_git_dir(const char *path);
481481
extern int get_common_dir_noenv(struct strbuf *sb, const char *gitdir);
482482
extern int get_common_dir(struct strbuf *sb, const char *gitdir);

commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static void prepare_commit_graft_the_repository(void)
204204

205205
if (commit_graft_prepared)
206206
return;
207-
graft_file = get_graft_file();
207+
graft_file = get_graft_file(the_repository);
208208
read_graft_file(the_repository, graft_file);
209209
/* make sure shallows are read */
210210
is_repository_shallow(the_repository);

environment.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,11 @@ char *get_index_file(void)
316316
return the_repository->index_file;
317317
}
318318

319-
char *get_graft_file(void)
319+
char *get_graft_file(struct repository *r)
320320
{
321-
if (!the_repository->graft_file)
321+
if (!r->graft_file)
322322
BUG("git environment hasn't been setup");
323-
return the_repository->graft_file;
323+
return r->graft_file;
324324
}
325325

326326
int set_git_dir(const char *path)

0 commit comments

Comments
 (0)