Skip to content

Commit 732106b

Browse files
committed
Merge 'unc-alternates' into HEAD
2 parents 20539f4 + f2259d6 commit 732106b

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
@@ -423,6 +423,7 @@ HANDLE winansi_get_osfhandle(int fd);
423423
(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)
424424
int mingw_skip_dos_drive_prefix(char **path);
425425
#define skip_dos_drive_prefix mingw_skip_dos_drive_prefix
426+
#define has_unc_prefix(path) (*(path) == '\\' && (path)[1] == '\\' ? 2 : 0)
426427
#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
427428
static inline char *mingw_find_last_dir_sep(const char *path)
428429
{

git-compat-util.h

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

354+
#ifndef has_unc_prefix
355+
static inline int git_has_unc_prefix(const char *path)
356+
{
357+
return 0;
358+
}
359+
#define has_unc_prefix git_has_unc_prefix
360+
#endif
361+
354362
#ifndef is_dir_sep
355363
static inline int git_is_dir_sep(int c)
356364
{

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)