diff options
Diffstat (limited to 'src/fileops.c')
| -rw-r--r-- | src/fileops.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/fileops.c b/src/fileops.c index f481bb01d..1d991b36d 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -536,13 +536,25 @@ int git_futils_find_system_file(git_buf *path, const char *filename) int git_futils_dir_for_path(git_buf *dir, const char *path, const char *base) { - if (git_path_prettify(dir, path, base) == GIT_SUCCESS) { - /* call dirname if this is not a directory */ - if (git_futils_isdir(dir->ptr) != GIT_SUCCESS) - git_path_dirname_r(dir, dir->ptr); + int error = GIT_SUCCESS; + + if (base != NULL && git_path_root(path) < 0) + error = git_buf_joinpath(dir, base, path); + else + error = git_buf_sets(dir, path); - git_path_to_dir(dir); + if (error == GIT_SUCCESS) { + char buf[GIT_PATH_MAX]; + if (p_realpath(dir->ptr, buf) != NULL) + error = git_buf_sets(dir, buf); } - return git_buf_lasterror(dir); + /* call dirname if this is not a directory */ + if (error == GIT_SUCCESS && git_futils_isdir(dir->ptr) != GIT_SUCCESS) + error = git_path_dirname_r(dir, dir->ptr); + + if (error == GIT_SUCCESS) + error = git_path_to_dir(dir); + + return error; } |
