<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/parse-options.c, branch v2.22.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.22.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.22.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2019-05-30T17:50:44Z</updated>
<entry>
<title>Merge branch 'nd/diff-parseopt'</title>
<updated>2019-05-30T17:50:44Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-05-30T17:50:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=20aa7c594fbc2e36476daae2f53d7c020306c62c'/>
<id>urn:sha1:20aa7c594fbc2e36476daae2f53d7c020306c62c</id>
<content type='text'>
A brown-paper-bag bugfix to a change already in 'master'.

* nd/diff-parseopt:
  parse-options: check empty value in OPT_INTEGER and OPT_ABBREV
  diff-parseopt: restore -U (no argument) behavior
  diff-parseopt: correct variable types that are used by parseopt
</content>
</entry>
<entry>
<title>parse-options: check empty value in OPT_INTEGER and OPT_ABBREV</title>
<updated>2019-05-29T18:04:33Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2019-05-29T09:11:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f7e68a08780e91d7c2f830f33457041407172b96'/>
<id>urn:sha1:f7e68a08780e91d7c2f830f33457041407172b96</id>
<content type='text'>
When parsing the argument for OPT_INTEGER and OPT_ABBREV, we check if we
can parse the entire argument to a number with "if (*s)". There is one
missing check: if "arg" is empty to begin with, we fail to notice.

This could happen with long option by writing like

  git diff --inter-hunk-context= blah blah

Before 16ed6c97cc (diff-parseopt: convert --inter-hunk-context,
2019-03-24), --inter-hunk-context is handled by a custom parser
opt_arg() and does detect this correctly.

This restores the bahvior for --inter-hunk-context and make sure all
other integer options are handled the same (sane) way. For OPT_ABBREV
this is new behavior. But it makes it consistent with the rest.

PS. OPT_MAGNITUDE has similar code but git_parse_ulong() does detect
empty "arg". So it's good to go.

Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse-options: don't emit "ambiguous option" for aliases</title>
<updated>2019-05-07T03:23:22Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2019-04-29T10:05:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5c387428f10c27c24d3adb890cd466e2300518fa'/>
<id>urn:sha1:5c387428f10c27c24d3adb890cd466e2300518fa</id>
<content type='text'>
Change the option parsing machinery so that e.g. "clone --recurs ..."
doesn't error out because "clone" understands both "--recursive" and
"--recurse-submodules" to mean the same thing.

