diff options
author | Denton Liu <liu.denton@gmail.com> | 2021-03-24 08:36:27 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-03-24 17:05:47 (GMT) |
commit | e94fb4404280c07a668b4669c072983cdd079592 (patch) | |
tree | f32840e03a63a1e3cef70d540d5f06f122c1196b /diff-no-index.c | |
parent | a5828ae6b52137b913b978e16cd2334482eb4c1f (diff) | |
download | git-e94fb4404280c07a668b4669c072983cdd079592.zip git-e94fb4404280c07a668b4669c072983cdd079592.tar.gz git-e94fb4404280c07a668b4669c072983cdd079592.tar.bz2 |
git-completion.bash: pass $__git_subcommand_idx from __git_main()
Many completion functions perform hardcoded comparisons with $cword.
This fails in the case where the main git command is given arguments
(e.g. `git -C . bundle<TAB>` would fail to complete its subcommands).
Even _git_worktree(), which uses __git_find_on_cmdline(), could still
fail. With something like `git -C add worktree move<TAB>`, the
subcommand would be incorrectly identified as "add" instead of "move".
Assign $__git_subcommand_idx in __git_main(), where the git subcommand
is actually found and the corresponding completion function is called.
Use this variable to replace hardcoded comparisons with $cword.
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff-no-index.c')
0 files changed, 0 insertions, 0 deletions