🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #753

[PATCH/RFC] upload-pack: fix slow fetches from a shallow repository

#753
From: "Harald Nordgren via GitGitGadge...
Date: Sat, 17 Oct 2026 22:11
69 lines
10134 bytes
From: Harald Nordgren <haraldnordgren@gmail.com>

Fetching from a shallow repository with a long history can hang. In a
homebrew-core clone with 900k commits, fetching one new commit into
another clone took 7 minutes. The same fetch over protocol v0 takes
about a second.

Over protocol v2, the server goes through all of its history to work
out which of its shallow commits to tell the client about, and a
history with many merges makes it go over the same commits again and
again. Protocol v0 lists all shallow commits and lets the client sort
them out.

Do the same in v2 when the client does not ask for a depth. This also
makes `git clone --reject-shallow` refuse a shallow repository over v2
in every case, as it already does over v0. For `git fetch --unshallow`,
which still needs to go through the history, visit each commit only
once.

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
---
    upload-pack: fix slow fetches from a shallow repository
    
    Fix git fetch hanging for minutes when the remote is a shallow
    repository with a long history.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2455%2FHaraldNordgren%2Fupload-pack-shallow-walk-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2455/HaraldNordgren/upload-pack-shallow-walk-v1
Pull-Request: https://github.com/git/git/pull/2455

 shallow.c     | 3 ++-
 upload-pack.c | 5 ++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/shallow.c b/shallow.c
index 8e244a5669..921db5e17a 100644
--- a/shallow.c
+++ b/shallow.c
@@ -209,7 +209,8 @@ static struct commit_list *get_shallows_or_depth(struct object_array *heads,
 				*depth_slot = xmalloc(sizeof(int));
 				**depth_slot = cur_depth;
 			} else {
-				if (cur_depth >= **depth_slot)
+				if (depth == INFINITE_DEPTH ||
+				    cur_depth >= **depth_slot)
 					continue;
 				**depth_slot = cur_depth;
 			}
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);
 
 	packet_delim(1);
 }

base-commit: c51408889c3b372814bc20b9431c3b74d0d268eb
-- 
gitgitgadget
Technical Details
Message-ID: <pull.2455.git.git.1792275106640.gitgitgadget@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-72324-linux-kernel-git=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-72324-linux-kernel-git=dewy.ru
From: gitgitgadget@gmail.com ("Harald Nordgren via GitGitGadget")
Newsgroups: linux.kernel.git
Subject: [PATCH/RFC] upload-pack: fix slow fetches from a shallow repository
Date: Sat, 17 Oct 2026 22:11:46 +0000
Organization: Usenet Network
Message-ID: <pull.2455.git.git.1792275106640.gitgitgadget@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3157265"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+wSIJf5315MN6GSKpWWC4NBXsfc= sha256:mqsavFziWvPyZNM48AuMbSd107LmG5bLZhUGTmVwzsI=
	sha1:Xw3iydd83oa3Z8nKEEOgQ1VyxxA= sha256:P3hXZ3rq7/X3FJg0dVzYF+653DInHSZokuO/W04PIYs=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id E298D11075A; Sun, 18 Oct 2026 01:12:43 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id jVJDHa2wE7Or;
	Sun, 18 Oct 2026 01:12:41 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-72324-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 8F4891105D3; Sun, 18 Oct 2026 01:12:31 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id 7E5343C7C7; Sat, 17 Oct 2026 22:11:51 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 4976849CF27;
	Sat, 17 Oct 2026 22:11:51 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oS+RpcY5"
