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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
454cb6bd52
commit
de95302a4c
@ -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 \
|
test_expect_success \
|
||||||
'populate workdir' \
|
'populate workdir' \
|
||||||
'mkdir a &&
|
'mkdir a &&
|
||||||
|
@ -994,3 +994,17 @@ test_copy_bytes () {
|
|||||||
}
|
}
|
||||||
' - "$1"
|
' - "$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 &&
|
||||||
|
"$@"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user