Skip to content

Commit 31a5e17

Browse files
committed
Merge 'unc-alternates' into HEAD
2 parents 5cd5b40 + 6e9dfb8 commit 31a5e17

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

compat/mingw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ HANDLE winansi_get_osfhandle(int fd);
424424
(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)
425425
int mingw_skip_dos_drive_prefix(char **path);
426426
#define skip_dos_drive_prefix mingw_skip_dos_drive_prefix
427+
#define has_unc_prefix(path) (*(path) == '\\' && (path)[1] == '\\' ? 2 : 0)
427428
#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
428429
static inline char *mingw_find_last_dir_sep(const char *path)
429430
{

git-compat-util.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,14 @@ static inline int git_skip_dos_drive_prefix(char **path)
348348
#define skip_dos_drive_prefix git_skip_dos_drive_prefix
349349
#endif
350350

351+
#ifndef has_unc_prefix
352+
static inline int git_has_unc_prefix(const char *path)
353+
{
354+
return 0;
355+
}
356+
#define has_unc_prefix git_has_unc_prefix
357+
#endif
358+
351359
#ifndef is_dir_sep
352360
static inline int git_is_dir_sep(int c)
353361
{

path.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,9 +989,9 @@ const char *remove_leading_path(const char *in, const char *prefix)
989989
int normalize_path_copy_len(char *dst, const char *src, int *prefix_len)
990990
{
991991
char *dst0;
992-
int i;
992+
int i = has_unc_prefix(src);
993993

994-
for (i = has_dos_drive_prefix(src); i > 0; i--)
994+
for (i = i ? i : has_dos_drive_prefix(src); i > 0; i--)
995995
*dst++ = *src++;
996996
dst0 = dst;
997997

0 commit comments

Comments
 (0)