Code

t/t8006: Demonstrate blame is broken when cachetextconv is on
[git.git] / setup.c
diff --git a/setup.c b/setup.c
index d19aa7d7a9633eaf8bb7d65d31bad6b67bf85ead..346ef2eb2d678b742280c0816a09b8ca174ca799 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -46,7 +46,7 @@ const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
 {
        static char path[PATH_MAX];
 #ifndef WIN32
-       if (!pfx || !*pfx || is_absolute_path(arg))
+       if (!pfx_len || is_absolute_path(arg))
                return arg;
        memcpy(path, pfx, pfx_len);
        strcpy(path + pfx_len, arg);
@@ -55,7 +55,7 @@ const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
        /* don't add prefix to absolute paths, but still replace '\' by '/' */
        if (is_absolute_path(arg))
                pfx_len = 0;
-       else
+       else if (pfx_len)
                memcpy(path, pfx, pfx_len);
        strcpy(path + pfx_len, arg);
        for (p = path + pfx_len; *p; p++)
@@ -426,7 +426,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);
@@ -507,6 +507,16 @@ const char *setup_git_directory_gently(int *nongit_ok)
        }
 }
 
+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;