🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #3222

[PATCH v2 3/4] diffcore-delta: use size_t for the size of the buffer to hash

#3222
From: Elia Pinto
Date: Tue, 17 Nov 2026 10:37
36 lines
11823 bytes
hash_chars() in diffcore-delta.c takes the buffer size as an "unsigned
int". With a file of 4GiB or more, it hashes only a prefix; because the
similarity score is calculated against the full size, similarity is
undervalued, so true renames are missed, which also affects
"git log --follow" and merges.

This was verified using a 16-bit simulation, where
"git diff --cached -M" reported a delete and add instead of a rename
(e.g., "D a" and "A b" instead of "R099 a b").

Make the size variable "size_t".

Triggering this requires processing a file of 4GiB or more, so no test
is added.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 diffcore-delta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/diffcore-delta.c b/diffcore-delta.c
index 2b7db39983..7f10f79ffe 100644
--- a/diffcore-delta.c
+++ b/diffcore-delta.c
@@ -127,7 +127,7 @@ static struct spanhash_top *hash_chars(struct repository *r,
 	unsigned int accum1, accum2, hashval;
 	struct spanhash_top *hash;
 	unsigned char *buf = one->data;
-	unsigned int sz = one->size;
+	size_t sz = one->size;
 	int is_text = !diff_filespec_is_binary(r, one);
 
 	i = INITIAL_HASH_SIZE;
-- 
2.53.0
Technical Details
Message-ID: <3427c3d2c8c689371bcc111f0915853a0f679f5d.1794909894.git.gitter.spiros@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-75593-linux-kernel-git=dewy.ru
References: <cover.1793546752.git.gitter.spiros@gmail.com> <cover.1794909894.git.gitter.spiros@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-75593-linux-kernel-git=dewy.ru
From: gitter.spiros@gmail.com (Elia Pinto)
Newsgroups: linux.kernel.git
Subject: [PATCH v2 3/4] diffcore-delta: use size_t for the size of the buffer to hash
Date: Tue, 17 Nov 2026 11:37:55 +0100
Organization: Usenet Network
Message-ID: <3427c3d2c8c689371bcc111f0915853a0f679f5d.1794909894.git.gitter.spiros@gmail.com>
References: <cover.1793546752.git.gitter.spiros@gmail.com> <cover.1794909894.git.gitter.spiros@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2304691"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:tsGOSHq05gjyoIzlRO2FeEP3UYY= sha256:/0D/979Sgl6GUPJ8V8DVW2Dn+VumjXDbqS1yPliBq8g=
	sha1:zzv54y2gQk/1lmuil8ZYoVoEUMI= sha256:INWKx6CzhKKc5GdRovwl50NVmmo3D+ODcAoVb0F7NVo=
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 93F76114F09; Tue, 17 Nov 2026 13:38:31 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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.249,
	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 BHEoBApMyJse;
	Tue, 17 Nov 2026 13:38:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=git+bounces-75593-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 61ECB114F06; Tue, 17 Nov 2026 13:38:20 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id E76AC2BE9E; Tue, 17 Nov 2026 10:38:16 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794911891;
	b=g20HrVq5ZqzNEVy8l4pO6UqkUVOMcgrCp68cZAkY1Ya1Ng/aP4gc0G4qtJse8egdn7/P
	 FbV8fVqSw97IFScXWgyqsVv2iO3rC/BIhYCKi60uTYbqBzhlnpZ4M8nUWBsu4PRkq7S6/
	 IVdvhptq/AHVORXCcUzpo0tLVltjhpdbemc2Og5TKBgOzoyZuWSef2m+Q4GmdUhuB++ud
	 jxKaSLu0OCYZilYQkN9nSAx5J6o+5my+lxaUNEqy4JPZKTGUVbAtaJzjWqI6pi9tzKau9
	 dgNagrhGGkgm6bzDhZhv68je6qFTdLO+zsYKjkVY/uHYGbdFuaLHuGhcuYfoMzCOYTg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794911891;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=WgBAFchSM0ukp7/Xjkswu8plhhaucOrtBSThrOjqYFY=;
	b=N69n3itbwxb5WRXvqibPZBF4DME/z6FpcfwW4pWchWlCCJ0KGrdePm7xNUVJKrMeIm98
	 66+PXXwxJoyOp8M4EMUBIybP+2stiifkocC2YzKCwc8WcAeMC9+TjfjmfZIVgb3/dS9B7
	 7xzK6x37bZTHFCcVbo5TCmdiD0lv0h0PWOvv6cRnH+iPQOdrlA7yNdMOILkU17HqwiBCU
	 DW/V9bK3tOujDHoDLkg088nEaefXVN7tsEIimHw85euUrvu+y5oN/KyAfhKH+wJDVb0T3
	 mPJMSEOSmiktG+ZOaTgTGY71fBcRS+DlHkJTGAdILz3cVkUeLaTIIvuMFzNTzpftwRg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=HpS1GDSR;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 28EAF606A88A;
	Tue, 17 Nov 2026 10:38:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=HpS1GDSR
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.48
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794911890;
	b=5rqyVAEY0fd8GLgJaVpuV3jUpY55DaKHxZ6MVSv19Rb20o7tnMRrVab4B2/4mZSlxG8j
	 CvO689FhCoYsH8Fw1M6ywTn8bdxv+vOYYNIYAdlGxZdOnHk1yw2iginieDk7gL0Th+LDz
	 EJ/eDiLNHrW1Y75IsVrdHx7YOp2H/Gz4pFDSViYfsWk6K/J8zQwhimY2B1ISlSOuBJ9ja
	 3sE06jDWJlkCudeclpVWJVs2+FxUyp3nhiDPBo0NG00T9UUNZ8pUr/D5dOj6UjRTyIX9C
	 sq6XqfT1uV1WQOJvPI7rm9Gql553LMj54TbqmvUyBEOpT2iD1Ma4CtE1Rzfgx9TiSrA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794911890;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=WgBAFchSM0ukp7/Xjkswu8plhhaucOrtBSThrOjqYFY=;
	b=Sl2UwZPXQu9AlVPWhPYnmSNXsP8T2WxR7il9SFB2XBHOAzV6aLAccnV2H7DrOYDbtsFF
	 6IauEE8qltRSz4gJMh62c7QYCm3oWijaF+TQ0pAIhHGRaVel3zXck4l0WHBU6CuKor7Se
	 WMCVoLylPMChAVpDRCbByW7Cho5gAmIVw81cu5Fo2k4jw31rPhPPcLK7AA1RWpojWPbke
	 JqmVR8AlWa7HuRe6XjkpV1wEndRbc/nEsdF8G4CVsiz13c6Ia/XRFn2y3I/Ant37qCYOD
	 MLvWyhkryjCEXZA0ptSs9he/dhI887nkog7oTTc7chIOV7nt9jaZ2GC22IyXOu5MKjg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=HpS1GDSR;
	arc=none smtp.remote-ip=209.85.221.48
X-Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0831606A895
	for <git@vger.kernel.org>; Tue, 17 Nov 2026 10:38:09 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F0831606A895
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-wr1-f48.google.com with SMTP id ffacd0b85a97d-4a42b34e930so378045f8f.2
        for <git@vger.kernel.org>; Tue, 17 Nov 2026 02:38:09 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1794911888; x=1795516688; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=WgBAFchSM0ukp7/Xjkswu8plhhaucOrtBSThrOjqYFY=;
        b=HpS1GDSR9jD50zhUPfRXbMoHEmXo8bWMyqxLJGA5ex/e3QZyDqPoFUv7jyEwZiIgR/
         xMUtWQUGOOZL/ZExDp8HUKLIIeAtIdP7xYGpNzFQaHSpP1JlkFVmh967aorDCRtAS16x
         zBEnaBh42+WGT6hM63xkBo9MBxzWGd8wiXSVkOHcEpM9cnj8LYs0BOD12yJ7uicKe+wi
         gafy0awr5aQaQVqVWyeKfaycAZB6BWrbCTMuE+NGqJCb/gIG+q4xaIhRAaaT0qAG/hMH
         HVo39PnQejxzEOHhDJEPW4fpZhEfcCSNzBRvafyJBKnvsN3xvRDcoVqwh3No3pOV+M+G
         raRw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1794911888; x=1795516688;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=WgBAFchSM0ukp7/Xjkswu8plhhaucOrtBSThrOjqYFY=;
        b=VOJ/R23lAZhodTJ/7qr/wW6VNetZlAf9RcBohEbgF2YJpRVtZqhy1u7BUwpHoVhHOh
         ERRu9AR4qCtmdijjW9Esu0+gbfc30ZXucL/9jtyl7oalKEARA4zBHApLqTYs8rYoIILs
         U2o1qPYjpi9rzsCaABB70HojKPzeA1BYZcS9umhjs7H/BA/39mwP4x7z/KMhrRKOk5bG
         /xkRaWBhbq4efuZEll7/UdzhmBqiRB4CeXHcf8fW/uf373/742u4/8MyrS8Ky8gB93zP
         vCIHr9Oh/nLw7sVd7MlekI/EkoGAzD0Jr7N8B4F3bowHi6NhCViRrfkzLXhgqxXjjU4D
         6Cxw==
X-Gm-Message-State: APuU4Z8eM6dqJEkxMh1w8Z3FNHXDhgKx98yk4SBdoax38HQLCyFS8eqW
	d0ZYbMMZrQpl+x3Lar4NsshJtQuTGaKwLVGIYmLQHo12MIokxpWaaITqYE+93Q==
X-Gm-Gg: AZFdTZc6fhlCnKdNiVyxU5IOEVCzo+ll6gd6YUOrrN0+ipKBBTkD+IP2scAmOQfelWn
	NVlku7IMd+DMdlKZBqyr19hdr2RLxgT5i6slUTGMyQPl4g5vhaZhgJxzei8LWObwKWLKcyZC/jN
	p3rR3xgOOnBtMQ4Ff/pM02eKFPVOvQclIJqq5KdJMBjkv+goTEp/8tOUmEURJj+M2QM5gKZkmbZ
	WPgjZb5ZhKgxSi9Pn00qkw3HmmiUNgxZt9KI3lRC0e5Uu5+H0RA/hfifVqJpyUabq5NCzDD5E1g
	LjS+GexvwRujeTFOM64FzYr1B1F5UPua+mpRhzWiNX5Jr38rQcrdTPjCTtGh73Mvssp0v95SDu1
	zDrqBjtASpK/ltk8JNHhINO/x7HaqasDF0T+PZ5KJgJNP0CwxQ/d02MQidKM/evSE6kisn8LTgH
	6ycB4I9N/K4RpKKFLoGUQipnyfB+YPu7HyL+oE+QsfgZIY1AjD3xAaoMmK42F7KzL/oMPpaykRY
	yB6NVtBT3S8G77dPxYNY9SpwE/GqhvjG62WUGyv/dwM8yghe1T4CL4m+IlFO0siGU8QmExiahZa
	NbITK1zXmTrOtdhwRA6ZLxV/THQxeKjLWDqCK8yLgKQ/B7E74N6+srauX7POu89Y
X-Received: by 2002:a05:6000:2010:b0:4a3:1e75:16c9 with SMTP id ffacd0b85a97d-4a31e751912mr5733653f8f.40.1794911888270;
        Tue, 17 Nov 2026 02:38:08 -0800 (PST)
X-Received: from ubuntu26lts1.example.com ([151.31.213.44])
        by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49c608d10b2sm44715932f8f.44.2026.11.17.02.38.06
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Tue, 17 Nov 2026 02:38:06 -0800 (PST)
X-Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Elia Pinto <gitter.spiros@gmail.com>,
	Junio C Hamano <gitster@pobox.com>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <cover.1794909894.git.gitter.spiros@gmail.com>
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list