summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-01-17 13:46:44 -0800
committerRussell Belfer <rb@github.com>2014-01-17 13:46:44 -0800
commit6b415f622e93a81471ac485411ae9126a1e1938f (patch)
tree56fe8914bad8953455b78271b43b471aa9f8b8b6 /src
parentb6815fe0d5a9abc80b4f91b0f57fdc9e5a8bbcf1 (diff)
downloadlibgit2-6b415f622e93a81471ac485411ae9126a1e1938f.tar.gz
Convert gitdir paths to posix on Windows
Apparently, a .git file with "gitdir: path" link on Windows is allowed to use backslashes in the path. Who knew?
Diffstat (limited to 'src')
-rw-r--r--src/repository.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/repository.c b/src/repository.c
index c584d30c8..8645357b8 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -289,16 +289,20 @@ static int read_gitfile(git_buf *path_out, const char *file_path)
return -1;
git_buf_rtrim(&file);
+ /* apparently on Windows, some people use backslashes in paths */
+ git_path_mkposix(file.ptr);
if (git_buf_len(&file) <= prefix_len ||
memcmp(git_buf_cstr(&file), GIT_FILE_CONTENT_PREFIX, prefix_len) != 0)
{
- giterr_set(GITERR_REPOSITORY, "The `.git` file at '%s' is malformed", file_path);
+ giterr_set(GITERR_REPOSITORY,
+ "The `.git` file at '%s' is malformed", file_path);
error = -1;
}
else if ((error = git_path_dirname_r(path_out, file_path)) >= 0) {
const char *gitlink = git_buf_cstr(&file) + prefix_len;
while (*gitlink && git__isspace(*gitlink)) gitlink++;
+
error = git_path_prettify_dir(
path_out, gitlink, git_buf_cstr(path_out));
}