git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] fetch-pack: print all relevant supported capabilities with -v -v

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jun 20, 2019, 11:59 UTC
Message-ID
<20190620115951.13629-2-pclouds@gmail.com>
In-Reply-To
<20190620115951.13629-1-pclouds@gmail.com>

When we check if some capability is supported, we do print something in verbose mode. Some capabilities are not printed though (and it made me think it's not supported; I was more used to GIT_TRACE_PACKET) so let's print them all.

It's a bit more code. And one could argue for printing all supported capabilities the server sends us. But I think it's still valuable this way because we see the capabilities that the client cares about.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 fetch-pack.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/fetch-pack.c b/fetch-pack.c
index 0532029f2c..de935f8776 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -902,7 +902,9 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
 	sort_ref_list(&ref, ref_compare_name);
 	QSORT(sought, nr_sought, cmp_ref_by_name);
 
-	if ((args->depth > 0 || is_repository_shallow(the_repository)) && !server_supports("shallow"))
+	if (server_supports("shallow"))
+		print_verbose(args, _("Server supports %s"), "shallow");
+	else if (args->depth > 0 || is_repository_shallow(the_repository))
 		die(_("Server does not support shallow clients"));
 	if (args->depth > 0 || args->deepen_since || args->deepen_not)
 		args->deepen = 1;
@@ -935,11 +937,17 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
 		print_verbose(args, _("Server supports %s"), "allow-reachable-sha1-in-want");
 		allow_unadvertised_object_request |= ALLOW_REACHABLE_SHA1;
 	}
-	if (!server_supports("thin-pack"))
+	if (server_supports("thin-pack"))
+		print_verbose(args, _("Server supports %s"), "thin-pack");
+	else
 		args->use_thin_pack = 0;
-	if (!server_supports("no-progress"))
+	if (server_supports("no-progress"))
+		print_verbose(args, _("Server supports %s"), "no-progress");
+	else
 		args->no_progress = 0;
-	if (!server_supports("include-tag"))
+	if (server_supports("include-tag"))
+		print_verbose(args, _("Server supports %s"), "include-tag");
+	else
 		args->include_tag = 0;
 	if (server_supports("ofs-delta"))
 		print_verbose(args, _("Server supports %s"), "ofs-delta");
@@ -959,15 +967,19 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
 			print_verbose(args, _("Server version is %.*s"),
 				      agent_len, agent_feature);
 	}
-	if (server_supports("deepen-since"))
+	if (server_supports("deepen-since")) {
+		print_verbose(args, _("Server supports %s"), "deepen-since");
 		deepen_since_ok = 1;
-	else if (args->deepen_since)
+	} else if (args->deepen_since)
 		die(_("Server does not support --shallow-since"));
-	if (server_supports("deepen-not"))
+	if (server_supports("deepen-not")) {
+		print_verbose(args, _("Server supports %s"), "deepen-not");
 		deepen_not_ok = 1;
-	else if (args->deepen_not)
+	} else if (args->deepen_not)
 		die(_("Server does not support --shallow-exclude"));
-	if (!server_supports("deepen-relative") && args->deepen_relative)
+	if (server_supports("deepen-relative"))
+		print_verbose(args, _("Server supports %s"), "deepen-relative");
+	else if (args->deepen_relative)
 		die(_("Server does not support --deepen"));
 
 	if (!args->no_dependents) {
-- 
2.22.0.rc0.322.g2b0371e29a
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 2 of 3 in “fetch-pack: move capability names out of i18n strings”
  1. 1/3 fetch-pack: move capability names out of i18n stringsNguyễn Thái Ngọc Duy, Jun 20, 2019
  2. 2/3 fetch-pack: print all relevant supported capabilities with -v -vNguyễn Thái Ngọc Duy, Jun 20, 2019
  3. 3/3 fetch-pack: print server version at the top in -v -vNguyễn Thái Ngọc Duy, Jun 20, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.