]> git.ipfire.org Git - thirdparty/git.git/commitdiff
cygwin: allow pushing to UNC paths
authorTorsten Bögershausen <tboegi@web.de>
Mon, 3 Jul 2017 14:41:37 +0000 (16:41 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Jul 2017 21:01:03 +0000 (14:01 -0700)
 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>
compat/cygwin.c [new file with mode: 0644]
compat/cygwin.h [new file with mode: 0644]
config.mak.uname
git-compat-util.h
t/t0060-path-utils.sh

diff --git a/compat/cygwin.c b/compat/cygwin.c
new file mode 100644 (file)
index 0000000..b9862d6
--- /dev/null
@@ -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 (file)
index 0000000..8e52de4
--- /dev/null
@@ -0,0 +1,2 @@
+int cygwin_offset_1st_component(const char *path);
+#define offset_1st_component cygwin_offset_1st_component
index 192629f1431072f242f10a8528f1853b8bbaddeb..6367cc023d313d50d5c39217cb6858be80a0bae3 100644 (file)
@@ -181,6 +181,7 @@ ifeq ($(uname_O),Cygwin)
        UNRELIABLE_FSTAT = UnfortunatelyYes
        SPARSE_FLAGS = -isystem /usr/include/w32api -Wno-one-bit-signed-bitfield
        OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
+       COMPAT_OBJS += compat/cygwin.o
 endif
 ifeq ($(uname_S),FreeBSD)
        NEEDS_LIBICONV = YesPlease
index 199042ac91466783201bdd483bad9f89c78db122..59866d72fa3bb5aff109632b42c7178b24f528bc 100644 (file)
 #include <sys/sysctl.h>
 #endif
 
+#if defined(__CYGWIN__)
+#include "compat/cygwin.h"
+#endif
 #if defined(__MINGW32__)
 /* pull in Windows compatibility stuff */
 #include "compat/mingw.h"
index 444b5a4df801975cf4f96f8193cb04ac91af3e4d..7ea2bb515bd80cc026a18dbfdf4a66cb77d27f20 100755 (executable)
@@ -70,6 +70,8 @@ ancestor() {
 case $(uname -s) in
 *MINGW*)
        ;;
+*CYGWIN*)
+       ;;
 *)
        test_set_prereq POSIX
        ;;