aboutsummaryrefslogtreecommitdiff
path: root/t/t5802-connect-helper.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-09-24 17:07:27 -0400
committerJunio C Hamano <gitster@pobox.com>2015-09-25 10:18:18 -0700
commitdf1ed03a6fabf58b63b26950c71d36eff4aa25e8 (patch)
treedd0a0fdaf95bcfa067f4c1bc1bdd35328e747f5a /t/t5802-connect-helper.sh
parent0cb9d6d6b63ad7fea4ca8363f7f1f921b1e16ec7 (diff)
downloadgit-df1ed03a6fabf58b63b26950c71d36eff4aa25e8.tar.gz
git-df1ed03a6fabf58b63b26950c71d36eff4aa25e8.tar.xz
remote-ext: simplify git pkt-line generation
We format a pkt-line into a heap buffer, which requires manual computation of the required size, and uses some bare sprintf calls. We could use a strbuf instead, which would take care of the computation for us. But it's even easier still to use packet_write(). Besides handling the formatting and writing for us, it fixes two things: 1. Our manual max-size check used 0xFFFF, while technically LARGE_PACKET_MAX is slightly smaller than this. 2. Our packet will now be output as part of GIT_TRACE_PACKET debugging. Unfortunately packet_write() does not let us build up the buffer progressively, so we do have to repeat ourselves a little depending on the "vhost" setting, but the end result is still far more readable than the original. Since there were no tests covering this feature at all, we'll add a few into t5802. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5802-connect-helper.sh')
-rwxr-xr-xt/t5802-connect-helper.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/t/t5802-connect-helper.sh b/t/t5802-connect-helper.sh
index 878faf2b6..b7a7f9d58 100755
--- a/t/t5802-connect-helper.sh
+++ b/t/t5802-connect-helper.sh
@@ -69,4 +69,32 @@ test_expect_success 'update backfilled tag without primary transfer' '
test_cmp expect actual
'
+
+test_expect_success 'set up fake git-daemon' '
+ mkdir remote &&
+ git init --bare remote/one.git &&
+ mkdir remote/host &&
+ git init --bare remote/host/two.git &&
+ write_script fake-daemon <<-\EOF &&
+ git daemon --inetd \
+ --informative-errors \
+ --export-all \
+ --base-path="$TRASH_DIRECTORY/remote" \
+ --interpolated-path="$TRASH_DIRECTORY/remote/%H%D" \
+ "$TRASH_DIRECTORY/remote"
+ EOF
+ export TRASH_DIRECTORY &&
+ PATH=$TRASH_DIRECTORY:$PATH
+'
+
+test_expect_success 'ext command can connect to git daemon (no vhost)' '
+ rm -rf dst &&
+ git clone "ext::fake-daemon %G/one.git" dst
+'
+
+test_expect_success 'ext command can connect to git daemon (vhost)' '
+ rm -rf dst &&
+ git clone "ext::fake-daemon %G/two.git %Vhost" dst
+'
+
test_done