Skip to content

Commit 72411ab

Browse files
committed
Merge 'unc-alternates' into HEAD
2 parents 0a35c93 + 68cdffa commit 72411ab

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
@@ -347,6 +347,14 @@ static inline int git_skip_dos_drive_prefix(char **path)
347347
#define skip_dos_drive_prefix git_skip_dos_drive_prefix
348348
#endif
349349

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

path.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,9 +945,9 @@ const char *remove_leading_path(const char *in, const char *prefix)
945945
int normalize_path_copy_len(char *dst, const char *src, int *prefix_len)
946946
{
947947
char *dst0;
948-
int i;
948+
int i = has_unc_prefix(src);
949949

950-
for (i = has_dos_drive_prefix(src); i > 0; i--)
950+
for (i = i ? i : has_dos_drive_prefix(src); i > 0; i--)
951951
*dst++ = *src++;
952952
dst0 = dst;
953953

0 commit comments

Comments
 (0)