Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Harald Nordgren <haraldnordgren@gmail.com>
Subject: Re: [PATCH/RFC] upload-pack: fix slow fetches from a shallow repository
Date: Mon, 19 Oct 2026 06:27:28 -0700	[thread overview]
Message-ID: <xmqqpkx57rcv.fsf@gitster.g> (raw)
In-Reply-To: <pull.2455.git.git.1792275106640.gitgitgadget@gmail.com> (Harald Nordgren via GitGitGadget's message of "Sat, 17 Oct 2026 22:11:46 +0000")

"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> diff --git a/upload-pack.c b/upload-pack.c
> index 197bcfa279..844bf80575 100644
> --- a/upload-pack.c
> +++ b/upload-pack.c
> @@ -1718,9 +1718,8 @@ static void send_shallow_info(struct upload_pack_data *data)
>  
>  	packet_writer_write(&data->writer, "shallow-info\n");
>  
> -	if (!send_shallow_list(data) &&
> -	    is_repository_shallow(the_repository))
> -		deepen(data, INFINITE_DEPTH);
> +	if (!send_shallow_list(data))
> +		advertise_shallow_grafts(1);

The advertise_shallow_grafts() function is written for protocol
v0 and uses packet_write_fmt() to write raw data directly to the
named file descriptor (in this case, fd #1).

However, protocol v2 negotiation uses the packet_writer API.  When
sideband-all is in use, the response must be multiplexed over the
sideband channel.  Because the updated code fails to use the
packet_writer API, 'shallow' lines are written without the '\001'
band designator.  The other side then interprets 's' (the first
byte of 'shallow', which is 115 in decimal) as the sideband channel
and dies with a protocol violation.

 t/t5702-protocol-v2.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git c/t/t5702-protocol-v2.sh w/t/t5702-protocol-v2.sh
index 7e69ba7f84..df3ec8c1c9 100755
--- c/t/t5702-protocol-v2.sh
+++ w/t/t5702-protocol-v2.sh
@@ -15,6 +15,18 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 start_git_daemon --export-all --enable=receive-pack
 daemon_parent=$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent
 
+test_expect_success 'fetch from shallow server over v2' '
+	test_when_finished "rm -fr server shallow-server client" &&
+	git init server &&
+	test_commit -C server one &&
+	test_commit -C server two &&
+	git clone --depth=1 "file://$(pwd)/server" shallow-server &&
+	test_commit -C shallow-server three &&
+
+	git -C shallow-server config uploadpack.allowsidebandall true &&
+	git -c protocol.version=2 clone "file://$(pwd)/shallow-server" client
+'
+
 test_expect_success 'create repo to be served by git-daemon' '
 	git init "$daemon_parent" &&
 	test_commit -C "$daemon_parent" one


  reply	other threads:[~2026-10-19 13:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-17 22:11 [PATCH/RFC] upload-pack: fix slow fetches from a shallow repository Harald Nordgren via GitGitGadget
2026-10-19 13:27 ` Junio C Hamano [this message]
2026-10-19 14:50   ` Harald Nordgren
2026-10-20 13:40 ` [PATCH v2] " Harald Nordgren via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqpkx57rcv.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=haraldnordgren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox