diff options
| author | Lutz Lengemann <lutz@lengemann.net> | 2026-08-19 13:07:51 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-08-19 10:22:14 -0700 |
| commit | da9c6e7e04c3ee8ab4e5ae014615163f3449221b (patch) | |
| tree | 485f8ebc82f8ffdf794e3f73f6c8802ad9a7ad14 /t/t4013/diff.diff_initial..side | |
| parent | dea0ea3582e6980ddbc1173cc8e3e9f9db91cde0 (diff) | |
completion: zsh: support completion after "git -C <path>"
The zsh completion wrapper does not handle the global -C option, so
git -C <path> <command> <TAB>
offers nothing. -C is not part of the _arguments specification, and the
wrapper hard-codes __git_cmd_idx=1, i.e. it assumes that the command is
the first argument, so the bash helpers look at the wrong word. The
latter is not specific to -C; the assumption breaks after any global
option, e.g. "git -p checkout <TAB>" does not complete branch names.
Add -C to the specification, and find the command by skipping over the
global options and, where they take one, their arguments, as __git_main
in git-completion.bash does. The index is one less than zsh's, as the
helpers count the words from zero. Collect the paths given to -C into
__git_C_args, or else the helpers run git in the current directory and
fail to resolve the aliases and refs of the repository the command runs
in.
The argument of a -C is still completed without regard for the -C
options before it, i.e. "git -C dir -C <TAB>" offers the directories in
".", not the ones in "dir".
Signed-off-by: Lutz Lengemann <lutz@lengemann.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4013/diff.diff_initial..side')
0 files changed, 0 insertions, 0 deletions
