<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/diff-delta.c, branch jch</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=jch</id>
<link rel='self' href='https://git.shady.money/git/atom?h=jch'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2025-12-11T05:44:43Z</updated>
<entry>
<title>git-compat-util: introduce MEMZERO_ARRAY() macro</title>
<updated>2025-12-11T05:44:43Z</updated>
<author>
<name>Toon Claes</name>
<email>toon@iotcl.com</email>
</author>
<published>2025-12-10T13:13:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a67b902c94a2f33275a3947a8bcdab03f64ae75e'/>
<id>urn:sha1:a67b902c94a2f33275a3947a8bcdab03f64ae75e</id>
<content type='text'>
Introduce a new macro MEMZERO_ARRAY() that zeroes the memory allocated
by ALLOC_ARRAY() and friends. And add coccinelle rule to enforce the use
of this macro.

Signed-off-by: Toon Claes &lt;toon@iotcl.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-delta: avoid using the comma operator</title>
<updated>2025-03-29T00:38:10Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2025-03-27T11:52:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=be7a517ce4606b46479fe06fae6c1ab117b0d384'/>
<id>urn:sha1:be7a517ce4606b46479fe06fae6c1ab117b0d384</id>
<content type='text'>
The comma operator is a somewhat obscure C feature that is often used by
mistake and can even cause unintentional code flow. That is why the
`-Wcomma` option of clang was introduced: To identify unintentional uses
of the comma operator.

Intentional uses include situations where one wants to avoid curly
brackets around multiple statements that need to be guarded by a
condition. This is the case here, as the repetitive nature of the
statements is easier to see for a human reader this way. At least in my
opinion.

However, opinions on this differ wildly, take 10 people and you have 10
different preferences.

On the Git mailing list, it seems that the consensus is to use the long
form instead, so let's do just that.

Suggested-by: Phillip Wood &lt;phillip.wood123@gmail.com&gt;
Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Acked-by: Phillip Wood &lt;phillip.wood@dunelm.org.uk&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>global: mark code units that generate warnings with `-Wsign-compare`</title>
<updated>2024-12-06T11:20:02Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-12-06T10:27:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=41f43b8243f42b9df2e98be8460646d4c0100ad3'/>
<id>urn:sha1:41f43b8243f42b9df2e98be8460646d4c0100ad3</id>
<content type='text'>
Mark code units that generate warnings with `-Wsign-compare`. This
allows for a structured approach to get rid of all such warnings over
time in a way that can be easily measured.

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>diff-delta: set size out-parameter to 0 for NULL delta</title>
<updated>2019-09-06T18:03:39Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2019-09-05T22:53:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e4b369069e4a7630233a045784d0b1e2425b0a05'/>
<id>urn:sha1:e4b369069e4a7630233a045784d0b1e2425b0a05</id>
<content type='text'>
When we cannot generate a delta, we return NULL but leave delta_size
untouched. This is generally OK, as callers rely on NULL to decide if
the output is usable or not. But it can confuse compilers; in
particular, gcc 9.2.1 with "-flto -O3" complains in fast-import's
store_object() that delta_len may be used uninitialized.

Let's change the diff-delta code to set the size explicitly to 0 for a
NULL return. That silences the compiler and makes it easier to reason
about the result.

Reported-by: Stephan Beyer &lt;s-beyer@gmx.net&gt;
Helped-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'mk/diff-delta-avoid-large-offset'</title>
<updated>2017-09-28T05:47:56Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-09-28T05:47:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fdbe2ac1983c1224ce40b465b22e44d7e22de6c4'/>
<id>urn:sha1:fdbe2ac1983c1224ce40b465b22e44d7e22de6c4</id>
<content type='text'>
The delta format used in the packfile cannot reference data at
offset larger than what can be expressed in 4-byte, but the
generator for the data failed to make sure the offset does not
overflow.  This has been corrected.

* mk/diff-delta-avoid-large-offset:
  diff-delta: do not allow delta offset truncation
</content>
</entry>
<entry>
<title>diff-delta: do not allow delta offset truncation</title>
<updated>2017-08-11T22:25:40Z</updated>
<author>
<name>Martin Koegler</name>
<email>martin.koegler@chello.at</email>
</author>
<published>2017-08-10T18:13:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fed1ef9550d528dffa8891e8b2f49b486c7985bc'/>
<id>urn:sha1:fed1ef9550d528dffa8891e8b2f49b486c7985bc</id>
<content type='text'>
Prevent generating delta offsets beyond 4G, as the xdelta used in
the pack format cannot represent such large offset.

Signed-off-by: Martin Koegler &lt;martin.koegler@chello.at&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-delta: fix encoding size that would not fit in "unsigned int"</title>
<updated>2017-08-10T20:55:22Z</updated>
<author>
<name>Martin Koegler</name>
<email>martin.koegler@chello.at</email>
</author>
<published>2017-08-10T07:01:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3f0a67a1f68d79f102ac11a8b6e7a72dc86be613'/>
<id>urn:sha1:3f0a67a1f68d79f102ac11a8b6e7a72dc86be613</id>
<content type='text'>
The current delta code produces incorrect pack objects for files &gt; 4GB,
because the size is copied from size_t field to "unsigned int" variables
during the encoding process.

Signed-off-by: Martin Koegler &lt;martin.koegler@chello.at&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>create_delta_index: simplify condition always evaluating to true</title>
<updated>2013-08-18T19:56:23Z</updated>
<author>
<name>Stefan Beller</name>
<email>stefanbeller@googlemail.com</email>
</author>
<published>2013-08-16T21:22:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f7466e94375b3be27f229c78873f0acf8301c0a5'/>
<id>urn:sha1:f7466e94375b3be27f229c78873f0acf8301c0a5</id>
<content type='text'>
The code sequence  ' (1u &lt;&lt; i) &lt; hsize &amp;&amp; i &lt; 31 ' is a multi step
process, whose first step requires that 'i' is already less that 31,
otherwise the result (1u &lt;&lt; i)  is undefined (and  'undef_val &lt; hsize'
can therefore be assumed to be 'false'), and so the later test  i &lt; 31
can always be optimized away as dead code ('i' is already less than 31,
or the short circuit 'and' applies).

So we need to get rid of that code. One way would be to exchange the
order of the conditions, so the expression 'i &lt; 31 &amp;&amp; (1u &lt;&lt; i) &lt; hsize'
would remove that optimized unstable code already.

However when checking the previous lines in that function, we can deduce
that 'hsize' must always be smaller than (1u&lt;&lt;31), since 506049c7df2c6
(fix &gt;4GiB source delta assertion failure), because 'entries' is
capped at an upper bound of 0xfffffffeU, so 'hsize' contains a maximum
value of 0x3fffffff, which is smaller than (1u&lt;&lt;31), so the value of
'i' will never be larger than 31 and we can remove that condition
entirely.

Signed-off-by: Stefan Beller &lt;stefanbeller@googlemail.com&gt;
Acked-by: Nicolas Pitre &lt;nico@fluxnic.net&gt;
Acked-by: Philip Oakley &lt;philipoakley@iee.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fix &gt;4GiB source delta assertion failure</title>
<updated>2010-08-22T06:53:26Z</updated>
<author>
<name>Nicolas Pitre</name>
<email>nico@fluxnic.net</email>
</author>
<published>2010-08-21T05:00:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=506049c7df2c68f1db5a4bae502cfb1af0a73048'/>
<id>urn:sha1:506049c7df2c68f1db5a4bae502cfb1af0a73048</id>
<content type='text'>
When people try insane things such as delta-compressing 4GiB files, they
get this assertion:

diff-delta.c:285: create_delta_index: Assertion `packed_entry - (struct index_entry *)mem == entries' failed.

This happens because:

1) the 'entries' variable is an unsigned int

2) it is assigned with entries = (bufsize - 1) / RABIN_WINDOW
   (that itself is not a problem unless bufsize &gt; 4G * RABIN_WINDOW)

3) the buffer is indexed from top to bottom starting at
   "data = buffer + entries * RABIN_WINDOW" and the multiplication
   here does indeed overflows, making the resulting top of the buffer
   much lower than expected.

This makes the number of actually produced index entries smaller than
what was computed initially, hence the assertion.

Furthermore, the current delta encoding format cannot represent offsets
into a reference buffer with more than 32 bits anyway.  So let's just
limit the number of entries to what the delta format can encode.

Reported-by: Ilari Liusvaara &lt;ilari.liusvaara@elisanet.fi&gt;
Signed-off-by: Nicolas Pitre &lt;nico@fluxnic.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Nicolas Pitre has a new email address</title>
<updated>2009-09-14T09:23:36Z</updated>
<author>
<name>Nicolas Pitre</name>
<email>nico@fluxnic.net</email>
</author>
<published>2009-09-14T06:41:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=03aa8ff3be3b35522b2e378651e65e0e86778018'/>
<id>urn:sha1:03aa8ff3be3b35522b2e378651e65e0e86778018</id>
<content type='text'>
Due to problems at cam.org, my nico@cam.org email address is no longer
valid.  From now on, nico@fluxnic.net should be used instead.

Signed-off-by: Nicolas Pitre &lt;nico@fluxnic.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
