diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-06-16 19:56:48 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-06-17 22:30:29 +0200 |
| commit | 3de5df7d8e0e35653d49fb6484a4f0cf98af6c88 (patch) | |
| tree | e49b862644b865c4bf3af8569eb34810bf507bd3 /tests | |
| parent | 9ba9e513bc20d83f5c00dcabf8d0aa1d6df1e5f7 (diff) | |
| download | libgit2-3de5df7d8e0e35653d49fb6484a4f0cf98af6c88.tar.gz | |
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>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/resources/config/.gitconfig | 2 | ||||
| -rw-r--r-- | tests/resources/testrepo.git/config | 5 | ||||
| -rw-r--r-- | tests/t15-config.c | 21 |
3 files changed, 28 insertions, 0 deletions
diff --git a/tests/resources/config/.gitconfig b/tests/resources/config/.gitconfig new file mode 100644 index 000000000..8f8075b60 --- /dev/null +++ b/tests/resources/config/.gitconfig @@ -0,0 +1,2 @@ +[core] + repositoryformatversion = 5 diff --git a/tests/resources/testrepo.git/config b/tests/resources/testrepo.git/config new file mode 100644 index 000000000..2f8958058 --- /dev/null +++ b/tests/resources/testrepo.git/config @@ -0,0 +1,5 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true + logallrefupdates = true diff --git a/tests/t15-config.c b/tests/t15-config.c index c11c5a932..04b2fdea3 100644 --- a/tests/t15-config.c +++ b/tests/t15-config.c @@ -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 |
