t: use nongit() function where applicable
authorJeff King <peff@peff.net>
Fri, 16 Dec 2016 02:31:59 +0000 (21:31 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Dec 2016 17:31:00 +0000 (09:31 -0800)
Many tests want to run a command outside of any git repo;
with the nongit() function this is now a one-liner. It saves
a few lines, but more importantly, it's immediately obvious
what the code is trying to accomplish.

This doesn't convert every such case in the test suite; it
just covers those that want to do a one-off command. Other
cases, such as the ones in t4035, are part of a larger
scheme of outside-repo files, and it's less confusing for
them to stay consistent with the surrounding tests.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1308-config-set.sh
t/t9100-git-svn-basic.sh
t/t9902-completion.sh
index 7655c94c2801f0070a7b60ea17f30414b16c8d12..ff50960ccaed9953c5738c9bbf602bf0d326e15a 100755 (executable)
@@ -219,14 +219,8 @@ test_expect_success 'check line errors for malformed values' '
 '
 
 test_expect_success 'error on modifying repo config without repo' '
-       mkdir no-repo &&
-       (
-               GIT_CEILING_DIRECTORIES=$(pwd) &&
-               export GIT_CEILING_DIRECTORIES &&
-               cd no-repo &&
-               test_must_fail git config a.b c 2>err &&
-               grep "not in a git directory" err
-       )
+       nongit test_must_fail git config a.b c 2>err &&
+       grep "not in a git directory" err
 '
 
 cmdline_config="'foo.bar=from-cmdline'"
index 92a3aa8063f810bd2b8df68f3f0f30c2faf3bdc6..8a8ba65a2ae583aa5d0b0526e604a8f9613b5a5e 100755 (executable)
@@ -17,25 +17,12 @@ case "$GIT_SVN_LC_ALL" in
        ;;
 esac
 
-deepdir=nothing-above
-ceiling=$PWD
-
 test_expect_success 'git svn --version works anywhere' '
-       mkdir -p "$deepdir" && (
-               GIT_CEILING_DIRECTORIES="$ceiling" &&
-               export GIT_CEILING_DIRECTORIES &&
-               cd "$deepdir" &&
-               git svn --version
-       )
+       nongit git svn --version
 '
 
 test_expect_success 'git svn help works anywhere' '
-       mkdir -p "$deepdir" && (
-               GIT_CEILING_DIRECTORIES="$ceiling" &&
-               export GIT_CEILING_DIRECTORIES &&
-               cd "$deepdir" &&
-               git svn help
-       )
+       nongit git svn help
 '
 
 test_expect_success \
index 2ba62fbc178e1c92dff493beebdc9683b36efd2a..a34e55f874ca06da4cae6ab5d46bc3263c58d521 100755 (executable)
@@ -257,12 +257,7 @@ test_expect_success SYMLINKS '__gitdir - resulting path avoids symlinks' '
 '
 
 test_expect_success '__gitdir - not a git repository' '
-       (
-               cd subdir/subsubdir &&
-               GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY" &&
-               export GIT_CEILING_DIRECTORIES &&
-               test_must_fail __gitdir
-       )
+       nongit test_must_fail __gitdir
 '
 
 test_expect_success '__gitcomp - trailing space - options' '