Skip to content

Commit 8b07530

Browse files
committed
mingw: support UNC alternates
Just like we support having alternates pointing to different drives, we want to support alternates pointing to network shares, i.e. UNC paths. Technically, what we do in this patch is not to support UNC alternates, but to support UNC paths when normalizing paths. But the latter implies the former, and the former really was the motivation for this patch. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 78e3a23 commit 8b07530

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
@@ -666,7 +666,7 @@ int normalize_path_copy_len(char *dst, const char *src, int *prefix_len)
666666
{
667667
char *dst0;
668668

669-
if (has_dos_drive_prefix(src)) {
669+
if (has_unc_prefix(src) || has_dos_drive_prefix(src)) {
670670
*dst++ = *src++;
671671
*dst++ = *src++;
672672
}

0 commit comments

Comments
 (0)