Blame include/git2/odb.h

Packit Service 20376f
/*
Packit Service 20376f
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit Service 20376f
 *
Packit Service 20376f
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit Service 20376f
 * a Linking Exception. For full terms see the included COPYING file.
Packit Service 20376f
 */
Packit Service 20376f
#ifndef INCLUDE_git_odb_h__
Packit Service 20376f
#define INCLUDE_git_odb_h__
Packit Service 20376f
Packit Service 20376f
#include "common.h"
Packit Service 20376f
#include "types.h"
Packit Service 20376f
#include "oid.h"
Packit Service 20376f
#include "oidarray.h"
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * @file git2/odb.h
Packit Service 20376f
 * @brief Git object database routines
Packit Service 20376f
 * @defgroup git_odb Git object database routines
Packit Service 20376f
 * @ingroup Git
Packit Service 20376f
 * @{
Packit Service 20376f
 */
Packit Service 20376f
GIT_BEGIN_DECL
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Function type for callbacks from git_odb_foreach.
Packit Service 20376f
 */
Packit Service 20376f
typedef int (*git_odb_foreach_cb)(const git_oid *id, void *payload);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Create a new object database with no backends.
Packit Service 20376f
 *
Packit Service 20376f
 * Before the ODB can be used for read/writing, a custom database
Packit Service 20376f
 * backend must be manually added using `git_odb_add_backend()`
Packit Service 20376f
 *
Packit Service 20376f
 * @param out location to store the database pointer, if opened.
Packit Service 20376f
 *			Set to NULL if the open failed.
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_new(git_odb **out);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Create a new object database and automatically add
Packit Service 20376f
 * the two default backends:
Packit Service 20376f
 *
Packit Service 20376f
 *	- git_odb_backend_loose: read and write loose object files
Packit Service 20376f
 *		from disk, assuming `objects_dir` as the Objects folder
Packit Service 20376f
 *
Packit Service 20376f
 *	- git_odb_backend_pack: read objects from packfiles,
Packit Service 20376f
 *		assuming `objects_dir` as the Objects folder which
Packit Service 20376f
 *		contains a 'pack/' folder with the corresponding data
Packit Service 20376f
 *
Packit Service 20376f
 * @param out location to store the database pointer, if opened.
Packit Service 20376f
 *			Set to NULL if the open failed.
Packit Service 20376f
 * @param objects_dir path of the backends' "objects" directory.
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_open(git_odb **out, const char *objects_dir);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Add an on-disk alternate to an existing Object DB.
Packit Service 20376f
 *
Packit Service 20376f
 * Note that the added path must point to an `objects`, not
Packit Service 20376f
 * to a full repository, to use it as an alternate store.
Packit Service 20376f
 *
Packit Service 20376f
 * Alternate backends are always checked for objects *after*
Packit Service 20376f
 * all the main backends have been exhausted.
Packit Service 20376f
 *
Packit Service 20376f
 * Writing is disabled on alternate backends.
Packit Service 20376f
 *
Packit Service 20376f
 * @param odb database to add the backend to
Packit Service 20376f
 * @param path path to the objects folder for the alternate
Packit Service 20376f
 * @return 0 on success; error code otherwise
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_add_disk_alternate(git_odb *odb, const char *path);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Close an open object database.
Packit Service 20376f
 *
Packit Service 20376f
 * @param db database pointer to close. If NULL no action is taken.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(void) git_odb_free(git_odb *db);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Read an object from the database.
Packit Service 20376f
 *
Packit Service 20376f
 * This method queries all available ODB backends
Packit Service 20376f
 * trying to read the given OID.
Packit Service 20376f
 *
Packit Service 20376f
 * The returned object is reference counted and
Packit Service 20376f
 * internally cached, so it should be closed
Packit Service 20376f
 * by the user once it's no longer in use.
Packit Service 20376f
 *
Packit Service 20376f
 * @param out pointer where to store the read object
Packit Service 20376f
 * @param db database to search for the object in.
Packit Service 20376f
 * @param id identity of the object to read.
Packit Service 20376f
 * @return
Packit Service 20376f
 * - 0 if the object was read;
Packit Service 20376f
 * - GIT_ENOTFOUND if the object is not in the database.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Read an object from the database, given a prefix
Packit Service 20376f
 * of its identifier.
Packit Service 20376f
 *
Packit Service 20376f
 * This method queries all available ODB backends
Packit Service 20376f
 * trying to match the 'len' first hexadecimal
Packit Service 20376f
 * characters of the 'short_id'.
Packit Service 20376f
 * The remaining (GIT_OID_HEXSZ-len)*4 bits of
Packit Service 20376f
 * 'short_id' must be 0s.
Packit Service 20376f
 * 'len' must be at least GIT_OID_MINPREFIXLEN,
Packit Service 20376f
 * and the prefix must be long enough to identify
Packit Service 20376f
 * a unique object in all the backends; the
Packit Service 20376f
 * method will fail otherwise.
Packit Service 20376f
 *
Packit Service 20376f
 * The returned object is reference counted and
Packit Service 20376f
 * internally cached, so it should be closed
Packit Service 20376f
 * by the user once it's no longer in use.
Packit Service 20376f
 *
Packit Service 20376f
 * @param out pointer where to store the read object
Packit Service 20376f
 * @param db database to search for the object in.
Packit Service 20376f
 * @param short_id a prefix of the id of the object to read.
Packit Service 20376f
 * @param len the length of the prefix
Packit Service 20376f
 * @return
Packit Service 20376f
 * - 0 if the object was read;
Packit Service 20376f
 * - GIT_ENOTFOUND if the object is not in the database.
Packit Service 20376f
 * - GIT_EAMBIGUOUS if the prefix is ambiguous (several objects match the prefix)
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git_oid *short_id, size_t len);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Read the header of an object from the database, without
Packit Service 20376f
 * reading its full contents.
Packit Service 20376f
 *
Packit Service 20376f
 * The header includes the length and the type of an object.
Packit Service 20376f
 *
Packit Service 20376f
 * Note that most backends do not support reading only the header
Packit Service 20376f
 * of an object, so the whole object will be read and then the
Packit Service 20376f
 * header will be returned.
Packit Service 20376f
 *
Packit Service 20376f
 * @param len_out pointer where to store the length
Packit Service 20376f
 * @param type_out pointer where to store the type
Packit Service 20376f
 * @param db database to search for the object in.
Packit Service 20376f
 * @param id identity of the object to read.
Packit Service 20376f
 * @return
Packit Service 20376f
 * - 0 if the object was read;
Packit Service 20376f
 * - GIT_ENOTFOUND if the object is not in the database.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_otype *type_out, git_odb *db, const git_oid *id);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Determine if the given object can be found in the object database.
Packit Service 20376f
 *
Packit Service 20376f
 * @param db database to be searched for the given object.
Packit Service 20376f
 * @param id the object to search for.
Packit Service 20376f
 * @return
Packit Service 20376f
 * - 1, if the object was found
Packit Service 20376f
 * - 0, otherwise
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Determine if an object can be found in the object database by an
Packit Service 20376f
 * abbreviated object ID.
Packit Service 20376f
 *
Packit Service 20376f
 * @param out The full OID of the found object if just one is found.
Packit Service 20376f
 * @param db The database to be searched for the given object.
Packit Service 20376f
 * @param short_id A prefix of the id of the object to read.
Packit Service 20376f
 * @param len The length of the prefix.
Packit Service 20376f
 * @return 0 if found, GIT_ENOTFOUND if not found, GIT_EAMBIGUOUS if multiple
Packit Service 20376f
 *         matches were found, other value < 0 if there was a read error.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_exists_prefix(
Packit Service 20376f
	git_oid *out, git_odb *db, const git_oid *short_id, size_t len);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * The information about object IDs to query in `git_odb_expand_ids`,
