Commit 91369100 by Jakob Pfender Committed by Vicent Marti

blob.c: Move to new error handling mechanism

parent b0b527e0
...@@ -69,6 +69,8 @@ int git_blob_create_frombuffer(git_oid *oid, git_repository *repo, const void *b ...@@ -69,6 +69,8 @@ int git_blob_create_frombuffer(git_oid *oid, git_repository *repo, const void *b
error = stream->finalize_write(oid, stream); error = stream->finalize_write(oid, stream);
stream->free(stream); stream->free(stream);
if (error < GIT_SUCCESS)
return git__rethrow(error, "Failed to create blob");
return error; return error;
} }
...@@ -86,16 +88,16 @@ int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *pat ...@@ -86,16 +88,16 @@ int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *pat
git__joinpath(full_path, repo->path_workdir, path); git__joinpath(full_path, repo->path_workdir, path);
if ((fd = gitfo_open(full_path, O_RDONLY)) < 0) if ((fd = gitfo_open(full_path, O_RDONLY)) < 0)
return GIT_ENOTFOUND; return git__throw(GIT_ENOTFOUND, "Failed to create blob. Could not open %s", full_path);
if ((size = gitfo_size(fd)) < 0 || !git__is_sizet(size)) { if ((size = gitfo_size(fd)) < 0 || !git__is_sizet(size)) {
gitfo_close(fd); gitfo_close(fd);
return GIT_EOSERR; return git__throw(GIT_EOSERR, "Failed to create blob. %s appears to be corrupted", full_path);
} }
if ((error = git_odb_open_wstream(&stream, repo->db, (size_t)size, GIT_OBJ_BLOB)) < GIT_SUCCESS) { if ((error = git_odb_open_wstream(&stream, repo->db, (size_t)size, GIT_OBJ_BLOB)) < GIT_SUCCESS) {
gitfo_close(fd); gitfo_close(fd);
return error; return git__rethrow(error, "Failed to create blob");
} }
while (size > 0) { while (size > 0) {
...@@ -117,6 +119,8 @@ int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *pat ...@@ -117,6 +119,8 @@ int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *pat
stream->free(stream); stream->free(stream);
gitfo_close(fd); gitfo_close(fd);
if (error < GIT_SUCCESS)
return git__rethrow(error, "Failed to create blob");
return error; return error;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment