Merge branch 'tb/push-to-cygwin-unc-path' into maint

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
This commit is contained in:
Junio C Hamano 2017-07-31 13:51:04 -07:00
commit 49f1e2eb1b
5 changed files with 27 additions and 0 deletions

19
compat/cygwin.c Normal file
View file

@ -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;
}

2
compat/cygwin.h Normal file
View file

@ -0,0 +1,2 @@
int cygwin_offset_1st_component(const char *path);
#define offset_1st_component cygwin_offset_1st_component

View 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

View file

@ -189,6 +189,9 @@
#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"

View file

@ -70,6 +70,8 @@ ancestor() {
case $(uname -s) in
*MINGW*)
;;
*CYGWIN*)
;;
*)
test_set_prereq POSIX
;;