🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #3251

[PATCH 0/3] Allow merges with results over 2 GiB on 64-bit Windows

#3251
From: Christian Couder
Date: Tue, 17 Nov 2026 17:43
79 lines
13656 bytes
Two recent series improved how merge results are sized:

  - `jk/xdiff-size_t` (merged by 81db32ddce) replaced `mmbuffer_t`
    with `mmfile_t`, whose size is a `size_t` instead of a `long`.

  - `kn/safer-mem-arithmetic-in-xdiff` (merged by 1c93cc03ea) computes
    the merge buffer size as a `size_t` instead of an `int`, with
    overflow checks.

As the latter targets the `maint` branches, which don't have
`jk/xdiff-size_t`, it also makes `xdl_do_merge()` fail when the result
is bigger than `LONG_MAX`, so that it cannot be silently truncated
when stored into mmbuffer_t's `long` size on LLP64 platforms like
64-bit Windows.

On `master`, that check is not needed for `mmfile_t` anymore, but as
Kaartic pointed out when that series was discussed, merge results were
still passed on to a few functions taking an `unsigned long`. This
series converts those to `size_t`, and then removes the check.

Patch 1/3 also fixes an existing bug: since c6a4629e32 (odb: use
size_t for object_info.sizep and the size APIs, 2026-06-15), a
delete/modify conflict in `git notes merge` on a note of 4 GiB or more
silently writes a truncated note on LLP64 platforms. That patch could
be applied on its own.

## Overview of the patches

  - Patch 1/3 changes the size argument of `write_buf_to_worktree()`
    in "notes-merge.c" from `unsigned long` to `size_t`.

  - Patch 2/3 uses `size_t` for the length argument of
    `odb_write_object()`, `odb_write_object_ext()`, the
    `odb_source_write_object()` wrapper and `write_loose_object()`,
    and for the size stored in `struct inmemory_object`, so that
    object lengths are not truncated before reaching the already
    `size_t` backends.

  - Patch 3/3 removes the `size > LONG_MAX` check in `xdl_do_merge()`,
    lets the `t4300` tests that expect a successful big merge run on
    LLP64 platforms, and removes the test that expected a failure
    there.

## Testing

The code paths changed here only behave differently where `long` is 32
bits and `size_t` is 64 bits, so Linux and macOS CI cannot exercise
them. It would be very nice if someone with a 64-bit Windows setup
could run `t4300` with `GIT_TEST_LONG=1`. Beware that it needs enough
memory and disk for a merge result just over 4 GiB.

## CI

Some test scripts didn't want to start on MacOS but otherwise all the
tests passed, see:

https://github.com/chriscool/git/actions/runs/44118577071


Christian Couder (3):
  notes-merge: use size_t in write_buf_to_worktree()
  odb: widen odb_write_object() length to size_t
  xdiff: drop LONG_MAX check on merge result size

 notes-merge.c         |  2 +-
 odb.c                 |  2 +-
 odb.h                 |  4 ++--
 odb/source-inmemory.c |  2 +-
 odb/source-loose.c    |  2 +-
 odb/source.h          |  2 +-
 t/t4300-merge-tree.sh | 13 ++-----------
 xdiff/xmerge.c        |  4 ----
 8 files changed, 9 insertions(+), 22 deletions(-)


