<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/parse-options.c, branch v2.45.4</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.45.4</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.45.4'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2024-03-03T17:49:22Z</updated>
<entry>
<title>parse-options: rearrange long_name matching code</title>
<updated>2024-03-03T17:49:22Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-03-03T12:19:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=28a92478b825a4a2c7c2c0c6b725ce92cd0b83e0'/>
<id>urn:sha1:28a92478b825a4a2c7c2c0c6b725ce92cd0b83e0</id>
<content type='text'>
Move the code for handling a full match of long_name first and get rid
of negations.  Reduce the indent of the code for matching abbreviations
and remove unnecessary curly braces.  Combine the checks for whether
negation is allowed and whether arg is "n", "no" or "no-" because they
belong together and avoid a continue statement.  The result is shorter,
more readable code.

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: normalize arg and long_name before comparison</title>
<updated>2024-03-03T17:49:22Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-03-03T12:19:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b1ce2b62fa4c6cf6d972698ac48be451cbc07718'/>
<id>urn:sha1:b1ce2b62fa4c6cf6d972698ac48be451cbc07718</id>
<content type='text'>
Strip "no-" from arg and long_name before comparing them.  This way we
no longer have to repeat the comparison with an offset of 3 for negated
arguments.

Note that we must not modify the "flags" value, which tracks whether arg
is negated, inside the loop.  When registering "--n", "--no" or "--no-"
as abbreviation for any negative option, we used to OR it with OPT_UNSET
and end the loop.  We can simply hard-code OPT_UNSET and leave flags
unchanged instead.

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 ambiguous self-negation</title>
<updated>2024-03-03T17:49:21Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-03-03T12:19:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0d8a3097c74ed3b78442c4d533f3427316596a46'/>
<id>urn:sha1:0d8a3097c74ed3b78442c4d533f3427316596a46</id>
<content type='text'>
Git currently does not detect the ambiguity of an option that starts
with "no" like --notes and its negated form if given just --n or --no.
All Git commands with such options have other negatable options, and
we detect the ambiguity with them, so that's currently only a potential
problem for scripts that use git rev-parse --parseopt.

Let's fix it nevertheless, as there's no need for that confusion.  To
detect the ambiguity we have to loosen the check in register_abbrev(),
as an option is considered an alias of itself.  Add non-matching
negation flags as a criterion to recognize an option being ambiguous
with its negated form.

And we need to keep going after finding a non-negated option as an
abbreviated candidate and perform the negation checks in the same
loop.

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: factor out register_abbrev() and struct parsed_option</title>
<updated>2024-03-03T17:49:21Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-03-03T12:19:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cb46c3faf843fa46ce2df22baeb02ad2f60da6fb'/>
<id>urn:sha1:cb46c3faf843fa46ce2df22baeb02ad2f60da6fb</id>
<content type='text'>
Add a function, register_abbrev(), for storing the necessary details for
remembering an abbreviated and thus potentially ambiguous option.  Call
it instead of sharing the code using goto, to make the control flow more
explicit.

Conveniently collect these details in the new struct parsed_option to
reduce the number of necessary function arguments.

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: set arg of abbreviated option lazily</title>
<updated>2024-03-03T17:49:21Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-03-03T12:19:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=597f9d037df56334b9dc938ffcfeb9a879f80a7c'/>
<id>urn:sha1:597f9d037df56334b9dc938ffcfeb9a879f80a7c</id>
<content type='text'>
Postpone setting the opt pointer until we're about to call get_value(),
which uses it.  There's no point in setting it eagerly for every
abbreviated candidate option, which may turn out to be ambiguous.
Removing this assignment from the loop doesn't noticeably improve the
performance, but allows further simplification.

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: recognize abbreviated negated option with arg</title>
<updated>2024-03-03T17:49:21Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-03-03T12:19:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=289cb15541874e5c1599fee2e145a7af39085069'/>
<id>urn:sha1:289cb15541874e5c1599fee2e145a7af39085069</id>
<content type='text'>
Giving an argument to an option that doesn't take one causes Git to
report that error specifically:

   $ git rm --dry-run=bogus
   error: option `dry-run' takes no value

The same is true when the option is negated or abbreviated:

   $ git rm --no-dry-run=bogus
   error: option `no-dry-run' takes no value

   $ git rm --dry=bogus
   error: option `dry-run' takes no value

Not so when doing both, though:

   $ git rm --no-dry=bogus
   error: unknown option `no-dry=bogus'
   usage: git rm [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch]

