summaryrefslogtreecommitdiff
path: root/src/odb.c
diff options
context:
space:
mode:
authorDavid Michael Barr <b@rr-dav.id.au>2012-12-19 14:30:06 +1100
committerDavid Michael Barr <b@rr-dav.id.au>2012-12-21 13:05:20 +1100
commit4d185dd9b0dde93bf30b250e6c7dd751bc893268 (patch)
tree5400c2cd3b547a84ccefb4b1e1779b81b0091d3b /src/odb.c
parente62171e2fc1b101512a7e86f6d990a38b78ed12b (diff)
downloadlibgit2-4d185dd9b0dde93bf30b250e6c7dd751bc893268.tar.gz
odb: check if object exists before writing
Update the procondition of git_odb_backend::write. It may now be assumed that the object has already been hashed.
Diffstat (limited to 'src/odb.c')
-rw-r--r--src/odb.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/odb.c b/src/odb.c
index 2385a580c..1995669d9 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -713,6 +713,10 @@ int git_odb_write(
assert(oid && db);
+ git_odb_hash(oid, data, len, type);
+ if (git_odb_exists(db, oid))
+ return 0;
+
for (i = 0; i < db->backends.length && error < 0; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;