X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=path.c;h=066f62195508033a5f72504e4805ea436424296e;hb=ae41098714898acd52dba291e476a2fedbd2eae2;hp=db8905f3c352592124b2f0bda18fc0ccd048528e;hpb=0f2ca9d5c99436d048bfe0a7161b4365a731938f;p=git.git diff --git a/path.c b/path.c index db8905f3c..066f62195 100644 --- a/path.c +++ b/path.c @@ -11,11 +11,16 @@ * which is what it's designed for. */ #include "cache.h" -#include -static char pathname[PATH_MAX]; static char bad_path[] = "/bad-path/"; +static char *get_pathname(void) +{ + static char pathname_array[4][PATH_MAX]; + static int index; + return pathname_array[3 & ++index]; +} + static char *cleanup_path(char *path) { /* Clean it up */ @@ -31,6 +36,7 @@ char *mkpath(const char *fmt, ...) { va_list args; unsigned len; + char *pathname = get_pathname(); va_start(args, fmt); len = vsnprintf(pathname, PATH_MAX, fmt, args); @@ -43,6 +49,7 @@ char *mkpath(const char *fmt, ...) char *git_path(const char *fmt, ...) { const char *git_dir = get_git_dir(); + char *pathname = get_pathname(); va_list args; unsigned len; @@ -271,7 +278,7 @@ int adjust_shared_perm(const char *path) : 0)); if (S_ISDIR(mode)) mode |= S_ISGID; - if (chmod(path, mode) < 0) + if ((mode & st.st_mode) != mode && chmod(path, mode) < 0) return -2; return 0; }