test-lib.sh: do tests for color support after changing HOME
commit102fc80d32094ad6598b17ab9d607516ee8edc4a
authorRichard Hansen <rhansen@bbn.com>
Tue, 6 Jan 2015 22:57:51 +0000 (6 17:57 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 7 Jan 2015 18:38:01 +0000 (7 10:38 -0800)
tree7740cee5fc1b3946cbf292f6726b422e2b1a4cb0
parent46f32a99b836ddb79a87690c4c4e2c7922f05896
test-lib.sh: do tests for color support after changing HOME

If ncurses needs ~/.terminfo for the current $TERM, then tput will
succeed before changing HOME to $TRASH_DIRECTORY but fail afterward.
Move the tests that determine whether there is color support after
changing HOME so that color=t is set if and only if tput would succeed
when say_color() is run.

Note that color=t is now set after --no-color is processed, so the
condition to set color=t has changed:  it is now set only if
color has not already been set to the empty string by --no-color.

This disables color support for those that need ~/.terminfo for
their TERM, but it's better than filling the screen with:

    tput: unknown terminal "custom-terminal-name-here"

An alternative would be to symlink or copy the user's terminfo
database into $TRASH_DIRECTORY, but this is tricky due to the lack of
a standard name for the terminfo database (for example, instead of a
~/.terminfo directory, NetBSD uses a ~/.terminfo.cdb database file).

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh