<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/parse-options.h, 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>2026-03-16T18:21:08Z</updated>
<entry>
<title>parseopt: enable subcommand autocorrection for git-remote and git-notes</title>
<updated>2026-03-16T18:21:08Z</updated>
<author>
<name>Jiamu Sun</name>
<email>39@barroit.sh</email>
</author>
<published>2026-03-16T15:36:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ae8b7e1d200977165755c2e6d5a22e1df8ab6bf1'/>
<id>urn:sha1:ae8b7e1d200977165755c2e6d5a22e1df8ab6bf1</id>
<content type='text'>
Add PARSE_OPT_SUBCOMMAND_AUTOCORR to enable autocorrection for
subcommands parsed with PARSE_OPT_SUBCOMMAND_OPTIONAL.

Use it for git-remote and git-notes, so mistyped subcommands can be
automatically corrected, and builtin entry points no longer need to
handle the unknown subcommand error path themselves.

This is safe for these two builtins, because they either resolve to a
single subcommand or take no subcommand at all. This means that if the
subcommand parser encounters an unknown argument, it must be a mistyped
subcommand.

Signed-off-by: Jiamu Sun &lt;39@barroit.sh&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'lm/add-p-context'</title>
<updated>2025-08-04T15:10:33Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-08-04T15:10:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d63f334a8242f9e993b5bfb451f03394023ab877'/>
<id>urn:sha1:d63f334a8242f9e993b5bfb451f03394023ab877</id>
<content type='text'>
"git add/etc -p" now honor the diff.context configuration variable,
and also they learn to honor the -U&lt;n&gt; command-line option.

* lm/add-p-context:
  add-patch: add diff.context command line overrides
  add-patch: respect diff.context configuration
  t: use test_config in t4055
  t: use test_grep in t3701 and t4055
</content>
</entry>
<entry>
<title>add-patch: add diff.context command line overrides</title>
<updated>2025-07-29T15:52:45Z</updated>
<author>
<name>Leon Michalak</name>
<email>leonmichalak6@gmail.com</email>
</author>
<published>2025-07-29T07:01:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2b3ae04011c3d679ba601c7ef9e20b9dec125ebb'/>
<id>urn:sha1:2b3ae04011c3d679ba601c7ef9e20b9dec125ebb</id>
<content type='text'>
This patch compliments the previous commit, where builtins that use
add-patch infrastructure now respect diff.context and
diff.interHunkContext file configurations.

In particular, this patch helps users who don't want to set persistent
context configurations or just want a way to override them on a one-time
basis, by allowing the relevant builtins to accept corresponding command
line options that override the file configurations.

This mimics commands such as diff and log, which allow for both context
file configuration and command line overrides.

Signed-off-by: Leon Michalak &lt;leonmichalak6@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse-options: add precision handling for OPTION_COUNTUP</title>
<updated>2025-07-09T15:40:32Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2025-07-09T09:46:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c1e616c39b31e78acc595790bf3a9553a022a19d'/>
<id>urn:sha1:c1e616c39b31e78acc595790bf3a9553a022a19d</id>
<content type='text'>
Similar to 09705696f7 (parse-options: introduce precision handling for
`OPTION_INTEGER`, 2025-04-17) support value variables of different sizes
for OPTION_COUNTUP.  Do that by requiring their "precision" to be set,
casting their "value" pointer accordingly and checking whether the value
fits.

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>parse-options: add precision handling for OPTION_BITOP</title>
<updated>2025-07-09T15:39:46Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2025-07-09T09:46:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1d918bf2a5eb9d860df1dd115ef2641d7b5870e9'/>
<id>urn:sha1:1d918bf2a5eb9d860df1dd115ef2641d7b5870e9</id>
<content type='text'>
Similar to 09705696f7 (parse-options: introduce precision handling for
`OPTION_INTEGER`, 2025-04-17) support value variables of different sizes
for OPTION_BITOP.  Do that by requiring their "precision" to be set,
casting their "value" pointer accordingly and checking whether the value
fits.

