Skip to content

Commit de95302

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

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

t/t5000-tar-tree.sh

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,6 @@ check_tar() {
9494
'
9595
}
9696

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-
11197
test_expect_success \
11298
'populate workdir' \
11399
'mkdir a &&

t/test-lib-functions.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,3 +994,17 @@ test_copy_bytes () {
994994
}
995995
' - "$1"
996996
}
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+
}

0 commit comments

Comments
 (0)