From: Gabriel Filion Date: Wed, 17 Feb 2010 04:18:50 +0000 (-0500) Subject: require_work_tree broken with NONGIT_OK X-Git-Tag: v1.7.0.2~13^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ab62677b1424d4e53cf222c973b841d3dada4cf3;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 7bef43f39..d2789410d 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -59,7 +59,7 @@ cd_to_toplevel () { } 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." }