Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2022-07-26 19:27:11 +0300
committerJunio C Hamano <gitster@pobox.com>2022-07-27 09:45:01 +0300
commit1007557a4e6faf93339f5477b69bd42979c20a30 (patch)
treeb2ce74deba33d92556727bdb207fabcfed127793 /fetch-pack.c
parentbbea4dcf42b28eb7ce64a6306cdde875ae5d09ca (diff)
fetch-pack: write effective filter to trace2
Administrators of a managed Git environment (like the one at $DAYJOB) might want to quantify the performance change of fetches with and without filters from the client's point of view, and also detect if a server does not support it. Therefore, log the filter information being sent to the server whenever a fetch (or clone) occurs. Note that this is not necessarily the same as what's specified on the CLI, because during a fetch, the configured filter is used whenever a filter is not specified on the CLI. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fetch-pack.c')
-rw-r--r--fetch-pack.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/fetch-pack.c b/fetch-pack.c
index cb6647d657..a44eb32a71 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -292,6 +292,29 @@ static void mark_tips(struct fetch_negotiator *negotiator,
return;
}
+static void send_filter(struct fetch_pack_args *args,
+ struct strbuf *req_buf,
+ int server_supports_filter)
+{
+ if (args->filter_options.choice) {
+ const char *spec =
+ expand_list_objects_filter_spec(&args->filter_options);
+ if (server_supports_filter) {
+ print_verbose(args, _("Server supports filter"));
+ packet_buf_write(req_buf, "filter %s", spec);
+ trace2_data_string("fetch", the_repository,
+ "filter/effective", spec);
+ } else {
+ warning("filtering not recognized by server, ignoring");
+ trace2_data_string("fetch", the_repository,
+ "filter/unsupported", spec);
+ }
+ } else {
+ trace2_data_string("fetch", the_repository,
+ "filter/none", "");
+ }
+}
+
static int find_common(struct fetch_negotiator *negotiator,
struct fetch_pack_args *args,
int fd[2], struct object_id *result_oid,
@@ -389,11 +412,7 @@ static int find_common(struct fetch_negotiator *negotiator,
packet_buf_write(&req_buf, "deepen-not %s", s->string);
}
}
- if (server_supports_filtering && args->filter_options.choice) {
- const char *spec =
- expand_list_objects_filter_spec(&args->filter_options);
- packet_buf_write(&req_buf, "filter %s", spec);
- }
+ send_filter(args, &req_buf, server_supports_filtering);
packet_buf_flush(&req_buf);
state_len = req_buf.len;
@@ -1323,15 +1342,8 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out,
die(_("Server does not support shallow requests"));
/* Add filter */
- if (server_supports_feature("fetch", "filter", 0) &&
- args->filter_options.choice) {
- const char *spec =
- expand_list_objects_filter_spec(&args->filter_options);
- print_verbose(args, _("Server supports filter"));
- packet_buf_write(&req_buf, "filter %s", spec);
- } else if (args->filter_options.choice) {
- warning("filtering not recognized by server, ignoring");
- }
+ send_filter(args, &req_buf,
+ server_supports_feature("fetch", "filter", 0));
if (server_supports_feature("fetch", "packfile-uris", 0)) {
int i;