Merge branch 'jk/shell-portability'
authorJunio C Hamano <gitster@pobox.com>
Fri, 10 Jun 2016 22:26:04 +0000 (15:26 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Jun 2016 22:26:05 +0000 (15:26 -0700)
test fixes.

* jk/shell-portability:
t5500 & t7403: lose bash-ism "local"
test-lib: add in-shell "env" replacement

t/t4014-format-patch.sh
t/t5500-fetch-pack.sh
t/t7403-submodule-sync.sh
t/test-lib-functions.sh
index 8049cad374827d15ec098218b01acb59b65383ee..805dc9012d5f765eb40a67e58c1572b1fe316bd6 100755 (executable)
@@ -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 &&
index 91a69fc33a590d22cf80e101f9b58b9a0b2d9d48..82d913a6a87c45dd8141e3c7384df9943f9b83cb 100755 (executable)
@@ -558,7 +558,6 @@ check_prot_path () {
 }
 
 check_prot_host_port_path () {
-       local diagport
        case "$2" in
                *ssh*)
                pp=ssh
index 79bc135bf69ea5813f0a372db6bbefa0f9a92753..5503ec067fa8e5d62b5308ceb7f538ad6e7dc81f 100755 (executable)
@@ -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"
        )
index 3978fc0b45de2645560207cc6e884a505506215d..48884d520813998a735d89d406b45c63b0bf748d 100644 (file)
@@ -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
+       )
+}