cache: convert get_graft_file to handle arbitrary repositories
authorStefan Beller <sbeller@google.com>
Thu, 17 May 2018 22:51:50 +0000 (15:51 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 May 2018 23:13:10 +0000 (08:13 +0900)
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>
cache.h
commit.c
environment.c
diff --git a/cache.h b/cache.h
index ab716011b7ef209715c6f41107d358e1ba987bf7..cb1aeb1dcbf7bc1dea3f020154035c7a37e053a5 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -476,7 +476,7 @@ extern const char *get_git_dir(void);
 extern const char *get_git_common_dir(void);
 extern char *get_object_directory(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 get_common_dir_noenv(struct strbuf *sb, const char *gitdir);
 extern int get_common_dir(struct strbuf *sb, const char *gitdir);
index 3fcb2fd66ce7fc57638f4dc0ba912995915fe70f..24028fd257a661734a60d86f748517fca7fa7a94 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -204,7 +204,7 @@ static void prepare_commit_graft_the_repository(void)
 
        if (commit_graft_prepared)
                return;
-       graft_file = get_graft_file();
+       graft_file = get_graft_file(the_repository);
        read_graft_file(the_repository, graft_file);
        /* make sure shallows are read */
        is_repository_shallow(the_repository);
index 87d9e52ffde897d4dd30b1346312c5217469b68f..ab42346e563e113091d9faf8fde02d58a074108c 100644 (file)
@@ -316,11 +316,11 @@ char *get_index_file(void)
        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");
-       return the_repository->graft_file;
+       return r->graft_file;
 }
 
 int set_git_dir(const char *path)