Skip to content

Commit 87e6297

Browse files
Denton-Lgitster
authored andcommitted
git-completion.bash: rename to $__git_cmd_idx
In e94fb44 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8c8c8c0 commit 87e6297

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

contrib/completion/git-completion.bash

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,12 +1474,12 @@ _git_branch ()
14741474

14751475
_git_bundle ()
14761476
{
1477-
local cmd="${words[__git_subcommand_idx+1]}"
1477+
local cmd="${words[__git_cmd_idx+1]}"
14781478
case "$cword" in
1479-
$((__git_subcommand_idx+1)))
1479+
$((__git_cmd_idx+1)))
14801480
__gitcomp "create list-heads verify unbundle"
14811481
;;
1482-
$((__git_subcommand_idx+2)))
1482+
$((__git_cmd_idx+2)))
14831483
# looking for a file
14841484
;;
14851485
*)
@@ -1894,7 +1894,7 @@ _git_grep ()
18941894
esac
18951895

18961896
case "$cword,$prev" in
1897-
$((__git_subcommand_idx+1)),*|*,-*)
1897+
$((__git_cmd_idx+1)),*|*,-*)
18981898
__git_complete_symbol && return
18991899
;;
19001900
esac
@@ -3017,7 +3017,7 @@ _git_stash ()
30173017
local subcommand="$(__git_find_on_cmdline "$subcommands save")"
30183018

30193019
if [ -z "$subcommand" ]; then
3020-
case "$((cword - __git_subcommand_idx)),$cur" in
3020+
case "$((cword - __git_cmd_idx)),$cur" in
30213021
*,--*)
30223022
__gitcomp_builtin stash_push
30233023
;;
@@ -3058,7 +3058,7 @@ _git_stash ()
30583058
__gitcomp_builtin stash_branch
30593059
;;
30603060
branch,*)
3061-
if [ $cword -eq $((__git_subcommand_idx+2)) ]; then
3061+
if [ $cword -eq $((__git_cmd_idx+2)) ]; then
30623062
__git_complete_refs
30633063
else
30643064
__gitcomp_nl "$(__git stash list \
@@ -3303,7 +3303,7 @@ _git_worktree ()
33033303
# be either the 'add' subcommand, the unstuck
33043304
# argument of an option (e.g. branch for -b|-B), or
33053305
# the path for the new worktree.
3306-
if [ $cword -eq $((__git_subcommand_idx+2)) ]; then
3306+
if [ $cword -eq $((__git_cmd_idx+2)) ]; then
33073307
# Right after the 'add' subcommand: have to
33083308
# complete the path, so fall back to Bash
33093309
# filename completion.
@@ -3327,7 +3327,7 @@ _git_worktree ()
33273327
__git_complete_worktree_paths
33283328
;;
33293329
move,*)
3330-
if [ $cword -eq $((__git_subcommand_idx+2)) ]; then
3330+
if [ $cword -eq $((__git_cmd_idx+2)) ]; then
33313331
# The first parameter must be an existing working
33323332
# tree to be moved.
33333333
__git_complete_worktree_paths
@@ -3395,7 +3395,7 @@ __git_main ()
33953395
{
33963396
local i c=1 command __git_dir __git_repo_path
33973397
local __git_C_args C_args_count=0
3398-
local __git_subcommand_idx
3398+
local __git_cmd_idx
33993399

34003400
while [ $c -lt $cword ]; do
34013401
i="${words[c]}"
@@ -3426,7 +3426,7 @@ __git_main ()
34263426
;;
34273427
*)
34283428
command="$i"
3429-
__git_subcommand_idx="$c"
3429+
__git_cmd_idx="$c"
34303430
break
34313431
;;
34323432
esac

0 commit comments

Comments
 (0)