]>
git.proxmox.com Git - libgit2.git/blob - tests/config/config_helpers.c
ecdab5bf616501a68e4559267acade37d1d8ad74
1 #include "clar_libgit2.h"
2 #include "config_helpers.h"
3 #include "repository.h"
5 void assert_config_entry_existence(
8 bool is_supposed_to_exist
)
11 git_config_entry
*entry
= NULL
;
14 cl_git_pass(git_repository_config__weakptr(&config
, repo
));
16 result
= git_config_get_entry(&entry
, config
, name
);
17 git_config_entry_free(entry
);
19 if (is_supposed_to_exist
)
22 cl_assert_equal_i(GIT_ENOTFOUND
, result
);
25 void assert_config_entry_value(
28 const char *expected_value
)
31 git_buf buf
= GIT_BUF_INIT
;
33 cl_git_pass(git_repository_config__weakptr(&config
, repo
));
35 cl_git_pass(git_config_get_string_buf(&buf
, config
, name
));
37 cl_assert_equal_s(expected_value
, buf
.ptr
);
38 git_buf_dispose(&buf
);
41 static int count_config_entries_cb(
42 const git_config_entry
*entry
,
45 int *how_many
= (int *)payload
;
54 int count_config_entries_match(git_repository
*repo
, const char *pattern
)
59 cl_git_pass(git_repository_config(&config
, repo
));
61 cl_assert_equal_i(0, git_config_foreach_match(
62 config
, pattern
, count_config_entries_cb
, &how_many
));
64 git_config_free(config
);