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>
Denton Liu committed
Apr 22, 2021 at 03:00 UTC
87e629756f3bbd5125237f504f12e394c576b26d
1 file changed
+10
-10
contrib/completion/git-completion.bash
+10
-10
@@ -1474,12 +1474,12 @@ _git_branch ()
1474
1475
_git_bundle ()
1476
{
1477
- local cmd="${words[__git_subcommand_idx+1]}"
1477
+ local cmd="${words[__git_cmd_idx+1]}"
1478
case "$cword" in
1479
- $((__git_subcommand_idx+1)))
1479
+ $((__git_cmd_idx+1)))
1480
__gitcomp "create list-heads verify unbundle"
1481
;;
1482
- $((__git_subcommand_idx+2)))
1482
+ $((__git_cmd_idx+2)))
1483
# looking for a file
1484
;;
1485
*)
@@ -1894,7 +1894,7 @@ _git_grep ()
1894
esac
1895
1896
case "$cword,$prev" in
1897
- $((__git_subcommand_idx+1)),*|*,-*)
1897
+ $((__git_cmd_idx+1)),*|*,-*)
1898
__git_complete_symbol && return
1899
;;
1900
esac
@@ -3017,7 +3017,7 @@ _git_stash ()
3017
local subcommand="$(__git_find_on_cmdline "$subcommands save")"
3018
3019
if [ -z "$subcommand" ]; then
3020
- case "$((cword - __git_subcommand_idx)),$cur" in
3020
+ case "$((cword - __git_cmd_idx)),$cur" in
3021
*,--*)
3022
__gitcomp_builtin stash_push
3023
;;
@@ -3058,7 +3058,7 @@ _git_stash ()
3058
__gitcomp_builtin stash_branch
3059
;;
3060
branch,*)
3061
- if [ $cword -eq $((__git_subcommand_idx+2)) ]; then
3061
+ if [ $cword -eq $((__git_cmd_idx+2)) ]; then
3062
__git_complete_refs
3063
else
3064
__gitcomp_nl "$(__git stash list \
@@ -3303,7 +3303,7 @@ _git_worktree ()
3303
# be either the 'add' subcommand, the unstuck
3304
# argument of an option (e.g. branch for -b|-B), or
3305
# the path for the new worktree.
3306
- if [ $cword -eq $((__git_subcommand_idx+2)) ]; then
3306
+ if [ $cword -eq $((__git_cmd_idx+2)) ]; then
3307
# Right after the 'add' subcommand: have to
3308
# complete the path, so fall back to Bash
3309
# filename completion.
@@ -3327,7 +3327,7 @@ _git_worktree ()
3327
__git_complete_worktree_paths
3328
;;
3329
move,*)
3330
- if [ $cword -eq $((__git_subcommand_idx+2)) ]; then
3330
+ if [ $cword -eq $((__git_cmd_idx+2)) ]; then
3331
# The first parameter must be an existing working
3332
# tree to be moved.
3333
__git_complete_worktree_paths
@@ -3395,7 +3395,7 @@ __git_main ()
3395
{
3396
local i c=1 command __git_dir __git_repo_path
3397
local __git_C_args C_args_count=0
3398
- local __git_subcommand_idx
3398
+ local __git_cmd_idx
3399
3400
while [ $c -lt $cword ]; do
3401
i="${words[c]}"
@@ -3426,7 +3426,7 @@ __git_main ()
3426
;;
3427
*)
3428
command="$i"
3429
- __git_subcommand_idx="$c"
3429
+ __git_cmd_idx="$c"
3430
break
3431
;;
3432
esac