git/contrib/completion
Denton Liu 59d85a2a05 git-completion.bash: use $__git_cmd_idx in more places
With the introduction of the $__git_cmd_idx variable in e94fb44042
(git-completion.bash: pass $__git_subcommand_idx from __git_main(),
2021-03-24), completion functions were able to know the index at which
the git command is listed, allowing them to skip options that are given
to the underlying git itself, not the corresponding command (e.g.
`-C asdf` in `git -C asdf branch`).

While most of the changes here are self-explanatory, some bear further
explanation.

For the __git_find_on_cmdline() and __git_find_last_on_cmdline() pair of
functions, these functions are only ever called in the context of a git
command completion function. These functions will only care about words
after the command so we can safely ignore the words before this.

For _git_worktree(), this change is technically a no-op (once the
__git_find_last_on_cmdline change is also applied). It was in poor style
to have hard-coded on the index right after `worktree`. In case
`git worktree` were to ever learn to accept options, the current
situation would be inflexible.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-04-27 15:41:07 +09:00
..
.gitattributes completion: mark bash script as LF-only 2017-05-10 13:32:51 +09:00
git-completion.bash git-completion.bash: use $__git_cmd_idx in more places 2021-04-27 15:41:07 +09:00
git-completion.tcsh git-completion.tcsh: fix redirect with noclobber 2015-06-09 11:21:15 -07:00
git-completion.zsh completion: zsh: fix file completion regression 2020-12-01 10:32:40 -08:00
git-prompt.sh Merge branch 'sd/prompt-local-variable' 2020-11-11 13:18:38 -08:00