Packit Service 20376f
 * which will be populated upon return.
Packit Service 20376f
 */
Packit Service 20376f
typedef struct git_odb_expand_id {
Packit Service 20376f
	/** The object ID to expand */
Packit Service 20376f
	git_oid id;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * The length of the object ID (in nibbles, or packets of 4 bits; the
Packit Service 20376f
	 * number of hex characters)
Packit Service 20376f
	 * */
Packit Service 20376f
	unsigned short length;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * The (optional) type of the object to search for; leave as `0` or set
Packit Service 20376f
	 * to `GIT_OBJ_ANY` to query for any object matching the ID.
Packit Service 20376f
	 */
Packit Service 20376f
	git_otype type;
Packit Service 20376f
} git_odb_expand_id;
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Determine if one or more objects can be found in the object database
Packit Service 20376f
 * by their abbreviated object ID and type.  The given array will be
Packit Service 20376f
 * updated in place:  for each abbreviated ID that is unique in the
Packit Service 20376f
 * database, and of the given type (if specified), the full object ID,
Packit Service 20376f
 * object ID length (`GIT_OID_HEXSZ`) and type will be written back to
Packit Service 20376f
 * the array.  For IDs that are not found (or are ambiguous), the
Packit Service 20376f
 * array entry will be zeroed.
Packit Service 20376f
 *
Packit Service 20376f
 * Note that since this function operates on multiple objects, the
Packit Service 20376f
 * underlying database will not be asked to be reloaded if an object is
Packit Service 20376f
 * not found (which is unlike other object database operations.)
Packit Service 20376f
 *
Packit Service 20376f
 * @param db The database to be searched for the given objects.
Packit Service 20376f
 * @param ids An array of short object IDs to search for
Packit Service 20376f
 * @param count The length of the `ids` array
Packit Service 20376f
 * @return 0 on success or an error code on failure
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_expand_ids(
Packit Service 20376f
	git_odb *db,
Packit Service 20376f
	git_odb_expand_id *ids,
Packit Service 20376f
	size_t count);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Refresh the object database to load newly added files.
Packit Service 20376f
 *
Packit Service 20376f
 * If the object databases have changed on disk while the library
Packit Service 20376f
 * is running, this function will force a reload of the underlying
Packit Service 20376f
 * indexes.
Packit Service 20376f
 *
Packit Service 20376f
 * Use this function when you're confident that an external
Packit Service 20376f
 * application has tampered with the ODB.
Packit Service 20376f
 *
Packit Service 20376f
 * NOTE that it is not necessary to call this function at all. The
Packit Service 20376f
 * library will automatically attempt to refresh the ODB
Packit Service 20376f
 * when a lookup fails, to see if the looked up object exists
Packit Service 20376f
 * on disk but hasn't been loaded yet.
Packit Service 20376f
 *
Packit Service 20376f
 * @param db database to refresh
Packit Service 20376f
 * @return 0 on success, error code otherwise
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_refresh(struct git_odb *db);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * List all objects available in the database
Packit Service 20376f
 *
Packit Service 20376f
 * The callback will be called for each object available in the
Packit Service 20376f
 * database. Note that the objects are likely to be returned in the index
Packit Service 20376f
 * order, which would make accessing the objects in that order inefficient.
Packit Service 20376f
 * Return a non-zero value from the callback to stop looping.
Packit Service 20376f
 *
Packit Service 20376f
 * @param db database to use
Packit Service 20376f
 * @param cb the callback to call for each object
Packit Service 20376f
 * @param payload data to pass to the callback
Packit Service 20376f
 * @return 0 on success, non-zero callback return value, or error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payload);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Write an object directly into the ODB
Packit Service 20376f
 *
Packit Service 20376f
 * This method writes a full object straight into the ODB.
Packit Service 20376f
 * For most cases, it is preferred to write objects through a write
Packit Service 20376f
 * stream, which is both faster and less memory intensive, specially
