ls-remote: pass ref prefixes when requesting a remote's refs
[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 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
36 test_when_finished "rm -f log" &&
37
38 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
39 ls-remote "$GIT_DAEMON_URL/parent" master >actual &&
40
41 cat >expect <<-EOF &&
42 $(git -C "$daemon_parent" rev-parse refs/heads/master)$(printf "\t")refs/heads/master
43 EOF
44
45 test_cmp actual expect
46 '
47
48 stop_git_daemon
49
50 # Test protocol v2 with 'file://' transport
51 #
52 test_expect_success 'create repo to be served by file:// transport' '
53 git init file_parent &&
54 test_commit -C file_parent one
55 '
56
57 test_expect_success 'list refs with file:// using protocol v2' '
58 test_when_finished "rm -f log" &&
59
60 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
61 ls-remote --symref "file://$(pwd)/file_parent" >actual &&
62
63 # Server responded using protocol v2
64 grep "git< version 2" log &&
65
66 git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
67 test_cmp actual expect
68 '
69
70 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
71 test_when_finished "rm -f log" &&
72
73 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
74 ls-remote "file://$(pwd)/file_parent" master >actual &&
75
76 cat >expect <<-EOF &&
77 $(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
78 EOF
79
80 test_cmp actual expect
81 '
82
83 test_done