Sync with maint to grab trivial doc fixes
[gitweb.git] / abspath.c
index a7ab8e908f8188ae1b55fca15cc2fb8772f40096..64adbe2a1b5e5679fb0dc772452b4aca1865ee4c 100644 (file)
--- a/abspath.c
+++ b/abspath.c
@@ -35,7 +35,14 @@ static const char *real_path_internal(const char *path, int die_on_error)
 {
        static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1];
        char *retval = NULL;
+
+       /*
+        * If we have to temporarily chdir(), store the original CWD
+        * here so that we can chdir() back to it at the end of the
+        * function:
+        */
        char cwd[1024] = "";
+
        int buf_index = 1;
 
        int depth = MAXDEPTH;
@@ -146,6 +153,11 @@ const char *real_path(const char *path)
        return real_path_internal(path, 1);
 }
 
+const char *real_path_if_valid(const char *path)
+{
+       return real_path_internal(path, 0);
+}
+
 static const char *get_pwd_cwd(void)
 {
        static char cwd[PATH_MAX + 1];
@@ -204,7 +216,7 @@ const char *absolute_path(const char *path)
 const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
 {
        static char path[PATH_MAX];
-#ifndef WIN32
+#ifndef GIT_WINDOWS_NATIVE
        if (!pfx_len || is_absolute_path(arg))
                return arg;
        memcpy(path, pfx, pfx_len);