From: Christian Couder <christian.couder@gmail.com>
To: git@vger.kernel.org
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>
Subject: [PATCH 0/3] Allow merges with results over 2 GiB on 64-bit Windows
Date: Tue, 17 Nov 2026 18:43:54 +0100 [thread overview]
Message-ID: <20261117174353.1158905-5-christian.couder@gmail.com> (raw)
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
next reply other threads:[~2026-11-17 17:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 17:43 Christian Couder [this message]
2026-11-17 17:43 ` [PATCH 1/3] notes-merge: use size_t in write_buf_to_worktree() Christian Couder
2026-11-17 17:43 ` [PATCH 2/3] odb: widen odb_write_object() length to size_t Christian Couder
2026-11-17 17:43 ` [PATCH 3/3] xdiff: drop LONG_MAX check on merge result size Christian Couder
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=20261117174353.1158905-5-christian.couder@gmail.com \
--to=christian.couder@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=kaartic.sivaraam@gmail.com \
--cc=peff@peff.net \
--cc=ps@pks.im \
/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