summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-11-12 10:31:48 +0000
committerPatrick Steinhardt <ps@pks.im>2018-06-22 09:52:12 +0200
commitc16556aaddffc1d663c6403747d793adc0819e0a (patch)
tree6bf65254b08ffa9eb528e392b8b44bc274eedcba /include/git2
parenta616fb1668fcf406dbcd8dcc241d5a3613669e62 (diff)
downloadlibgit2-c16556aaddffc1d663c6403747d793adc0819e0a.tar.gz
indexer: introduce options struct to `git_indexer_new`
We strive to keep an options structure to many functions to be able to extend options in the future without breaking the API. `git_indexer_new` doesn't have one right now, but we want to be able to add an option for enabling strict packfile verification. Add a new `git_indexer_options` structure and adjust callers to use that.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/indexer.h31
1 files changed, 27 insertions, 4 deletions
diff --git a/include/git2/indexer.h b/include/git2/indexer.h
index d2d315e47..53a59fc81 100644
--- a/include/git2/indexer.h
+++ b/include/git2/indexer.h
@@ -15,6 +15,30 @@ GIT_BEGIN_DECL
typedef struct git_indexer git_indexer;
+typedef struct git_indexer_options {
+ unsigned int version;
+
+ /** progress_cb function to call with progress information */
+ git_transfer_progress_cb progress_cb;
+ /** progress_cb_payload payload for the progress callback */
+ void *progress_cb_payload;
+} git_indexer_options;
+
+#define GIT_INDEXER_OPTIONS_VERSION 1
+#define GIT_INDEXER_OPTIONS_INIT { GIT_INDEXER_OPTIONS_VERSION }
+
+/**
+ * Initializes a `git_indexer_options` with default values. Equivalent to
+ * creating an instance with GIT_INDEXER_OPTIONS_INIT.
+ *
+ * @param opts the `git_indexer_options` struct to initialize.
+ * @param version Version of struct; pass `GIT_INDEXER_OPTIONS_VERSION`
+ * @return Zero on success; -1 on failure.
+ */
+GIT_EXTERN(int) git_indexer_init_options(
+ git_indexer_options *opts,
+ unsigned int version);
+
/**
* Create a new indexer instance
*
@@ -24,16 +48,15 @@ typedef struct git_indexer git_indexer;
* @param odb object database from which to read base objects when
* fixing thin packs. Pass NULL if no thin pack is expected (an error
* will be returned if there are bases missing)
- * @param progress_cb function to call with progress information
- * @param progress_cb_payload payload for the progress callback
+ * @param opts Optional structure containing additional options. See
+ * `git_indexer_options` above.
*/
GIT_EXTERN(int) git_indexer_new(
git_indexer **out,
const char *path,
unsigned int mode,
git_odb *odb,
- git_transfer_progress_cb progress_cb,
- void *progress_cb_payload);
+ git_indexer_options *opts);
/**
* Add data to the indexer