<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/git-compat-util.h, branch v2.48.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.48.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.48.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2024-12-06T11:20:01Z</updated>
<entry>
<title>git-compat-util: introduce macros to disable "-Wsign-compare" warnings</title>
<updated>2024-12-06T11:20:01Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-12-06T10:27:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2121a76d71e6742fe9627289b45717663bcef832'/>
<id>urn:sha1:2121a76d71e6742fe9627289b45717663bcef832</id>
<content type='text'>
When compiling with DEVELOPER=YesPlease, we explicitly disable the
"-Wsign-compare" warning. This is mostly because our code base is full
of cases where we don't bother at all whether something should be signed
or unsigned, and enabling the warning would thus cause tons of warnings
to pop up.

Unfortunately, disabling this warning also masks real issues. There have
been multiple CVEs in the Git project that would have been flagged by
this warning (e.g. CVE-2022-39260, CVE-2022-41903 and several fixes in
the vicinity of these CVEs). Furthermore, the final audit report by
X41 D-Sec, who are the ones who have discovered some of the CVEs, hinted
that it might be a good idea to become more strict in this context.

Now simply enabling the warning globally does not fly due to the stated
reason above that we simply have too many sites where we use the wrong
integer types. Instead, introduce a new set of macros that allow us to
mark a file as being free of warnings with "-Wsign-compare". The
mechanism is similar to what we do with `USE_THE_REPOSITORY_VARIABLE`:
every file that is not marked with `DISABLE_SIGN_COMPARE_WARNINGS` will
be compiled with those warnings enabled.

These new markings will be wired up in the subsequent commits.

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>git-compat-util: drop now-unused `UNLEAK()` macro</title>
<updated>2024-11-20T23:23:46Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-11-20T13:39:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=52c7dbd036e1e5dd2ef854737c3010b3d0a2f3ca'/>
<id>urn:sha1:52c7dbd036e1e5dd2ef854737c3010b3d0a2f3ca</id>
<content type='text'>
The `UNLEAK()` macro has been introduced with 0e5bba53af (add UNLEAK
annotation for reducing leak false positives, 2017-09-08) to help us
reduce the amount of reported memory leaks in cases we don't care about,
e.g. when exiting immediately afterwards. We have since removed all of
its users in favor of freeing the memory and thus don't need the macro
anymore.

Remove it.

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>CodingGuidelines: also mention MAYBE_UNUSED</title>
<updated>2024-08-29T18:28:07Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-08-29T18:18:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a051ca5e650138230f3dd61bda911f0f409ebf23'/>
<id>urn:sha1:a051ca5e650138230f3dd61bda911f0f409ebf23</id>
<content type='text'>
A function that uses a parameter in one build may lose all uses of
the parameter in another build, depending on the configuration.  A
workaround for such a case, MAYBE_UNUSED, should also be mentioned
when we recommend the use of UNUSED to our developers.

Keep the addition to the guideline short and document the criteria
to choose between UNUSED and MAYBE_UNUSED near their definition.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>win32: override `fspathcmp()` with a directory separator-aware version</title>
<updated>2024-07-13T23:23:36Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2024-07-13T21:08:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=193eda7507d0ccb2fe6fd42b403c56ecc205e546'/>
<id>urn:sha1:193eda7507d0ccb2fe6fd42b403c56ecc205e546</id>
<content type='text'>
On Windows, the backslash is the directory separator, even if the
forward slash can be used, too, at least since Windows NT.

This means that the paths `a/b` and `a\b` are equivalent, and
`fspathcmp()` needs to be made aware of that fact.

Note that we have to override both `fspathcmp()` and `fspathncmp()`, and
the former cannot be a mere pre-processor constant that transforms calls
to `fspathcmp(a, b)` into `fspathncmp(a, b, (size_t)-1)` because the
function `report_collided_checkout()` in `unpack-trees.c` wants to
assign `list.cmp = fspathcmp`.

Also note that `fspatheq()` does _not_ need to be overridden because it
calls `fspathcmp()` internally.

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>Merge branch 'rs/no-openssl-compilation-fix-on-macos'</title>
<updated>2024-04-23T18:52:38Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-04-23T18:52:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ec465fcb753c991f04b6f5ec3983ad21a247dc7d'/>
<id>urn:sha1:ec465fcb753c991f04b6f5ec3983ad21a247dc7d</id>
<content type='text'>
Build fix.

* rs/no-openssl-compilation-fix-on-macos:
  git-compat-util: fix NO_OPENSSL on current macOS
