Git-Raw
view release on metacpan or search on metacpan
deps/libgit2/include/git2/odb.h view on Meta::CPAN
* the array entry will be zeroed.
*
* Note that since this function operates on multiple objects, the
* underlying database will not be asked to be reloaded if an object is
* not found (which is unlike other object database operations.)
*
* @param db The database to be searched for the given objects.
* @param ids An array of short object IDs to search for
* @param count The length of the `ids` array
* @return 0 on success or an error code on failure
*/
GIT_EXTERN(int) git_odb_expand_ids(
git_odb *db,
git_odb_expand_id *ids,
size_t count);
/**
* Refresh the object database to load newly added files.
*
* If the object databases have changed on disk while the library
* is running, this function will force a reload of the underlying
* indexes.
*
* Use this function when you're confident that an external
* application has tampered with the ODB.
*
* NOTE that it is not necessary to call this function at all. The
* library will automatically attempt to refresh the ODB
* when a lookup fails, to see if the looked up object exists
* on disk but hasn't been loaded yet.
*
* @param db database to refresh
* @return 0 on success, error code otherwise
*/
GIT_EXTERN(int) git_odb_refresh(struct git_odb *db);
/**
* List all objects available in the database
*
* The callback will be called for each object available in the
* database. Note that the objects are likely to be returned in the index
* order, which would make accessing the objects in that order inefficient.
* Return a non-zero value from the callback to stop looping.
*
* @param db database to use
* @param cb the callback to call for each object
* @param payload data to pass to the callback
* @return 0 on success, non-zero callback return value, or error code
*/
GIT_EXTERN(int) git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payload);
/**
* Write an object directly into the ODB
*
* This method writes a full object straight into the ODB.
* For most cases, it is preferred to write objects through a write
* stream, which is both faster and less memory intensive, specially
* for big objects.
*
* This method is provided for compatibility with custom backends
* which are not able to support streaming writes
*
* @param out pointer to store the OID result of the write
* @param odb object database where to store the object
* @param data buffer with the data to store
* @param len size of the buffer
* @param type type of the data to store
* @return 0 or an error code
*/
GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size_t len, git_object_t type);
/**
* Open a stream to write an object into the ODB
*
* The type and final length of the object must be specified
* when opening the stream.
*
* The returned stream will be of type `GIT_STREAM_WRONLY`, and it
* won't be effective until `git_odb_stream_finalize_write` is called
* and returns without an error
*
* The stream must always be freed when done with `git_odb_stream_free` or
* will leak memory.
*
* @see git_odb_stream
*
* @param out pointer where to store the stream
* @param db object database where the stream will write
* @param size final size of the object that will be written
* @param type type of the object that will be written
* @return 0 if the stream was created; error code otherwise
*/
GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, git_object_size_t size, git_object_t type);
/**
* Write to an odb stream
*
* This method will fail if the total number of received bytes exceeds the
* size declared with `git_odb_open_wstream()`
*
* @param stream the stream
* @param buffer the data to write
* @param len the buffer's length
* @return 0 if the write succeeded, error code otherwise
*/
GIT_EXTERN(int) git_odb_stream_write(git_odb_stream *stream, const char *buffer, size_t len);
/**
* Finish writing to an odb stream
*
* The object will take its final name and will be available to the
* odb.
*
* This method will fail if the total number of received bytes
* differs from the size declared with `git_odb_open_wstream()`
*
* @param out pointer to store the resulting object's id
* @param stream the stream
* @return 0 on success, an error code otherwise
*/
GIT_EXTERN(int) git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stream);
/**
* Read from an odb stream
*
* Most backends don't implement streaming reads
*
* @param stream the stream
* @param buffer a user-allocated buffer to store the data in.
* @param len the buffer's length
* @return 0 if the read succeeded, error code otherwise
*/
GIT_EXTERN(int) git_odb_stream_read(git_odb_stream *stream, char *buffer, size_t len);
/**
* Free an odb stream
*
* @param stream the stream to free
*/
GIT_EXTERN(void) git_odb_stream_free(git_odb_stream *stream);
/**
* Open a stream to read an object from the ODB
*
* Note that most backends do *not* support streaming reads
* because they store their objects as compressed/delta'ed blobs.
*
* It's recommended to use `git_odb_read` instead, which is
* assured to work on all backends.
*
* The returned stream will be of type `GIT_STREAM_RDONLY` and
* will have the following methods:
*
* - stream->read: read `n` bytes from the stream
* - stream->free: free the stream
*
* The stream must always be free'd or will leak memory.
*
* @see git_odb_stream
*
* @param out pointer where to store the stream
* @param len pointer where to store the length of the object
* @param type pointer where to store the type of the object
* @param db object database where the stream will read from
* @param oid oid of the object the stream will read from
* @return 0 if the stream was created, error code otherwise
*/
GIT_EXTERN(int) git_odb_open_rstream(
git_odb_stream **out,
size_t *len,
git_object_t *type,
git_odb *db,
const git_oid *oid);
/**
* Open a stream for writing a pack file to the ODB.
*
* If the ODB layer understands pack files, then the given
* packfile will likely be streamed directly to disk (and a
* corresponding index created). If the ODB layer does not
* understand pack files, the objects will be stored in whatever
* format the ODB layer uses.
*
* @see git_odb_writepack
*
* @param out pointer to the writepack functions
* @param db object database where the stream will read from
* @param progress_cb function to call with progress information.
* Be aware that this is called inline with network and indexing operations,
* so performance may be affected.
* @param progress_payload payload for the progress callback
* @return 0 or an error code.
*/
GIT_EXTERN(int) git_odb_write_pack(
git_odb_writepack **out,
git_odb *db,
git_indexer_progress_cb progress_cb,
void *progress_payload);
/**
* Write a `multi-pack-index` file from all the `.pack` files in the ODB.
*
* If the ODB layer understands pack files, then this will create a file called
* `multi-pack-index` next to the `.pack` and `.idx` files, which will contain
* an index of all objects stored in `.pack` files. This will allow for
( run in 2.961 seconds using v1.01-cache-2.11-cpan-140bd7fdf52 )