summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2012-07-12 09:42:54 -0700
committerVicent Martí <vicent@github.com>2012-07-12 09:42:54 -0700
commitdd4345b4247f067e282ccbcde0f0b36d3d571470 (patch)
tree7db054c78dd6335c3308fb7ea02e82cf6c178720 /include
parent0cf6b2f29ebf9d6342bd205197938e881ccc246f (diff)
parent521aedad307c6f72d6f6d660943508b2b015f6dd (diff)
downloadlibgit2-dd4345b4247f067e282ccbcde0f0b36d3d571470.tar.gz
Merge pull request #789 from carlosmn/odb-foreach
odb: add git_odb_foreach()
Diffstat (limited to 'include')
-rw-r--r--include/git2/odb.h14
-rw-r--r--include/git2/odb_backend.h6
2 files changed, 20 insertions, 0 deletions
diff --git a/include/git2/odb.h b/include/git2/odb.h
index e2443178c..dac9e06a9 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -173,6 +173,20 @@ GIT_EXTERN(int) git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *d
GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
/**
+ * 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.
+ *
+ * @param db database to use
+ * @param cb the callback to call for each object
+ * @param data data to pass to the callback
+ */
+GIT_EXTERN(int) git_odb_foreach(git_odb *db, int (*cb)(git_oid *oid, void *data), void *data);
+
+/**
* Write an object directly into the ODB
*
* This method writes a full object straight into the ODB.
diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h
index f4620f5f4..3f67202d1 100644
--- a/include/git2/odb_backend.h
+++ b/include/git2/odb_backend.h
@@ -71,6 +71,12 @@ struct git_odb_backend {
struct git_odb_backend *,
const git_oid *);
+ int (*foreach)(
+ struct git_odb_backend *,
+ int (*cb)(git_oid *oid, void *data),
+ void *data
+ );
+
void (* free)(struct git_odb_backend *);
};