Packit Service 20376f
 * for big objects.
Packit Service 20376f
 *
Packit Service 20376f
 * This method is provided for compatibility with custom backends
Packit Service 20376f
 * which are not able to support streaming writes
Packit Service 20376f
 *
Packit Service 20376f
 * @param out pointer to store the OID result of the write
Packit Service 20376f
 * @param odb object database where to store the object
Packit Service 20376f
 * @param data buffer with the data to store
Packit Service 20376f
 * @param len size of the buffer
Packit Service 20376f
 * @param type type of the data to store
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size_t len, git_otype type);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Open a stream to write an object into the ODB
Packit Service 20376f
 *
Packit Service 20376f
 * The type and final length of the object must be specified
Packit Service 20376f
 * when opening the stream.
Packit Service 20376f
 *
Packit Service 20376f
 * The returned stream will be of type `GIT_STREAM_WRONLY`, and it
Packit Service 20376f
 * won't be effective until `git_odb_stream_finalize_write` is called
Packit Service 20376f
 * and returns without an error
Packit Service 20376f
 *
Packit Service 20376f
 * The stream must always be freed when done with `git_odb_stream_free` or
Packit Service 20376f
 * will leak memory.
Packit Service 20376f
 *
Packit Service 20376f
 * @see git_odb_stream
Packit Service 20376f
 *
Packit Service 20376f
 * @param out pointer where to store the stream
Packit Service 20376f
 * @param db object database where the stream will write
Packit Service 20376f
 * @param size final size of the object that will be written
Packit Service 20376f
 * @param type type of the object that will be written
Packit Service 20376f
 * @return 0 if the stream was created; error code otherwise
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, git_off_t size, git_otype type);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Write to an odb stream
Packit Service 20376f
 *
Packit Service 20376f
 * This method will fail if the total number of received bytes exceeds the
Packit Service 20376f
 * size declared with `git_odb_open_wstream()`
Packit Service 20376f
 *
Packit Service 20376f
 * @param stream the stream
Packit Service 20376f
 * @param buffer the data to write
Packit Service 20376f
 * @param len the buffer's length
Packit Service 20376f
 * @return 0 if the write succeeded; error code otherwise
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_stream_write(git_odb_stream *stream, const char *buffer, size_t len);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Finish writing to an odb stream
Packit Service 20376f
 *
Packit Service 20376f
 * The object will take its final name and will be available to the
Packit Service 20376f
 * odb.
Packit Service 20376f
 *
Packit Service 20376f
 * This method will fail if the total number of received bytes
Packit Service 20376f
 * differs from the size declared with `git_odb_open_wstream()`
Packit Service 20376f
 *
Packit Service 20376f
 * @param out pointer to store the resulting object's id
Packit Service 20376f
 * @param stream the stream
Packit Service 20376f
 * @return 0 on success; an error code otherwise
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stream);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Read from an odb stream
Packit Service 20376f
 *
Packit Service 20376f
 * Most backends don't implement streaming reads
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_stream_read(git_odb_stream *stream, char *buffer, size_t len);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Free an odb stream
Packit Service 20376f
 *
Packit Service 20376f
 * @param stream the stream to free
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(void) git_odb_stream_free(git_odb_stream *stream);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Open a stream to read an object from the ODB
Packit Service 20376f
 *
Packit Service 20376f
 * Note that most backends do *not* support streaming reads
Packit Service 20376f
 * because they store their objects as compressed/delta'ed blobs.
Packit Service 20376f
 *
Packit Service 20376f
 * It's recommended to use `git_odb_read` instead, which is
Packit Service 20376f
 * assured to work on all backends.
Packit Service 20376f
 *
Packit Service 20376f
 * The returned stream will be of type `GIT_STREAM_RDONLY` and
Packit Service 20376f
 * will have the following methods:
Packit Service 20376f
 *
Packit Service 20376f
 *		- stream->read: read `n` bytes from the stream
