summaryrefslogtreecommitdiff
path: root/src/odb_loose.c
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2012-02-17 00:13:34 +0100
committerVicent Martí <tanoku@gmail.com>2012-03-06 00:43:10 +0100
commit1a48112342932e9fcd45a1ff5935f1c9c53b83d1 (patch)
treefbb18cfe64e65025c6e1790972d1a106eea4cc54 /src/odb_loose.c
parent45d387ac78bcf3167d69b736d0b322717bc492d4 (diff)
downloadlibgit2-1a48112342932e9fcd45a1ff5935f1c9c53b83d1.tar.gz
error-handling: References
Yes, this is error handling solely for `refs.c`, but some of the abstractions leak all ofer the code base.
Diffstat (limited to 'src/odb_loose.c')
-rw-r--r--src/odb_loose.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/odb_loose.c b/src/odb_loose.c
index f5f6e35ac..6546fa839 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -466,7 +466,7 @@ static int locate_object(
int error = object_file_name(object_location, backend->objects_dir, oid);
if (error == GIT_SUCCESS)
- error = git_path_exists(git_buf_cstr(object_location));
+ error = git_path_exists(git_buf_cstr(object_location)) ? GIT_SUCCESS : GIT_ENOTFOUND;
return error;
}
@@ -480,7 +480,7 @@ static int fn_locate_object_short_oid(void *state, git_buf *pathbuf) {
return GIT_SUCCESS;
}
- if (!git_path_exists(pathbuf->ptr) && git_path_isdir(pathbuf->ptr)) {
+ if (git_path_isdir(pathbuf->ptr) == true) {
/* We are already in the directory matching the 2 first hex characters,
* compare the first ncmp characters of the oids */
if (!memcmp(sstate->short_oid + 2,
@@ -533,8 +533,7 @@ static int locate_object_short_oid(
return git__rethrow(error, "Failed to locate object from short oid");
/* Check that directory exists */
- if (git_path_exists(object_location->ptr) ||
- git_path_isdir(object_location->ptr))
+ if (git_path_isdir(object_location->ptr) == false)
return git__throw(GIT_ENOTFOUND, "Failed to locate object from short oid. Object not found");
state.dir_len = object_location->size;
@@ -716,7 +715,7 @@ static int loose_backend__stream_fwrite(git_oid *oid, git_odb_stream *_stream)
* is what git does and allows us to sidestep the fact that
* we're not allowed to overwrite a read-only file on Windows.
*/
- if (git_path_exists(final_path.ptr) == GIT_SUCCESS) {
+ if (git_path_exists(final_path.ptr) == true) {
git_filebuf_cleanup(&stream->fbuf);
goto cleanup;
}