summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorTorsten Bögershausen <tboegi@web.de>2017-07-03 16:41:37 +0200
committerJunio C Hamano <gitster@pobox.com>2017-07-05 14:01:03 -0700
commit496f2569892273a142889193350ceb95b6019011 (patch)
treef071c3b1494dba4510bd63c410b906db791703b3 /compat
parent8c8e978f5719c6a58fb998742207bf907f963143 (diff)
downloadgit-496f2569892273a142889193350ceb95b6019011.tar.gz
cygwin: allow pushing to UNC pathstb/push-to-cygwin-unc-path
cygwin can use an UNC path like //server/share/repo $ cd //server/share/dir $ mkdir test $ cd test $ git init --bare However, when we try to push from a local Git repository to this repo, there is a problem: Git converts the leading "//" into a single "/". As cygwin handles an UNC path so well, Git can support them better: - Introduce cygwin_offset_1st_component() which keeps the leading "//", similar to what Git for Windows does. - Move CYGWIN out of the POSIX in the tests for path normalization in t0060 Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat')
-rw-r--r--compat/cygwin.c19
-rw-r--r--compat/cygwin.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/compat/cygwin.c b/compat/cygwin.c
new file mode 100644
index 0000000000..b9862d606d
--- /dev/null
+++ b/compat/cygwin.c
@@ -0,0 +1,19 @@
+#include "../git-compat-util.h"
+#include "../cache.h"
+
+int cygwin_offset_1st_component(const char *path)
+{
+ const char *pos = path;
+ /* unc paths */
+ if (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {
+ /* skip server name */
+ pos = strchr(pos + 2, '/');
+ if (!pos)
+ return 0; /* Error: malformed unc path */
+
+ do {
+ pos++;
+ } while (*pos && pos[0] != '/');
+ }
+ return pos + is_dir_sep(*pos) - path;
+}
diff --git a/compat/cygwin.h b/compat/cygwin.h
new file mode 100644
index 0000000000..8e52de4644
--- /dev/null
+++ b/compat/cygwin.h
@@ -0,0 +1,2 @@
+int cygwin_offset_1st_component(const char *path);
+#define offset_1st_component cygwin_offset_1st_component