summaryrefslogtreecommitdiff
path: root/src/pack-objects.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2012-11-05 12:37:15 -0600
committerEdward Thomson <ethomson@edwardthomson.com>2012-11-13 10:23:05 -0600
commitd6fb09240913c9756de5f4a2462062008ebac252 (patch)
treec4a99509abd1dffdcd52353d551089f257b54c1e /src/pack-objects.c
parente45423dd2c5ef8262f70605b81c6da0751d000a3 (diff)
downloadlibgit2-d6fb09240913c9756de5f4a2462062008ebac252.tar.gz
Win32 CryptoAPI and CNG support for SHA1
Diffstat (limited to 'src/pack-objects.c')
-rw-r--r--src/pack-objects.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/pack-objects.c b/src/pack-objects.c
index 7acc93328..58a70d0e0 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -113,7 +113,7 @@ int git_packbuilder_new(git_packbuilder **out, git_repository *repo)
pb->repo = repo;
pb->nr_threads = 1; /* do not spawn any thread by default */
- pb->ctx = git_hash_new_ctx();
+ pb->ctx = git_hash_ctx_new();
if (!pb->ctx ||
git_repository_odb(&pb->odb, repo) < 0 ||
@@ -297,14 +297,13 @@ static int write_object(git_buf *buf, git_packbuilder *pb, git_pobject *po)
if (git_buf_put(buf, (char *)hdr, hdr_len) < 0)
goto on_error;
- git_hash_update(pb->ctx, hdr, hdr_len);
+ if (git_hash_update(pb->ctx, hdr, hdr_len) < 0)
+ goto on_error;
if (type == GIT_OBJ_REF_DELTA) {
- if (git_buf_put(buf, (char *)po->delta->id.id,
- GIT_OID_RAWSZ) < 0)
+ if (git_buf_put(buf, (char *)po->delta->id.id, GIT_OID_RAWSZ) < 0 ||
+ git_hash_update(pb->ctx, po->delta->id.id, GIT_OID_RAWSZ) < 0)
goto on_error;
-
- git_hash_update(pb->ctx, po->delta->id.id, GIT_OID_RAWSZ);
}
/* Write data */
@@ -319,11 +318,10 @@ static int write_object(git_buf *buf, git_packbuilder *pb, git_pobject *po)
size = zbuf.size;
}
- if (git_buf_put(buf, data, size) < 0)
+ if (git_buf_put(buf, data, size) < 0 ||
+ git_hash_update(pb->ctx, data, size) < 0)
goto on_error;
- git_hash_update(pb->ctx, data, size);
-
if (po->delta_data)
git__free(po->delta_data);
@@ -573,7 +571,8 @@ static int write_pack(git_packbuilder *pb,
if (cb(&ph, sizeof(ph), data) < 0)
goto on_error;
- git_hash_update(pb->ctx, &ph, sizeof(ph));
+ if (git_hash_update(pb->ctx, &ph, sizeof(ph)) < 0)
+ goto on_error;
pb->nr_remaining = pb->nr_objects;
do {
@@ -592,7 +591,9 @@ static int write_pack(git_packbuilder *pb,
git__free(write_order);
git_buf_free(&buf);
- git_hash_final(&pb->pack_oid, pb->ctx);
+
+ if (git_hash_final(&pb->pack_oid, pb->ctx) < 0)
+ goto on_error;
return cb(pb->pack_oid.id, GIT_OID_RAWSZ, data);
@@ -1319,7 +1320,7 @@ void git_packbuilder_free(git_packbuilder *pb)
git_odb_free(pb->odb);
if (pb->ctx)
- git_hash_free_ctx(pb->ctx);
+ git_hash_ctx_free(pb->ctx);
if (pb->object_ix)
git_oidmap_free(pb->object_ix);