Packit Service 20376f
 *		- stream->free: free the stream
Packit Service 20376f
 *
Packit Service 20376f
 * The stream must always be free'd or will leak memory.
Packit Service 20376f
 *
Packit Service 20376f
 * @see git_odb_stream
Packit Service 20376f
 *
Packit Service 20376f
 * @param out pointer where to store the stream
Packit Service 20376f
 * @param db object database where the stream will read from
Packit Service 20376f
 * @param oid oid of the object the stream will read from
Packit Service 20376f
 * @return 0 if the stream was created; error code otherwise
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_open_rstream(git_odb_stream **out, git_odb *db, const git_oid *oid);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Open a stream for writing a pack file to the ODB.
Packit Service 20376f
 *
Packit Service 20376f
 * If the ODB layer understands pack files, then the given
Packit Service 20376f
 * packfile will likely be streamed directly to disk (and a
Packit Service 20376f
 * corresponding index created).  If the ODB layer does not
Packit Service 20376f
 * understand pack files, the objects will be stored in whatever
Packit Service 20376f
 * format the ODB layer uses.
Packit Service 20376f
 *
Packit Service 20376f
 * @see git_odb_writepack
Packit Service 20376f
 *
Packit Service 20376f
 * @param out pointer to the writepack functions
Packit Service 20376f
 * @param db object database where the stream will read from
Packit Service 20376f
 * @param progress_cb function to call with progress information.
Packit Service 20376f
 * Be aware that this is called inline with network and indexing operations,
Packit Service 20376f
 * so performance may be affected.
Packit Service 20376f
 * @param progress_payload payload for the progress callback
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_write_pack(
Packit Service 20376f
	git_odb_writepack **out,
Packit Service 20376f
	git_odb *db,
Packit Service 20376f
	git_transfer_progress_cb progress_cb,
Packit Service 20376f
	void *progress_payload);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Determine the object-ID (sha1 hash) of a data buffer
Packit Service 20376f
 *
Packit Service 20376f
 * The resulting SHA-1 OID will be the identifier for the data
Packit Service 20376f
 * buffer as if the data buffer it were to written to the ODB.
Packit Service 20376f
 *
Packit Service 20376f
 * @param out the resulting object-ID.
Packit Service 20376f
 * @param data data to hash
Packit Service 20376f
 * @param len size of the data
Packit Service 20376f
 * @param type of the data to hash
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_hash(git_oid *out, const void *data, size_t len, git_otype type);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Read a file from disk and fill a git_oid with the object id
Packit Service 20376f
 * that the file would have if it were written to the Object
Packit Service 20376f
 * Database as an object of the given type (w/o applying filters).
Packit Service 20376f
 * Similar functionality to git.git's `git hash-object` without
Packit Service 20376f
 * the `-w` flag, however, with the --no-filters flag.
Packit Service 20376f
 * If you need filters, see git_repository_hashfile.
Packit Service 20376f
 *
Packit Service 20376f
 * @param out oid structure the result is written into.
Packit Service 20376f
 * @param path file to read and determine object id for
Packit Service 20376f
 * @param type the type of the object that will be hashed
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_otype type);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Create a copy of an odb_object
Packit Service 20376f
 *
Packit Service 20376f
 * The returned copy must be manually freed with `git_odb_object_free`.
Packit Service 20376f
 * Note that because of an implementation detail, the returned copy will be
Packit Service 20376f
 * the same pointer as `source`: the object is internally refcounted, so the
Packit Service 20376f
 * copy still needs to be freed twice.
Packit Service 20376f
 *
Packit Service 20376f
 * @param dest pointer where to store the copy
Packit Service 20376f
 * @param source object to copy
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_object_dup(git_odb_object **dest, git_odb_object *source);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Close an ODB object
Packit Service 20376f
 *
Packit Service 20376f
 * This method must always be called once a `git_odb_object` is no
Packit Service 20376f
 * longer needed, otherwise memory will leak.
