summaryrefslogtreecommitdiff
path: root/contrib/completion
diff options
context:
space:
mode:
authorLibravatar Denton Liu <liu.denton@gmail.com>2021-04-22 03:00:50 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-04-27 15:41:07 +0900
commit87e629756f3bbd5125237f504f12e394c576b26d (patch)
treea4a1a8f99024b7d06ac7e3196afe27ea1153c3ba /contrib/completion
parentgit-completion.bash: separate some commands onto their own line (diff)
downloadtgif-87e629756f3bbd5125237f504f12e394c576b26d.tar.xz
git-completion.bash: rename to $__git_cmd_idx
In e94fb44042 (git-completion.bash: pass $__git_subcommand_idx from __git_main(), 2021-03-24), the $__git_subcommand_idx variable was introduced. Naming it after the index of the subcommand is needlessly confusing as, when this variable is used, it is in the completion functions for commands (e.g. _git_remote()) where for `git remote add`, the `remote` is referred to as the command and `add` is referred to as the subcommand. Rename this variable so that it's obvious it's about git commands. While we're at it, shorten up its name so that it's still readable without being a handful to type. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/completion')
-rw-r--r--contrib/completion/git-completion.bash20
1 files changed, 10 insertions, 10 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 1dedb14b47..c29c129f87 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1474,12 +1474,12 @@ _git_branch ()
_git_bundle ()
{
- local cmd="${words[__git_subcommand_idx+1]}"
+ local cmd="${words[__git_cmd_idx+1]}"
case "$cword" in
- $((__git_subcommand_idx+1)))
+ $((__git_cmd_idx+1)))
__gitcomp "create list-heads verify unbundle"
;;
- $((__git_subcommand_idx+2)))
+ $((__git_cmd_idx+2)))
# looking for a file
;;
*)
@@ -1894,7 +1894,7 @@ _git_grep ()
esac
case "$cword,$prev" in
- $((__git_subcommand_idx+1)),*|*,-*)
+ $((__git_cmd_idx+1)),*|*,-*)
__git_complete_symbol && return
;;
esac
@@ -3017,7 +3017,7 @@ _git_stash ()
local subcommand="$(__git_find_on_cmdline "$subcommands save")"
if [ -z "$subcommand" ]; then
- case "$((cword - __git_subcommand_idx)),$cur" in
+ case "$((cword - __git_cmd_idx)),$cur" in
*,--*)
__gitcomp_builtin stash_push
;;
@@ -3058,7 +3058,7 @@ _git_stash ()
__gitcomp_builtin stash_branch
;;
branch,*)
- if [ $cword -eq $((__git_subcommand_idx+2)) ]; then
+ if [ $cword -eq $((__git_cmd_idx+2)) ]; then
__git_complete_refs
else
__gitcomp_nl "$(__git stash list \
@@ -3303,7 +3303,7 @@ _git_worktree ()
# be either the 'add' subcommand, the unstuck
# argument of an option (e.g. branch for -b|-B), or
# the path for the new worktree.
- if [ $cword -eq $((__git_subcommand_idx+2)) ]; then
+ if [ $cword -eq $((__git_cmd_idx+2)) ]; then
# Right after the 'add' subcommand: have to
# complete the path, so fall back to Bash
# filename completion.
@@ -3327,7 +3327,7 @@ _git_worktree ()
__git_complete_worktree_paths
;;
move,*)
- if [ $cword -eq $((__git_subcommand_idx+2)) ]; then
+ if [ $cword -eq $((__git_cmd_idx+2)) ]; then
# The first parameter must be an existing working
# tree to be moved.
__git_complete_worktree_paths
@@ -3395,7 +3395,7 @@ __git_main ()
{
local i c=1 command __git_dir __git_repo_path
local __git_C_args C_args_count=0
- local __git_subcommand_idx
+ local __git_cmd_idx
while [ $c -lt $cword ]; do
i="${words[c]}"
@@ -3426,7 +3426,7 @@ __git_main ()
;;
*)
command="$i"
- __git_subcommand_idx="$c"
+ __git_cmd_idx="$c"
break
;;
esac