summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-12-03 14:33:11 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2023-02-12 21:26:11 +0000
commitf6dbf9c5949e731b928b75090e793150d522afd1 (patch)
treea7c9379d02c3f9e99faeacee72dac5af11bb86c8 /tests
parent366973f3785b7a2cf95a118fc4e13210ca277529 (diff)
downloadlibgit2-f6dbf9c5949e731b928b75090e793150d522afd1.tar.gz
tests: helpers for getting ints from configuration
Diffstat (limited to 'tests')
-rw-r--r--tests/clar/clar_libgit2.c19
-rw-r--r--tests/clar/clar_libgit2.h3
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/clar/clar_libgit2.c b/tests/clar/clar_libgit2.c
index 783b457f9..2ba272706 100644
--- a/tests/clar/clar_libgit2.c
+++ b/tests/clar/clar_libgit2.c
@@ -476,6 +476,25 @@ int cl_repo_get_bool(git_repository *repo, const char *cfg)
return val;
}
+void cl_repo_set_int(git_repository *repo, const char *cfg, int value)
+{
+ git_config *config;
+ cl_git_pass(git_repository_config(&config, repo));
+ cl_git_pass(git_config_set_int32(config, cfg, value));
+ git_config_free(config);
+}
+
+int cl_repo_get_int(git_repository *repo, const char *cfg)
+{
+ int val = 0;
+ git_config *config;
+ cl_git_pass(git_repository_config(&config, repo));
+ if (git_config_get_int32(&val, config, cfg) < 0)
+ git_error_clear();
+ git_config_free(config);
+ return val;
+}
+
void cl_repo_set_string(git_repository *repo, const char *cfg, const char *value)
{
git_config *config;
diff --git a/tests/clar/clar_libgit2.h b/tests/clar/clar_libgit2.h
index d2d9da0aa..a002a6d14 100644
--- a/tests/clar/clar_libgit2.h
+++ b/tests/clar/clar_libgit2.h
@@ -231,6 +231,9 @@ void cl_repo_commit_from_index(
void cl_repo_set_bool(git_repository *repo, const char *cfg, int value);
int cl_repo_get_bool(git_repository *repo, const char *cfg);
+void cl_repo_set_int(git_repository *repo, const char *cfg, int value);
+int cl_repo_get_int(git_repository *repo, const char *cfg);
+
void cl_repo_set_string(git_repository *repo, const char *cfg, const char *value);
/* set up a fake "home" directory and set libgit2 GLOBAL search path.