t: use nongit() function where applicable
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>
Jeff King committed
Dec 15, 2016 at 21:31 UTC
a3c45d126012e01b23edc4923ffddffac61d703b
3 files changed
+5
-29
t/t1308-config-set.sh
+2
-8
@@ -219,14 +219,8 @@ test_expect_success 'check line errors for malformed values' '
219
'
220
221
test_expect_success 'error on modifying repo config without repo' '
222
- mkdir no-repo &&
223
- (
224
- GIT_CEILING_DIRECTORIES=$(pwd) &&
225
- export GIT_CEILING_DIRECTORIES &&
226
- cd no-repo &&
227
- test_must_fail git config a.b c 2>err &&
228
- grep "not in a git directory" err
229
- )
222
+ nongit test_must_fail git config a.b c 2>err &&
223
+ grep "not in a git directory" err
224
'
225
226
cmdline_config="'foo.bar=from-cmdline'"
t/t9100-git-svn-basic.sh
+2
-15
@@ -17,25 +17,12 @@ case "$GIT_SVN_LC_ALL" in
17
;;
18
esac
19
20
-deepdir=nothing-above
21
-ceiling=$PWD
22
-
20
test_expect_success 'git svn --version works anywhere' '
24
- mkdir -p "$deepdir" && (
25
- GIT_CEILING_DIRECTORIES="$ceiling" &&
26
- export GIT_CEILING_DIRECTORIES &&
27
- cd "$deepdir" &&
28
- git svn --version
29
- )
21
+ nongit git svn --version
22
'
23
24
test_expect_success 'git svn help works anywhere' '
33
- mkdir -p "$deepdir" && (
34
- GIT_CEILING_DIRECTORIES="$ceiling" &&
35
- export GIT_CEILING_DIRECTORIES &&
36
- cd "$deepdir" &&
37
- git svn help
38
- )
25
+ nongit git svn help
26
'
27
28
test_expect_success \
t/t9902-completion.sh
+1
-6
@@ -257,12 +257,7 @@ test_expect_success SYMLINKS '__gitdir - resulting path avoids symlinks' '
257
'
258
259
test_expect_success '__gitdir - not a git repository' '
260
- (
261
- cd subdir/subsubdir &&
262
- GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY" &&
263
- export GIT_CEILING_DIRECTORIES &&
264
- test_must_fail __gitdir
265
- )
260
+ nongit test_must_fail __gitdir
261
'
262
263
test_expect_success '__gitcomp - trailing space - options' '