Merge branch 'jt/packfile-as-uri-doc'
[git] / t / t5705-session-id-in-capabilities.sh
1 #!/bin/sh
2
3 test_description='session ID in capabilities'
4
5 . ./test-lib.sh
6
7 REPO="$(pwd)/repo"
8 LOCAL_PRISTINE="$(pwd)/local_pristine"
9
10 test_expect_success 'setup repos for session ID capability tests' '
11         git init "$REPO" &&
12         test_commit -C "$REPO" a &&
13         git clone "file://$REPO" "$LOCAL_PRISTINE" &&
14         test_commit -C "$REPO" b
15 '
16
17 for PROTO in 0 1 2
18 do
19         test_expect_success "session IDs not advertised by default (fetch v${PROTO})" '
20                 test_when_finished "rm -rf local tr2-client-events tr2-server-events" &&
21                 cp -r "$LOCAL_PRISTINE" local &&
22                 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
23                 git -c protocol.version=$PROTO -C local fetch \
24                         --upload-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-upload-pack" \
25                         origin &&
26                 test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" &&
27                 test -z "$(grep \"key\":\"client-sid\" tr2-server-events)"
28         '
29
30         test_expect_success "session IDs not advertised by default (push v${PROTO})" '
31                 test_when_finished "rm -rf local tr2-client-events tr2-server-events" &&
32                 test_when_finished "git -C local push --delete origin new-branch" &&
33                 cp -r "$LOCAL_PRISTINE" local &&
34                 git -C local pull --no-rebase origin &&
35                 GIT_TRACE2_EVENT_NESTING=5 \
36                 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
37                 git -c protocol.version=$PROTO -C local push \
38                         --receive-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-receive-pack" \
39                         origin HEAD:new-branch &&
40                 test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" &&
41                 test -z "$(grep \"key\":\"client-sid\" tr2-server-events)"
42         '
43 done
44
45 test_expect_success 'enable SID advertisement' '
46         git -C "$REPO" config transfer.advertiseSID true &&
47         git -C "$LOCAL_PRISTINE" config transfer.advertiseSID true
48 '
49
50 for PROTO in 0 1 2
51 do
52         test_expect_success "session IDs advertised (fetch v${PROTO})" '
53                 test_when_finished "rm -rf local tr2-client-events tr2-server-events" &&
54                 cp -r "$LOCAL_PRISTINE" local &&
55                 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
56                 git -c protocol.version=$PROTO -C local fetch \
57                         --upload-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-upload-pack" \
58                         origin &&
59                 grep \"key\":\"server-sid\" tr2-client-events &&
60                 grep \"key\":\"client-sid\" tr2-server-events
61         '
62
63         test_expect_success "session IDs advertised (push v${PROTO})" '
64                 test_when_finished "rm -rf local tr2-client-events tr2-server-events" &&
65                 test_when_finished "git -C local push --delete origin new-branch" &&
66                 cp -r "$LOCAL_PRISTINE" local &&
67                 git -C local pull --no-rebase origin &&
68                 GIT_TRACE2_EVENT_NESTING=5 \
69                 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
70                 git -c protocol.version=$PROTO -C local push \
71                         --receive-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-receive-pack" \
72                         origin HEAD:new-branch &&
73                 grep \"key\":\"server-sid\" tr2-client-events &&
74                 grep \"key\":\"client-sid\" tr2-server-events
75         '
76 done
77
78 test_done