Fix .git/ discovery at the root of UNC shares
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index bb039ee14d612afadbab2859856f70d7f24f66d9..a0cb42c2356fed92815694391b5020e7f25d769f 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -947,6 +947,12 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
        if (ceil_offset < 0)
                ceil_offset = min_offset - 2;
 
+       if (min_offset && min_offset == dir->len &&
+           !is_dir_sep(dir->buf[min_offset - 1])) {
+               strbuf_addch(dir, '/');
+               min_offset++;
+       }
+
        /*
         * Test in the following order (relative to the dir):
         * - .git (file containing "gitdir: <path>")