path: short-circuit git_path_apply_relative on error

Short-circuit the call to `git_path_resolve_relative` in case
`git_buf_joinpath` returns an error. While this does not fix any
immediate errors, the resulting code is easier to read and handles
potential new error conditions raised by `git_buf_joinpath`.
This commit is contained in:
Patrick Steinhardt 2017-03-28 09:12:34 +02:00
parent cffd616a72
commit a76d75021c

View File

@ -826,8 +826,8 @@ int git_path_resolve_relative(git_buf *path, size_t ceiling)
int git_path_apply_relative(git_buf *target, const char *relpath) int git_path_apply_relative(git_buf *target, const char *relpath)
{ {
git_buf_joinpath(target, git_buf_cstr(target), relpath); return git_buf_joinpath(target, git_buf_cstr(target), relpath) ||
return git_path_resolve_relative(target, 0); git_path_resolve_relative(target, 0);
} }
int git_path_cmp( int git_path_cmp(