Skip to content

Commit f0ef8a9

Browse files
committed
Merge 'unc-alternates' into HEAD
2 parents 73ac8c8 + 715e2e2 commit f0ef8a9

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
@@ -948,9 +948,9 @@ const char *remove_leading_path(const char *in, const char *prefix)
948948
int normalize_path_copy_len(char *dst, const char *src, int *prefix_len)
949949
{
950950
char *dst0;
951-
int i;
951+
int i = has_unc_prefix(src);
952952

953-
for (i = has_dos_drive_prefix(src); i > 0; i--)
953+
for (i = i ? i : has_dos_drive_prefix(src); i > 0; i--)
954954
*dst++ = *src++;
955955
dst0 = dst;
956956

0 commit comments

Comments
 (0)