]>
git.proxmox.com Git - libgit2.git/blob - tests/config/config_helpers.c
1 #include "clar_libgit2.h"
2 #include "config_helpers.h"
3 #include "repository.h"
6 void assert_config_entry_existence(
9 bool is_supposed_to_exist
)
12 git_config_entry
*entry
= NULL
;
15 cl_git_pass(git_repository_config__weakptr(&config
, repo
));
17 result
= git_config_get_entry(&entry
, config
, name
);
18 git_config_entry_free(entry
);
20 if (is_supposed_to_exist
)
23 cl_assert_equal_i(GIT_ENOTFOUND
, result
);
26 void assert_config_entry_value(
29 const char *expected_value
)
32 git_buf buf
= GIT_BUF_INIT
;
34 cl_git_pass(git_repository_config__weakptr(&config
, repo
));
36 cl_git_pass(git_config_get_string_buf(&buf
, config
, name
));
38 cl_assert_equal_s(expected_value
, git_buf_cstr(&buf
));
42 static int count_config_entries_cb(
43 const git_config_entry
*entry
,
46 int *how_many
= (int *)payload
;
55 int count_config_entries_match(git_repository
*repo
, const char *pattern
)
60 cl_git_pass(git_repository_config(&config
, repo
));
62 cl_assert_equal_i(0, git_config_foreach_match(
63 config
, pattern
, count_config_entries_cb
, &how_many
));
65 git_config_free(config
);