X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fgit.git;a=blobdiff_plain;f=setup.c;h=61c22e6becc1e49f1e92c916a4b8badd30a9cb2f;hp=1b06db53fc24f1347e2a73bbecb44a059882e898;hb=bc1bbe0c19a6ff39522b4fa3259f34150e308e1f;hpb=a574c04fbfa06d9b40c4c32db27135c503da7c15 diff --git a/setup.c b/setup.c index 1b06db53fc..61c22e6bec 100644 --- a/setup.c +++ b/setup.c @@ -40,34 +40,6 @@ char *prefix_path(const char *prefix, int len, const char *path) return sanitized; } -/* - * Unlike prefix_path, this should be used if the named file does - * not have to interact with index entry; i.e. name of a random file - * on the filesystem. - */ -const char *prefix_filename(const char *pfx, int pfx_len, const char *arg) -{ - static char path[PATH_MAX]; -#ifndef WIN32 - if (!pfx_len || is_absolute_path(arg)) - return arg; - memcpy(path, pfx, pfx_len); - strcpy(path + pfx_len, arg); -#else - char *p; - /* don't add prefix to absolute paths, but still replace '\' by '/' */ - if (is_absolute_path(arg)) - pfx_len = 0; - else if (pfx_len) - memcpy(path, pfx, pfx_len); - strcpy(path + pfx_len, arg); - for (p = path + pfx_len; *p; p++) - if (*p == '\\') - *p = '/'; -#endif - return path; -} - int check_filename(const char *prefix, const char *arg) { const char *name; @@ -710,6 +682,11 @@ const char *setup_git_directory_gently(int *nongit_ok) const char *prefix; prefix = setup_git_directory_gently_1(nongit_ok); + if (prefix) + setenv("GIT_PREFIX", prefix, 1); + else + setenv("GIT_PREFIX", "", 1); + if (startup_info) { startup_info->have_repository = !nongit_ok || !*nongit_ok; startup_info->prefix = prefix; @@ -803,3 +780,10 @@ const char *setup_git_directory(void) { return setup_git_directory_gently(NULL); } + +const char *resolve_gitdir(const char *suspect) +{ + if (is_git_directory(suspect)) + return suspect; + return read_gitfile(suspect); +}