summaryrefslogtreecommitdiff
path: root/src/odb.c
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2013-08-29 14:19:34 +0200
committernulltoken <emeric.fermas@gmail.com>2013-09-06 22:47:28 +0200
commit4047950f30618c160cd2fdf5da39fb8e26b031d9 (patch)
treebd6682f4c713b9a012582a0cffe60137c24b235d /src/odb.c
parentae4a486605c258aa38a53534c99f94e66379c9ae (diff)
downloadlibgit2-4047950f30618c160cd2fdf5da39fb8e26b031d9.tar.gz
odb: Prevent stream_finalize_write() from overwriting
Now that #1785 is merged, git_odb_stream_finalize_write() calculates the object id before invoking the odb backend. This commit gives a chance to the backend to check if it already knows this object.
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 e47715f79..dfb252178 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -900,6 +900,10 @@ int git_odb_stream_write(git_odb_stream *stream, const char *buffer, size_t len)
int git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stream)
{
git_hash_final(out, stream->hash_ctx);
+
+ if (git_odb_exists(stream->backend->odb, out))
+ return 0;
+
return stream->finalize_write(stream, out);
}