mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-03 00:43:41 +00:00
Deploy GIT_INIT_STRUCTURE
This commit is contained in:
parent
c7231c45fe
commit
0ab3a2ab2c
@ -225,12 +225,10 @@ static int retrieve_symlink_caps(git_repository *repo, bool *can_symlink)
|
||||
static void normalize_options(
|
||||
git_checkout_opts *normalized, git_checkout_opts *proposed)
|
||||
{
|
||||
git_checkout_opts init_opts = GIT_CHECKOUT_OPTS_INIT;
|
||||
|
||||
assert(normalized);
|
||||
|
||||
if (!proposed)
|
||||
memmove(normalized, &init_opts, sizeof(git_checkout_opts));
|
||||
GIT_INIT_STRUCTURE(normalized, GIT_CHECKOUT_OPTS_VERSION);
|
||||
else
|
||||
memmove(normalized, proposed, sizeof(git_checkout_opts));
|
||||
|
||||
|
10
src/common.h
10
src/common.h
@ -82,6 +82,16 @@ GIT_INLINE(bool) giterr__check_version(const void *structure, unsigned int expec
|
||||
}
|
||||
#define GITERR_CHECK_VERSION(S,V,N) if (!giterr__check_version(S,V,N)) return -1
|
||||
|
||||
/**
|
||||
* Initialize a structure with a version.
|
||||
*/
|
||||
GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int version)
|
||||
{
|
||||
memset(structure, 0, len);
|
||||
*((int*)structure) = version;
|
||||
}
|
||||
#define GIT_INIT_STRUCTURE(S,V) git__init_structure(S, sizeof(*S), V)
|
||||
|
||||
/* NOTE: other giterr functions are in the public errors.h header file */
|
||||
|
||||
#include "util.h"
|
||||
|
@ -1,5 +0,0 @@
|
||||
GIT_INLINE(void) reset_checkout_opts(git_checkout_opts *opts)
|
||||
{
|
||||
git_checkout_opts init_opts = GIT_CHECKOUT_OPTS_INIT;
|
||||
memmove(opts, &init_opts, sizeof(git_checkout_opts));
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "git2/checkout.h"
|
||||
#include "repository.h"
|
||||
#include "checkout_util.h"
|
||||
|
||||
static git_repository *g_repo;
|
||||
static git_checkout_opts g_opts;
|
||||
@ -26,7 +25,7 @@ void test_checkout_index__initialize(void)
|
||||
{
|
||||
git_tree *tree;
|
||||
|
||||
reset_checkout_opts(&g_opts);
|
||||
GIT_INIT_STRUCTURE(&g_opts, GIT_CHECKOUT_OPTS_VERSION);
|
||||
g_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
|
||||
|
||||
g_repo = cl_git_sandbox_init("testrepo");
|
||||
@ -67,7 +66,7 @@ void test_checkout_index__cannot_checkout_a_bare_repository(void)
|
||||
{
|
||||
test_checkout_index__cleanup();
|
||||
|
||||
reset_checkout_opts(&g_opts);
|
||||
GIT_INIT_STRUCTURE(&g_opts, GIT_CHECKOUT_OPTS_VERSION);
|
||||
g_repo = cl_git_sandbox_init("testrepo.git");
|
||||
|
||||
cl_git_fail(git_checkout_index(g_repo, NULL, NULL));
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "git2/checkout.h"
|
||||
#include "repository.h"
|
||||
#include "checkout_util.h"
|
||||
|
||||
static git_repository *g_repo;
|
||||
static git_checkout_opts g_opts;
|
||||
@ -12,7 +11,7 @@ void test_checkout_tree__initialize(void)
|
||||
{
|
||||
g_repo = cl_git_sandbox_init("testrepo");
|
||||
|
||||
reset_checkout_opts(&g_opts);
|
||||
GIT_INIT_STRUCTURE(&g_opts, GIT_CHECKOUT_OPTS_VERSION);
|
||||
g_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ void test_diff_blob__initialize(void)
|
||||
|
||||
g_repo = cl_git_sandbox_init("attr");
|
||||
|
||||
reset_diff_opts(&opts);
|
||||
GIT_INIT_STRUCTURE(&opts, GIT_DIFF_OPTIONS_VERSION);
|
||||
opts.context_lines = 1;
|
||||
opts.interhunk_lines = 0;
|
||||
|
||||
|
@ -49,9 +49,3 @@ extern int diff_foreach_via_iterator(
|
||||
|
||||
extern void diff_print(FILE *fp, git_diff_list *diff);
|
||||
|
||||
|
||||
GIT_INLINE(void) reset_diff_opts(git_diff_options *opts)
|
||||
{
|
||||
git_diff_options init = GIT_DIFF_OPTIONS_INIT;
|
||||
memmove(opts, &init, sizeof(init));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user