Code

Merge branch 'jl/fetch-submodule-recursive'
[git.git] / dir.c
diff --git a/dir.c b/dir.c
index 852e60f2a8d4784bf73d044f89fe822538121286..38f3e3eb9770a9f3d85f175881bd2dd4ced6548b 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -1033,6 +1033,12 @@ char *get_relative_cwd(char *buffer, int size, const char *dir)
        case '/':
                return cwd + 1;
        default:
+               /*
+                * dir can end with a path separator when it's root
+                * directory. Return proper prefix in that case.
+                */
+               if (dir[-1] == '/')
+                       return cwd;
                return NULL;
        }
 }