Skip to content

Commit 7b94b82

Browse files
committed
Merge pull request #286 from dscho/unc-alternates
Make alternates work on UNC paths
2 parents 8a22fb2 + 4ddd0a3 commit 7b94b82

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
@@ -396,6 +396,7 @@ HANDLE winansi_get_osfhandle(int fd);
396396
*/
397397

398398
#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
399+
#define has_unc_prefix(path) (*(path) == '\\' && (path)[1] == '\\')
399400
#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
400401
static inline char *mingw_find_last_dir_sep(const char *path)
401402
{

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
@@ -708,7 +708,7 @@ int normalize_path_copy_len(char *dst, const char *src, int *prefix_len)
708708
{
709709
char *dst0;
710710

711-
if (has_dos_drive_prefix(src)) {
711+
if (has_unc_prefix(src) || has_dos_drive_prefix(src)) {
712712
*dst++ = *src++;
713713
*dst++ = *src++;
714714
}

0 commit comments

Comments
 (0)