mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 20:29:27 +00:00
Fix remaining init_options inconsistencies
There were a couple of "init_opts()" functions a few more cases of structure initialization that I somehow missed.
This commit is contained in:
parent
702efc891f
commit
bc91347b58
@ -270,14 +270,13 @@ typedef struct git_checkout_options {
|
|||||||
* Initializes a `git_checkout_options` with default values. Equivalent to
|
* Initializes a `git_checkout_options` with default values. Equivalent to
|
||||||
* creating an instance with GIT_CHECKOUT_OPTIONS_INIT.
|
* creating an instance with GIT_CHECKOUT_OPTIONS_INIT.
|
||||||
*
|
*
|
||||||
* @param opts the `git_checkout_options` instance to initialize.
|
* @param opts the `git_checkout_options` struct to initialize.
|
||||||
* @param version the version of the struct; you should pass
|
* @param version Version of struct; pass `GIT_CHECKOUT_OPTIONS_VERSION`
|
||||||
* `GIT_CHECKOUT_OPTIONS_VERSION` here.
|
|
||||||
* @return Zero on success; -1 on failure.
|
* @return Zero on success; -1 on failure.
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_checkout_init_opts(
|
GIT_EXTERN(int) git_checkout_init_options(
|
||||||
git_checkout_options* opts,
|
git_checkout_options *opts,
|
||||||
int version);
|
unsigned int version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates files in the index and the working tree to match the content of
|
* Updates files in the index and the working tree to match the content of
|
||||||
|
@ -37,14 +37,13 @@ typedef struct {
|
|||||||
* Initializes a `git_cherry_pick_options` with default values. Equivalent to
|
* Initializes a `git_cherry_pick_options` with default values. Equivalent to
|
||||||
* creating an instance with GIT_CHERRY_PICK_OPTIONS_INIT.
|
* creating an instance with GIT_CHERRY_PICK_OPTIONS_INIT.
|
||||||
*
|
*
|
||||||
* @param opts the `git_cherry_pick_options` instance to initialize.
|
* @param opts the `git_cherry_pick_options` struct to initialize
|
||||||
* @param version the version of the struct; you should pass
|
* @param version Version of struct; pass `GIT_CHERRY_PICK_OPTIONS_VERSION`
|
||||||
* `GIT_CHERRY_PICK_OPTIONS_VERSION` here.
|
|
||||||
* @return Zero on success; -1 on failure.
|
* @return Zero on success; -1 on failure.
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_cherry_pick_init_opts(
|
GIT_EXTERN(int) git_cherry_pick_init_options(
|
||||||
git_cherry_pick_options* opts,
|
git_cherry_pick_options *opts,
|
||||||
int version);
|
unsigned int version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cherry-picks the given commit against the given "our" commit, producing an
|
* Cherry-picks the given commit against the given "our" commit, producing an
|
||||||
|
@ -501,14 +501,13 @@ struct git_remote_callbacks {
|
|||||||
* Initializes a `git_remote_callbacks` with default values. Equivalent to
|
* Initializes a `git_remote_callbacks` with default values. Equivalent to
|
||||||
* creating an instance with GIT_REMOTE_CALLBACKS_INIT.
|
* creating an instance with GIT_REMOTE_CALLBACKS_INIT.
|
||||||
*
|
*
|
||||||
* @param opts the `git_remote_callbacks` instance to initialize.
|
* @param opts the `git_remote_callbacks` struct to initialize
|
||||||
* @param version the version of the struct; you should pass
|
* @param version Version of struct; pass `GIT_REMOTE_CALLBACKS_VERSION`
|
||||||
* `GIT_REMOTE_CALLBACKS_VERSION` here.
|
|
||||||
* @return Zero on success; -1 on failure.
|
* @return Zero on success; -1 on failure.
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_remote_init_callbacks(
|
GIT_EXTERN(int) git_remote_init_callbacks(
|
||||||
git_remote_callbacks* opts,
|
git_remote_callbacks *opts,
|
||||||
int version);
|
unsigned int version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the callbacks for a remote
|
* Set the callbacks for a remote
|
||||||
|
@ -37,14 +37,13 @@ typedef struct {
|
|||||||
* Initializes a `git_revert_options` with default values. Equivalent to
|
* Initializes a `git_revert_options` with default values. Equivalent to
|
||||||
* creating an instance with GIT_REVERT_OPTIONS_INIT.
|
* creating an instance with GIT_REVERT_OPTIONS_INIT.
|
||||||
*
|
*
|
||||||
* @param opts the `git_revert_options` instance to initialize.
|
* @param opts the `git_revert_options` struct to initialize
|
||||||
* @param version the version of the struct; you should pass
|
* @param version Version of struct; pass `GIT_REVERT_OPTIONS_VERSION`
|
||||||
* `GIT_REVERT_OPTIONS_VERSION` here.
|
|
||||||
* @return Zero on success; -1 on failure.
|
* @return Zero on success; -1 on failure.
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_revert_init_opts(
|
GIT_EXTERN(int) git_revert_init_options(
|
||||||
git_revert_options* opts,
|
git_revert_options *opts,
|
||||||
int version);
|
unsigned int version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverts the given commit against the given "our" commit, producing an
|
* Reverts the given commit against the given "our" commit, producing an
|
||||||
|
@ -73,14 +73,13 @@ struct git_config_backend {
|
|||||||
* Initializes a `git_config_backend` with default values. Equivalent to
|
* Initializes a `git_config_backend` with default values. Equivalent to
|
||||||
* creating an instance with GIT_CONFIG_BACKEND_INIT.
|
* creating an instance with GIT_CONFIG_BACKEND_INIT.
|
||||||
*
|
*
|
||||||
* @param opts the `git_config_backend` instance to initialize.
|
* @param opts the `git_config_backend` struct to initialize.
|
||||||
* @param version the version of the struct; you should pass
|
* @param version Version of struct; pass `GIT_CONFIG_BACKEND_VERSION`
|
||||||
* `GIT_CONFIG_BACKEND_VERSION` here.
|
|
||||||
* @return Zero on success; -1 on failure.
|
* @return Zero on success; -1 on failure.
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_config_init_backend(
|
GIT_EXTERN(int) git_config_init_backend(
|
||||||
git_config_backend* backend,
|
git_config_backend *backend,
|
||||||
int version);
|
unsigned int version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a generic config file instance to an existing config
|
* Add a generic config file instance to an existing config
|
||||||
|
@ -93,14 +93,13 @@ struct git_odb_backend {
|
|||||||
* Initializes a `git_odb_backend` with default values. Equivalent to
|
* Initializes a `git_odb_backend` with default values. Equivalent to
|
||||||
* creating an instance with GIT_ODB_BACKEND_INIT.
|
* creating an instance with GIT_ODB_BACKEND_INIT.
|
||||||
*
|
*
|
||||||
* @param opts the `git_odb_backend` instance to initialize.
|
* @param opts the `git_odb_backend` struct to initialize.
|
||||||
* @param version the version of the struct; you should pass
|
* @param version Version the struct; pass `GIT_ODB_BACKEND_VERSION`
|
||||||
* `GIT_ODB_BACKEND_VERSION` here.
|
|
||||||
* @return Zero on success; -1 on failure.
|
* @return Zero on success; -1 on failure.
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_odb_init_backend(
|
GIT_EXTERN(int) git_odb_init_backend(
|
||||||
git_odb_backend* backend,
|
git_odb_backend *backend,
|
||||||
int version);
|
unsigned int version);
|
||||||
|
|
||||||
GIT_EXTERN(void *) git_odb_backend_malloc(git_odb_backend *backend, size_t len);
|
GIT_EXTERN(void *) git_odb_backend_malloc(git_odb_backend *backend, size_t len);
|
||||||
|
|
||||||
|
@ -162,14 +162,13 @@ struct git_refdb_backend {
|
|||||||
* Initializes a `git_refdb_backend` with default values. Equivalent to
|
* Initializes a `git_refdb_backend` with default values. Equivalent to
|
||||||
* creating an instance with GIT_REFDB_BACKEND_INIT.
|
* creating an instance with GIT_REFDB_BACKEND_INIT.
|
||||||
*
|
*
|
||||||
* @param opts the `git_refdb_backend` instance to initialize.
|
* @param opts the `git_refdb_backend` struct to initialize
|
||||||
* @param version the version of the struct; you should pass
|
* @param version Version of struct; pass `GIT_REFDB_BACKEND_VERSION`
|
||||||
* `GIT_REFDB_BACKEND_VERSION` here.
|
|
||||||
* @return Zero on success; -1 on failure.
|
* @return Zero on success; -1 on failure.
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_refdb_init_backend(
|
GIT_EXTERN(int) git_refdb_init_backend(
|
||||||
git_refdb_backend* backend,
|
git_refdb_backend *backend,
|
||||||
int version);
|
unsigned int version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructors for default filesystem-based refdb backend
|
* Constructors for default filesystem-based refdb backend
|
||||||
|
@ -314,14 +314,13 @@ struct git_transport {
|
|||||||
* Initializes a `git_transport` with default values. Equivalent to
|
* Initializes a `git_transport` with default values. Equivalent to
|
||||||
* creating an instance with GIT_TRANSPORT_INIT.
|
* creating an instance with GIT_TRANSPORT_INIT.
|
||||||
*
|
*
|
||||||
* @param opts the `git_transport` instance to initialize.
|
* @param opts the `git_transport` struct to initialize
|
||||||
* @param version the version of the struct; you should pass
|
* @param version Version of struct; pass `GIT_TRANSPORT_VERSION`
|
||||||
* `GIT_TRANSPORT_VERSION` here.
|
|
||||||
* @return Zero on success; -1 on failure.
|
* @return Zero on success; -1 on failure.
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_transport_init(
|
GIT_EXTERN(int) git_transport_init(
|
||||||
git_transport* opts,
|
git_transport *opts,
|
||||||
int version);
|
unsigned int version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to use to create a transport from a URL. The transport database
|
* Function to use to create a transport from a URL. The transport database
|
||||||
|
@ -2240,14 +2240,9 @@ int git_checkout_head(
|
|||||||
return git_checkout_tree(repo, NULL, opts);
|
return git_checkout_tree(repo, NULL, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_checkout_init_opts(git_checkout_options* opts, int version)
|
int git_checkout_init_options(git_checkout_options *opts, unsigned int version)
|
||||||
{
|
{
|
||||||
if (version != GIT_CHECKOUT_OPTIONS_VERSION) {
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
||||||
giterr_set(GITERR_INVALID, "Invalid version %d for git_checkout_options", version);
|
opts, version, git_checkout_options, GIT_CHECKOUT_OPTIONS_INIT);
|
||||||
return -1;
|
return 0;
|
||||||
} else {
|
|
||||||
git_checkout_options o = GIT_CHECKOUT_OPTIONS_INIT;
|
|
||||||
memcpy(opts, &o, sizeof(o));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -217,14 +217,10 @@ done:
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_cherry_pick_init_opts(git_cherry_pick_options* opts, int version)
|
int git_cherry_pick_init_options(
|
||||||
|
git_cherry_pick_options *opts, unsigned int version)
|
||||||
{
|
{
|
||||||
if (version != GIT_CHERRY_PICK_OPTIONS_VERSION) {
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
||||||
giterr_set(GITERR_INVALID, "Invalid version %d for git_cherry_pick_options", version);
|
opts, version, git_cherry_pick_options, GIT_CHERRY_PICK_OPTIONS_INIT);
|
||||||
return -1;
|
return 0;
|
||||||
} else {
|
|
||||||
git_cherry_pick_options o = GIT_CHERRY_PICK_OPTIONS_INIT;
|
|
||||||
memcpy(opts, &o, sizeof(o));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
13
src/config.c
13
src/config.c
@ -1276,14 +1276,9 @@ cleanup:
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_config_init_backend(git_config_backend* backend, int version)
|
int git_config_init_backend(git_config_backend *backend, unsigned int version)
|
||||||
{
|
{
|
||||||
if (version != GIT_CONFIG_BACKEND_VERSION) {
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
||||||
giterr_set(GITERR_INVALID, "Invalid version %d for git_config_backend", version);
|
backend, version, git_config_backend, GIT_CONFIG_BACKEND_INIT);
|
||||||
return -1;
|
return 0;
|
||||||
} else {
|
|
||||||
git_config_backend b = GIT_CONFIG_BACKEND_INIT;
|
|
||||||
memcpy(backend, &b, sizeof(b));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
11
src/diff.c
11
src/diff.c
@ -1310,17 +1310,10 @@ int git_diff_is_sorted_icase(const git_diff *diff)
|
|||||||
return (diff->opts.flags & GIT_DIFF_IGNORE_CASE) != 0;
|
return (diff->opts.flags & GIT_DIFF_IGNORE_CASE) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int diff_options_bad_version(int version, const char *thing)
|
|
||||||
{
|
|
||||||
giterr_set(GITERR_INVALID, "Invalid version %d for %s", version, thing);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int git_diff_get_perfdata(git_diff_perfdata *out, const git_diff *diff)
|
int git_diff_get_perfdata(git_diff_perfdata *out, const git_diff *diff)
|
||||||
{
|
{
|
||||||
if (!out || out->version != GIT_DIFF_PERFDATA_VERSION)
|
assert(out);
|
||||||
return diff_options_bad_version(
|
GITERR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata");
|
||||||
out ? out->version : 0, "git_diff_perfdata");
|
|
||||||
out->stat_calls = diff->perf.stat_calls;
|
out->stat_calls = diff->perf.stat_calls;
|
||||||
out->oid_calculations = diff->perf.oid_calculations;
|
out->oid_calculations = diff->perf.oid_calculations;
|
||||||
return 0;
|
return 0;
|
||||||
|
13
src/odb.c
13
src/odb.c
@ -1123,14 +1123,9 @@ int git_odb__error_ambiguous(const char *message)
|
|||||||
return GIT_EAMBIGUOUS;
|
return GIT_EAMBIGUOUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_odb_init_backend(git_odb_backend* backend, int version)
|
int git_odb_init_backend(git_odb_backend *backend, unsigned int version)
|
||||||
{
|
{
|
||||||
if (version != GIT_ODB_BACKEND_VERSION) {
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
||||||
giterr_set(GITERR_INVALID, "Invalid version %d for git_odb_backend", version);
|
backend, version, git_odb_backend, GIT_ODB_BACKEND_INIT);
|
||||||
return -1;
|
return 0;
|
||||||
} else {
|
|
||||||
git_odb_backend b = GIT_ODB_BACKEND_INIT;
|
|
||||||
memcpy(backend, &b, sizeof(b));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
13
src/refdb.c
13
src/refdb.c
@ -236,14 +236,9 @@ int git_refdb_ensure_log(git_refdb *db, const char *refname)
|
|||||||
return db->backend->ensure_log(db->backend, refname);
|
return db->backend->ensure_log(db->backend, refname);
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_refdb_init_backend(git_refdb_backend* backend, int version)
|
int git_refdb_init_backend(git_refdb_backend *backend, unsigned int version)
|
||||||
{
|
{
|
||||||
if (version != GIT_REFDB_BACKEND_VERSION) {
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
||||||
giterr_set(GITERR_INVALID, "Invalid version %d for git_refdb_backend", version);
|
backend, version, git_refdb_backend, GIT_REFDB_BACKEND_INIT);
|
||||||
return -1;
|
return 0;
|
||||||
} else {
|
|
||||||
git_refdb_backend b = GIT_REFDB_BACKEND_INIT;
|
|
||||||
memcpy(backend, &b, sizeof(b));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
13
src/remote.c
13
src/remote.c
@ -1736,14 +1736,9 @@ const git_refspec *git_remote_get_refspec(const git_remote *remote, size_t n)
|
|||||||
return git_vector_get(&remote->refspecs, n);
|
return git_vector_get(&remote->refspecs, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_remote_init_callbacks(git_remote_callbacks* opts, int version)
|
int git_remote_init_callbacks(git_remote_callbacks *opts, unsigned int version)
|
||||||
{
|
{
|
||||||
if (version != GIT_REMOTE_CALLBACKS_VERSION) {
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
||||||
giterr_set(GITERR_INVALID, "Invalid version %d for git_remote_callbacks", version);
|
opts, version, git_remote_callbacks, GIT_REMOTE_CALLBACKS_INIT);
|
||||||
return -1;
|
return 0;
|
||||||
} else {
|
|
||||||
git_remote_callbacks o = GIT_REMOTE_CALLBACKS_INIT;
|
|
||||||
memcpy(opts, &o, sizeof(o));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
13
src/revert.c
13
src/revert.c
@ -220,14 +220,9 @@ done:
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_revert_init_opts(git_revert_options* opts, int version)
|
int git_revert_init_options(git_revert_options *opts, unsigned int version)
|
||||||
{
|
{
|
||||||
if (version != GIT_REVERT_OPTIONS_VERSION) {
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
||||||
giterr_set(GITERR_INVALID, "Invalid version %d for git_revert_options", version);
|
opts, version, git_revert_options, GIT_REVERT_OPTIONS_INIT);
|
||||||
return -1;
|
return 0;
|
||||||
} else {
|
|
||||||
git_revert_options o = GIT_REVERT_OPTIONS_INIT;
|
|
||||||
memcpy(opts, &o, sizeof(o));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -528,11 +528,8 @@ int git_status_init_options(git_status_options *opts, unsigned int version)
|
|||||||
int git_status_list_get_perfdata(
|
int git_status_list_get_perfdata(
|
||||||
git_diff_perfdata *out, const git_status_list *status)
|
git_diff_perfdata *out, const git_status_list *status)
|
||||||
{
|
{
|
||||||
if (!out || out->version != GIT_DIFF_PERFDATA_VERSION) {
|
assert(out);
|
||||||
giterr_set(GITERR_INVALID, "Invalid version %d for git_diff_perfdata",
|
GITERR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata");
|
||||||
out ? out->version : 0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
out->stat_calls = 0;
|
out->stat_calls = 0;
|
||||||
out->oid_calculations = 0;
|
out->oid_calculations = 0;
|
||||||
|
@ -218,14 +218,9 @@ int git_remote_supported_url(const char* url)
|
|||||||
return fn != &git_transport_dummy;
|
return fn != &git_transport_dummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_transport_init(git_transport* opts, int version)
|
int git_transport_init(git_transport *opts, unsigned int version)
|
||||||
{
|
{
|
||||||
if (version != GIT_TRANSPORT_VERSION) {
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
||||||
giterr_set(GITERR_INVALID, "Invalid version %d for git_transport", version);
|
opts, version, git_transport, GIT_TRANSPORT_INIT);
|
||||||
return -1;
|
return 0;
|
||||||
} else {
|
|
||||||
git_transport o = GIT_TRANSPORT_INIT;
|
|
||||||
memcpy(opts, &o, sizeof(o));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ void test_structinit_structinit__compare(void)
|
|||||||
/* checkout */
|
/* checkout */
|
||||||
CHECK_MACRO_FUNC_INIT_EQUAL( \
|
CHECK_MACRO_FUNC_INIT_EQUAL( \
|
||||||
git_checkout_options, GIT_CHECKOUT_OPTIONS_VERSION, \
|
git_checkout_options, GIT_CHECKOUT_OPTIONS_VERSION, \
|
||||||
GIT_CHECKOUT_OPTIONS_INIT, git_checkout_init_opts);
|
GIT_CHECKOUT_OPTIONS_INIT, git_checkout_init_options);
|
||||||
|
|
||||||
/* clone */
|
/* clone */
|
||||||
CHECK_MACRO_FUNC_INIT_EQUAL( \
|
CHECK_MACRO_FUNC_INIT_EQUAL( \
|
||||||
@ -98,7 +98,7 @@ void test_structinit_structinit__compare(void)
|
|||||||
/* revert */
|
/* revert */
|
||||||
CHECK_MACRO_FUNC_INIT_EQUAL( \
|
CHECK_MACRO_FUNC_INIT_EQUAL( \
|
||||||
git_revert_options, GIT_REVERT_OPTIONS_VERSION, \
|
git_revert_options, GIT_REVERT_OPTIONS_VERSION, \
|
||||||
GIT_REVERT_OPTIONS_INIT, git_revert_init_opts);
|
GIT_REVERT_OPTIONS_INIT, git_revert_init_options);
|
||||||
|
|
||||||
/* status */
|
/* status */
|
||||||
CHECK_MACRO_FUNC_INIT_EQUAL( \
|
CHECK_MACRO_FUNC_INIT_EQUAL( \
|
||||||
|
Loading…
Reference in New Issue
Block a user