Skip to content

Commit a3c45d1

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7176a31 commit a3c45d1

File tree

3 files changed

+5
-29
lines changed

3 files changed

+5
-29
lines changed

t/t1308-config-set.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,8 @@ test_expect_success 'check line errors for malformed values' '
219219
'
220220

221221
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
230224
'
231225

232226
cmdline_config="'foo.bar=from-cmdline'"

t/t9100-git-svn-basic.sh

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,12 @@ case "$GIT_SVN_LC_ALL" in
1717
;;
1818
esac
1919

20-
deepdir=nothing-above
21-
ceiling=$PWD
22-
2320
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
3022
'
3123

3224
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
3926
'
4027

4128
test_expect_success \

t/t9902-completion.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,7 @@ test_expect_success SYMLINKS '__gitdir - resulting path avoids symlinks' '
257257
'
258258

259259
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
266261
'
267262

268263
test_expect_success '__gitcomp - trailing space - options' '

0 commit comments

Comments
 (0)