summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--connect.c4
-rwxr-xr-xt/t5507-remote-environment.sh34
2 files changed, 36 insertions, 2 deletions
diff --git a/connect.c b/connect.c
index c0144d859a..962f9904d4 100644
--- a/connect.c
+++ b/connect.c
@@ -721,6 +721,8 @@ struct child_process *git_connect(int fd[2], const char *url,
strbuf_addch(&cmd, ' ');
sq_quote_buf(&cmd, path);
+ /* remove repo-local variables from the environment */
+ conn->env = local_repo_env;
conn->in = conn->out = -1;
if (protocol == PROTO_SSH) {
const char *ssh;
@@ -778,8 +780,6 @@ struct child_process *git_connect(int fd[2], const char *url,
}
argv_array_push(&conn->args, ssh_host);
} else {
- /* remove repo-local variables from the environment */
- conn->env = local_repo_env;
conn->use_shell = 1;
}
argv_array_push(&conn->args, cmd.buf);
diff --git a/t/t5507-remote-environment.sh b/t/t5507-remote-environment.sh
new file mode 100755
index 0000000000..e6149295b1
--- /dev/null
+++ b/t/t5507-remote-environment.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+test_description='check environment showed to remote side of transports'
+. ./test-lib.sh
+
+test_expect_success 'set up "remote" push situation' '
+ test_commit one &&
+ git config push.default current &&
+ git init remote
+'
+
+test_expect_success 'set up fake ssh' '
+ GIT_SSH_COMMAND="f() {
+ cd \"\$TRASH_DIRECTORY\" &&
+ eval \"\$2\"
+ }; f" &&
+ export GIT_SSH_COMMAND &&
+ export TRASH_DIRECTORY
+'
+
+# due to receive.denyCurrentBranch=true
+test_expect_success 'confirm default push fails' '
+ test_must_fail git push remote
+'
+
+test_expect_success 'config does not travel over same-machine push' '
+ test_must_fail git -c receive.denyCurrentBranch=false push remote
+'
+
+test_expect_success 'config does not travel over ssh push' '
+ test_must_fail git -c receive.denyCurrentBranch=false push host:remote
+'
+
+test_done