git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] fix config reading in tests

From
Jeff King <peff@peff.net>
Date
Feb 6, 2008, 09:07 UTC
Message-ID
<20080206090755.GB3258@coredump.intra.peff.net>
In-Reply-To
<20080206090453.GA6762@coredump.intra.peff.net>

Previously, we set the GIT_CONFIG environment variable in our tests so that only that file was read. However, setting it to a static value is not correct, since we are not necessarily always in the same directory; instead, we want the usual git config file lookup to happen.

To do this, we stop setting GIT_CONFIG, which means that we must now suppress the reading of the system-wide and user configs.

This exposes an incorrect test in t1500, which is also fixed (the incorrect test worked because we were failing to read the core.bare value from the config file, since the GIT_CONFIG variable was pointing us to the wrong file).

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t1500-rev-parse.sh |    4 ++--
 t/test-lib.sh        |    7 +++++--
 2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index e474b3f..38a2bf0 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -33,9 +33,9 @@ test_rev_parse() {
 test_rev_parse toplevel false false true ''
 
 cd .git || exit 1
-test_rev_parse .git/ true true false ''
+test_rev_parse .git/ false true false ''
 cd objects || exit 1
-test_rev_parse .git/objects/ true true false ''
+test_rev_parse .git/objects/ false true false ''
 cd ../.. || exit 1
 
 mkdir -p sub/dir || exit 1
diff --git a/t/test-lib.sh b/t/test-lib.sh
index da47bd7..40db00c 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -324,8 +324,11 @@ test_done () {
 PATH=$(pwd)/..:$PATH
 GIT_EXEC_PATH=$(pwd)/..
 GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
-GIT_CONFIG=.git/config
-export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG
+unset GIT_CONFIG
+unset GIT_CONFIG_LOCAL
+HOME=$(pwd)
+GIT_CONFIG_ETC=$GIT_CONFIG_LOCAL
+export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR HOME GIT_CONFIG_ETC
 
 GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
 export GITPERLLIB
-- 
1.5.4.26.g9be9
Previous: Jeff KingNext: Junio C Hamano
Message 4 of 8 in “Re: [PATCH] Make tests independent of global config files”
  1. Jeff KingFeb 6, 2008
  2. Jeff KingFeb 6, 2008
  3. 1/2 allow GIT_CONFIG_ETC to override compile-time settingJeff King, Feb 6, 2008
  4. 2/2 fix config reading in testsJeff King, Feb 6, 2008
  5. Junio C HamanoFeb 6, 2008
  6. Jeff KingFeb 6, 2008
  7. 1/2 allow suppressing of global and system configJeff King, Feb 6, 2008
  8. 2/2 fix config reading in testsJeff King, Feb 6, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.