Skip to content

Commit 626beeb

Browse files
steadmongitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6626245 commit 626beeb

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

connect.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ enum protocol_version discover_version(struct packet_reader *reader)
164164
BUG("unknown protocol version");
165165
}
166166

167+
trace2_data_intmax("transfer", NULL, "negotiated-version", version);
168+
167169
return version;
168170
}
169171

protocol.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ enum protocol_version determine_protocol_version_server(void)
7373
string_list_clear(&list, 0);
7474
}
7575

76+
trace2_data_intmax("transfer", NULL, "negotiated-version", version);
77+
7678
return version;
7779
}
7880

t/t5705-session-id-in-capabilities.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ do
7373
grep \"key\":\"server-sid\" tr2-client-events &&
7474
grep \"key\":\"client-sid\" tr2-server-events
7575
'
76+
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
86+
'
7687
done
7788

7889
test_done

0 commit comments

Comments
 (0)