git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Christian Couder <christian.couder@gmail.com>
Date
Nov 17, 2026, 17:43 UTC
Message-ID
<20261117174353.1158905-5-christian.couder@gmail.com>
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: Christian Couder
Message 1 of 7 in “Allow merges with results over 2 GiB on 64-bit Windows”
  1. 0/3 Allow merges with results over 2 GiB on 64-bit WindowsChristian Couder, Nov 17, 2026
  2. 1/3 notes-merge: use size_t in write_buf_to_worktree()Christian Couder, Nov 17, 2026
  3. Patrick SteinhardtNov 18, 2026
  4. 2/3 odb: widen odb_write_object() length to size_tChristian Couder, Nov 17, 2026
  5. Patrick SteinhardtNov 18, 2026
  6. Christian CouderNov 18, 2026
  7. 3/3 xdiff: drop LONG_MAX check on merge result sizeChristian Couder, Nov 17, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.