</content>
</entry>
<entry>
<title>git-compat-util: fix NO_OPENSSL on current macOS</title>
<updated>2024-04-15T18:01:31Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-04-14T16:47:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=44bdba2fa6b677b58d4761d41ee9b31dc98b12d0'/>
<id>urn:sha1:44bdba2fa6b677b58d4761d41ee9b31dc98b12d0</id>
<content type='text'>
b195aa00c1 (git-compat-util: suppress unavoidable Apple-specific
deprecation warnings, 2014-12-16) started to define
__AVAILABILITY_MACROS_USES_AVAILABILITY in git-compat-util.h.  On
current versions it is already defined (e.g. on macOS 14.4.1).  Undefine
it before redefining it to avoid a compilation error.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Win32: detect unix socket support at runtime</title>
<updated>2024-04-03T21:54:28Z</updated>
<author>
<name>Matthias Aßhauer</name>
<email>mha1993@live.de</email>
</author>
<published>2024-04-03T15:42:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2406bf5fc5fbaa042e05fc0001ba72beb888d60f'/>
<id>urn:sha1:2406bf5fc5fbaa042e05fc0001ba72beb888d60f</id>
<content type='text'>
Windows 10 build 17063 introduced support for unix sockets to Windows.
bb390b1 (git-compat-util: include declaration for unix sockets in
windows, 2021-09-14) introduced a way to build git with unix socket
support on Windows, but you still had to decide at build time which
Windows version the compiled executable was supposed to run on.

We can detect at runtime wether the operating system supports unix
sockets and act accordingly for all supported Windows versions.

This fixes https://github.com/git-for-windows/git/issues/3892

Signed-off-by: Matthias Aßhauer &lt;mha1993@live.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'tb/multi-pack-verbatim-reuse'</title>
<updated>2024-01-13T00:09:56Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-01-13T00:09:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0fea6b73f1771469cc423288fcd754d374865400'/>
<id>urn:sha1:0fea6b73f1771469cc423288fcd754d374865400</id>
<content type='text'>
Streaming spans of packfile data used to be done only from a
single, primary, pack in a repository with multiple packfiles.  It
has been extended to allow reuse from other packfiles, too.

* tb/multi-pack-verbatim-reuse: (26 commits)
  t/perf: add performance tests for multi-pack reuse
  pack-bitmap: enable reuse from all bitmapped packs
  pack-objects: allow setting `pack.allowPackReuse` to "single"
  t/test-lib-functions.sh: implement `test_trace2_data` helper
  pack-objects: add tracing for various packfile metrics
  pack-bitmap: prepare to mark objects from multiple packs for reuse
  pack-revindex: implement `midx_pair_to_pack_pos()`
  pack-revindex: factor out `midx_key_to_pack_pos()` helper
  midx: implement `midx_preferred_pack()`
  git-compat-util.h: implement checked size_t to uint32_t conversion
  pack-objects: include number of packs reused in output
  pack-objects: prepare `write_reused_pack_verbatim()` for multi-pack reuse
  pack-objects: prepare `write_reused_pack()` for multi-pack reuse
  pack-objects: pass `bitmapped_pack`'s to pack-reuse functions
  pack-objects: keep track of `pack_start` for each reuse pack
  pack-objects: parameterize pack-reuse routines over a single pack
  pack-bitmap: return multiple packs via `reuse_partial_packfile_from_bitmap()`
  pack-bitmap: simplify `reuse_partial_packfile_from_bitmap()` signature
  ewah: implement `bitmap_is_empty()`
  pack-bitmap: pass `bitmapped_pack` struct to pack-reuse functions
  ...
</content>
</entry>
<entry>
<title>git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool</title>
<updated>2023-12-18T17:08:24Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2023-12-16T10:47:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8277dbe9872205be1588ddfbf01d5439847db1d9'/>
<id>urn:sha1:8277dbe9872205be1588ddfbf01d5439847db1d9</id>
<content type='text'>
Use the data type bool and its values true and false to document the
binary return value of skip_prefix() and friends more explicitly.

This first use of stdbool.h, introduced with C99, is meant to check
whether there are platforms that claim support for C99, as tested by
7bc341e21b (git-compat-util: add a test balloon for C99 support,
2021-12-01), but still lack that header for some reason.

A fallback based on a wider type, e.g. int, would have to deal with
comparisons somehow to emulate that any non-zero value is true:

   bool b1 = 1;
   bool b2 = 2;
   if (b1 == b2) puts("This is true.");

   int i1 = 1;
   int i2 = 2;
   if (i1 == i2) puts("Not printed.");
   #define BOOLEQ(a, b) (!(a) == !(b))
   if (BOOLEQ(i1, i2)) puts("This is true.");

So we'd be better off using bool everywhere without a fallback, if
possible.  That's why this patch doesn't include any.

Signed-off-by: René Scharfe &lt;l.s.r@web.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>git-compat-util.h: implement checked size_t to uint32_t conversion</title>
<updated>2023-12-14T22:38:08Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2023-12-14T22:24:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ed9f41480a32fff7f3ec66ba2d4bf618885e6ad2'/>
<id>urn:sha1:ed9f41480a32fff7f3ec66ba2d4bf618885e6ad2</id>
<content type='text'>
In a similar fashion as other checked cast functions in this header
(such as `cast_size_t_to_ulong()` and `cast_size_t_to_int()`), implement
a checked cast function for going from a size_t to a uint32_t value.

This function will be utilized in a future commit which needs to make
such a conversion.

Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
