Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschu <schu-github@schulog.org>2011-06-26 19:57:40 +0400
committerschu <schu-github@schulog.org>2011-06-27 14:37:46 +0400
commit7b608b3b96d468427b2fbf2cad63988ed67be704 (patch)
treedd91721660597d954bdee1bdd9e87cc7124a8a27 /src/blob.c
parent0b10c9ea6ef5d85d862edd044d96561c4fd16e9b (diff)
git_blob_create_fromfile: remove old code
Remove call of gitfo_size, since we call gitfo_lstat anyway; remove some old workaround code for gitfo_read, which is obsolete now. Signed-off-by: schu <schu-github@schulog.org>
Diffstat (limited to 'src/blob.c')
-rw-r--r--src/blob.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/blob.c b/src/blob.c
index d18aa5c36..2e3c7b3b2 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -99,20 +99,12 @@ int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *pat
}
islnk = S_ISLNK(st.st_mode);
+ size = st.st_size;
-
- if (!islnk) {
+ if (!islnk)
if ((fd = gitfo_open(full_path, O_RDONLY)) < 0)
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)) {
- gitfo_close(fd);
- return git__throw(GIT_EOSERR, "Failed to create blob. '%s' appears to be corrupted", full_path);
- }
- } else {
- size = st.st_size;
- }
-
if ((error = git_odb_open_wstream(&stream, repo->db, (size_t)size, GIT_OBJ_BLOB)) < GIT_SUCCESS) {
if (!islnk)
gitfo_close(fd);
@@ -123,9 +115,9 @@ int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *pat
ssize_t read_len;
if (!islnk)
- read_len = gitfo_read(fd, buffer, (size_t)(size < sizeof(buffer) ? size : sizeof(buffer)));
+ read_len = gitfo_read(fd, buffer, sizeof(buffer));
else
- read_len = gitfo_readlink(full_path, buffer, (size_t)size);
+ read_len = gitfo_readlink(full_path, buffer, sizeof(buffer));
if (read_len < 0) {
if (!islnk)
@@ -143,9 +135,6 @@ int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *pat
if (!islnk)
gitfo_close(fd);
- if (error < GIT_SUCCESS)
- return git__rethrow(error, "Failed to create blob");
-
- return GIT_SUCCESS;
+ return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to create blob");
}