Skip to content

Commit bfeff87

Browse files
committed
Merge pull request #286 from dscho/unc-alternates
Make alternates work on UNC paths
2 parents fce0f95 + 10183d9 commit bfeff87

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

compat/mingw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ HANDLE winansi_get_osfhandle(int fd);
399399
*/
400400

401401
#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
402+
#define has_unc_prefix(path) (*(path) == '\\' && (path)[1] == '\\')
402403
#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
403404
static inline char *mingw_find_last_dir_sep(const char *path)
404405
{

git-compat-util.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,14 @@ static inline int git_has_dos_drive_prefix(const char *path)
337337
#define has_dos_drive_prefix git_has_dos_drive_prefix
338338
#endif
339339

340+
#ifndef has_unc_prefix
341+
static inline int git_has_unc_prefix(const char *path)
342+
{
343+
return 0;
344+
}
345+
#define has_unc_prefix git_has_unc_prefix
346+
#endif
347+
340348
#ifndef is_dir_sep
341349
static inline int git_is_dir_sep(int c)
342350
{

path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ int normalize_path_copy_len(char *dst, const char *src, int *prefix_len)
949949
{
950950
char *dst0;
951951

952-
if (has_dos_drive_prefix(src)) {
952+
if (has_unc_prefix(src) || has_dos_drive_prefix(src)) {
953953
*dst++ = *src++;
954954
*dst++ = *src++;
955955
}

0 commit comments

Comments
 (0)