Commit bc91347b by Russell Belfer

Fix remaining init_options inconsistencies

There were a couple of "init_opts()" functions a few more cases
of structure initialization that I somehow missed.
parent 702efc89
......@@ -270,14 +270,13 @@ typedef struct git_checkout_options {
* Initializes a `git_checkout_options` with default values. Equivalent to
* creating an instance with GIT_CHECKOUT_OPTIONS_INIT.
*
* @param opts the `git_checkout_options` instance to initialize.
* @param version the version of the struct; you should pass
* `GIT_CHECKOUT_OPTIONS_VERSION` here.
* @param opts the `git_checkout_options` struct to initialize.
* @param version Version of struct; pass `GIT_CHECKOUT_OPTIONS_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_checkout_init_opts(
git_checkout_options* opts,
int version);
GIT_EXTERN(int) git_checkout_init_options(
git_checkout_options *opts,
unsigned int version);
/**
* 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
* creating an instance with GIT_CHERRY_PICK_OPTIONS_INIT.
*
* @param opts the `git_cherry_pick_options` instance to initialize.
* @param version the version of the struct; you should pass
* `GIT_CHERRY_PICK_OPTIONS_VERSION` here.
* @param opts the `git_cherry_pick_options` struct to initialize
* @param version Version of struct; pass `GIT_CHERRY_PICK_OPTIONS_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_cherry_pick_init_opts(
git_cherry_pick_options* opts,
int version);
GIT_EXTERN(int) git_cherry_pick_init_options(
git_cherry_pick_options *opts,
unsigned int version);
/**
* 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
* creating an instance with GIT_REMOTE_CALLBACKS_INIT.
*
* @param opts the `git_remote_callbacks` instance to initialize.
* @param version the version of the struct; you should pass
* `GIT_REMOTE_CALLBACKS_VERSION` here.
* @param opts the `git_remote_callbacks` struct to initialize
* @param version Version of struct; pass `GIT_REMOTE_CALLBACKS_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_remote_init_callbacks(
git_remote_callbacks* opts,
int version);
git_remote_callbacks *opts,
unsigned int version);
/**
* Set the callbacks for a remote
......
......@@ -37,14 +37,13 @@ typedef struct {
* Initializes a `git_revert_options` with default values. Equivalent to
* creating an instance with GIT_REVERT_OPTIONS_INIT.
*
* @param opts the `git_revert_options` instance to initialize.
* @param version the version of the struct; you should pass
* `GIT_REVERT_OPTIONS_VERSION` here.
* @param opts the `git_revert_options` struct to initialize
* @param version Version of struct; pass `GIT_REVERT_OPTIONS_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_revert_init_opts(
git_revert_options* opts,
int version);
GIT_EXTERN(int) git_revert_init_options(
git_revert_options *opts,
unsigned int version);
/**
* 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
* creating an instance with GIT_CONFIG_BACKEND_INIT.
*
* @param opts the `git_config_backend` instance to initialize.
* @param version the version of the struct; you should pass
* `GIT_CONFIG_BACKEND_VERSION` here.
* @param opts the `git_config_backend` struct to initialize.
* @param version Version of struct; pass `GIT_CONFIG_BACKEND_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_config_init_backend(
git_config_backend* backend,
int version);
git_config_backend *backend,
unsigned int version);
/**
* 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
* creating an instance with GIT_ODB_BACKEND_INIT.
*
* @param opts the `git_odb_backend` instance to initialize.
* @param version the version of the struct; you should pass
* `GIT_ODB_BACKEND_VERSION` here.
* @param opts the `git_odb_backend` struct to initialize.
* @param version Version the struct; pass `GIT_ODB_BACKEND_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_odb_init_backend(
git_odb_backend* backend,
int version);
git_odb_backend *backend,
unsigned int version);
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
* creating an instance with GIT_REFDB_BACKEND_INIT.
*
* @param opts the `git_refdb_backend` instance to initialize.
* @param version the version of the struct; you should pass
* `GIT_REFDB_BACKEND_VERSION` here.
* @param opts the `git_refdb_backend` struct to initialize
* @param version Version of struct; pass `GIT_REFDB_BACKEND_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_refdb_init_backend(
git_refdb_backend* backend,
int version);
git_refdb_backend *backend,
unsigned int version);
/**
* Constructors for default filesystem-based refdb backend
......
......@@ -314,14 +314,13 @@ struct git_transport {
* Initializes a `git_transport` with default values. Equivalent to
* creating an instance with GIT_TRANSPORT_INIT.
*
* @param opts the `git_transport` instance to initialize.
* @param version the version of the struct; you should pass
* `GIT_TRANSPORT_VERSION` here.
* @param opts the `git_transport` struct to initialize
* @param version Version of struct; pass `GIT_TRANSPORT_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_transport_init(
git_transport* opts,
int version);
git_transport *opts,
unsigned int version);
/**
* 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);
}
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) {
giterr_set(GITERR_INVALID, "Invalid version %d for git_checkout_options", version);
return -1;
} else {
git_checkout_options o = GIT_CHECKOUT_OPTIONS_INIT;
memcpy(opts, &o, sizeof(o));
return 0;
}
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
opts, version, git_checkout_options, GIT_CHECKOUT_OPTIONS_INIT);
return 0;
}
......@@ -217,14 +217,10 @@ done:
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) {
giterr_set(GITERR_INVALID, "Invalid version %d for git_cherry_pick_options", version);
return -1;
} else {
git_cherry_pick_options o = GIT_CHERRY_PICK_OPTIONS_INIT;
memcpy(opts, &o, sizeof(o));
return 0;
}
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
opts, version, git_cherry_pick_options, GIT_CHERRY_PICK_OPTIONS_INIT);
return 0;
}
......@@ -1276,14 +1276,9 @@ cleanup:
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) {
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;
}
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
backend, version, git_config_backend, GIT_CONFIG_BACKEND_INIT);
return 0;
}
......@@ -1310,17 +1310,10 @@ int git_diff_is_sorted_icase(const git_diff *diff)
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)
{
if (!out || out->version != GIT_DIFF_PERFDATA_VERSION)
return diff_options_bad_version(
out ? out->version : 0, "git_diff_perfdata");
assert(out);
GITERR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata");
out->stat_calls = diff->perf.stat_calls;
out->oid_calculations = diff->perf.oid_calculations;
return 0;
......
......@@ -1123,14 +1123,9 @@ int git_odb__error_ambiguous(const char *message)
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) {
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;
}
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
backend, version, git_odb_backend, GIT_ODB_BACKEND_INIT);
return 0;
}
......@@ -236,14 +236,9 @@ 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)
int git_refdb_init_backend(git_refdb_backend *backend, unsigned 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;
}
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
backend, version, git_refdb_backend, GIT_REFDB_BACKEND_INIT);
return 0;
}
......@@ -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);
}
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) {
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;
}
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
opts, version, git_remote_callbacks, GIT_REMOTE_CALLBACKS_INIT);
return 0;
}
......@@ -220,14 +220,9 @@ done:
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) {
giterr_set(GITERR_INVALID, "Invalid version %d for git_revert_options", version);
return -1;
} else {
git_revert_options o = GIT_REVERT_OPTIONS_INIT;
memcpy(opts, &o, sizeof(o));
return 0;
}
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
opts, version, git_revert_options, GIT_REVERT_OPTIONS_INIT);
return 0;
}
......@@ -528,11 +528,8 @@ int git_status_init_options(git_status_options *opts, unsigned int version)
int git_status_list_get_perfdata(
git_diff_perfdata *out, const git_status_list *status)
{
if (!out || out->version != GIT_DIFF_PERFDATA_VERSION) {
giterr_set(GITERR_INVALID, "Invalid version %d for git_diff_perfdata",
out ? out->version : 0);
return -1;
}
assert(out);
GITERR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata");
out->stat_calls = 0;
out->oid_calculations = 0;
......
......@@ -218,14 +218,9 @@ int git_remote_supported_url(const char* url)
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) {
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;
}
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
opts, version, git_transport, GIT_TRANSPORT_INIT);
return 0;
}
......@@ -48,7 +48,7 @@ void test_structinit_structinit__compare(void)
/* checkout */
CHECK_MACRO_FUNC_INIT_EQUAL( \
git_checkout_options, GIT_CHECKOUT_OPTIONS_VERSION, \
GIT_CHECKOUT_OPTIONS_INIT, git_checkout_init_opts);
GIT_CHECKOUT_OPTIONS_INIT, git_checkout_init_options);
/* clone */
CHECK_MACRO_FUNC_INIT_EQUAL( \
......@@ -98,7 +98,7 @@ void test_structinit_structinit__compare(void)
/* revert */
CHECK_MACRO_FUNC_INIT_EQUAL( \
git_revert_options, GIT_REVERT_OPTIONS_VERSION, \
GIT_REVERT_OPTIONS_INIT, git_revert_init_opts);
GIT_REVERT_OPTIONS_INIT, git_revert_init_options);
/* status */
CHECK_MACRO_FUNC_INIT_EQUAL( \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment