mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 20:42:23 +00:00
Add a test for overriding config
The repo's configuration should take precedence over the global one. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
This commit is contained in:
parent
9ba9e513bc
commit
3de5df7d8e
BIN
tests/resources/config/.gitconfig
Normal file
BIN
tests/resources/config/.gitconfig
Normal file
Binary file not shown.
BIN
tests/resources/testrepo.git/config
Normal file
BIN
tests/resources/testrepo.git/config
Normal file
Binary file not shown.
@ -210,6 +210,26 @@ BEGIN_TEST
|
||||
|
||||
END_TEST
|
||||
|
||||
BEGIN_TEST(config10, "a repo's config overrides the global config")
|
||||
git_repository *repo;
|
||||
char home_orig[GIT_PATH_MAX];
|
||||
char *home;
|
||||
git_config *cfg;
|
||||
int version;
|
||||
|
||||
home = getenv("HOME");
|
||||
strcpy(home_orig, home);
|
||||
setenv("HOME", CONFIG_BASE, 1);
|
||||
|
||||
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
|
||||
must_pass(git_repository_config(&cfg, repo));
|
||||
setenv("HOME", home_orig, 1);
|
||||
must_pass(git_config_get_int(cfg, "core.repositoryformatversion", &version));
|
||||
must_be_true(version == 0);
|
||||
git_config_free(cfg);
|
||||
git_repository_free(repo);
|
||||
END_TEST
|
||||
|
||||
BEGIN_SUITE(config)
|
||||
ADD_TEST(config0);
|
||||
ADD_TEST(config1);
|
||||
@ -221,4 +241,5 @@ BEGIN_SUITE(config)
|
||||
ADD_TEST(config7);
|
||||
ADD_TEST(config8);
|
||||
ADD_TEST(config9);
|
||||
ADD_TEST(config10);
|
||||
END_SUITE
|
||||
|
Loading…
Reference in New Issue
Block a user