Check if "devfal" fits into an integer variable with the given
"precision", but don't check "extra", as its value is only used to clear
bits, so cannot lead to an overflow.  Not checking continues to allow
e.g., using -1 to clear all bits even if the value variable has a
narrower type than intptr_t.

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>parse-options: add precision handling for OPTION_NEGBIT</title>
<updated>2025-07-09T15:39:46Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2025-07-09T09:45:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=feeebbf1b7d5ed8761355d354e9529c791b77e7d'/>
<id>urn:sha1:feeebbf1b7d5ed8761355d354e9529c791b77e7d</id>
<content type='text'>
Similar to 09705696f7 (parse-options: introduce precision handling for
`OPTION_INTEGER`, 2025-04-17) support value variables of different sizes
for OPTION_NEGBIT.  Do that by requiring their "precision" to be set,
casting their "value" pointer accordingly and checking whether the value
fits.

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>parse-options: add precision handling for OPTION_BIT</title>
<updated>2025-07-09T15:39:28Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2025-07-09T09:45:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5228211c4b92052c0a38f2ab67cd0b87a7baec30'/>
<id>urn:sha1:5228211c4b92052c0a38f2ab67cd0b87a7baec30</id>
<content type='text'>
Similar to 09705696f7 (parse-options: introduce precision handling for
`OPTION_INTEGER`, 2025-04-17) support value variables of different sizes
for OPTION_BIT.  Do that by requiring their "precision" to be set,
casting their "value" pointer accordingly and checking whether the value
fits.

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>parse-options: add precision handling for OPTION_SET_INT</title>
<updated>2025-07-09T15:39:26Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2025-07-09T09:45:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c898bbc5e4b582c28379bc64b7f9c9ec96106993'/>
<id>urn:sha1:c898bbc5e4b582c28379bc64b7f9c9ec96106993</id>
<content type='text'>
Similar to 09705696f7 (parse-options: introduce precision handling for
`OPTION_INTEGER`, 2025-04-17) support value variables of different sizes
for OPTION_SET_INT.  Do that by requiring their "precision" to be set,
casting their "value" pointer accordingly and checking whether the value
fits.

Factor out the casting code from the part of do_get_value() that handles
OPTION_INTEGER to avoid code duplication.  We're going to use it in the
next patches as well.

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>parse-options: add precision handling for PARSE_OPT_CMDMODE</title>
<updated>2025-07-09T15:39:10Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2025-07-09T09:45:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0d3e045b34f38d23e6160ce8aae363f358bd5cdc'/>
<id>urn:sha1:0d3e045b34f38d23e6160ce8aae363f358bd5cdc</id>
<content type='text'>
Build on 09705696f7 (parse-options: introduce precision handling for
`OPTION_INTEGER`, 2025-04-17) to support value variables of different
sizes for PARSE_OPT_CMDMODE options.  Do that by requiring their
"precision" to be set and casting their "value" pointer accordingly.

Call the function that does the raw casting do_get_int_value() to
reserve the name get_int_value() for a more friendly wrapper we're
going to introduce in one of the next patches.

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>parse-options: detect mismatches in integer signedness</title>
<updated>2025-04-17T15:15:16Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2025-04-17T10:49:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=791aeddfa2fdb9e830e24c50c97bb5e8bf3613e6'/>
<id>urn:sha1:791aeddfa2fdb9e830e24c50c97bb5e8bf3613e6</id>
<content type='text'>
It was reported that "t5620-backfill.sh" fails on s390x and sparc64 in a
test that exercises the "--min-batch-size" command line option. The
symptom was that the option didn't seem to have an effect: we didn't
fetch objects with a batch size of 20, but instead fetched all objects
at once.

As it turns out, the root cause is that `--min-batch-size` uses
`OPT_INTEGER()` to parse the command line option. While this macro
expects the caller to pass a pointer to an integer, we instead pass a
pointer to a `size_t`. This coincidentally works on most platforms, but
it breaks apart on the mentioned platforms because they are big endian.

This issue isn't specific to git-backfill(1): there are a couple of
other places where we have the same type confusion going on. This
indicates that the issue really is the interface that the parse-options
subsystem provides -- it is simply too easy to get this wrong as there
isn't any kind of compiler warning, and things just work on the most
common systems.

Address the systemic issue by introducing two new build asserts
`BARF_UNLESS_SIGNED()` and `BARF_UNLESS_UNSIGNED()`. As the names
already hint at, those macros will cause a compiler error when passed a
value that is not signed or unsigned, respectively.

Adapt `OPT_INTEGER()`, `OPT_UNSIGNED()` as well as `OPT_MAGNITUDE()` to
use those asserts. This uncovers a small set of sites where we indeed
have the same bug as in git-backfill(1). Adapt all of them to use the
correct option.

Reported-by: Todd Zullinger &lt;tmz@pobox.com&gt;
Reported-by: John Paul Adrian Glaubitz &lt;glaubitz@physik.fu-berlin.de&gt;
Helped-by: SZEDER Gábor &lt;szeder.dev@gmail.com&gt;
Helped-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
