mirror of
https://github.com/git/git.git
synced 2026-04-05 22:40:09 +02:00
Allow using UNC path for git repository
[efl: moved MinGW-specific part to compat/] [jes: fixed compilation on non-Windows] Signed-off-by: Cezary Zawadka <czawadka@gmail.com> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
committed by
Pat Thoyts
parent
86a7918970
commit
3f91f5a8a2
@@ -1749,3 +1749,26 @@ const char *get_windows_home_directory()
|
||||
|
||||
return home_directory;
|
||||
}
|
||||
|
||||
int mingw_offset_1st_component(const char *path)
|
||||
{
|
||||
if (has_dos_drive_prefix(path))
|
||||
return 2 + is_dir_sep(path[2]);
|
||||
|
||||
/* unc paths */
|
||||
if (is_dir_sep(path[0]) && is_dir_sep(path[1])) {
|
||||
|
||||
/* skip server name */
|
||||
char *pos = strpbrk(path + 2, "\\/");
|
||||
if (!pos)
|
||||
return 0;
|
||||
|
||||
do {
|
||||
pos++;
|
||||
} while (*pos && !is_dir_sep(*pos));
|
||||
|
||||
return pos - path;
|
||||
}
|
||||
|
||||
return is_dir_sep(path[0]);
|
||||
}
|
||||
|
||||
@@ -270,6 +270,8 @@ int winansi_fprintf(FILE *stream, const char *format, ...) __attribute__((format
|
||||
|
||||
#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
|
||||
#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
|
||||
int mingw_offset_1st_component(const char *path);
|
||||
#define offset_1st_component mingw_offset_1st_component
|
||||
#define PATH_SEP ';'
|
||||
#define PRIuMAX "I64u"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user