threads / patch / 56353

patchls-remote: set packet_trace_identity(<name>)

Subject: [PATCH] ls-remote: set packet_trace_identity(<name>)

## tl;dr

2 messages between Aug 23, 2021 and Aug 23, 2021. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Ævar Arnfjörð Bjarmason· Aug 23, 2021, 13:17 UTC · lore

Set packet_trace_identity() for ls-remote. This replaces the generic "git" identity in GIT_TRACE_PACKET=<file> traces to "ls-remote", e.g.:

    [...] packet:  upload-pack> version 2
    [...] packet:  upload-pack> agent=git/2.32.0-dev
    [...] packet:    ls-remote< version 2
    [...] packet:    ls-remote< agent=git/2.32.0-dev

Where in an "git ls-remote file://<path>" dialog ">" is the sender (or "to the server") and "<" is the recipient (or "received by the client").

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/ls-remote.c    | 2 ++
 t/t5702-protocol-v2.sh | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)
Show changes to 2 files +5 −3

builtin/ls-remote.c, t/t5702-protocol-v2.sh

diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 1794548c711..f4fd823af83 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -84,6 +84,8 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 			     PARSE_OPT_STOP_AT_NON_OPTION);
 	dest = argv[0];
 
+	packet_trace_identity("ls-remote");
+
 	UNLEAK(sorting);
 
 	if (argc > 1) {
diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh
index 78de1ff2ad5..d3687b1a2e7 100755
--- a/t/t5702-protocol-v2.sh
+++ b/t/t5702-protocol-v2.sh
@@ -27,9 +27,9 @@ test_expect_success 'list refs with git:// using protocol v2' '
 		ls-remote --symref "$GIT_DAEMON_URL/parent" >actual &&
 
 	# Client requested to use protocol v2
-	grep "git> .*\\\0\\\0version=2\\\0$" log &&
+	grep "ls-remote> .*\\\0\\\0version=2\\\0$" log &&
 	# Server responded using protocol v2
-	grep "git< version 2" log &&
+	grep "ls-remote< version 2" log &&
 
 	git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
 	test_cmp expect actual
@@ -151,7 +151,7 @@ test_expect_success 'list refs with file:// using protocol v2' '
 		ls-remote --symref "file://$(pwd)/file_parent" >actual &&
 
 	# Server responded using protocol v2
-	grep "git< version 2" log &&
+	grep "ls-remote< version 2" log &&
 
 	git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
 	test_cmp expect actual
-- 
2.33.0.662.gbc81f8cbdca
Jeff King· Aug 23, 2021, 16:08 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH] ls-remote: set packet_trace_identity(<name>)

On Mon, Aug 23, 2021 at 03:17:49PM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 11 quoted lines
> Set packet_trace_identity() for ls-remote. This replaces the generic
> "git" identity in GIT_TRACE_PACKET=<file> traces to "ls-remote", e.g.:
> 
>     [...] packet:  upload-pack> version 2
>     [...] packet:  upload-pack> agent=git/2.32.0-dev
>     [...] packet:    ls-remote< version 2
>     [...] packet:    ls-remote< agent=git/2.32.0-dev
> 
> Where in an "git ls-remote file://<path>" dialog ">" is the sender (or
> "to the server") and "<" is the recipient (or "received by the
> client").

Thanks, this looks like an obvious improvement. I'm a little surprised it wasn't there already, but I guess I just missed it way back in bbc30f9963 (add packet tracing debug code, 2011-02-24).

-Peff

← back to recent threads