summaryrefslogtreecommitdiff
path: root/include/git2/blob.h
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-05-27 15:00:05 +0200
committernulltoken <emeric.fermas@gmail.com>2012-06-07 20:33:22 +0200
commitcd445767906aa60077ec7ecac562e08c83764430 (patch)
tree253bc11eea05ad1f9675da26a22d79a531941c2e /include/git2/blob.h
parent9bea8e85908d4c4a788766d50a91be79829c016c (diff)
downloadlibgit2-cd445767906aa60077ec7ecac562e08c83764430.tar.gz
blob: add git_blob_create_fromchunks()
Diffstat (limited to 'include/git2/blob.h')
-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