Git.pm: allow command_close_bidi_pipe to be called as method
[gitweb.git] / abspath.c
index a7ab8e908f8188ae1b55fca15cc2fb8772f40096..40cdc46219d4eba87ba947d9f5556eb80dfdfa9b 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];