Skip to content

Commit 4ddd0a3

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 c54c439 commit 4ddd0a3

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
@@ -359,6 +359,7 @@ HANDLE winansi_get_osfhandle(int fd);
359359
*/
360360

361361
#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
362+
#define has_unc_prefix(path) (*(path) == '\\' && (path)[1] == '\\')
362363
#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
363364
static inline char *mingw_find_last_dir_sep(const char *path)
364365
{

git-compat-util.h

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

338+
#ifndef has_unc_prefix
339+
static inline int git_has_unc_prefix(const char *path)
340+
{
341+
return 0;
342+
}
343+
#define has_unc_prefix git_has_unc_prefix
344+
#endif
345+
338346
#ifndef is_dir_sep
339347
static inline int git_is_dir_sep(int c)
340348
{

path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ int normalize_path_copy_len(char *dst, const char *src, int *prefix_len)
704704
{
705705
char *dst0;
706706

707-
if (has_dos_drive_prefix(src)) {
707+
if (has_unc_prefix(src) || has_dos_drive_prefix(src)) {
708708
*dst++ = *src++;
709709
*dst++ = *src++;
710710
}

0 commit comments

Comments
 (0)