upload-pack: introduce fetch server command
[git] / t / t5702-protocol-v2.sh
1 #!/bin/sh
2
3 test_description='test git wire-protocol version 2'
4
5 TEST_NO_CREATE_REPO=1
6
7 . ./test-lib.sh
8
9 # Test protocol v2 with 'git://' transport
10 #
11 . "$TEST_DIRECTORY"/lib-git-daemon.sh
12 start_git_daemon --export-all --enable=receive-pack
13 daemon_parent=$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent
14
15 test_expect_success 'create repo to be served by git-daemon' '
16         git init "$daemon_parent" &&
17         test_commit -C "$daemon_parent" one
18 '
19
20 test_expect_success 'list refs with git:// using protocol v2' '
21         GIT_TRACE_PACKET=1 git -c protocol.version=2 \
22                 ls-remote --symref "$GIT_DAEMON_URL/parent" >actual 2>log &&
23
24         # Client requested to use protocol v2
25         grep "git> .*\\\0\\\0version=2\\\0$" log &&
26         # Server responded using protocol v2
27         grep "git< version 2" log &&
28
29         git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
30         test_cmp actual expect
31 '
32
33 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
34         GIT_TRACE_PACKET=1 git -c protocol.version=2 \
35                 ls-remote "$GIT_DAEMON_URL/parent" master 2>log &&
36
37         grep "ref-pattern master" log &&
38         ! grep "refs/tags/" log
39 '
40
41 stop_git_daemon
42
43 # Test protocol v2 with 'file://' transport
44 #
45 test_expect_success 'create repo to be served by file:// transport' '
46         git init file_parent &&
47         test_commit -C file_parent one
48 '
49
50 test_expect_success 'list refs with file:// using protocol v2' '
51         GIT_TRACE_PACKET=1 git -c protocol.version=2 \
52                 ls-remote --symref "file://$(pwd)/file_parent" >actual 2>log &&
53
54         # Server responded using protocol v2
55         grep "git< version 2" log &&
56
57         git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
58         test_cmp actual expect
59 '
60
61 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
62         GIT_TRACE_PACKET=1 git -c protocol.version=2 \
63                 ls-remote "file://$(pwd)/file_parent" master 2>log &&
64
65         grep "ref-pattern master" log &&
66         ! grep "refs/tags/" log
67 '
68
69 test_done