var: run setup_git_directory_gently() sooner
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index 5734a1f1c1f30bb2312db1a86c345e895948b75b..6ee1e28bd8650332aade03b78a2660abbde5478a 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -404,7 +404,7 @@ static dev_t get_device_or_die(const char *path, const char *prefix)
  * We cannot decide in this function whether we are in the work tree or
  * not, since the config can only be read _after_ this function was called.
  */
-const char *setup_git_directory_gently(int *nongit_ok)
+static const char *setup_git_directory_gently_1(int *nongit_ok)
 {
        const char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT);
        const char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT);
@@ -500,6 +500,16 @@ const char *setup_git_directory_gently(int *nongit_ok)
        return cwd + offset;
 }
 
+const char *setup_git_directory_gently(int *nongit_ok)
+{
+       const char *prefix;
+
+       prefix = setup_git_directory_gently_1(nongit_ok);
+       if (startup_info)
+               startup_info->have_repository = !nongit_ok || !*nongit_ok;
+       return prefix;
+}
+
 int git_config_perm(const char *var, const char *value)
 {
        int i;