mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
tests/clar: introduce cl_repo_has_ref_format()
Introduce a function that reads the "refStorage" extension so that we can easily figure out whether a specific repository uses the "files" or any other reference format. While we don't support other formats yet, we are about to add support for the "reftable" format.
This commit is contained in:
20
deps/clar/clar_libgit2.c
vendored
20
deps/clar/clar_libgit2.c
vendored
@@ -504,6 +504,26 @@ void cl_repo_set_string(git_repository *repo, const char *cfg, const char *value
|
||||
git_config_free(config);
|
||||
}
|
||||
|
||||
int cl_repo_has_ref_format(git_repository *repo, const char *format)
|
||||
{
|
||||
const char *configured_format;
|
||||
git_config *config;
|
||||
int result;
|
||||
|
||||
cl_git_pass(git_repository_config_snapshot(&config, repo));
|
||||
result = git_config_get_string(&configured_format, config,
|
||||
"extensions.refStorage");
|
||||
if (result < 0 && result != GIT_ENOTFOUND)
|
||||
cl_fail("cannot read extensions.refStorage");
|
||||
if (result < 0)
|
||||
configured_format = "files";
|
||||
|
||||
result = !strcmp(configured_format, format);
|
||||
|
||||
git_config_free(config);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* this is essentially the code from git__unescape modified slightly */
|
||||
static size_t strip_cr_from_buf(char *start, size_t len)
|
||||
{
|
||||
|
||||
2
deps/clar/clar_libgit2.h
vendored
2
deps/clar/clar_libgit2.h
vendored
@@ -254,6 +254,8 @@ 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);
|
||||
|
||||
int cl_repo_has_ref_format(git_repository *repo, const char *format);
|
||||
|
||||
/*
|
||||
* set up a fake "home" directory -- automatically configures cleanup
|
||||
* function to restore the home directory, although you can call it
|
||||
|
||||
Reference in New Issue
Block a user