diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-09-12 17:25:46 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-09-12 17:25:46 +0200 |
| commit | f9d4b0c39569148c1fe5a4e48c00f26325f2875f (patch) | |
| tree | f96015ca8e33906603fadd527e5d3998fdaa024b /tests/t15-config.c | |
| parent | 3f3f6225f8237e974b135de30eaac731c929936e (diff) | |
| download | libgit2-f9d4b0c39569148c1fe5a4e48c00f26325f2875f.tar.gz | |
git_repository_config: open global config file automatically
If the global configuration file is missing, it is ignored.
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'tests/t15-config.c')
| -rw-r--r-- | tests/t15-config.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/t15-config.c b/tests/t15-config.c index 05de25f8..fdfa092e 100644 --- a/tests/t15-config.c +++ b/tests/t15-config.c @@ -214,26 +214,40 @@ BEGIN_TEST(config10, "a repo's config overrides the global config") git_repository *repo; git_config *cfg; int version; + char *old_home; + + old_home = git__strdup(getenv("HOME")); + setenv("HOME", CONFIG_BASE, 1); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); - must_pass(git_repository_config(&cfg, repo, CONFIG_BASE "/.gitconfig", NULL)); + must_pass(git_repository_config(&cfg, repo, NULL)); must_pass(git_config_get_int(cfg, "core.repositoryformatversion", &version)); must_be_true(version == 0); git_config_free(cfg); git_repository_free(repo); + + setenv("HOME", old_home, 1); + free(old_home); END_TEST BEGIN_TEST(config11, "fall back to the global config") git_repository *repo; git_config *cfg; int num; + char *old_home; + + old_home = git__strdup(getenv("HOME")); + setenv("HOME", CONFIG_BASE, 1); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); - must_pass(git_repository_config(&cfg, repo, CONFIG_BASE "/.gitconfig", NULL)); + must_pass(git_repository_config(&cfg, repo, NULL)); must_pass(git_config_get_int(cfg, "core.something", &num)); must_be_true(num == 2); git_config_free(cfg); git_repository_free(repo); + + setenv("HOME", old_home, 1); + free(old_home); END_TEST BEGIN_TEST(config12, "delete a value") |