Packit Service 20376f
 *
Packit Service 20376f
 * @param object object to close
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(void) git_odb_object_free(git_odb_object *object);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Return the OID of an ODB object
Packit Service 20376f
 *
Packit Service 20376f
 * This is the OID from which the object was read from
Packit Service 20376f
 *
Packit Service 20376f
 * @param object the object
Packit Service 20376f
 * @return a pointer to the OID
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(const git_oid *) git_odb_object_id(git_odb_object *object);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Return the data of an ODB object
Packit Service 20376f
 *
Packit Service 20376f
 * This is the uncompressed, raw data as read from the ODB,
Packit Service 20376f
 * without the leading header.
Packit Service 20376f
 *
Packit Service 20376f
 * This pointer is owned by the object and shall not be free'd.
Packit Service 20376f
 *
Packit Service 20376f
 * @param object the object
Packit Service 20376f
 * @return a pointer to the data
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(const void *) git_odb_object_data(git_odb_object *object);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Return the size of an ODB object
Packit Service 20376f
 *
Packit Service 20376f
 * This is the real size of the `data` buffer, not the
Packit Service 20376f
 * actual size of the object.
Packit Service 20376f
 *
Packit Service 20376f
 * @param object the object
Packit Service 20376f
 * @return the size
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(size_t) git_odb_object_size(git_odb_object *object);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Return the type of an ODB object
Packit Service 20376f
 *
Packit Service 20376f
 * @param object the object
Packit Service 20376f
 * @return the type
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(git_otype) git_odb_object_type(git_odb_object *object);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Add a custom backend to an existing Object DB
Packit Service 20376f
 *
Packit Service 20376f
 * The backends are checked in relative ordering, based on the
Packit Service 20376f
 * value of the `priority` parameter.
Packit Service 20376f
 *
Packit Service 20376f
 * Read <sys/odb_backend.h> for more information.
Packit Service 20376f
 *
Packit Service 20376f
 * @param odb database to add the backend to
Packit Service 20376f
 * @param backend pointer to a git_odb_backend instance
Packit Service 20376f
 * @param priority Value for ordering the backends queue
Packit Service 20376f
 * @return 0 on success; error code otherwise
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Add a custom backend to an existing Object DB; this
Packit Service 20376f
 * backend will work as an alternate.
Packit Service 20376f
 *
Packit Service 20376f
 * Alternate backends are always checked for objects *after*
Packit Service 20376f
 * all the main backends have been exhausted.
Packit Service 20376f
 *
Packit Service 20376f
 * The backends are checked in relative ordering, based on the
Packit Service 20376f
 * value of the `priority` parameter.
Packit Service 20376f
 *
Packit Service 20376f
 * Writing is disabled on alternate backends.
Packit Service 20376f
 *
Packit Service 20376f
 * Read <sys/odb_backend.h> for more information.
Packit Service 20376f
 *
Packit Service 20376f
 * @param odb database to add the backend to
Packit Service 20376f
 * @param backend pointer to a git_odb_backend instance
Packit Service 20376f
 * @param priority Value for ordering the backends queue
Packit Service 20376f
 * @return 0 on success; error code otherwise
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get the number of ODB backend objects
Packit Service 20376f
 *
Packit Service 20376f
 * @param odb object database
Packit Service 20376f
 * @return number of backends in the ODB
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(size_t) git_odb_num_backends(git_odb *odb);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Lookup an ODB backend object by index
Packit Service 20376f
 *
Packit Service 20376f
 * @param out output pointer to ODB backend at pos
Packit Service 20376f
 * @param odb object database
Packit Service 20376f
 * @param pos index into object database backend list
Packit Service 20376f
 * @return 0 on success; GIT_ENOTFOUND if pos is invalid; other errors < 0
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos);
Packit Service 20376f
Packit Service 20376f
/** @} */
Packit Service 20376f
GIT_END_DECL
Packit Service 20376f
#endif