<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/contrib/completion/git-completion.zsh, 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-02-19T18:13:20Z</updated>
<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: zsh: stop leaking local cache variable</title>
<updated>2024-04-30T22:24:56Z</updated>
<author>
<name>D. Ben Knoble</name>
<email>ben.knoble+github@gmail.com</email>
</author>
<published>2024-04-30T21:53:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3c20acdf465ba211978108ca8507d41e62a016fd'/>
<id>urn:sha1:3c20acdf465ba211978108ca8507d41e62a016fd</id>
<content type='text'>
Completing commands like "git rebase" in one repository will leak the
local __git_repo_path into the shell's environment so that completing
commands after changing to a different repository will give the old
repository's references (or none at all).

The bug report on the mailing list [1] suggests one simple way to observe
this yourself:

Enter the following commands from some directory:
  mkdir a b b/c
  for d (a b); git -C $d init &amp;&amp; git -C $d commit --allow-empty -m init
  cd a
  git branch foo
  pushd ../b/c
  git branch bar

Now type these:
  git rebase &lt;TAB&gt;… # completion for bar available; C-c to abort
  declare -p __git_repo_path # outputs /path/to/b/.git
  popd
  git branch # outputs foo, main
  git rebase &lt;TAB&gt;… # completion candidates are bar, main!

Ideally, the last typed &lt;TAB&gt; should be yielding foo, main.

Commit beb6ee7163 (completion: extract repository discovery from
__gitdir(), 2017-02-03) anticipated this problem by marking
__git_repo_path as local in __git_main and __gitk_main for Bash
completion but did not give the same mark to _git for Zsh completion.
Thus make __git_repo_path local for Zsh completion, too.

[1]: https://lore.kernel.org/git/CALnO6CBv3+e2WL6n6Mh7ZZHCX2Ni8GpvM4a-bQYxNqjmgZdwdg@mail.gmail.com/

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>contrib/completion: fix zsh completion regression from 59d85a2a05</title>
<updated>2021-06-02T03:49:40Z</updated>
<author>
<name>David Aguilar</name>
<email>davvid@gmail.com</email>
</author>
<published>2021-06-01T20:52:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0b18023d000ed8c0851a025fcd4fd518cb2df673'/>
<id>urn:sha1:0b18023d000ed8c0851a025fcd4fd518cb2df673</id>
<content type='text'>
A recent change to make git-completion.bash use $__git_cmd_idx
in more places broke a number of completions on zsh because it
modified __git_main but did not update __git_zsh_main.

Notably, completions for "add", "branch", "mv" and "push" were
broken as a result of this change.

In addition to the undefined variable usage, "git mv &lt;tab&gt;" also
prints the following error:

	__git_count_arguments:7: bad math expression:
	operand expected at `"1"'

	_git_mv:[:7: unknown condition: -gt

Remove the quotes around $__git_cmd_idx in __git_count_arguments
and set __git_cmd_idx=1 early in __git_zsh_main to fix the
regressions from 59d85a2a05.

This was tested on zsh 5.7.1 (x86_64-apple-darwin19.0).

Suggested-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: David Aguilar &lt;davvid@gmail.com&gt;
Acked-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: zsh: fix file completion regression</title>
<updated>2020-12-01T18:32:40Z</updated>
<author>
<name>Felipe Contreras</name>
<email>felipe.contreras@gmail.com</email>
</author>
<published>2020-12-01T00:54:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c5dd0c861ab0db5ad1ecaf9508bdddca83c5cc6e'/>
<id>urn:sha1:c5dd0c861ab0db5ad1ecaf9508bdddca83c5cc6e</id>
<content type='text'>
Turns out we always need to set the ignored prefix (compset) to have
similar behavior as in default Bash.

The issue can be seen with:

  git show master:&lt;tab&gt;

Commit 94b2901cfe wrongly removed it.

Signed-off-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>zsh: update copyright notices</title>
<updated>2020-10-28T21:31:19Z</updated>
<author>
<name>Felipe Contreras</name>
<email>felipe.contreras@gmail.com</email>
</author>
<published>2020-10-28T02:07:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=af806a2c2417d21dc024bf013ec511765441e286'/>
<id>urn:sha1:af806a2c2417d21dc024bf013ec511765441e286</id>
<content type='text'>
Signed-off-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: zsh: add simple version check</title>
<updated>2020-10-28T21:30:59Z</updated>
<author>
<name>Felipe Contreras</name>
<email>felipe.contreras@gmail.com</email>
</author>
<published>2020-10-28T02:07:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=35a4170d8656b27d08458c3c381dd163199da4f3'/>
<id>urn:sha1:35a4170d8656b27d08458c3c381dd163199da4f3</id>
<content type='text'>
A lot of people are confused about which completion script they are
using; Zsh's Git script, or Git's Zsh script.

Add a simple helper so they can type 'git zsh&lt;tab&gt;' and find out if they
are running the correct one: this.

Signed-off-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: zsh: trivial simplification</title>
<updated>2020-10-28T21:30:59Z</updated>
<author>
<name>Felipe Contreras</name>
<email>felipe.contreras@gmail.com</email>
</author>
<published>2020-10-28T02:07:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bbd7f45884ca379e3cd28bb5fb8e804bcfb3360c'/>
<id>urn:sha1:bbd7f45884ca379e3cd28bb5fb8e804bcfb3360c</id>
<content type='text'>
&gt;From upstream bash simplification:

  d9ee1e0617 (completion: simplify inner 'case' pattern in __gitcomp())

Signed-off-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: zsh: add alias descriptions</title>
<updated>2020-10-28T21:30:59Z</updated>
<author>
<name>Felipe Contreras</name>
<email>felipe.contreras@gmail.com</email>
</author>
<published>2020-10-28T02:07:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2769e567d140a51e4e6e426fe776005ae889e9b0'/>
<id>urn:sha1:2769e567d140a51e4e6e426fe776005ae889e9b0</id>
<content type='text'>
Signed-off-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: zsh: improve command tags</title>
<updated>2020-10-28T21:30:59Z</updated>
<author>
<name>Felipe Contreras</name>
<email>felipe.contreras@gmail.com</email>
</author>
<published>2020-10-28T02:07:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9d760527addc576c87e9b0e66b63376e580b434a'/>
<id>urn:sha1:9d760527addc576c87e9b0e66b63376e580b434a</id>
<content type='text'>
There's no need to use _alternative and repeat a lot of the code.

Signed-off-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: zsh: refactor command completion</title>
<updated>2020-10-28T21:30:59Z</updated>
<author>
<name>Felipe Contreras</name>
<email>felipe.contreras@gmail.com</email>
</author>
<published>2020-10-28T02:07:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9a397ea5ad59e64ff6eebfd1d7dad43aac790e0a'/>
<id>urn:sha1:9a397ea5ad59e64ff6eebfd1d7dad43aac790e0a</id>
<content type='text'>
Signed-off-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
