mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-06 09:41:04 +00:00
tests: Introduce count_config_entries_match() helper
This commit is contained in:
parent
892778ee84
commit
48ebea662a
@ -35,3 +35,31 @@ void assert_config_entry_value(
|
||||
|
||||
cl_assert_equal_s(expected_value, out);
|
||||
}
|
||||
|
||||
static int count_config_entries_cb(
|
||||
const git_config_entry *entry,
|
||||
void *payload)
|
||||
{
|
||||
int *how_many = (int *)payload;
|
||||
|
||||
GIT_UNUSED(entry);
|
||||
|
||||
(*how_many)++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count_config_entries_match(git_repository *repo, const char *pattern)
|
||||
{
|
||||
git_config *config;
|
||||
int how_many = 0;
|
||||
|
||||
cl_git_pass(git_repository_config(&config, repo));
|
||||
|
||||
cl_assert_equal_i(0, git_config_foreach_match(
|
||||
config, pattern, count_config_entries_cb, &how_many));
|
||||
|
||||
git_config_free(config);
|
||||
|
||||
return how_many;
|
||||
}
|
||||
|
@ -7,3 +7,7 @@ extern void assert_config_entry_value(
|
||||
git_repository *repo,
|
||||
const char *name,
|
||||
const char *expected_value);
|
||||
|
||||
extern int count_config_entries_match(
|
||||
git_repository *repo,
|
||||
const char *pattern);
|
||||
|
Loading…
Reference in New Issue
Block a user