#include "common.h"
#include "types.h"
#include "oid.h"
+#include "oidarray.h"
+#include "indexer.h"
/**
* @file git2/odb.h
/**
* Function type for callbacks from git_odb_foreach.
*/
-typedef int (*git_odb_foreach_cb)(const git_oid *id, void *payload);
+typedef int GIT_CALLBACK(git_odb_foreach_cb)(const git_oid *id, void *payload);
/**
* Create a new object database with no backends.
* - 0 if the object was read;
* - GIT_ENOTFOUND if the object is not in the database.
*/
-GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_otype *type_out, git_odb *db, const git_oid *id);
+GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_object_t *type_out, git_odb *db, const git_oid *id);
/**
* Determine if the given object can be found in the object database.
GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
/**
- * Determine if objects can be found in the object database from a short OID.
+ * Determine if an object can be found in the object database by an
+ * abbreviated object ID.
*
* @param out The full OID of the found object if just one is found.
* @param db The database to be searched for the given object.
GIT_EXTERN(int) git_odb_exists_prefix(
git_oid *out, git_odb *db, const git_oid *short_id, size_t len);
+/**
+ * The information about object IDs to query in `git_odb_expand_ids`,
+ * which will be populated upon return.
+ */
+typedef struct git_odb_expand_id {
+ /** The object ID to expand */
+ git_oid id;
+
+ /**
+ * The length of the object ID (in nibbles, or packets of 4 bits; the
+ * number of hex characters)
+ * */
+ unsigned short length;
+
+ /**
+ * The (optional) type of the object to search for; leave as `0` or set
+ * to `GIT_OBJECT_ANY` to query for any object matching the ID.
+ */
+ git_object_t type;
+} git_odb_expand_id;
+
+/**
+ * Determine if one or more objects can be found in the object database
+ * by their abbreviated object ID and type. The given array will be
+ * updated in place: for each abbreviated ID that is unique in the
+ * database, and of the given type (if specified), the full object ID,
+ * object ID length (`GIT_OID_HEXSZ`) and type will be written back to
+ * the array. For IDs that are not found (or are ambiguous), 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.
*
* @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_otype type);
+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
* @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_off_t size, git_otype type);
+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
* @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, git_odb *db, const git_oid *oid);
+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.
GIT_EXTERN(int) git_odb_write_pack(
git_odb_writepack **out,
git_odb *db,
- git_transfer_progress_cb progress_cb,
+ git_indexer_progress_cb progress_cb,
void *progress_payload);
/**
* @param type of the data to hash
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_odb_hash(git_oid *out, const void *data, size_t len, git_otype type);
+GIT_EXTERN(int) git_odb_hash(git_oid *out, const void *data, size_t len, git_object_t type);
/**
* Read a file from disk and fill a git_oid with the object id
* @param type the type of the object that will be hashed
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_otype type);
+GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_object_t type);
/**
* Create a copy of an odb_object
* @param object the object
* @return the type
*/
-GIT_EXTERN(git_otype) git_odb_object_type(git_odb_object *object);
+GIT_EXTERN(git_object_t) git_odb_object_type(git_odb_object *object);
/**
* Add a custom backend to an existing Object DB
* The backends are checked in relative ordering, based on the
* value of the `priority` parameter.
*
- * Read <odb_backends.h> for more information.
+ * Read <sys/odb_backend.h> for more information.
*
* @param odb database to add the backend to
* @param backend pointer to a git_odb_backend instance
*
* Writing is disabled on alternate backends.
*
- * Read <odb_backends.h> for more information.
+ * Read <sys/odb_backend.h> for more information.
*
* @param odb database to add the backend to
* @param backend pointer to a git_odb_backend instance