Skip to content

Commit a76d750

Browse files
committed
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`.
1 parent cffd616 commit a76d750

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/path.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,8 +826,8 @@ int git_path_resolve_relative(git_buf *path, size_t ceiling)
826826

827827
int git_path_apply_relative(git_buf *target, const char *relpath)
828828
{
829-
git_buf_joinpath(target, git_buf_cstr(target), relpath);
830-
return git_path_resolve_relative(target, 0);
829+
return git_buf_joinpath(target, git_buf_cstr(target), relpath) ||
830+
git_path_resolve_relative(target, 0);
831831
}
832832

833833
int git_path_cmp(

0 commit comments

Comments
 (0)