Skip to content

Commit

Permalink
Merge pull request libgit2#2058 from libgit2/rb/gitdir-windows-paths
Browse files Browse the repository at this point in the history
Convert gitdir paths to posix on Windows
  • Loading branch information
ethomson committed Jan 17, 2014
2 parents b6815fe + 6b415f6 commit fed9815
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/repository.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit fed9815

Please sign in to comment.