Initially "clone" just understood --recursive until the
--recurses-submodules alias was added in ccdd3da652 ("clone: Add the
--recurse-submodules option as alias for --recursive",
2010-11-04). Since bb62e0a99f ("clone: teach --recurse-submodules to
optionally take a pathspec", 2017-03-17) the longer form has been
promoted to the default.

But due to the way the options parsing machinery works this resulted
in the rather absurd situation of:

    $ git clone --recurs [...]
    error: ambiguous option: recurs (could be --recursive or --recurse-submodules)

Add OPT_ALIAS() to express this link between two or more options and use
it in git-clone. Multiple aliases of an option could be written as

    OPT_ALIAS(0, "alias1", "original-name"),
    OPT_ALIAS(0, "alias2", "original-name"),
    ...

The current implementation is not exactly optimal in this case. But we
can optimize it when it becomes a problem. So far we don't even have two
aliases of any option.

A big chunk of code is actually from Junio C Hamano.

Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'js/difftool-no-index'</title>
<updated>2019-04-25T07:41:14Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-04-25T07:41:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b72e90712eb0e802b232ad4c88460d04279c7111'/>
<id>urn:sha1:b72e90712eb0e802b232ad4c88460d04279c7111</id>
<content type='text'>
"git difftool" can now run outside a repository.

* js/difftool-no-index:
  difftool: allow running outside Git worktrees with --no-index
  parse-options: make OPT_ARGUMENT() more useful
  difftool: remove obsolete (and misleading) comment
</content>
</entry>
<entry>
<title>Merge branch 'jk/unused-params-even-more'</title>
<updated>2019-04-25T07:41:12Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-04-25T07:41:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4284497396eb52b2c096c2f442b70a52138b6e1b'/>
<id>urn:sha1:4284497396eb52b2c096c2f442b70a52138b6e1b</id>
<content type='text'>
Code cleanup.

* jk/unused-params-even-more:
  parse_opt_ref_sorting: always use with NONEG flag
  pretty: drop unused strbuf from parse_padding_placeholder()
  pretty: drop unused "type" parameter in needs_rfc2047_encoding()
  parse-options: drop unused ctx parameter from show_gitcomp()
  fetch_pack(): drop unused parameters
  report_path_error(): drop unused prefix parameter
  unpack-trees: drop unused error_type parameters
  unpack-trees: drop name_entry from traverse_by_cache_tree()
  test-date: drop unused "now" parameter from parse_dates()
  update-index: drop unused prefix_length parameter from do_reupdate()
  log: drop unused "len" from show_tagger()
  log: drop unused rev_info from early output
  revision: drop some unused "revs" parameters
</content>
</entry>
<entry>
<title>tests: disallow the use of abbreviated options (by default)</title>
<updated>2019-04-15T02:54:04Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-04-12T09:37:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b02e7d5d701a6217a3a522d9169b483b25c262dc'/>
<id>urn:sha1:b02e7d5d701a6217a3a522d9169b483b25c262dc</id>
<content type='text'>
Git's command-line parsers support uniquely abbreviated options, e.g.
`git init --ba` would automatically expand `--ba` to `--bare`.

This is a very convenient feature in every day life for Git users, in
particular when tab completion is not available.

However, it is not a good idea to rely on that in Git's test suite, as
something that is a unique abbreviation of a command line option today
might no longer be a unique abbreviation tomorrow.

For example, if a future contribution added a new mode
`git init --babyproofing` and a previously-introduced test case used the
fact that `git init --ba` expanded to `git init --bare`, that future
contribution would now have to touch seemingly unrelated tests just to
keep the test suite from failing.

So let's disallow abbreviated options in the test suite by default.

Note: for ease of implementation, this patch really only touches the
`parse-options` machinery: more and more hand-rolled option parsers are
converted to use that internal API, and more and more scripts are
converted to built-ins (naturally using the parse-options API, too), so
in practice this catches most issues, and is definitely the biggest bang
for the buck.

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>parse-options: drop unused ctx parameter from show_gitcomp()</title>
<updated>2019-03-20T09:34:09Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2019-03-20T08:16:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5205749d2ca81ea1d124ba7d799f4b319084ca68'/>
<id>urn:sha1:5205749d2ca81ea1d124ba7d799f4b319084ca68</id>
<content type='text'>
The completion display doesn't actually care about where we are in the
parsing. It's generated completely from the set of available options. So
we don't need to see the parse-options context struct at all.

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>parse-options: make OPT_ARGUMENT() more useful</title>
<updated>2019-03-18T02:44:14Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-03-14T11:25:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1a85b49b87af0e17a503b94df10d0b39472ad5b8'/>
<id>urn:sha1:1a85b49b87af0e17a503b94df10d0b39472ad5b8</id>
<content type='text'>
`OPT_ARGUMENT()` is intended to keep the specified long option in `argv`
and not to do anything else.

However, it would make a lot of sense for the caller to know whether
this option was seen at all or not. For example, we want to teach `git
difftool` to work outside of any Git worktree, but only when
`--no-index` was specified.

Note: nothing in Git uses OPT_ARGUMENT(). Even worse, looking through
the commit history, one can easily see that nothing even
ever used it, apart from the regression test.

So not only do we make `OPT_ARGUMENT()` more useful, we are also about
to introduce its first real user!

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>parse-options: allow ll_callback with OPTION_CALLBACK</title>
<updated>2019-01-28T00:28:18Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2019-01-27T00:35:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3ebbe289896a698b99c91b797440563272dcd716'/>
<id>urn:sha1:3ebbe289896a698b99c91b797440563272dcd716</id>
<content type='text'>
OPTION_CALLBACK is much simpler/safer to use, but parse_opt_cb does
not allow access to parse_opt_ctx_t, which sometimes is useful
(e.g. to obtain the prefix).

Extending parse_opt_cb to take parse_opt_cb could result in a lot of
changes. Instead let's just allow ll_callback to be used with
OPTION_CALLBACK. The user will have to be careful, not to change
anything in ctx, or return wrong result code. But that's the price for
ll_callback.

Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse-options: avoid magic return codes</title>
<updated>2019-01-28T00:28:18Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2019-01-27T00:35:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f41179f16ba2fc16e31be81518536008afe2e278'/>
<id>urn:sha1:f41179f16ba2fc16e31be81518536008afe2e278</id>
<content type='text'>
Give names to these magic negative numbers. Make parse_opt_ll_cb
return an enum to make clear it can actually control parse_options()
with different return values (parse_opt_cb can too, but nobody needs
it).

Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
