summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-01-22 23:07:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-01-22 23:07:32 (GMT)
commit45f47ff01d048d47f30e0a5cacb5c5768d4858be (patch)
tree29aeaa81b832925fbdc9a2117b6080df6b83f0c9
parent0f501545a3f2500c850dc80b9409964a18bd9453 (diff)
parent4d8cab95ccdac8a0859ba0a6c044bd024f8d8a5f (diff)
downloadgit-45f47ff01d048d47f30e0a5cacb5c5768d4858be.zip
git-45f47ff01d048d47f30e0a5cacb5c5768d4858be.tar.gz
git-45f47ff01d048d47f30e0a5cacb5c5768d4858be.tar.bz2
Merge branch 'jk/no-flush-upon-disconnecting-slrpc-transport'
Reduce unnecessary round-trip when running "ls-remote" over the stateless RPC mechanism. * jk/no-flush-upon-disconnecting-slrpc-transport: transport: don't flush when disconnecting stateless-rpc helper
-rwxr-xr-xt/t5702-protocol-v2.sh12
-rw-r--r--transport.c2
2 files changed, 13 insertions, 1 deletions
diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh
index e73067d..7fd7102 100755
--- a/t/t5702-protocol-v2.sh
+++ b/t/t5702-protocol-v2.sh
@@ -665,6 +665,18 @@ test_expect_success 'fetch from namespaced repo respects namespaces' '
test_cmp expect actual
'
+test_expect_success 'ls-remote with v2 http sends only one POST' '
+ test_when_finished "rm -f log" &&
+
+ git ls-remote "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" >expect &&
+ GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
+ ls-remote "$HTTPD_URL/smart/http_parent" >actual &&
+ test_cmp expect actual &&
+
+ grep "Send header: POST" log >posts &&
+ test_line_count = 1 posts
+'
+
test_expect_success 'push with http:// and a config of v2 does not request v2' '
test_when_finished "rm -f log" &&
# Till v2 for push is designed, make sure that if a client has
diff --git a/transport.c b/transport.c
index 83379a0..1fdc7da 100644
--- a/transport.c
+++ b/transport.c
@@ -737,7 +737,7 @@ static int disconnect_git(struct transport *transport)
{
struct git_transport_data *data = transport->data;
if (data->conn) {
- if (data->got_remote_heads)
+ if (data->got_remote_heads && !transport->stateless_rpc)
packet_flush(data->fd[1]);
close(data->fd[0]);
close(data->fd[1]);