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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Dec 15, 2016 at 21:30 UTC de95302a4c0c6c733fb734b5a3d3d54dd54ec674
2 files changed +14 -14
t/t5000-tar-tree.sh
-14
@@ -94,20 +94,6 @@ check_tar() {
94 '
95 }
96
97 -# run "$@" inside a non-git directory
98 -nongit () {
99 - test -d non-repo ||
100 - mkdir non-repo ||
101 - return 1
102 -
103 - (
104 - GIT_CEILING_DIRECTORIES=$(pwd) &&
105 - export GIT_CEILING_DIRECTORIES &&
106 - cd non-repo &&
107 - "$@"
108 - )
109 -}
110 -
97 test_expect_success \
98 'populate workdir' \
99 'mkdir a &&
t/test-lib-functions.sh
+14
@@ -994,3 +994,17 @@ test_copy_bytes () {
994 }
995 ' - "$1"
996 }
997 +
998 +# run "$@" inside a non-git directory
999 +nongit () {
1000 + test -d non-repo ||
1001 + mkdir non-repo ||
1002 + return 1
1003 +
1004 + (
1005 + GIT_CEILING_DIRECTORIES=$(pwd) &&
1006 + export GIT_CEILING_DIRECTORIES &&
1007 + cd non-repo &&
1008 + "$@"
1009 + )
1010 +}