diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2022-12-03 14:32:32 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2023-02-12 21:26:11 +0000 |
commit | 366973f3785b7a2cf95a118fc4e13210ca277529 (patch) | |
tree | 2dc60dabb3b542bde76ee6d5eca8b8eeddd2ff96 /tests | |
parent | 3dfc12d5e210a6e15c7c54f3514eeeb12fb2108a (diff) | |
download | libgit2-366973f3785b7a2cf95a118fc4e13210ca277529.tar.gz |
repo: don't overwrite repo format version on reinit
Ensure that we maintain the `core.repositoryFormatVersion` value instead
of always overwriting it with the default.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libgit2/repo/init.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/tests/libgit2/repo/init.c b/tests/libgit2/repo/init.c index adcd9e025..637d4a903 100644 --- a/tests/libgit2/repo/init.c +++ b/tests/libgit2/repo/init.c @@ -142,27 +142,46 @@ void test_repo_init__reinit_bare_repo(void) cl_git_pass(git_repository_init(&g_repo, "reinit.git", 1)); } -void test_repo_init__reinit_too_recent_bare_repo(void) +void test_repo_init__reinit_nondefault_version(void) { git_config *config; + cl_set_cleanup(&cleanup_repository, "reinit.git"); + /* Initialize the repository */ cl_git_pass(git_repository_init(&g_repo, "reinit.git", 1)); git_repository_config(&config, g_repo); + /* Set the config to a supported but not default version */ + cl_repo_set_string(g_repo, "core.repositoryformatversion", "1"); + git_config_free(config); + git_repository_free(g_repo); + g_repo = NULL; + + /* Try to reinitialize the repository */ + cl_git_pass(git_repository_init(&g_repo, "reinit.git", 1)); + cl_assert_equal_i(1, cl_repo_get_int(g_repo, "core.repositoryformatversion")); + + cl_fixture_cleanup("reinit.git"); +} + +void test_repo_init__reinit_unsupported_version(void) +{ + cl_set_cleanup(&cleanup_repository, "reinit.git"); + + /* Initialize the repository */ + cl_git_pass(git_repository_init(&g_repo, "reinit.git", 1)); + /* * Hack the config of the repository to make it look like it has - * been created by a recenter version of git/libgit2 + * been created by a too new and unsupported version of git/libgit2 */ - cl_git_pass(git_config_set_int32(config, "core.repositoryformatversion", 42)); - - git_config_free(config); + cl_repo_set_string(g_repo, "core.repositoryformatversion", "42"); git_repository_free(g_repo); g_repo = NULL; - /* Try to reinitialize the repository */ + /* Try and fail to reinitialize the repository */ cl_git_fail(git_repository_init(&g_repo, "reinit.git", 1)); - cl_fixture_cleanup("reinit.git"); } |