mirror of
https://github.com/git/git.git
synced 2024-12-18 06:14:59 +08:00
496f256989
cygwin can use an UNC path like //server/share/repo $ cd //server/share/dir $ mkdir test $ cd test $ git init --bare However, when we try to push from a local Git repository to this repo, there is a problem: Git converts the leading "//" into a single "/". As cygwin handles an UNC path so well, Git can support them better: - Introduce cygwin_offset_1st_component() which keeps the leading "//", similar to what Git for Windows does. - Move CYGWIN out of the POSIX in the tests for path normalization in t0060 Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
20 lines
407 B
C
20 lines
407 B
C
#include "../git-compat-util.h"
|
|
#include "../cache.h"
|
|
|
|
int cygwin_offset_1st_component(const char *path)
|
|
{
|
|
const char *pos = path;
|
|
/* unc paths */
|
|
if (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {
|
|
/* skip server name */
|
|
pos = strchr(pos + 2, '/');
|
|
if (!pos)
|
|
return 0; /* Error: malformed unc path */
|
|
|
|
do {
|
|
pos++;
|
|
} while (*pos && pos[0] != '/');
|
|
}
|
|
return pos + is_dir_sep(*pos) - path;
|
|
}
|