Skip to content

Commit

Permalink
fix config reading in tests
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Feb 6, 2008
1 parent ab88c36 commit 8bfa6bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions t/t1500-rev-parse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
GIT_CONFIG_NOSYSTEM=1
GIT_CONFIG_NOGLOBAL=1
export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL

GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
export GITPERLLIB
Expand Down

0 comments on commit 8bfa6bd

Please sign in to comment.