Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Bowen <matthew@mgbowen.com>2014-03-06 06:49:23 +0400
committerMatthew Bowen <matthew@mgbowen.com>2014-03-06 06:49:23 +0400
commitb9f819978c571cc806827e8b3ebc1a58a0755999 (patch)
tree64c94ef334360b064a3bdf9b6069c1422f727150 /src
parenta064dc2d0b6206116a35be4b62c58c3c1170d5de (diff)
Added function-based initializers for every options struct.
The basic structure of each function is courtesy of arrbee.
Diffstat (limited to 'src')
-rw-r--r--src/blame.c12
-rw-r--r--src/checkout.c12
-rw-r--r--src/clone.c12
-rw-r--r--src/config.c12
-rw-r--r--src/diff.c24
-rw-r--r--src/merge.c24
-rw-r--r--src/odb.c11
-rw-r--r--src/push.c12
-rw-r--r--src/refdb.c12
-rw-r--r--src/remote.c12
-rw-r--r--src/repository.c12
-rw-r--r--src/revert.c12
-rw-r--r--src/status.c11
-rw-r--r--src/transport.c12
14 files changed, 190 insertions, 0 deletions
diff --git a/src/blame.c b/src/blame.c
index 71bc460c6..01f88b729 100644
--- a/src/blame.c
+++ b/src/blame.c
@@ -476,3 +476,15 @@ int git_blame_buffer(
*out = blame;
return 0;
}
+
+int git_blame_init_options(git_blame_options* opts, int version)
+{
+ if (version != GIT_BLAME_OPTIONS_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_blame_options", version);
+ return -1;
+ } else {
+ git_blame_options o = GIT_BLAME_OPTIONS_INIT;
+ memcpy(opts, &o, sizeof(o));
+ return 0;
+ }
+}
diff --git a/src/checkout.c b/src/checkout.c
index 72fe5368f..4ef8da076 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -2194,3 +2194,15 @@ int git_checkout_head(
assert(repo);
return git_checkout_tree(repo, NULL, opts);
}
+
+int git_checkout_init_opts(git_checkout_opts* opts, int version)
+{
+ if (version != GIT_CHECKOUT_OPTS_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_checkout_opts", version);
+ return -1;
+ } else {
+ git_checkout_opts o = GIT_CHECKOUT_OPTS_INIT;
+ memcpy(opts, &o, sizeof(o));
+ return 0;
+ }
+}
diff --git a/src/clone.c b/src/clone.c
index bcc38678f..b5333bdb7 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -439,3 +439,15 @@ int git_clone(
*out = repo;
return error;
}
+
+int git_clone_init_options(git_clone_options* opts, int version)
+{
+ if (version != GIT_CLONE_OPTIONS_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_clone_options", version);
+ return -1;
+ } else {
+ git_clone_options o = GIT_CLONE_OPTIONS_INIT;
+ memcpy(opts, &o, sizeof(o));
+ return 0;
+ }
+}
diff --git a/src/config.c b/src/config.c
index ae093ed64..1a205fe13 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1245,3 +1245,15 @@ cleanup:
return error;
}
+
+int git_config_init_backend(git_config_backend* backend, int version)
+{
+ if (version != GIT_CONFIG_BACKEND_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_config_backend", version);
+ return -1;
+ } else {
+ git_config_backend b = GIT_CONFIG_BACKEND_INIT;
+ memcpy(backend, &b, sizeof(b));
+ return 0;
+ }
+}
diff --git a/src/diff.c b/src/diff.c
index 151990ed6..dc7735f4f 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -1413,3 +1413,27 @@ int git_diff__paired_foreach(
return error;
}
+
+int git_diff_init_options(git_diff_options* opts, int version)
+{
+ if (version != GIT_DIFF_OPTIONS_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_diff_options", version);
+ return -1;
+ } else {
+ git_diff_options o = GIT_DIFF_OPTIONS_INIT;
+ memcpy(opts, &o, sizeof(o));
+ return 0;
+ }
+}
+
+int git_diff_find_init_options(git_diff_find_options* opts, int version)
+{
+ if (version != GIT_DIFF_FIND_OPTIONS_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_diff_find_options", version);
+ return -1;
+ } else {
+ git_diff_find_options o = GIT_DIFF_FIND_OPTIONS_INIT;
+ memcpy(opts, &o, sizeof(o));
+ return 0;
+ }
+}
diff --git a/src/merge.c b/src/merge.c
index 12ff1c91c..124e8c3a7 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -2744,3 +2744,27 @@ void git_merge_head_free(git_merge_head *head)
git__free(head);
}
+
+int git_merge_init_opts(git_merge_opts* opts, int version)
+{
+ if (version != GIT_MERGE_OPTS_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_merge_opts", version);
+ return -1;
+ } else {
+ git_merge_opts o = GIT_MERGE_OPTS_INIT;
+ memcpy(opts, &o, sizeof(o));
+ return 0;
+ }
+}
+
+int git_merge_tree_init_opts(git_merge_tree_opts* opts, int version)
+{
+ if (version != GIT_MERGE_TREE_OPTS_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_merge_tree_opts", version);
+ return -1;
+ } else {
+ git_merge_tree_opts o = GIT_MERGE_TREE_OPTS_INIT;
+ memcpy(opts, &o, sizeof(o));
+ return 0;
+ }
+}
diff --git a/src/odb.c b/src/odb.c
index 30bba9603..085eda594 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -1113,3 +1113,14 @@ int git_odb__error_ambiguous(const char *message)
return GIT_EAMBIGUOUS;
}
+int git_odb_init_backend(git_odb_backend* backend, int version)
+{
+ if (version != GIT_ODB_BACKEND_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_odb_backend", version);
+ return -1;
+ } else {
+ git_odb_backend b = GIT_ODB_BACKEND_INIT;
+ memcpy(backend, &b, sizeof(b));
+ return 0;
+ }
+}
diff --git a/src/push.c b/src/push.c
index c2947808e..521355621 100644
--- a/src/push.c
+++ b/src/push.c
@@ -705,3 +705,15 @@ void git_push_free(git_push *push)
git__free(push);
}
+
+int git_push_init_options(git_push_options* opts, int version)
+{
+ if (version != GIT_PUSH_OPTIONS_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_push_options", version);
+ return -1;
+ } else {
+ git_push_options o = GIT_PUSH_OPTIONS_INIT;
+ memcpy(opts, &o, sizeof(o));
+ return 0;
+ }
+}
diff --git a/src/refdb.c b/src/refdb.c
index 984c3c7f6..3e7a592f8 100644
--- a/src/refdb.c
+++ b/src/refdb.c
@@ -235,3 +235,15 @@ int git_refdb_ensure_log(git_refdb *db, const char *refname)
return db->backend->ensure_log(db->backend, refname);
}
+
+int git_refdb_init_backend(git_refdb_backend* backend, int version)
+{
+ if (version != GIT_REFDB_BACKEND_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_refdb_backend", version);
+ return -1;
+ } else {
+ git_refdb_backend b = GIT_REFDB_BACKEND_INIT;
+ memcpy(backend, &b, sizeof(b));
+ return 0;
+ }
+}
diff --git a/src/remote.c b/src/remote.c
index 6f97d56a1..caefc686e 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -1731,3 +1731,15 @@ const git_refspec *git_remote_get_refspec(const git_remote *remote, size_t n)
{
return git_vector_get(&remote->refspecs, n);
}
+
+int git_remote_init_callbacks(git_remote_callbacks* opts, int version)
+{
+ if (version != GIT_REMOTE_CALLBACKS_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_remote_callbacks", version);
+ return -1;
+ } else {
+ git_remote_callbacks o = GIT_REMOTE_CALLBACKS_INIT;
+ memcpy(opts, &o, sizeof(o));
+ return 0;
+ }
+}
diff --git a/src/repository.c b/src/repository.c
index b94973c74..fccc16faa 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -2010,3 +2010,15 @@ int git_repository_is_shallow(git_repository *repo)
return error;
return st.st_size == 0 ? 0 : 1;
}
+
+int git_repository_init_init_options(git_repository_init_options* opts, int version)
+{
+ if (version != GIT_REPOSITORY_INIT_OPTIONS_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_repository_init_options", version);
+ return -1;
+ } else {
+ git_repository_init_options o = GIT_REPOSITORY_INIT_OPTIONS_INIT;
+ memcpy(opts, &o, sizeof(o));
+ return 0;
+ }
+}
diff --git a/src/revert.c b/src/revert.c
index 4ba329907..a397a8eeb 100644
--- a/src/revert.c
+++ b/src/revert.c
@@ -218,3 +218,15 @@ done:
return error;
}
+
+int git_revert_init_opts(git_revert_opts* opts, int version)
+{
+ if (version != GIT_REVERT_OPTS_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_revert_opts", version);
+ return -1;
+ } else {
+ git_revert_opts o = GIT_REVERT_OPTS_INIT;
+ memcpy(opts, &o, sizeof(o));
+ return 0;
+ }
+}
diff --git a/src/status.c b/src/status.c
index 3c95b347c..c4b990a84 100644
--- a/src/status.c
+++ b/src/status.c
@@ -495,3 +495,14 @@ int git_status_should_ignore(
return git_ignore_path_is_ignored(ignored, repo, path);
}
+int git_status_init_options(git_status_options* opts, int version)
+{
+ if (version != GIT_STATUS_OPTIONS_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_status_options", version);
+ return -1;
+ } else {
+ git_status_options o = GIT_STATUS_OPTIONS_INIT;
+ memcpy(opts, &o, sizeof(o));
+ return 0;
+ }
+}
diff --git a/src/transport.c b/src/transport.c
index 2b0c6a185..dc074a503 100644
--- a/src/transport.c
+++ b/src/transport.c
@@ -217,3 +217,15 @@ int git_remote_supported_url(const char* url)
return fn != &git_transport_dummy;
}
+
+int git_transport_init(git_transport* opts, int version)
+{
+ if (version != GIT_TRANSPORT_VERSION) {
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_transport", version);
+ return -1;
+ } else {
+ git_transport o = GIT_TRANSPORT_INIT;
+ memcpy(opts, &o, sizeof(o));
+ return 0;
+ }
+}