<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/contrib/completion, branch v2.44.3</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.44.3</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.44.3'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2024-02-14T23:36:06Z</updated>
<entry>
<title>Merge branch 'pb/complete-config'</title>
<updated>2024-02-14T23:36:06Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-02-14T23:36:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=89400c361510c58bbbeac7d98967627636069340'/>
<id>urn:sha1:89400c361510c58bbbeac7d98967627636069340</id>
<content type='text'>
The command line completion script (in contrib/) learned to
complete configuration variable names better.

* pb/complete-config:
  completion: add and use __git_compute_second_level_config_vars_for_section
  completion: add and use __git_compute_first_level_config_vars_for_section
  completion: complete 'submodule.*' config variables
  completion: add space after config variable names also in Bash 3
</content>
</entry>
<entry>
<title>Merge branch 'bk/complete-bisect'</title>
<updated>2024-02-12T21:16:10Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-02-12T21:16:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=46761378c3ba8915fd5a52995c8f6c1a847bed84'/>
<id>urn:sha1:46761378c3ba8915fd5a52995c8f6c1a847bed84</id>
<content type='text'>
Command line completion support (in contrib/) has been
updated for "git bisect".

* bk/complete-bisect:
  completion: bisect: recognize but do not complete view subcommand
  completion: bisect: complete log opts for visualize subcommand
  completion: new function __git_complete_log_opts
  completion: bisect: complete missing --first-parent and - -no-checkout options
  completion: bisect: complete custom terms and related options
  completion: bisect: complete bad, new, old, and help subcommands
  completion: tests: always use 'master' for default initial branch name
</content>
</entry>
<entry>
<title>completion: add and use __git_compute_second_level_config_vars_for_section</title>
<updated>2024-02-12T17:43:42Z</updated>
<author>
<name>Philippe Blain</name>
<email>levraiphilippeblain@gmail.com</email>
</author>
<published>2024-02-10T18:32:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6e32f718ffa2e1358f3c34dafb9ed0dc8e479781'/>
<id>urn:sha1:6e32f718ffa2e1358f3c34dafb9ed0dc8e479781</id>
<content type='text'>
In a previous commit we removed some hardcoded config variable names from
function __git_complete_config_variable_name in the completion script by
introducing a new function,
__git_compute_first_level_config_vars_for_section.

The remaining hardcoded config variables are "second level"
configuration variables, meaning 'branch.&lt;name&gt;.upstream',
'remote.&lt;name&gt;.url', etc. where &lt;name&gt; is a user-defined name.

Making use of the new existing --config flag to 'git help', add a new
function, __git_compute_second_level_config_vars_for_section. This
function takes as argument a config section name and computes the
corresponding second-level config variables, i.e. those that contain a
'&lt;' which indicates the start of a placeholder. Note that as in
__git_compute_first_level_config_vars_for_section added previsouly, we
use indirect expansion instead of associative arrays to stay compatible
with Bash 3 on which macOS is stuck for licensing reasons.

As explained in the previous commit, we use the existing pattern in the
completion script of using global variables to cache the list of
variables for each section.

Use this new function and the variables it defines in
__git_complete_config_variable_name to remove hardcoded config
variables, and add a test to verify the new function.  Use a single
'case' for all sections with second-level variables names, since the
code for each of them is now exactly the same.

Adjust the name of a test added in a previous commit to reflect that it
now tests the added function.

Signed-off-by: Philippe Blain &lt;levraiphilippeblain@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: add and use __git_compute_first_level_config_vars_for_section</title>
<updated>2024-02-12T17:43:42Z</updated>
<author>
<name>Philippe Blain</name>
<email>levraiphilippeblain@gmail.com</email>
</author>
<published>2024-02-10T18:32:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1e0ee4087e5e5f66882ce60dad522b4f49f79eb0'/>
<id>urn:sha1:1e0ee4087e5e5f66882ce60dad522b4f49f79eb0</id>
<content type='text'>
The function __git_complete_config_variable_name in the Bash completion
script hardcodes several config variable names. These variables are
those in config sections where user-defined names can appear, such as
"branch.&lt;name&gt;". These sections are treated first by the case statement,
and the two last "catch all" cases are used for other sections, making
use of the __git_compute_config_vars and __git_compute_config_sections
function, which omit listing any variables containing wildcards or
placeholders. Having hardcoded config variables introduces the risk of
the completion code becoming out of sync with the actual config
variables accepted by Git.

To avoid these hardcoded config variables, introduce a new function,
__git_compute_first_level_config_vars_for_section, making use of the
existing __git_config_vars variable. This function takes as argument a
config section name and computes the matching "first level" config
variables for that section, i.e. those _not_ containing any placeholder,
like 'branch.autoSetupMerge, 'remote.pushDefault', etc.  Use this
function and the variables it defines in the 'branch.*', 'remote.*' and
'submodule.*' switches of the case statement instead of hardcoding the
corresponding config variables.  Note that we use indirect expansion to
create a variable for each section, instead of using a single
associative array indexed by section names, because associative arrays
are not supported in Bash 3, on which macOS is stuck for licensing
reasons.

Use the existing pattern in the completion script of using global
variables to cache the list of config variables for each section. The
rationale for such caching is explained in eaa4e6ee2a (Speed up bash
completion loading, 2009-11-17), and the current approach to using and
defining them via 'test -n' is explained in cf0ff02a38 (completion: work
around zsh option propagation bug, 2012-02-02).

Adjust the name of one of the tests added in the previous commit,
reflecting that it now also tests the new function.

