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.
This commit is contained in:
nulltoken
2013-08-29 14:19:34 +02:00
parent ae4a486605
commit 4047950f30
4 changed files with 36 additions and 7 deletions

View File

@@ -92,6 +92,10 @@ struct git_odb_stream {
/**
* Store the contents of the stream as an object with the id
* specified in `oid`.
*
* This method will *not* be invoked by libgit2 if the object pointed at
* by `oid` already exists in any backend. Libgit2 will however take care
* of properly disposing the stream through a call to `free()`.
*/
int (*finalize_write)(git_odb_stream *stream, const git_oid *oid);