1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-04-16 06:44:22 +02:00

connect, protocol: log negotiated protocol version

It is useful for performance monitoring and debugging purposes to know
the wire protocol used for remote operations. This may differ from the
version set in local configuration due to differences in version and/or
configuration between the server and the client. Therefore, log the
negotiated wire protocol version via trace2, for both clients and
servers.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Josh Steadmon 2021-08-10 10:20:39 -07:00 committed by Junio C Hamano
parent 66262451ec
commit 626beebdf8
3 changed files with 15 additions and 0 deletions

View File

@ -164,6 +164,8 @@ enum protocol_version discover_version(struct packet_reader *reader)
BUG("unknown protocol version");
}
trace2_data_intmax("transfer", NULL, "negotiated-version", version);
return version;
}

View File

@ -73,6 +73,8 @@ enum protocol_version determine_protocol_version_server(void)
string_list_clear(&list, 0);
}
trace2_data_intmax("transfer", NULL, "negotiated-version", version);
return version;
}

View File

@ -73,6 +73,17 @@ do
grep \"key\":\"server-sid\" tr2-client-events &&
grep \"key\":\"client-sid\" tr2-server-events
'
test_expect_success "client & server log negotiated version (v${PROTO})" '
test_when_finished "rm -rf local tr2-client-events tr2-server-events" &&
cp -r "$LOCAL_PRISTINE" local &&
GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
git -c protocol.version=$PROTO -C local fetch \
--upload-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-upload-pack" \
origin &&
grep \"key\":\"negotiated-version\",\"value\":\"$PROTO\" tr2-client-events &&
grep \"key\":\"negotiated-version\",\"value\":\"$PROTO\" tr2-server-events
'
done
test_done