summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-06-10 15:26:04 -0700
committerJunio C Hamano <gitster@pobox.com>2016-06-10 15:26:05 -0700
commit45c0c21eb96ce45f05ffbe8600adf6ac65086415 (patch)
treeafd003477f8dbb33710bb193522c0c85af9cc1c1
parent8ffc9d26e41f1ce23acbaee0f14419d99677b5f9 (diff)
parente256eec79d375649ecda7cc21b527386898794a4 (diff)
downloadgit-45c0c21eb96ce45f05ffbe8600adf6ac65086415.tar.gz
Merge branch 'jk/shell-portability'
test fixes. * jk/shell-portability: t5500 & t7403: lose bash-ism "local" test-lib: add in-shell "env" replacement
-rwxr-xr-xt/t4014-format-patch.sh2
-rwxr-xr-xt/t5500-fetch-pack.sh1
-rwxr-xr-xt/t7403-submodule-sync.sh4
-rw-r--r--t/test-lib-functions.sh22
4 files changed, 25 insertions, 4 deletions
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 8049cad374..805dc9012d 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1072,7 +1072,7 @@ test_expect_success '--from omits redundant in-body header' '
'
test_expect_success 'in-body headers trigger content encoding' '
- GIT_AUTHOR_NAME="éxötìc" test_commit exotic &&
+ test_env GIT_AUTHOR_NAME="éxötìc" test_commit exotic &&
test_when_finished "git reset --hard HEAD^" &&
git format-patch -1 --stdout --from >patch &&
cat >expect <<-\EOF &&
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 91a69fc33a..82d913a6a8 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -558,7 +558,6 @@ check_prot_path () {
}
check_prot_host_port_path () {
- local diagport
case "$2" in
*ssh*)
pp=ssh
diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh
index 79bc135bf6..5503ec067f 100755
--- a/t/t7403-submodule-sync.sh
+++ b/t/t7403-submodule-sync.sh
@@ -62,13 +62,13 @@ test_expect_success 'change submodule' '
'
reset_submodule_urls () {
- local root
- root=$(pwd) &&
(
+ root=$(pwd) &&
cd super-clone/submodule &&
git config remote.origin.url "$root/submodule"
) &&
(
+ root=$(pwd) &&
cd super-clone/submodule/sub-submodule &&
git config remote.origin.url "$root/submodule"
)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 3978fc0b45..48884d5208 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -939,3 +939,25 @@ mingw_read_file_strip_cr_ () {
eval "$1=\$$1\$line"
done
}
+
+# Like "env FOO=BAR some-program", but run inside a subshell, which means
+# it also works for shell functions (though those functions cannot impact
+# the environment outside of the test_env invocation).
+test_env () {
+ (
+ while test $# -gt 0
+ do
+ case "$1" in
+ *=*)
+ eval "${1%%=*}=\${1#*=}"
+ eval "export ${1%%=*}"
+ shift
+ ;;
+ *)
+ "$@"
+ exit
+ ;;
+ esac
+ done
+ )
+}