diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-09-22 22:50:36 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-09-27 14:40:56 +0200 |
| commit | 40fe5fbea8f2e64dee1c2327c774cca0004f18f8 (patch) | |
| tree | 70dca8b1a4a6f8c4ad726bc1af623151af7a95dc /tests/t15-config.c | |
| parent | 4c562347aec5427ddf78d271f7dc2947ef7aa49e (diff) | |
| download | libgit2-40fe5fbea8f2e64dee1c2327c774cca0004f18f8.tar.gz | |
Make repo config loading automatic or completely explicit
git_repository_config wants to take the global and system paths again
so that one can be explicit if needed.
The git_repository_config_autoload function is provided for the cases
when it's good enough for the library to guess where those files are
located.
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'tests/t15-config.c')
| -rw-r--r-- | tests/t15-config.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/tests/t15-config.c b/tests/t15-config.c index ac2d79cf..40c4eb9d 100644 --- a/tests/t15-config.c +++ b/tests/t15-config.c @@ -30,6 +30,7 @@ #include "filebuf.h" #define CONFIG_BASE TEST_RESOURCES "/config" +#define GLOBAL_CONFIG CONFIG_BASE "/.gitconfig" /* * This one is so we know the code isn't completely broken @@ -233,40 +234,26 @@ 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")); - p_setenv("HOME", CONFIG_BASE, 1); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); - must_pass(git_repository_config(&cfg, repo, NULL)); + must_pass(git_repository_config(&cfg, repo, GLOBAL_CONFIG, NULL)); must_pass(git_config_get_int(cfg, "core.repositoryformatversion", &version)); must_be_true(version == 0); git_config_free(cfg); git_repository_free(repo); - - p_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")); - p_setenv("HOME", CONFIG_BASE, 1); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); - must_pass(git_repository_config(&cfg, repo, NULL)); + must_pass(git_repository_config(&cfg, repo, GLOBAL_CONFIG, NULL)); must_pass(git_config_get_int(cfg, "core.something", &num)); must_be_true(num == 2); git_config_free(cfg); git_repository_free(repo); - - p_setenv("HOME", old_home, 1); - free(old_home); END_TEST BEGIN_TEST(config12, "delete a value") |
