mirror of
https://github.com/git/git.git
synced 2024-11-05 00:37:55 +01:00
df1ed03a6f
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>
100 lines
2.3 KiB
Bash
Executable file
100 lines
2.3 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='ext::cmd remote "connect" helper'
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success setup '
|
|
test_tick &&
|
|
git commit --allow-empty -m initial &&
|
|
test_tick &&
|
|
git commit --allow-empty -m second &&
|
|
test_tick &&
|
|
git commit --allow-empty -m third &&
|
|
test_tick &&
|
|
git tag -a -m "tip three" three &&
|
|
|
|
test_tick &&
|
|
git commit --allow-empty -m fourth
|
|
'
|
|
|
|
test_expect_success clone '
|
|
cmd=$(echo "echo >&2 ext::sh invoked && %S .." | sed -e "s/ /% /g") &&
|
|
git clone "ext::sh -c %S% ." dst &&
|
|
git for-each-ref refs/heads/ refs/tags/ >expect &&
|
|
(
|
|
cd dst &&
|
|
git config remote.origin.url "ext::sh -c $cmd" &&
|
|
git for-each-ref refs/heads/ refs/tags/
|
|
) >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'update following tag' '
|
|
test_tick &&
|
|
git commit --allow-empty -m fifth &&
|
|
test_tick &&
|
|
git tag -a -m "tip five" five &&
|
|
git for-each-ref refs/heads/ refs/tags/ >expect &&
|
|
(
|
|
cd dst &&
|
|
git pull &&
|
|
git for-each-ref refs/heads/ refs/tags/ >../actual
|
|
) &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'update backfilled tag' '
|
|
test_tick &&
|
|
git commit --allow-empty -m sixth &&
|
|
test_tick &&
|
|
git tag -a -m "tip two" two three^1 &&
|
|
git for-each-ref refs/heads/ refs/tags/ >expect &&
|
|
(
|
|
cd dst &&
|
|
git pull &&
|
|
git for-each-ref refs/heads/ refs/tags/ >../actual
|
|
) &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'update backfilled tag without primary transfer' '
|
|
test_tick &&
|
|
git tag -a -m "tip one " one two^1 &&
|
|
git for-each-ref refs/heads/ refs/tags/ >expect &&
|
|
(
|
|
cd dst &&
|
|
git pull &&
|
|
git for-each-ref refs/heads/ refs/tags/ >../actual
|
|
) &&
|
|
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
|