<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/odb, branch next</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=next</id>
<link rel='self' href='https://git.shady.money/git/atom?h=next'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2026-05-09T02:25:31Z</updated>
<entry>
<title>odb, packfile: use size_t for streaming object sizes</title>
<updated>2026-05-09T02:25:31Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2026-05-08T08:16:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=606c1923803c6d49df45178041c486431ff7cb4b'/>
<id>urn:sha1:606c1923803c6d49df45178041c486431ff7cb4b</id>
<content type='text'>
The odb_read_stream structure uses unsigned long for the size field,
which is 32-bit on Windows even in 64-bit builds. When streaming
objects larger than 4GB, the size would be truncated to zero or an
incorrect value, resulting in empty files being written to disk.

Change the size field in odb_read_stream to size_t and introduce
unpack_object_header_sz() to return sizes via size_t pointer. Since
object_info.sizep remains unsigned long for API compatibility, use
temporary variables where the types differ, with comments noting the
truncation limitation for code paths that still use unsigned long.

Widening the producers to size_t in this way introduces a handful of
silent size_t -&gt; unsigned long narrowings on Windows, all in
builtin/pack-objects.c, where the consumers are still typed
unsigned long. Make those narrowings explicit with
cast_size_t_to_ulong() so they assert loudly the moment an object
actually exceeds ULONG_MAX bytes:

  - oe_get_size_slow() returns unsigned long but holds a size_t
    locally; cast at the return.
  - write_reuse_object() passes a size_t into check_pack_inflate(),
    whose expect parameter is unsigned long; cast at the call.
  - check_object() routes a size_t through SET_SIZE() and
    SET_DELTA_SIZE(), both of which take unsigned long via
    oe_set_size() / oe_set_delta_size(); cast at the three call
    sites in the OBJ_OFS_DELTA / OBJ_REF_DELTA branches and in the
    non-delta default arm.

The cast-only treatment is deliberately a stop-gap. Properly
widening oe_set_size, oe_get_size_slow's return type,
check_pack_inflate's expect parameter, object_info.sizep,
patch_delta, and the OE_SIZE_BITS bit-fields cascades into a series
that is too large to be reviewable, so the proper widening is
deferred to a follow-up topic. Until then,
cast_size_t_to_ulong() at least makes the truncation explicit at
the source: it documents the boundary, and on a 64-bit non-Windows
platform it is a no-op.

This was originally authored by LordKiRon &lt;https://github.com/LordKiRon&gt;,
who preferred not to reveal their real name and therefore agreed that I
take over authorship.

Helped-by: Torsten Bögershausen &lt;tboegi@web.de&gt;
Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>odb: use enum for `odb_write_object` flags</title>
<updated>2026-04-01T03:43:13Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-31T23:57:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b2d421ece6a8e095394e76930e6929ee036571ef'/>
<id>urn:sha1:b2d421ece6a8e095394e76930e6929ee036571ef</id>
<content type='text'>
We've got a couple of functions that accept `odb_write_object()` flags,
but all of them accept the flags as an `unsigned` integer. In fact, we
don't even have an `enum` for the flags field.

Introduce this `enum` and adapt functions accordingly according to our
coding style.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>odb: introduce generic `odb_find_abbrev_len()`</title>
<updated>2026-03-20T20:16:42Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-20T07:07:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=83869e15fa9ef3b0ea2adbfe2fe68a309f95b856'/>
<id>urn:sha1:83869e15fa9ef3b0ea2adbfe2fe68a309f95b856</id>
<content type='text'>
Introduce a new generic `odb_find_abbrev_len()` function as well as
source-specific callback functions. This makes the logic to compute the
required prefix length to make a given object unique fully pluggable.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>odb: introduce `struct odb_for_each_object_options`</title>
<updated>2026-03-20T20:16:41Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-20T07:07:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cfd575f0a9730712107e4ee6799a37665bcd8204'/>
<id>urn:sha1:cfd575f0a9730712107e4ee6799a37665bcd8204</id>
<content type='text'>
The `odb_for_each_object()` function only accepts a bitset of flags. In
a subsequent commit we'll want to change object iteration to also
support iterating over only those objects that have a specific prefix.
While we could of course add the prefix to the function signature, or
alternatively introduce a new function, both of these options don't
really seem to be that sensible.

Instead, introduce a new `struct odb_for_each_object_options` that can
be passed to a new `odb_for_each_object_ext()` function. Splice through
the options structure into the respective object database sources.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>odb/source: introduce generic object counting</title>
<updated>2026-03-12T15:38:42Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-12T08:43:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b259f2175b0ccd5574fc6b06b8ec5cbeaa860610'/>
<id>urn:sha1:b259f2175b0ccd5574fc6b06b8ec5cbeaa860610</id>
<content type='text'>
Introduce generic object counting on the object database source level
with a new backend-specific callback function.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>odb: stop including "odb/source.h"</title>
<updated>2026-03-12T15:38:42Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-12T08:42:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6daeb66baac581ab81148bcb9d5fcc61ae33347e'/>
<id>urn:sha1:6daeb66baac581ab81148bcb9d5fcc61ae33347e</id>
<content type='text'>
The "odb.h" header currently includes the "odb/source.h" file. This is
somewhat roundabout though: most callers shouldn't have to care about
the `struct odb_source`, but should rather use the ODB-level functions.
Furthermore, it means that a couple of definitions have to live on the
source level even though they should be part of the generic interface.

Reverse the relation between "odb/source.h" and "odb.h" and move the
enums and typedefs that relate to the generic interfaces back into
"odb.h". Add the necessary includes to all files that rely on the
transitive include.

Suggested-by: Justin Tobler &lt;jltobler@gmail.com&gt;
Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>odb/source: make `begin_transaction()` function pluggable</title>
<updated>2026-03-05T19:45:17Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-05T14:19:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d6fc6fe6f8b74e663d6013f830b535f50bfc1414'/>
<id>urn:sha1:d6fc6fe6f8b74e663d6013f830b535f50bfc1414</id>
<content type='text'>
Introduce a new callback function in `struct odb_source` to make the
function pluggable.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>odb/source: make `write_alternate()` function pluggable</title>
<updated>2026-03-05T19:45:17Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-05T14:19:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=eb9635d83b7ef16df527db3e84def9d0c772344d'/>
<id>urn:sha1:eb9635d83b7ef16df527db3e84def9d0c772344d</id>
<content type='text'>
Introduce a new callback function in `struct odb_source` to make the
function pluggable.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>odb/source: make `read_alternates()` function pluggable</title>
<updated>2026-03-05T19:45:16Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-05T14:19:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7ae23630c3ed012180edc88f0a9615a0d570a77c'/>
<id>urn:sha1:7ae23630c3ed012180edc88f0a9615a0d570a77c</id>
<content type='text'>
Introduce a new callback function in `struct odb_source` to make the
function pluggable.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>odb/source: make `write_object_stream()` function pluggable</title>
<updated>2026-03-05T19:45:16Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-05T14:19:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fc7fb0ef3575091bbc00d6bf8345c2da0c386052'/>
<id>urn:sha1:fc7fb0ef3575091bbc00d6bf8345c2da0c386052</id>
<content type='text'>
Introduce a new callback function in `struct odb_source` to make the
function pluggable.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
