summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2012-11-29 12:26:09 -0800
committerBen Straub <bs@github.com>2012-11-30 12:55:45 -0800
commitbde336ea51df071de922827ae322df7b01b059ce (patch)
tree1fbf4d0e9bf4dc9499abd83226e2452f6e8047c8 /include
parentda820437368aae2088e992e7ce8944253693aa16 (diff)
downloadlibgit2-bde336ea51df071de922827ae322df7b01b059ce.tar.gz
Add version fields and init macros for public input structs.
Diffstat (limited to 'include')
-rw-r--r--include/git2/checkout.h3
-rw-r--r--include/git2/config.h3
-rw-r--r--include/git2/diff.h21
-rw-r--r--include/git2/odb_backend.h4
-rw-r--r--include/git2/remote.h4
-rw-r--r--include/git2/repository.h4
-rw-r--r--include/git2/status.h3
-rw-r--r--include/git2/transport.h9
-rw-r--r--include/git2/types.h4
9 files changed, 46 insertions, 9 deletions
diff --git a/include/git2/checkout.h b/include/git2/checkout.h
index bd988db2c..ea6e219ba 100644
--- a/include/git2/checkout.h
+++ b/include/git2/checkout.h
@@ -186,7 +186,8 @@ typedef struct git_checkout_opts {
git_strarray paths;
} git_checkout_opts;
-#define GIT_CHECKOUT_OPTS_INIT {1, 0}
+#define GIT_CHECKOUT_OPTS_VERSION 1
+#define GIT_CHECKOUT_OPTS_INIT {GIT_CHECKOUT_OPTS_VERSION, 0}
/**
* Updates files in the index and the working tree to match the content of the
diff --git a/include/git2/config.h b/include/git2/config.h
index af4d54044..4855babec 100644
--- a/include/git2/config.h
+++ b/include/git2/config.h
@@ -49,6 +49,7 @@ typedef int (*git_config_foreach_cb)(const git_config_entry *, void *);
* access a configuration file
*/
struct git_config_backend {
+ unsigned int version;
struct git_config *cfg;
/* Open means open the file/database and parse if necessary */
@@ -62,6 +63,8 @@ struct git_config_backend {
int (*refresh)(struct git_config_backend *);
void (*free)(struct git_config_backend *);
};
+#define GIT_CONFIG_BACKEND_VERSION 1
+#define GIT_CONFIG_BACKEND_INIT {GIT_CONFIG_BACKEND_VERSION, 0}
typedef enum {
GIT_CVAR_FALSE = 0,
diff --git a/include/git2/diff.h b/include/git2/diff.h
index fd00378af..855e4beed 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -106,16 +106,19 @@ typedef enum {
* - max_size: maximum blob size to diff, above this treated as binary
*/
typedef struct {
- unsigned int version; /**< version for the struct */
- uint32_t flags; /**< defaults to GIT_DIFF_NORMAL */
- uint16_t context_lines; /**< defaults to 3 */
- uint16_t interhunk_lines; /**< defaults to 0 */
- char *old_prefix; /**< defaults to "a" */
- char *new_prefix; /**< defaults to "b" */
- git_strarray pathspec; /**< defaults to show all paths */
- git_off_t max_size; /**< defaults to 512Mb */
+ unsigned int version; /**< version for the struct */
+ uint32_t flags; /**< defaults to git_diff_normal */
+ uint16_t context_lines; /**< defaults to 3 */
+ uint16_t interhunk_lines; /**< defaults to 0 */
+ char *old_prefix; /**< defaults to "a" */
+ char *new_prefix; /**< defaults to "b" */
+ git_strarray pathspec; /**< defaults to show all paths */
+ git_off_t max_size; /**< defaults to 512mb */
} git_diff_options;
+#define GIT_DIFF_OPTIONS_VERSION 1
+#define GIT_DIFF_OPTIONS_INIT = {GIT_DIFF_OPTIONS_VERSION, 0}
+
/**
* The diff list object that contains all individual file deltas.
*/
@@ -304,6 +307,8 @@ typedef struct {
unsigned int target_limit;
} git_diff_find_options;
+#define GIT_DIFF_FIND_OPTIONS_VERSION 1
+#define GIT_DIFF_FIND_OPTIONS_INIT {GIT_DIFF_FIND_OPTIONS_VERSION, 0}
/** @name Diff List Generator Functions
*
diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h
index 04658f9b3..3963ae531 100644
--- a/include/git2/odb_backend.h
+++ b/include/git2/odb_backend.h
@@ -33,6 +33,7 @@ typedef int (*git_odb_foreach_cb)(const git_oid *id, void *payload);
* An instance for a custom backend
*/
struct git_odb_backend {
+ unsigned int version;
git_odb *odb;
/* read and read_prefix each return to libgit2 a buffer which
@@ -98,6 +99,9 @@ struct git_odb_backend {
void (* free)(struct git_odb_backend *);
};
+#define GIT_ODB_BACKEND_VERSION 1
+#define GIT_ODB_BACKEND_INIT {GIT_ODB_BACKEND_VERSION, 0}
+
/** Streaming mode */
enum {
GIT_STREAM_RDONLY = (1 << 1),
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 6c70d7fbc..e5b60b951 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -338,12 +338,16 @@ typedef enum git_remote_completion_type {
* Set the calbacks to be called by the remote.
*/
struct git_remote_callbacks {
+ unsigned int version;
void (*progress)(const char *str, int len, void *data);
int (*completion)(git_remote_completion_type type, void *data);
int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data);
void *payload;
};
+#define GIT_REMOTE_CALLBACKS_VERSION 1
+#define GIT_REMOTE_CALLBACKS_INIT {GIT_REMOTE_CALLBACKS_VERSION, 0}
+
/**
* Set the callbacks for a remote
*
diff --git a/include/git2/repository.h b/include/git2/repository.h
index e91108a33..0d82b9810 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -239,6 +239,7 @@ typedef enum {
* will be added pointing to this URL.
*/
typedef struct {
+ unsigned int version;
uint32_t flags;
uint32_t mode;
const char *workdir_path;
@@ -248,6 +249,9 @@ typedef struct {
const char *origin_url;
} git_repository_init_options;
+#define GIT_REPOSITORY_INIT_OPTIONS_VERSION 1
+#define GIT_REPOSITORY_INIT_OPTIONS_INIT {GIT_REPOSITORY_INIT_OPTIONS_VERSION, 0}
+
/**
* Create a new Git repository in the given folder with extended controls.
*
diff --git a/include/git2/status.h b/include/git2/status.h
index c6926f343..1211f1d9f 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -164,6 +164,9 @@ typedef struct {
git_strarray pathspec;
} git_status_options;
+#define GIT_STATUS_OPTIONS_VERSION 1
+#define GIT_STATUS_OPTIONS_INIT {GIT_STATUS_OPTIONS_VERSION, 0}
+
/**
* Gather file status information and run callbacks as requested.
*
diff --git a/include/git2/transport.h b/include/git2/transport.h
index 61726922f..84d71c612 100644
--- a/include/git2/transport.h
+++ b/include/git2/transport.h
@@ -31,11 +31,15 @@ typedef enum {
/* The base structure for all credential types */
typedef struct git_cred {
+ unsigned int version; /* This should update if subtypes are extended */
git_credtype_t credtype;
void (*free)(
struct git_cred *cred);
} git_cred;
+#define GIT_CRED_VERSION 1
+#define GIT_CRED_INIT {GIT_CRED_VERSION, 0}
+
/* A plaintext username and password */
typedef struct git_cred_userpass_plaintext {
git_cred parent;
@@ -82,6 +86,7 @@ typedef enum {
typedef void (*git_transport_message_cb)(const char *str, int len, void *data);
typedef struct git_transport {
+ unsigned int version;
/* Set progress and error callbacks */
int (*set_callbacks)(struct git_transport *transport,
git_transport_message_cb progress_cb,
@@ -140,6 +145,9 @@ typedef struct git_transport {
void (*free)(struct git_transport *transport);
} git_transport;
+#define GIT_TRANSPORT_VERSION 1
+#define GIT_TRANSPORT_INIT {GIT_TRANSPORT_VERSION, 0}
+
/**
* Function to use to create a transport from a URL. The transport database
* is scanned to find a transport that implements the scheme of the URI (i.e.
@@ -284,6 +292,7 @@ typedef int (*git_smart_subtransport_cb)(
typedef struct git_smart_subtransport_definition {
/* The function to use to create the git_smart_subtransport */
git_smart_subtransport_cb callback;
+
/* True if the protocol is stateless; false otherwise. For example,
* http:// is stateless, but git:// is not. */
unsigned rpc : 1;
diff --git a/include/git2/types.h b/include/git2/types.h
index 06fcf3613..d83b1d14b 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -151,11 +151,15 @@ typedef struct git_time {
/** An action signature (e.g. for committers, taggers, etc) */
typedef struct git_signature {
+ unsigned int version;
char *name; /** full name of the author */
char *email; /** email of the author */
git_time when; /** time when the action happened */
} git_signature;
+#define GIT_SIGNATURE_VERSION 1
+#define GIT_SIGNATURE_INIT {GIT_SIGNATURE_VERSION, 0}
+
/** In-memory representation of a reference. */
typedef struct git_reference git_reference;