(Rest of the usage message omitted.)

Improve consistency and usefulness of the error message by recognizing
abbreviated negated options even if they have a (most likely bogus)
argument.  With this patch we get:

   $ git rm --no-dry=bogus
   error: option `no-dry-run' takes no value

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 'rs/parse-options-with-keep-unknown-abbrev-fix'</title>
<updated>2024-01-30T21:34:12Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-01-30T21:34:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2e77b83993fa158da009dfdf18ec9f8856053895'/>
<id>urn:sha1:2e77b83993fa158da009dfdf18ec9f8856053895</id>
<content type='text'>
"git diff --no-rename A B" did not disable rename detection but did
not trigger an error from the command line parser.

* rs/parse-options-with-keep-unknown-abbrev-fix:
  parse-options: simplify positivation handling
  parse-options: fully disable option abbreviation with PARSE_OPT_KEEP_UNKNOWN
</content>
</entry>
<entry>
<title>parse-options: simplify positivation handling</title>
<updated>2024-01-22T15:17:12Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-01-21T17:56:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=457f96252fcfd64127f71e8663e2e4b6dfd4576c'/>
<id>urn:sha1:457f96252fcfd64127f71e8663e2e4b6dfd4576c</id>
<content type='text'>
We accept the positive version of options whose long name starts with
"no-" and are defined without the flag PARSE_OPT_NONEG.  E.g. git clone
has an explicitly defined --no-checkout option and also implicitly
accepts --checkout to override it.

parse_long_opt() handles that by restarting the option matching with the
positive version when it finds that only the current option definition
starts with "no-", but not the user-supplied argument.  This code is
located almost at the end of the matching logic.

Avoid the need for a restart by moving the code up.  We don't have to
check the positive arg against the negative long_name at all -- the
"no-" prefix of the latter makes a match impossible.  Skip it and toggle
OPT_UNSET right away to simplify the control flow.

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: fully disable option abbreviation with PARSE_OPT_KEEP_UNKNOWN</title>
<updated>2024-01-20T17:55:43Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-01-20T14:39:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5825268db1058516d05be03d6a8d8d55eea5a943'/>
<id>urn:sha1:5825268db1058516d05be03d6a8d8d55eea5a943</id>
<content type='text'>
baa4adc66a (parse-options: disable option abbreviation with
PARSE_OPT_KEEP_UNKNOWN, 2019-01-27) turned off support for abbreviated
options when the flag PARSE_OPT_KEEP_UNKNOWN is given, as any shortened
option could also be an abbreviation for one of the unknown options.

The code for handling abbreviated options is guarded by an if, but it
can also be reached via goto.  baa4adc66a only blocked the first way.
Add the condition to the other ones 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>Merge branch 'en/header-cleanup'</title>
<updated>2024-01-08T22:05:15Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-01-08T22:05:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=492ee03f60297e7e83d101f4519ab8abc98782bc'/>
<id>urn:sha1:492ee03f60297e7e83d101f4519ab8abc98782bc</id>
<content type='text'>
Remove unused header "#include".

* en/header-cleanup:
  treewide: remove unnecessary includes in source files
  treewide: add direct includes currently only pulled in transitively
  trace2/tr2_tls.h: remove unnecessary include
  submodule-config.h: remove unnecessary include
  pkt-line.h: remove unnecessary include
  line-log.h: remove unnecessary include
  http.h: remove unnecessary include
  fsmonitor--daemon.h: remove unnecessary includes
  blame.h: remove unnecessary includes
  archive.h: remove unnecessary include
  treewide: remove unnecessary includes in source files
  treewide: remove unnecessary includes from header files
</content>
</entry>
</feed>
