require_work_tree broken with NONGIT_OK

With NONGIT_OK set, require_work_tree function outside a git repository
gives a syntax error.  This is caused by an incorrect use of "test" that
didn't anticipate $(git rev-parse --is-inside-work-tree) may return an
empty string.

Properly quote the argument to "test", and send the standard error stream
to /dev/null to avoid giving duplicate error messages.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Gabriel Filion 2010-02-16 23:18:50 -05:00 committed by Junio C Hamano
parent e90fdc39b6
commit ab62677b14

View File

@ -59,7 +59,7 @@ cd_to_toplevel () {
} }
require_work_tree () { require_work_tree () {
test $(git rev-parse --is-inside-work-tree) = true || test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ||
die "fatal: $0 cannot be used without a working tree." die "fatal: $0 cannot be used without a working tree."
} }