<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/parse-options.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>2026-04-17T04:27:20Z</updated>
<entry>
<title>Merge branch 'js/parseopt-subcommand-autocorrection' into jch</title>
<updated>2026-04-17T04:27:20Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2026-04-17T04:27:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8dd4eed84bfa07d9ecab33ad6825111669775d0d'/>
<id>urn:sha1:8dd4eed84bfa07d9ecab33ad6825111669775d0d</id>
<content type='text'>
The parse-options library learned to auto-correct misspelled
subcommand names.

* js/parseopt-subcommand-autocorrection:
  doc: document autocorrect API
  parseopt: add tests for subcommand autocorrection
  parseopt: enable subcommand autocorrection for git-remote and git-notes
  parseopt: autocorrect mistyped subcommands
  autocorrect: provide config resolution API
  autocorrect: rename AUTOCORRECT_SHOW to AUTOCORRECT_HINT
  autocorrect: use mode and delay instead of magic numbers
  help: move tty check for autocorrection to autocorrect.c
  help: make autocorrect handling reusable
  parseopt: extract subcommand handling from parse_options_step()
</content>
</entry>
<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>parseopt: autocorrect mistyped subcommands</title>
<updated>2026-03-16T18:21:08Z</updated>
<author>
<name>Jiamu Sun</name>
<email>39@barroit.sh</email>
</author>
<published>2026-03-16T15:36:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=be9df6de6e2cfd09ffc327e9d4edd451248296f9'/>
<id>urn:sha1:be9df6de6e2cfd09ffc327e9d4edd451248296f9</id>
<content type='text'>
Try to autocorrect the mistyped mandatory subcommand before showing an
error and exiting. Subcommands parsed with PARSE_OPT_SUBCOMMAND_OPTIONAL
are skipped.

Use standard Damerau-Levenshtein distance (weights 1, 1, 1, 1) to
establish a predictable, mathematically sound baseline.

Scale the allowed edit distance based on input length to prevent
false positives on short commands, following common practice for
fuzziness thresholds (e.g., Elasticsearch's AUTO fuzziness):
  - Length 0-2: 0 edits allowed
  - Length 3-5: 1 edit allowed
  - Length 6+:  2 edits allowed

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>parseopt: extract subcommand handling from parse_options_step()</title>
<updated>2026-03-16T18:21:07Z</updated>
<author>
<name>Jiamu Sun</name>
<email>39@barroit.sh</email>
</author>
<published>2026-03-16T15:36:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=386fe44951c3d0f8eaee98809aae5f2d886bac83'/>
<id>urn:sha1:386fe44951c3d0f8eaee98809aae5f2d886bac83</id>
<content type='text'>
Move the subcommand branch out of parse_options_step() into a new
handle_subcommand() helper. Also, make parse_subcommand() return a
simple success/failure status.

This removes the switch over impossible parse_opt_result values and
makes the non-option path easier to follow and maintain.

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 'rs/parse-options-duplicated-long-options'</title>
<updated>2026-03-10T21:23:19Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2026-03-10T21:23:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6953f24e4040b57d461a755fac297f272095ade7'/>
<id>urn:sha1:6953f24e4040b57d461a755fac297f272095ade7</id>
<content type='text'>
The parse-options API learned to notice an options[] array with
duplicated long options.

* rs/parse-options-duplicated-long-options:
  parseopt: check for duplicate long names and numerical options
  pack-objects: remove duplicate --stdin-packs definition
</content>
</entry>
<entry>
<title>parseopt: check for duplicate long names and numerical options</title>
<updated>2026-03-02T15:39:01Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2026-02-28T09:19:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=237e520d81201eee609cf21e24f1c7ac6719ec8a'/>
<id>urn:sha1:237e520d81201eee609cf21e24f1c7ac6719ec8a</id>
<content type='text'>
We already check for duplicate short names.  Check for and report
duplicate long names and numerical options as well.

Perform the slightly expensive string duplicate check only when showing
the usage to keep the cost of normal invocations low.  t0012-help.sh
covers it.

Helped-by: Jeff King &lt;peff@peff.net&gt;
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>Merge branch 'dk/parseopt-optional-filename-fixes'</title>
<updated>2025-11-06T23:17:01Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-11-06T23:17:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4badef0c3503dc29059d678abba7fac0f042bc84'/>
<id>urn:sha1:4badef0c3503dc29059d678abba7fac0f042bc84</id>
<content type='text'>
A recently added configuration variable and command line option
syntax ":(optional)" for values that are of filename type
inconsistently behaved on an empty file (configuration took it
happily, while the command line option pretended as if it did not
exist), which has been corrected.

* dk/parseopt-optional-filename-fixes:
  parseopt: remove unreachable code
  parseopt: restore const qualifier to parsed filename
  config: use boolean type for a simple flag
  parseopt: use boolean type for a simple flag
  doc: clarify command equivalence comment
  parseopt: fix :(optional) at command line to only ignore missing files
</content>
</entry>
<entry>
<title>parseopt: remove unreachable code</title>
<updated>2025-11-04T17:36:10Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-11-04T17:34:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a2584d04344b93610ee9e958d477d743380fc8d7'/>
<id>urn:sha1:a2584d04344b93610ee9e958d477d743380fc8d7</id>
<content type='text'>
At this point in the code after running skip_prefix() on the
variable and receiving the result in the same variable, the contents
of the variable can never be NULL.  The function either (1) updates
the variable to point at a later part of the string it originally
pointed at, or (2) leaves it intact if the string does not have the
prefix.  (1) will never make the variable NULL, and (2) cannot be
the source of NULL, because the variable cannot be NULL before
calling skip_prefix(), which would die immediately by dereferencing
the NULL pointer in that case.

Helped-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>parseopt: restore const qualifier to parsed filename</title>
<updated>2025-11-04T17:25:52Z</updated>
<author>
<name>D. Ben Knoble</name>
<email>ben.knoble+github@gmail.com</email>
</author>
<published>2025-11-02T16:17:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=383e5e1c4bfa604bcd479100258b4ff354dbaabb'/>
<id>urn:sha1:383e5e1c4bfa604bcd479100258b4ff354dbaabb</id>
<content type='text'>
This was unintentionally dropped in ccfcaf399f (parseopt: values of
pathname type can be prefixed with :(optional), 2025-09-28). Notably,
continue dropping the const qualifier when free'ing value; see
4049b9cfc0 (fix const issues with some functions, 2007-10-16) or
83838d5c1b (cast variable in call to free() in builtin/diff.c and
submodule.c, 2011-11-06) for more details on why.

Suggested-by: Phillip Wood &lt;phillip.wood@dunelm.org.uk&gt;
Signed-off-by: D. Ben Knoble &lt;ben.knoble+github@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parseopt: use boolean type for a simple flag</title>
<updated>2025-11-04T17:25:51Z</updated>
<author>
<name>D. Ben Knoble</name>
<email>ben.knoble+github@gmail.com</email>
</author>
<published>2025-11-02T16:17:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4da5bebc17518bace2a15484f345c3494c120135'/>
<id>urn:sha1:4da5bebc17518bace2a15484f345c3494c120135</id>
<content type='text'>
Suggested-by: Phillip Wood &lt;phillip.wood@dunelm.org.uk&gt;
Signed-off-by: D. Ben Knoble &lt;ben.knoble+github@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
