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:
Carlos Martín Nieto 2011-06-16 19:56:48 +02:00 committed by Vicent Marti
parent 9ba9e513bc
commit 3de5df7d8e
3 changed files with 21 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View File

@ -210,6 +210,26 @@ BEGIN_TEST
END_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) BEGIN_SUITE(config)
ADD_TEST(config0); ADD_TEST(config0);
ADD_TEST(config1); ADD_TEST(config1);
@ -221,4 +241,5 @@ BEGIN_SUITE(config)
ADD_TEST(config7); ADD_TEST(config7);
ADD_TEST(config8); ADD_TEST(config8);
ADD_TEST(config9); ADD_TEST(config9);
ADD_TEST(config10);
END_SUITE END_SUITE