base-commit: e1ec09b23c8e0deb21a0b95ac5996422277395d4
-- 
2.56.0
Technical Details
Message-ID: <20261117174353.1158905-5-christian.couder@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!git+bounces-75621-linux-kernel-git=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!git+bounces-75621-linux-kernel-git=dewy.ru
From: christian.couder@gmail.com (Christian Couder)
Newsgroups: linux.kernel.git
Subject: [PATCH 0/3] Allow merges with results over 2 GiB on 64-bit Windows
Date: Tue, 17 Nov 2026 18:43:54 +0100
Organization: Usenet Network
Message-ID: <20261117174353.1158905-5-christian.couder@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2391660"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:vHGQkq8/3JuPfwEh5Oa7ndjfIEs= sha256:dmy3nMc9gYZ1/gNeh5QM1NBwOU0+jifaRTGhZyLPipc=
	sha1:00x+e70c7/5G/MmC22GhPUGdUxU= sha256:VT2K9mWoZAh2d+ywuSwbCP7DkbHxB6zuvBOMY4X/NcE=
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 C3EC411501E; Tue, 17 Nov 2026 20:44:48 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.148
X-Spam-Status: No, score=-3.148 tagged_above=-9999 required=6.31
	tests=[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,
	URIBL_BLOCKED=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 huMW6pPKvI1e;
	Tue, 17 Nov 2026 20:44:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=git+bounces-75621-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 2ADC6115020; Tue, 17 Nov 2026 20:44:30 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 0335E60ED37; Tue, 17 Nov 2026 17:44:30 +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=1794937469;
	b=V9oyxb4iEaQnFREIiGAmcvDDklH8mU9kSvo8fWGRJBmBg0u4lcxKV9IzIJUMcyV2P64T
	 BMK0mNFc8r8ypPG4rR3ZMG8z0QQwBS2aWS9pVJlKGTLMniiS2nzOmydkCP4kmEDt7VPTi
	 8ulwI2v8ob2kxoaXXOdhx5tf3pkGtBj0MRmk1qNp82SaZ9O49y149w4ocKEda2Xm8f5pp
	 +f1eDLNvIT9pH276qGRgiNpnTnit0icSuL4dZTRrcFUUfQD3zMz1zzGZ9pGIXWdtm1hii
	 A4f52/S1SQNodM+CULLsNtzlbUbmZRHXO64MCwqomSCY/xqMcdqoJSOSBRdENn1hOjw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794937469;
	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:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=eJPBlDee2qKhnySbxjTxynKyUfMc+GGtfZ/VYgKFv1Y=;
	b=SmXlAONgLZDkwx9Dd49z6DYJBialI86ep2ev7dEfOUBCsnnSx393fFUpXS7oV5+fw0Wk
	 rZ8Zl6HLMgY5izH3Rbiq5bl0g3BLOiJF2WJbNMB/gr5/ZWSGhktRNfFnLxcpJwxV7wEbH
	 JTOS4I3Ru7XzkYxmn8oZPMd66LklEFKP38vIg0y/IN966Cs5Qu4mrqAZvIijTInoRA2DT
	 O9PmNHYI4IIzzSxdfWbrclCpLA+vxSzNp3RszMWBbZZOJZrzabxDS+7zL+m3ISh1K/f4D
	 gmGq+lUP47PUzSIpNebLzATDVaN5TVeYct4g8CD5boPRn4zJ0v72xhnwqzk95GaWjMg==
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=KvFmfHqD;
	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 5A5F1606A888;
	Tue, 17 Nov 2026 17:44:29 +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=KvFmfHqD
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.51
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794937468;
	b=ZtxLOMW17iccqMuwdcPo5On64eaouAkFSE1SvXM83egOpKwr14xOMzQvbquBJjiIj31F
	 iXuXTHOqbC1hWRmvL7qckyC0MdruXAFBxHH7103Xj6WZt1XehjxsVC+kWZv+p0dC3WaAM
	 +Zj820ud3re5rkYNSoVwBExZwdrd314ORNBQyFusCYCBKhnoa9lVmvnMSkMLwKps2m+eD
	 2k0IIyKj3PzaCfnalWpBM7SJGDbDZzd5VOkHYlnx3rImX+DMjcDACNCHR/BhUp5UllTAo
	 Kdz/+AhQHq89QzgYqBLgCO7W3ZUeOZRB46akRGpRg5MQLgQyaostloTG4o+TykGlNkg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794937468;
	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:MIME-Version:Content-Transfer-Encoding;
	bh=eJPBlDee2qKhnySbxjTxynKyUfMc+GGtfZ/VYgKFv1Y=;
	b=EeiyKqZC6yPyZycZN+BBJaS7SsV0eyilEYuf9w/5WwdMX6POjXSoHhqsHco4QCrR9js4
	 c3CvdIPIVXMRgyc7ERq8gkYMUxK0pM/ZPj8OsHtkF206+iKmMCbO0Turkq0FWmQaUmwtv
	 ivPn2MYiELaUahMSSxtXJeiPOmqx8XHZufrrYlHqHKuiZH5kg55RX8xpPv4Z11fE1lntb
	 yYwwq8Viq5Ig+qUWxRn2iOcneRjJwqncPaCm3GaYBESYrw2BCnb5hQF2Zd+8Jg5PPRNJB
	 Pv0OX6lgU7kswRFb3JpdlEknqR/lg9Gbf8xEh54O7jlqv+lADgDSeSmpPpvNIW7WAOw==
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=KvFmfHqD;
	arc=none smtp.remote-ip=209.85.218.51
X-Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51])
	(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 2EE63606A33D
	for <git@vger.kernel.org>; Tue, 17 Nov 2026 17:44:28 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2EE63606A33D
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-ej1-f51.google.com with SMTP id a640c23a62f3a-c445c95d553so731406966b.1
        for <git@vger.kernel.org>; Tue, 17 Nov 2026 09:44:27 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1794937466; x=1795542266; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=eJPBlDee2qKhnySbxjTxynKyUfMc+GGtfZ/VYgKFv1Y=;
        b=KvFmfHqDHN1NquQ0si3ZIiLSvEI1yn7sQMaH03EA/mjgRgKsrc70gPZV+TeiGMu1i9
         GzaN65Enu6R6lxbQxfGEWFvQuHiBgJlvlKePXmPJVBFQauL+b3k8hBnQ2Rafz7PvT1Zo
         YHy4s5EkZx3IQeRpEApHUDAFWITmF1TxhSlwXQgQOY6Z1cQDNZhav+Ms+kBLB1gOQlXv
         thMxLl9JHmg8nVKykRx3a13RwJfL6bxOANZpRU0LrM0jabLbHYXTPDPK6CNJbQL9sMDf
         VTZcB2uHGXgspfivtjTZQcOG9n+vFYq9nfc76C934/UdyodELLx8t/JUUKPOnDiwJFi0
         7JCQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1794937466; x=1795542266;
        h=content-transfer-encoding:mime-version: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=eJPBlDee2qKhnySbxjTxynKyUfMc+GGtfZ/VYgKFv1Y=;
        b=id7Z/p91ppBjdeDX25P92Mu+ucJ+hGFPkqK7j58XokIgg/4O4TSQjfED0afkYmlCAE
         UsrYg6cgs9EDmk+4IdZW97jq9AvT2g7AsnfV3XhFW91EaIEEm+7rYkrWMYTIl6loGaIu
         h8qXpLsqYSl1lApTr5CCzfva/CWGdQ/Xq/WtDVgswARF8W30Bnrmi/qHdnn7n6a+GI4e
         4kQ2K8uJrZtRHIVXdt7nO2q1ynW8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Received: by 2002:a17:907:1b16:b0:c49:8fa2:4a22 with SMTP id a640c23a62f3a-c50963d4060mr1275916866b.41.1794937466325;
        Tue, 17 Nov 2026 09:44:26 -0800 (PST)
X-Received: from christian--20230123--2G7D3 ([62.35.114.108])
        by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c510c83fe47sm7947366b.5.2026.11.17.09.44.25
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Tue, 17 Nov 2026 09:44:25 -0800 (PST)
X-Cc: Junio C Hamano <gitster@pobox.com>,
	Patrick Steinhardt <ps@pks.im>,
	Kaartic Sivaraam <kaartic.sivaraam@gmail.com>,
	Jeff King <peff@peff.net>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Christian Couder <christian.couder@gmail.com>
X-Mailer: git-send-email 2.56.1.495.ge87f5c5eed.dirty
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