summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-06-16 17:07:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-06-16 17:07:03 (GMT)
commitb83163643bd7459385003fa58ae049a31f2984cb (patch)
treeed048a2befb3b9d4f1a51175db7d2db939bb0b46 /compat
parent4a43d4f98a1a6a472ce1e87c64cb6df0d1653d02 (diff)
parentc2369bdf7ff082d588c4a4efe280bc4a483d0192 (diff)
downloadgit-b83163643bd7459385003fa58ae049a31f2984cb.zip
git-b83163643bd7459385003fa58ae049a31f2984cb.tar.gz
git-b83163643bd7459385003fa58ae049a31f2984cb.tar.bz2
Merge branch 'sk/windows-unc-path'
* sk/windows-unc-path: Windows: allow using UNC path for git repository
Diffstat (limited to 'compat')
-rw-r--r--compat/mingw.c24
-rw-r--r--compat/mingw.h2
2 files changed, 26 insertions, 0 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
index e9892f8..a0e13bc 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1823,3 +1823,27 @@ pid_t waitpid(pid_t pid, int *status, int options)
errno = EINVAL;
return -1;
}
+
+int mingw_offset_1st_component(const char *path)
+{
+ int offset = 0;
+ if (has_dos_drive_prefix(path))
+ offset = 2;
+
+ /* unc paths */
+ else if (is_dir_sep(path[0]) && is_dir_sep(path[1])) {
+
+ /* skip server name */
+ char *pos = strpbrk(path + 2, "\\/");
+ if (!pos)
+ return 0; /* Error: malformed unc path */
+
+ do {
+ pos++;
+ } while (*pos && !is_dir_sep(*pos));
+
+ offset = pos - path;
+ }
+
+ return offset + is_dir_sep(path[offset]);
+}
diff --git a/compat/mingw.h b/compat/mingw.h
index e033e72..3eaf822 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -339,6 +339,8 @@ static inline char *mingw_find_last_dir_sep(const char *path)
return ret;
}
#define find_last_dir_sep mingw_find_last_dir_sep
+int mingw_offset_1st_component(const char *path);
+#define offset_1st_component mingw_offset_1st_component
#define PATH_SEP ';'
#define PRIuMAX "I64u"
#define PRId64 "I64d"