<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/contrib/completion, branch main</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=main</id>
<link rel='self' href='https://git.shady.money/git/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2026-02-27T23:11:53Z</updated>
<entry>
<title>Merge branch 'jh/alias-i18n'</title>
<updated>2026-02-27T23:11:53Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2026-02-27T23:11:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c0d0b8daedd336677ed30bfb6bb7cdc6c47a468a'/>
<id>urn:sha1:c0d0b8daedd336677ed30bfb6bb7cdc6c47a468a</id>
<content type='text'>
Extend the alias configuration syntax to allow aliases using
characters outside ASCII alphanumeric (plus '-').

* jh/alias-i18n:
  completion: fix zsh alias listing for subsection aliases
  alias: support non-alphanumeric names via subsection syntax
  alias: prepare for subsection aliases
  help: use list_aliases() for alias listing
</content>
</entry>
<entry>
<title>completion: fix zsh alias listing for subsection aliases</title>
<updated>2026-02-19T18:13:20Z</updated>
<author>
<name>Jonatan Holmgren</name>
<email>jonatan@jontes.page</email>
</author>
<published>2026-02-18T21:57:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=edd8ad18a643d47dd92b08ab865bf7f4a26f50bc'/>
<id>urn:sha1:edd8ad18a643d47dd92b08ab865bf7f4a26f50bc</id>
<content type='text'>
The zsh completion function __git_zsh_cmd_alias() uses 'git config
--get-regexp' to enumerate aliases and then strips the "alias." prefix
from each key. For subsection-style aliases (alias.name.command), this
leaves "name.command" as the completion candidate instead of just
"name".

The bash completion does not have this problem because it goes through
'git --list-cmds=alias', which calls list_aliases() in C and already
handles both alias syntaxes correctly. However, zsh needs both the
alias name and its value for descriptive completion, which
--list-cmds=alias does not provide.

Add a hidden --aliases-for-completion option to 'git help', following
the existing --config-for-completion pattern. It outputs NUL-separated
"name\nvalue" pairs using list_aliases(), which correctly resolves both
the traditional (alias.name) and subsection (alias.name.command)
formats. Update __git_zsh_cmd_alias() to use it.

Signed-off-by: Jonatan Holmgren &lt;jonatan@jontes.page&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: add stash import, export</title>
<updated>2026-02-08T01:27:56Z</updated>
<author>
<name>D. Ben Knoble</name>
<email>ben.knoble+github@gmail.com</email>
</author>
<published>2026-02-07T21:59:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bfc1b34859c973127cdef0cfba537c25ee39f763'/>
<id>urn:sha1:bfc1b34859c973127cdef0cfba537c25ee39f763</id>
<content type='text'>
These newer commands lack completion; implement basic support for
options and arguments.

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>completion: clarify support for short options and arguments</title>
<updated>2025-12-07T01:05:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-12-07T01:03:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dc8a00fafef0608c27cdf47cd8a8de0d31dc2197'/>
<id>urn:sha1:dc8a00fafef0608c27cdf47cd8a8de0d31dc2197</id>
<content type='text'>
The list of supported completions in the header of the file was
mostly written a long time ago when Shawn added the initial version
of this script in 2006.  The list explicitly states that we complete
"common --long-options", which implies that we do not complete
not-so-common ones and single letter options (this text dates back
to May 2007).

Update the description to explicitly state that single-letter
options are not completed.  Also, document that arguments to options
are completed, even for single-letter options (e.g., "git -c &lt;TAB&gt;"
offers configuration variables).

The reason why we do not complete single-letter options is because
it does not seem to help all that much to learn that the command
takes -c, -d, -e options when "git foo -&lt;TAB&gt;" offers these three,
unlike long options that is easier to guess what they are about.

Because this rationale is primarily for our developers, let's leave
it out of the completion script itself, whose messages are entirely
for end-users.  Our developers can run "git blame" to find this
commit as needed.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: complete some 'git log' options</title>
<updated>2025-10-20T18:07:24Z</updated>
<author>
<name>KIYOTA Fumiya</name>
<email>aimluck.kiyota@gmail.com</email>
</author>
<published>2025-10-20T17:32:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c568fa8e1c740c19f8b1cc7efeeef2c6c52961dd'/>
<id>urn:sha1:c568fa8e1c740c19f8b1cc7efeeef2c6c52961dd</id>
<content type='text'>
1. '--exclude=' option to 'git log' and 'git shortlog' are missing. Add the
option to __git_log_shortlog_options.

2. The `--committer` option in `git log` requires a pattern, such as
`--committer=ba`, but in `git shortlog`, specifying a pattern results in
an error: “error: option `committer' takes no value.” Handle them as
separate options for completion rather than a shared one.

Signed-off-by: KIYOTA Fumiya &lt;aimluck.kiyota@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>contrib/completion: install Bash completion</title>
<updated>2025-04-22T15:26:12Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2025-04-22T08:36:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fe35ce2ef83b597f0e0ca9fb0f7662ce018d3443'/>
<id>urn:sha1:fe35ce2ef83b597f0e0ca9fb0f7662ce018d3443</id>
<content type='text'>
The shell completion scripts in "contrib/completion" are being tested,
but none of our build systems support installing them. This is somewhat
confusing for Meson, where users can explicitly enable building these
scripts via `-Dcontrib=completion`. This option only controlls whether
the completions are built and tested against, where "building" is a bit
of an euphemism for "copying them into the build directory".

Teach both our Makefile and Meson to install our Bash completion script.
For now, this is the only completion script that we're installing given
that Bash completions "just work" with a canonical well-known location
nowadays. Other completion scripts, like for example the one for zsh,
don't have a well-known location and/or require extra steps by the user
to make them available. As such, we skip installing these scripts for
now, but we may do so in the future if we ever figure out a proper way
to do this.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: fix bugs with slashes in remote names</title>
<updated>2025-03-24T06:03:13Z</updated>
<author>
<name>David Mandelberg</name>
<email>david@mandelberg.org</email>
</author>
<published>2025-03-23T21:06:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=778d2f1760bf5411ab15657bdaf0ecf19352c502'/>
<id>urn:sha1:778d2f1760bf5411ab15657bdaf0ecf19352c502</id>
<content type='text'>
Previously, some calls to for-each-ref passed fixed numbers of path
components to strip from refs, assuming that remote names had no slashes
in them. This made completions like:

git push github/dseomn :com&lt;Tab&gt;

Result in:

git push github/dseomn :dseomn/completion-remote-slash

With this patch, it instead results in:

git push github/dseomn :completion-remote-slash

Signed-off-by: David Mandelberg &lt;david@mandelberg.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: add helper to count path components</title>
<updated>2025-03-24T06:03:12Z</updated>
<author>
<name>David Mandelberg</name>
<email>david@mandelberg.org</email>
</author>
<published>2025-03-23T21:05:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5637bdc352a7763e30290bb37239a61cb9865d1b'/>
<id>urn:sha1:5637bdc352a7763e30290bb37239a61cb9865d1b</id>
<content type='text'>
A follow-up commit will use this with for-each-ref to strip the right
number of path components from refnames.

Signed-off-by: David Mandelberg &lt;david@mandelberg.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'dk/zsh-config-completion-fix'</title>
<updated>2025-01-21T16:44:55Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-01-21T16:44:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c032b1d8bc29de4fb1322d841d8216ca961dcb53'/>
<id>urn:sha1:c032b1d8bc29de4fb1322d841d8216ca961dcb53</id>
<content type='text'>
Completion script updates for zsh

* dk/zsh-config-completion-fix:
  completion: repair config completion for Zsh
</content>
</entry>
<entry>
<title>completion: repair config completion for Zsh</title>
<updated>2025-01-06T22:21:26Z</updated>
<author>
<name>D. Ben Knoble</name>
<email>ben.knoble+github@gmail.com</email>
</author>
<published>2025-01-06T21:47:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8776470cf379f31d483d8512d28a0eaa47d2e3f2'/>
<id>urn:sha1:8776470cf379f31d483d8512d28a0eaa47d2e3f2</id>
<content type='text'>
Commit 1e0ee4087e (completion: add and use
__git_compute_first_level_config_vars_for_section, 2024-02-10) uses an
indirect variable syntax that is only valid for Bash, but the Zsh
completion code relies on the Bash completion code to function. Zsh
supports a different indirect variable expansion using ${(P)var}, but in
`emulate ksh` mode does not support Bash's ${!var}.

This manifests as completing strange config options like
"__git_first_level_config_vars_for_section_remote" as a choice for the
command line

    git config set remote.

Using Zsh's C-x ? _complete_debug widget with the cursor at the end of
that command line captures a trace, in which we see (some details
elided):

    +__git_complete_config_variable_name:7&gt; __git_compute_first_level_config_vars_for_section remote
     +__git_compute_first_level_config_vars_for_section:7&gt; local section=remote
     +__git_compute_first_level_config_vars_for_section:7&gt; __git_compute_config_vars
      +__git_compute_config_vars:7&gt; test -n $'add.ignoreErrors\nadvice.addEmbeddedRepo\nadvice.addEmptyPathspec\nadvice.addIgnoredFile[…]'
     +__git_compute_first_level_config_vars_for_section:7&gt; local this_section=__git_first_level_config_vars_for_section_remote
     +__git_compute_first_level_config_vars_for_section:7&gt; test -n __git_first_level_config_vars_for_section_remote
    +__git_complete_config_variable_name:7&gt; local this_section=__git_first_level_config_vars_for_section_remote
    +__git_complete_config_variable_name:7&gt; __gitcomp_nl_append __git_first_level_config_vars_for_section_remote remote. '' ' '
     +__gitcomp_nl_append:7&gt; __gitcomp_nl __git_first_level_config_vars_for_section_remote remote. '' ' '
      +__gitcomp_nl:7&gt; emulate -L zsh
      +__gitcomp_nl:7&gt; compset -P '*[=:]'
      +__gitcomp_nl:7&gt; compadd -Q -S ' ' -p remote. -- __git_first_level_config_vars_for_section_remote

We perform the test for __git_compute_config_vars correctly, but the
${!this_section} references are not expanded as expected.

Instead, portably expand indirect references through the new
__git_indirect. Contrary to some versions you might find online [1],
this version avoids echo non-portabilities [2] [3] and correctly quotes
the indirect expansion after eval (so that the result is not split or
globbed before being handed to printf).

[1]: https://unix.stackexchange.com/a/41409/301073
[2]: https://askubuntu.com/questions/715765/mysterious-behavior-of-echo-command#comment1056038_715769
[3]: https://mywiki.wooledge.org/CatEchoLs

The following demo program demonstrates how this works:

    b=1
    indirect() {
      eval printf '%s' "\"\$$1\""
    }
    f() {
      # Comment this out to see that it works for globals, too. Or, use
      # a value with spaces like '2 3 4' to see how it handles those.
      local b=2
      local a=b
      test -n "$(indirect $a)" &amp;&amp; echo nice
    }
    f

When placed in a file "demo", then both
    bash -x demo
and
    zsh -xc 'emulate ksh -c ". ./demo"' |&amp; tail
provide traces showing that "$(indirect $a)" produces 2 (or 1, with the
global, or "2 3 4" as a single string, etc.).

Signed-off-by: D. Ben Knoble &lt;ben.knoble+github@gmail.com&gt;
Acked-by: Philippe Blain &lt;levraiphilippeblain@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
