diff options
author | Denton Liu <liu.denton@gmail.com> | 2021-04-22 03:00:51 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-04-27 15:41:07 +0900 |
commit | 59d85a2a0528c3db2552b0786caac7bf0610c552 (patch) | |
tree | fcc76fd969abbefb6fa4c8353684b65bbc827219 /pack-objects.c | |
parent | git-completion.bash: rename to $__git_cmd_idx (diff) | |
download | tgif-59d85a2a0528c3db2552b0786caac7bf0610c552.tar.xz |
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>
Diffstat (limited to 'pack-objects.c')
0 files changed, 0 insertions, 0 deletions