summaryrefslogtreecommitdiff
path: root/include/git2/odb.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/git2/odb.h')
-rw-r--r--include/git2/odb.h44
1 files changed, 37 insertions, 7 deletions
diff --git a/include/git2/odb.h b/include/git2/odb.h
index dd484553f..0ffe3f328 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -22,6 +22,17 @@
*/
GIT_BEGIN_DECL
+/** Flags controlling the behavior of ODB lookup operations */
+typedef enum {
+ /**
+ * Don't call `git_odb_refresh` if the lookup fails. Useful when doing
+ * a batch of lookup operations for objects that may legitimately not
+ * exist. When using this flag, you may wish to manually call
+ * `git_odb_refresh` before processing a batch of objects.
+ */
+ GIT_ODB_LOOKUP_NO_REFRESH = (1 << 0)
+} git_odb_lookup_flags_t;
+
/**
* Function type for callbacks from git_odb_foreach.
*/
@@ -156,6 +167,17 @@ GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_object_t *type_out, git
GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
/**
+ * Determine if the given object can be found in the object database, with
+ * extended options.
+ *
+ * @param db database to be searched for the given object.
+ * @param id the object to search for.
+ * @param flags flags affecting the lookup (see `git_odb_lookup_flags_t`)
+ * @return 1 if the object was found, 0 otherwise
+ */
+GIT_EXTERN(int) git_odb_exists_ext(git_odb *db, const git_oid *id, unsigned int flags);
+
+/**
* Determine if an object can be found in the object database by an
* abbreviated object ID.
*
@@ -192,12 +214,13 @@ typedef struct 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.
+ * 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
@@ -323,6 +346,11 @@ GIT_EXTERN(int) git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stre
* 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);
@@ -383,6 +411,7 @@ GIT_EXTERN(int) git_odb_open_rstream(
* 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,
@@ -400,6 +429,7 @@ GIT_EXTERN(int) git_odb_write_pack(
* exist).
*
* @param db object database where the `multi-pack-index` file will be written.
+ * @return 0 or an error code.
*/
GIT_EXTERN(int) git_odb_write_multi_pack_index(
git_odb *db);
@@ -556,7 +586,7 @@ GIT_EXTERN(int) git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t
/**
* Set the git commit-graph for the ODB.
*
- * After a successfull call, the ownership of the cgraph parameter will be
+ * After a successful call, the ownership of the cgraph parameter will be
* transferred to libgit2, and the caller should not free it.
*
* The commit-graph can also be unset by explicitly passing NULL as the cgraph