Skip to content

Commit 49f1e2e

Browse files
committed
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
2 parents bc2c50f + 496f256 commit 49f1e2e

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

compat/cygwin.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include "../git-compat-util.h"
2+
#include "../cache.h"
3+
4+
int cygwin_offset_1st_component(const char *path)
5+
{
6+
const char *pos = path;
7+
/* unc paths */
8+
if (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {
9+
/* skip server name */
10+
pos = strchr(pos + 2, '/');
11+
if (!pos)
12+
return 0; /* Error: malformed unc path */
13+
14+
do {
15+
pos++;
16+
} while (*pos && pos[0] != '/');
17+
}
18+
return pos + is_dir_sep(*pos) - path;
19+
}

compat/cygwin.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
int cygwin_offset_1st_component(const char *path);
2+
#define offset_1st_component cygwin_offset_1st_component

config.mak.uname

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ ifeq ($(uname_O),Cygwin)
181181
UNRELIABLE_FSTAT = UnfortunatelyYes
182182
SPARSE_FLAGS = -isystem /usr/include/w32api -Wno-one-bit-signed-bitfield
183183
OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
184+
COMPAT_OBJS += compat/cygwin.o
184185
endif
185186
ifeq ($(uname_S),FreeBSD)
186187
NEEDS_LIBICONV = YesPlease

git-compat-util.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@
189189
#include <sys/sysctl.h>
190190
#endif
191191

192+
#if defined(__CYGWIN__)
193+
#include "compat/cygwin.h"
194+
#endif
192195
#if defined(__MINGW32__)
193196
/* pull in Windows compatibility stuff */
194197
#include "compat/mingw.h"

t/t0060-path-utils.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ ancestor() {
7070
case $(uname -s) in
7171
*MINGW*)
7272
;;
73+
*CYGWIN*)
74+
;;
7375
*)
7476
test_set_prereq POSIX
7577
;;

0 commit comments

Comments
 (0)