Signed-off-by: Philippe Blain &lt;levraiphilippeblain@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: complete 'submodule.*' config variables</title>
<updated>2024-02-12T17:43:42Z</updated>
<author>
<name>Philippe Blain</name>
<email>levraiphilippeblain@gmail.com</email>
</author>
<published>2024-02-10T18:32:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b1d0cc68d1921f8d26a947fe662697e42dffb730'/>
<id>urn:sha1:b1d0cc68d1921f8d26a947fe662697e42dffb730</id>
<content type='text'>
In the Bash completion script, function
__git_complete_config_variable_name completes config variables and has
special logic to deal with config variables involving user-defined
names, like branch.&lt;name&gt;.* and remote.&lt;name&gt;.*.

This special logic is missing for submodule-related config variables.
Add the appropriate branches to the case statement, making use of the
in-tree '.gitmodules' to list relevant submodules.

Add corresponding tests in t9902-completion.sh, making sure we complete
both first level submodule config variables as well as second level
variables involving submodule names.

Signed-off-by: Philippe Blain &lt;levraiphilippeblain@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: add space after config variable names also in Bash 3</title>
<updated>2024-02-12T17:43:41Z</updated>
<author>
<name>Philippe Blain</name>
<email>levraiphilippeblain@gmail.com</email>
</author>
<published>2024-02-10T18:32:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=30bd55f901c97c310e674c051f00920f38a66ee0'/>
<id>urn:sha1:30bd55f901c97c310e674c051f00920f38a66ee0</id>
<content type='text'>
In be6444d1ca (completion: bash: add correct suffix in variables,
2021-08-16), __git_complete_config_variable_name was changed to use
"${sfx- }" instead of "$sfx" as the fourth argument of _gitcomp_nl and
_gitcomp_nl_append, such that this argument evaluates to a space if sfx
is unset. This was to ensure that e.g.

	git config branch.autoSetupMe[TAB]

correctly completes to 'branch.autoSetupMerge ' with the trailing space.
This commits notes that the fix only works in Bash 4 because in Bash 3
the 'local sfx' construct at the beginning of
__git_complete_config_variable_name creates an empty string.

Make the fix also work for Bash 3 by using the "unset or null' parameter
expansion syntax ("${sfx:- }"), such that the parameter is also expanded
to a space if it is set but null, as is the behaviour of 'local sfx' in
Bash 3.

Signed-off-by: Philippe Blain &lt;levraiphilippeblain@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: bisect: recognize but do not complete view subcommand</title>
<updated>2024-02-06T23:11:46Z</updated>
<author>
<name>Britton Leo Kerin</name>
<email>britton.kerin@gmail.com</email>
</author>
<published>2024-02-06T21:50:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d8e08f0717c17b2ee629c50844c34adc83575ad0'/>
<id>urn:sha1:d8e08f0717c17b2ee629c50844c34adc83575ad0</id>
<content type='text'>
The "view" alias for the visualize subcommand is neither completed nor
recognized.  It's undesirable to complete it because it's first letters
are the same as for visualize, making completion less rather than more
efficient without adding much in the way of interface discovery.
However, it needs to be recognized in order to enable log option
completion for it.

Recognize but do not complete the view command by creating and using
separate lists of completable_subcommands and all_subcommands.  Add
tests.

Signed-off-by: Britton Leo Kerin &lt;britton.kerin@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: bisect: complete log opts for visualize subcommand</title>
<updated>2024-02-06T23:11:46Z</updated>
<author>
<name>Britton Leo Kerin</name>
<email>britton.kerin@gmail.com</email>
</author>
<published>2024-02-06T21:50:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d115b877879cc8d072971437395ea2b97d47a7d7'/>
<id>urn:sha1:d115b877879cc8d072971437395ea2b97d47a7d7</id>
<content type='text'>
Arguments passed to the "visualize" subcommand of git-bisect(1) get
forwarded to git-log(1). It thus supports the same options as git-log(1)
would, but our Bash completion script does not know to handle this.

Make completion of porcelain git-log options and option arguments to the
visualize subcommand work by calling __git_complete_log_opts when the
start of an option to the subcommand is seen (visualize doesn't support
any options besides the git-log options).  Add test.

Signed-off-by: Britton Leo Kerin &lt;britton.kerin@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: new function __git_complete_log_opts</title>
<updated>2024-02-06T23:11:46Z</updated>
<author>
<name>Britton Leo Kerin</name>
<email>britton.kerin@gmail.com</email>
</author>
<published>2024-02-06T21:50:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a9e5b7a76da5ceab772166c94830dd899cf55b88'/>
<id>urn:sha1:a9e5b7a76da5ceab772166c94830dd899cf55b88</id>
<content type='text'>
The options accepted by git-log are also accepted by at least one other
command (git-bisect).  Factor the common option completion code into a
new function and use it from _git_log.  The new function leaves
COMPREPLY empty if no option candidates are found, so that callers can
safely check it to determine if completion for other arguments should be
attempted.

Signed-off-by: Britton Leo Kerin &lt;britton.kerin@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: bisect: complete missing --first-parent and - -no-checkout options</title>
<updated>2024-02-06T23:11:46Z</updated>
<author>
<name>Britton Leo Kerin</name>
<email>britton.kerin@gmail.com</email>
</author>
<published>2024-02-06T21:50:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=41928aeb45e70d4361c780cc69d3975faee5eec4'/>
<id>urn:sha1:41928aeb45e70d4361c780cc69d3975faee5eec4</id>
<content type='text'>
The --first-parent and --no-checkout options to the start subcommand of
git-bisect(1) are not completed.

Enable completion of the --first-parent and --no-checkout options to the
start subcommand.  Add test.

Signed-off-by: Britton Leo Kerin &lt;britton.kerin@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
