dc5f813bebacb928d8bc0b9006e54b215bf7035d
[git/git.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 test_when_finished "rm -f log" &&
22
23 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
24 ls-remote --symref "$GIT_DAEMON_URL/parent" >actual &&
25
26 # Client requested to use protocol v2
27 grep "git> .*\\\0\\\0version=2\\\0$" log &&
28 # Server responded using protocol v2
29 grep "git< version 2" log &&
30
31 git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
32 test_cmp actual expect
33 '
34
35 stop_git_daemon
36
37 # Test protocol v2 with 'file://' transport
38 #
39 test_expect_success 'create repo to be served by file:// transport' '
40 git init file_parent &&
41 test_commit -C file_parent one
42 '
43
44 test_expect_success 'list refs with file:// using protocol v2' '
45 test_when_finished "rm -f log" &&
46
47 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
48 ls-remote --symref "file://$(pwd)/file_parent" >actual &&
49
50 # Server responded using protocol v2
51 grep "git< version 2" log &&
52
53 git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
54 test_cmp actual expect
55 '
56
57 test_done