diff options
author | Vicent Marti <tanoku@gmail.com> | 2011-05-23 21:12:18 +0300 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-05-23 21:12:18 +0300 |
commit | 60e1b49abd3fa2d50c2bf3f1a6718f56621582f8 (patch) | |
tree | 7dfd892f95a6ac169a26e295ff4bdd8b3f6c0e5c /src/odb_loose.c | |
parent | dfb12cd544f21d2ea9e457bea7a9c28a8c6ff26f (diff) | |
download | libgit2-60e1b49abd3fa2d50c2bf3f1a6718f56621582f8.tar.gz |
odb_loose: Reword errors
Diffstat (limited to 'src/odb_loose.c')
-rw-r--r-- | src/odb_loose.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/odb_loose.c b/src/odb_loose.c index f6339ccdf..9fb86f8bf 100644 --- a/src/odb_loose.c +++ b/src/odb_loose.c @@ -452,7 +452,11 @@ static int read_header_loose(git_rawobj *out, const char *loc) cleanup: finish_inflate(&zs); gitfo_close(fd); - return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to read loose object header"); + + if (error < GIT_SUCCESS) + return git__throw(error, "Failed to read loose object header. Header is corrupted"); + + return GIT_SUCCESS; } static int locate_object(char *object_location, loose_backend *backend, const git_oid *oid) @@ -485,11 +489,14 @@ int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backend assert(backend && oid); + raw.len = 0; + raw.type = GIT_OBJ_BAD; + if (locate_object(object_path, (loose_backend *)backend, oid) < 0) return git__throw(GIT_ENOTFOUND, "Failed to read loose backend header. Object not found"); if ((error = read_header_loose(&raw, object_path)) < GIT_SUCCESS) - return git__rethrow(error, "Failed to read loose backend header"); + return error; *len_p = raw.len; *type_p = raw.type; |