From de95302a4c0c6c733fb734b5a3d3d54dd54ec674 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 15 Dec 2016 21:30:12 -0500 Subject: t5000: extract nongit function to test-lib-functions.sh This function abstracts the idea of running a command outside of any repository (which is slightly awkward to do because even if you make a non-repo directory, git may keep walking up outside of the trash directory). There are several scripts that use the same technique, so let's make the function available for everyone. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/test-lib-functions.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't/test-lib-functions.sh') diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index fdaeb3a96b..adab7f51f4 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -994,3 +994,17 @@ test_copy_bytes () { } ' - "$1" } + +# run "$@" inside a non-git directory +nongit () { + test -d non-repo || + mkdir non-repo || + return 1 + + ( + GIT_CEILING_DIRECTORIES=$(pwd) && + export GIT_CEILING_DIRECTORIES && + cd non-repo && + "$@" + ) +} -- cgit v1.2.3