Skip to content

Commit 95a1d12

Browse files
jrngitster
authored andcommitted
tests: scrub environment of GIT_* variables
Variables from the inherited environment that are meaningful to git can break tests in undesirable ways. For example, GIT_PAGER=more sh t5400-send-pack.sh -v -i hangs. So unset all environment variables in the GIT_ namespace in test-lib, with a few exceptions: - GIT_TRACE* are useful for tracking down bugs exhibited by a failing test; - GIT_DEBUG* are GIT_TRACE variables by another name, practically speaking. They should probably be tweaked to follow the GIT_TRACE_foo scheme and use trace_printf machinery some time. - GIT_USE_LOOKUP from v1.5.6-rc0~134^2~1 (sha1-lookup: more memory efficient search in sorted list of SHA-1, 2007-12-29) is about trying an alternate implementation strategy rather than changing semantics and it can be useful to compare performance with and without it set. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8f323c0 commit 95a1d12

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

t/test-lib.sh

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,16 @@ TERM=dumb
4343
export LANG LC_ALL PAGER TERM TZ
4444
EDITOR=:
4545
unset VISUAL
46-
unset GIT_EDITOR
4746
unset EMAIL
48-
unset GIT_ALTERNATE_OBJECT_DIRECTORIES
49-
unset GIT_AUTHOR_DATE
47+
unset $(perl -e '
48+
my @env = keys %ENV;
49+
my @vars = grep(/^GIT_/ && !/^GIT_(TRACE|DEBUG|USE_LOOKUP)/, @env);
50+
print join("\n", @vars);
51+
')
5052
5153
GIT_AUTHOR_NAME='A U Thor'
52-
unset GIT_COMMITTER_DATE
5354
5455
GIT_COMMITTER_NAME='C O Mitter'
55-
unset GIT_DIFF_OPTS
56-
unset GIT_DIR
57-
unset GIT_WORK_TREE
58-
unset GIT_EXTERNAL_DIFF
59-
unset GIT_INDEX_FILE
60-
unset GIT_OBJECT_DIRECTORY
61-
unset GIT_CEILING_DIRECTORIES
62-
unset GIT_NOTES_REF
63-
unset GIT_NOTES_DISPLAY_REF
64-
unset GIT_NOTES_REWRITE_REF
65-
unset GIT_NOTES_REWRITE_MODE
66-
unset GIT_REFLOG_ACTION
67-
unset GIT_CHERRY_PICK_HELP
68-
unset GIT_QUIET
6956
GIT_MERGE_VERBOSITY=5
7057
export GIT_MERGE_VERBOSITY
7158
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME

0 commit comments

Comments
 (0)