Skip to content

Commit ab62677

Browse files
lelutingitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e90fdc3 commit ab62677

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

git-sh-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ cd_to_toplevel () {
5959
}
6060

6161
require_work_tree () {
62-
test $(git rev-parse --is-inside-work-tree) = true ||
62+
test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ||
6363
die "fatal: $0 cannot be used without a working tree."
6464
}
6565

0 commit comments

Comments
 (0)