From 3de5df7d8e0e35653d49fb6484a4f0cf98af6c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 16 Jun 2011 19:56:48 +0200 Subject: [PATCH] Add a test for overriding config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The repo's configuration should take precedence over the global one. Signed-off-by: Carlos Martín Nieto --- tests/resources/config/.gitconfig | Bin 0 -> 36 bytes tests/resources/testrepo.git/config | Bin 0 -> 119 bytes tests/t15-config.c | 21 +++++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 tests/resources/config/.gitconfig create mode 100644 tests/resources/testrepo.git/config diff --git a/tests/resources/config/.gitconfig b/tests/resources/config/.gitconfig new file mode 100644 index 0000000000000000000000000000000000000000..8f8075b60ac07b9be5cb10abdd334d30ebed3e38 GIT binary patch literal 36 rcmaz}&M!)h<>D+#Eyyp?o#qRO=VqTIxivecsD%=|nBTLlBSnzYQE)ZF}(RG?r< gQE4h%JSnjVLo6phJuxSzC^fCLASJORwHT%c08(KibN~PV literal 0 HcmV?d00001 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