X-Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F50743DEAC
	for <git@vger.kernel.org>; Sat, 17 Oct 2026 22:11:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.171
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792275110; cv=none; b=Yc8z1tGMDXwkKJGVNPNcU4KSJ4SfZJ36uTLJcyRj15+UA1BG6MLUFG3Gcu/21HYjsdVqPw7IYWkljk53UFtMOIKYqwbAX834+2bTsBhI0cY62Z2jqIqfvK+lhfQtdCjZgVL5bpz8s7k0w48MShrfSUDHL7U3zwyTnT3ju3PuNHU=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792275110; c=relaxed/simple;
	bh=aYCEkvxLkraEWgaCYYyTmGlQSoCSIJUP2FdkaBLz5IU=;
	h=Message-Id:From:Date:Subject:Content-Type:MIME-Version:To:Cc; b=rbrjzm3q37trnhmemPnJ2tIZWnsPBz1OWK2Iz5v5QcWzdCz87TpfEiPefjJNr2qx5IILU+vFMhHmkzlsScNf1E67pTR8F4nLuAVyEs67/KwSSioX4p94aF+zZ+OIDAa3iek38sR8z3WoXenRhMVOwYwu0vaAnorqLF+k+Q3UtlE=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=oS+RpcY5; arc=none smtp.client-ip=74.125.82.171
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-3514b90bb89so2579496eec.1
        for <git@vger.kernel.org>; Sat, 17 Oct 2026 15:11:48 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792275108; x=1792879908; darn=vger.kernel.org;
        h=cc:to:mime-version:content-transfer-encoding:content-type:fcc
         :subject:date:from:message-id:from:to:cc:subject:date:message-id
         :reply-to:content-type;
        bh=v+HlR+I8lODrRV4k5UNVO1Clv05kAqIMtf9qDFfWTj8=;
        b=oS+RpcY515dj21em3uakhSnpwdBoTOg7SRu7N/aD8sWXugBVMrsqjU3G6Ohcvg+Pxa
         uet8GIb/A+sjvT6xIsXl7Flp+Cla+uNz7nPaJypdFMzPEmFLTJmYWuIFGhNad+HrcpAF
         l1N/opO/2/2NWKLw1DwkIZgICcFVw7j6EaNOKguVeS442G060QpVhS7mm3Hpx/NDKq2O
         Pe5HA3vRCETeWtIMJ5KS7AaGB93VXGCOoL5fa20ErKWAAwv9o5UtuJ/y6Xv59b5rP/Ib
         lPHQCFu26p0LOgfv39d4FIGgTBW2pEv9wuKBY5ZuHN3AiC7maCEeJdn5+cvhtemP/lvA
         XEpg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792275108; x=1792879908;
        h=cc:to:mime-version:content-transfer-encoding:content-type:fcc
         :subject:date:from:message-id:x-gm-gg:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to:content-type;
        bh=v+HlR+I8lODrRV4k5UNVO1Clv05kAqIMtf9qDFfWTj8=;
        b=bkaiH/0KRR1ExOU7wvc47RenljyEtbIL6zBNjCNejWpz72g7Z0J6r38qEuO6E/d9yp
         xwUiyfQJsWfjyfaka4BDn0vhokO2t4TutcgBtGlWHDtxXdU468h+UvcGn6FOzEgHlFeK
         uGhsCMKieBev7JkYUB8+tsIxbBa2KcWIhRbpw88OCG7HQSO9mQ1waUofWhx8XYWk4mRx
         6Ykb5CxfIwJRc249XaCdE2xYpkQHkgCA8OiGO+lGyZbKte+MblrnGgFcvsScLnFDrC5h
         aqD32eRMfWh99rfhM95SSCt3puV0Wr8jNipjhRZm9YhnQPF8u0AUwAdY3PL+BYlKWgik
         mCxA==
X-Gm-Message-State: AFq9FYKEu28ZYmQPj5gHKXKnaeHox8lo5jwr1p2uqeJBor5JZiXEy8ME
	VIntrR1mWV2UnvuXqWzuiVT/T0SrZxhsSNaU6sBCIlGZ7R2c1StgOtSjUmzkJCj6
X-Gm-Gg: AYBFou3GpK6vGqul1SPDpa/BR/jGxg880OCelGpc6spO8xROOunShDd+W6ap9S4ZgYo
	QrYSLn7NxMs7v92YYzPNy6UUttLXX0MS3OwnAJAER5aVQraigT4NDHy4pHH7dj4oCJIMkL2Ef11
	JfckBvJ0QTrBsT+9RfelminUsiODFEfRNRxOjmuFdDSsjSDr0BM8a+/V+ncARMS27Eu4FVZYG5H
	qsTU0+DZYy2xBvI1lRoE746o4a3Zo0C85Wi2blLn/P86wCcgV2kYYn6QEKowmWH5QwjKqPFtJoT
	1KcS2d37U+juNn8fwL6Zftqo0nls6V4B3YcIHGoxGTGZszBZdGliDsgb2GYMGDxdKL3wvljsuKa
	gS5pLhPE7NBi0F8mxGmVIgJbkDC7SjZs2wTpSy0aVKGqwNqTVS9uFoqXaxb3G6bgrN0MBdojiiG
	246F/Lc9NNq/LQgI+1JlyoHfMdcUgLot9QUO6SzHI/fQB05q7snDmUuev5nml+DhteKS9Qucc=
X-Received: by 2002:a05:7300:e9cc:10b0:361:167c:2364 with SMTP id 5a478bee46e88-361a146d9dfmr5687926eec.8.1792275107975;
        Sat, 17 Oct 2026 15:11:47 -0700 (PDT)
X-Received: from [127.0.0.1] ([4.236.92.177])
        by smtp.gmail.com with ESMTPSA id 5a478bee46e88-36082a7b33bsm34249504eec.24.2026.10.17.15.11.47
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Sat, 17 Oct 2026 15:11:47 -0700 (PDT)
X-Fcc: Sent
X-Precedence: bulk
X-Mailing-List: git@vger.kernel.org
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-Cc: Harald Nordgren <haraldnordgren@gmail.com>,
    Harald Nordgren <haraldnordgren@gmail.com>