summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2012-06-07 11:34:48 -0700
committerVicent Martí <vicent@github.com>2012-06-07 11:34:48 -0700
commitcddb8efe564738873a4cf9ac63b7976d74035ae9 (patch)
treeeac28e45715c4e3861b060562ecf8bae20f55aa8 /include
parent5bb545822d2cea1dd1d5fa8da18fe08e85724bc8 (diff)
parentcd445767906aa60077ec7ecac562e08c83764430 (diff)
downloadlibgit2-cddb8efe564738873a4cf9ac63b7976d74035ae9.tar.gz
Merge pull request #704 from nulltoken/topic/blob_fromchunks
Add the ability to create blob given a provider of chunks of bytes
Diffstat (limited to 'include')
-rw-r--r--include/git2/blob.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/include/git2/blob.h b/include/git2/blob.h
index 551770678..544dc7c41 100644
--- a/include/git2/blob.h
+++ b/include/git2/blob.h
@@ -115,6 +115,48 @@ GIT_EXTERN(int) git_blob_create_fromfile(git_oid *oid, git_repository *repo, con
*/
GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *oid, git_repository *repo, const char *path);
+/**
+ * Write a loose blob to the Object Database from a
+ * provider of chunks of data.
+ *
+ * Provided the `hintpath` parameter is filled, its value
+ * will help to determine what git filters should be applied
+ * to the object before it can be placed to the object database.
+ *
+ *
+ * The implementation of the callback has to respect the
+ * following rules:
+ *
+ * - `content` will have to be filled by the consumer. The maximum number
+ * of bytes that the buffer can accept per call is defined by the
+ * `max_length` parameter. Allocation and freeing of the buffer will be taken
+ * care of by the function.
+ *
+ * - The callback is expected to return the number of bytes
+ * that `content` have been filled with.
+ *
+ * - When there is no more data to stream, the callback should
+ * return 0. This will prevent it from being invoked anymore.
+ *
+ * - When an error occurs, the callback should return -1.
+ *
+ *
+ * @param oid Return the id of the written blob
+ *
+ * @param repo repository where the blob will be written.
+ * This repository can be bare or not.
+ *
+ * @param hintpath if not NULL, will help selecting the filters
+ * to apply onto the content of the blob to be created.
+ *
+ * @return GIT_SUCCESS or an error code
+ */
+GIT_EXTERN(int) git_blob_create_fromchunks(
+ git_oid *oid,
+ git_repository *repo,
+ const char *hintpath,
+ int (*source_cb)(char *content, size_t max_length, void *payload),
+ void *payload);
/**
* Write an in-memory buffer to the ODB as a blob