Allow merges with results over 2 GiB on 64-bit Windows
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 6 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | notes-merge: use size_t in write_buf_to_worktree()notes-merge.c | +1 | 1 reply | |
| 2/3 | odb: widen odb_write_object() length to size_todb.c odb.h odb/ +2 more | +6 | 2 replies | |
| 3/3 | xdiff: drop LONG_MAX check on merge result sizet/ xdiff/ | +2 | 3 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/3] Allow merges with results over 2 GiB on 64-bit Windows
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
Signature · 1 line
2.56.0