From 16ac8b8db6ec7400719db6b5c76edaab33c47606 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 13 Mar 2017 21:10:45 +0100 Subject: setup: introduce the discover_git_directory() function We modified the setup_git_directory_gently_1() function earlier to make it possible to discover the GIT_DIR without changing global state. However, it is still a bit cumbersome to use if you only need to figure out the (possibly absolute) path of the .git/ directory. Let's just provide a convenient wrapper function with an easier signature that *just* discovers the .git/ directory. We will use it in a subsequent patch to fix the early config. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- cache.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cache.h') diff --git a/cache.h b/cache.h index 61fc86e6d7..3cba58e219 100644 --- a/cache.h +++ b/cache.h @@ -518,6 +518,13 @@ extern void set_git_work_tree(const char *tree); #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES" extern void setup_work_tree(void); +/* + * Find GIT_DIR of the repository that contains the current working directory, + * without changing the working directory or other global state. The result is + * appended to gitdir. The return value is either NULL if no repository was + * found, or pointing to the path inside gitdir's buffer. + */ +extern const char *discover_git_directory(struct strbuf *gitdir); extern const char *setup_git_directory_gently(int *); extern const char *setup_git_directory(void); extern char *prefix_path(const char *prefix, int len, const char *path); -- cgit v1.2.1