summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-07-18 12:48:09 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-07-18 12:48:09 -0700
commit33400c0e96460f36708789a6a3c8eeb7cbc8f0cc (patch)
tree353ea68a6b56abfa0ccc9590a23adaf25dbf3acb /compat
parentGit 2.14-rc0 (diff)
parentcygwin: allow pushing to UNC paths (diff)
downloadtgif-33400c0e96460f36708789a6a3c8eeb7cbc8f0cc.tar.xz
Merge branch 'tb/push-to-cygwin-unc-path'
On Cygwin, similar to Windows, "git push //server/share/repository" ought to mean a repository on a network share that can be accessed locally, but this did not work correctly due to stripping the double slashes at the beginning. This may need to be heavily tested before it gets unleashed to the wild, as the change is at a fairly low-level code and would affect not just the code to decide if the push destination is local. There may be unexpected fallouts in the path normalization. * tb/push-to-cygwin-unc-path: cygwin: allow pushing to UNC paths
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