t5000: extract nongit function to test-lib-functions.sh
authorJeff King <peff@peff.net>
Fri, 16 Dec 2016 02:30:12 +0000 (21:30 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Dec 2016 17:29:16 +0000 (09:29 -0800)
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>
t/t5000-tar-tree.sh
t/test-lib-functions.sh
index 830bf2a2f6d4d85358a54f58f74b4ed9fdc954d5..886b6953e40f9fceae18642ebec031e0bdf511e3 100755 (executable)
@@ -94,20 +94,6 @@ check_tar() {
        '
 }
 
-# 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 &&
-               "$@"
-       )
-}
-
 test_expect_success \
     'populate workdir' \
     'mkdir a &&
index fdaeb3a96bed361f53030cb6ea5c6bdde445163f..adab7f51f4c962967c90e3184853377feece2b1e 100644 (file)
@@ -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 &&
+               "$@"
+       )
+}