Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 926a92b

Browse files
committed
Merge 'unc' into HEAD
2 parents a5be7ee + bcdefd4 commit 926a92b

File tree

5 files changed

+31
-32
lines changed

5 files changed

+31
-32
lines changed

cache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,6 @@ int normalize_path_copy(char *dst, const char *src);
788788
int longest_ancestor_length(const char *path, struct string_list *prefixes);
789789
char *strip_path_suffix(const char *path, const char *suffix);
790790
int daemon_avoid_alias(const char *path);
791-
int offset_1st_component(const char *path);
792791

793792
/* object replacement */
794793
#define LOOKUP_REPLACE_OBJECT 1

compat/mingw.c

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,31 @@ const char *get_windows_home_directory(void)
19861986

19871987
return home_directory;
19881988
}
1989+
1990+
int mingw_offset_1st_component(const char *path)
1991+
{
1992+
int offset = 0;
1993+
if (has_dos_drive_prefix(path))
1994+
offset = 2;
1995+
1996+
/* unc paths */
1997+
else if (is_dir_sep(path[0]) && is_dir_sep(path[1])) {
1998+
1999+
/* skip server name */
2000+
char *pos = strpbrk(path + 2, "\\/");
2001+
if (!pos)
2002+
return 0; /* Error: malformed unc path */
2003+
2004+
do {
2005+
pos++;
2006+
} while (*pos && !is_dir_sep(*pos));
2007+
2008+
offset = pos - path;
2009+
}
2010+
2011+
return offset + is_dir_sep(path[offset]);
2012+
}
2013+
19892014
int xutftowcsn(wchar_t *wcs, const char *utfs, size_t wcslen, int utflen)
19902015
{
19912016
int upos = 0, wpos = 0;
@@ -2175,27 +2200,3 @@ void mingw_startup()
21752200
/* initialize Unicode console */
21762201
winansi_init();
21772202
}
2178-
2179-
int mingw_offset_1st_component(const char *path)
2180-
{
2181-
int offset = 0;
2182-
if (has_dos_drive_prefix(path))
2183-
offset = 2;
2184-
2185-
/* unc paths */
2186-
else if (is_dir_sep(path[0]) && is_dir_sep(path[1])) {
2187-
2188-
/* skip server name */
2189-
char *pos = strpbrk(path + 2, "\\/");
2190-
if (!pos)
2191-
return 0; /* Error: malformed unc path */
2192-
2193-
do {
2194-
pos++;
2195-
} while (*pos && !is_dir_sep(*pos));
2196-
2197-
offset = pos - path;
2198-
}
2199-
2200-
return offset + is_dir_sep(path[offset]);
2201-
}

compat/mingw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@ static inline char *mingw_find_last_dir_sep(const char *path)
348348
return ret;
349349
}
350350
#define find_last_dir_sep mingw_find_last_dir_sep
351+
int mingw_offset_1st_component(const char *path);
352+
#define offset_1st_component mingw_offset_1st_component
351353
#define PATH_SEP ';'
352354
#define PRIuMAX "I64u"
353355
#define PRId64 "I64d"

git-compat-util.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ extern char *gitbasename(char *);
270270
#define has_dos_drive_prefix(path) 0
271271
#endif
272272

273+
#ifndef offset_1st_component
274+
#define offset_1st_component(path) (is_dir_sep((path)[0]))
275+
#endif
276+
273277
#ifndef is_dir_sep
274278
#define is_dir_sep(c) ((c) == '/')
275279
#endif

path.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -823,10 +823,3 @@ int daemon_avoid_alias(const char *p)
823823
}
824824
}
825825
}
826-
827-
int offset_1st_component(const char *path)
828-
{
829-
if (has_dos_drive_prefix(path))
830-
return 2 + is_dir_sep(path[2]);
831-
return is_dir_sep(path[0]);
832-
}

0 commit comments

Comments
 (0)