Merge branch 'ar/submodule-add-config'
[git/debian.git] / t / t5705-session-id-in-capabilities.sh
blobeb8c79aafdd6aa4d203ff6d8ab85a191c37a5d9b
1 #!/bin/sh
3 test_description='session ID in capabilities'
5 . ./test-lib.sh
7 REPO="$(pwd)/repo"
8 LOCAL_PRISTINE="$(pwd)/local_pristine"
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
17 for PROTO in 0 1 2
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)"
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)"
43 done
45 test_expect_success 'enable SID advertisement' '
46 git -C "$REPO" config transfer.advertiseSID true &&
47 git -C "$LOCAL_PRISTINE" config transfer.advertiseSID true
50 for PROTO in 0 1 2
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
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
77 test_expect_success "client & server log negotiated version (v${PROTO})" '
78 test_when_finished "rm -rf local tr2-client-events tr2-server-events" &&
79 cp -r "$LOCAL_PRISTINE" local &&
80 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
81 git -c protocol.version=$PROTO -C local fetch \
82 --upload-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-upload-pack" \
83 origin &&
84 grep \"key\":\"negotiated-version\",\"value\":\"$PROTO\" tr2-client-events &&
85 grep \"key\":\"negotiated-version\",\"value\":\"$PROTO\" tr2-server-events
87 done
89 test_done