Skip to content

Commit

Permalink
require_work_tree broken with NONGIT_OK
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Gabriel Filion authored and Junio C Hamano committed Feb 17, 2010
1 parent e90fdc3 commit ab62677
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion git-sh-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}

Expand Down

0 comments on commit ab62677

Please sign in to comment.