All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denton Liu <liu.denton@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: [PATCH 2/5] git-completion.bash: rename to $__git_cmd_idx
Date: Tue, 20 Apr 2021 02:19:48 -0700	[thread overview]
Message-ID: <7c7d6de380d1aaa860e86627778bef6c0c78ca08.1618910364.git.liu.denton@gmail.com> (raw)
In-Reply-To: <cover.1618910364.git.liu.denton@gmail.com>

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 flat-out
wrong as this variable really holds the index of the git comand (e.g.
"stash").

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>
---
 contrib/completion/git-completion.bash | 20 ++++++++++----------
 1 file 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
-- 
2.31.1.424.g95a8dafae5


  parent reply	other threads:[~2021-04-20  9:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20  9:19 [PATCH 0/5] git-completion.bash: fixes on top of 'dl/complete-stash' Denton Liu
2021-04-20  9:19 ` [PATCH 1/5] git-completion.bash: separate some commands onto their own line Denton Liu
2021-04-20  9:19 ` Denton Liu [this message]
2021-04-20 20:50   ` [PATCH 2/5] git-completion.bash: rename to $__git_cmd_idx Junio C Hamano
2021-04-20 21:14     ` SZEDER Gábor
2021-04-20 22:31       ` Junio C Hamano
2021-04-20  9:19 ` [PATCH 3/5] git-completion.bash: use $__git_cmd_idx in more places Denton Liu
2021-04-20  9:19 ` [PATCH 4/5] git-completion.bash: consolidate cases in _git_stash() Denton Liu
2021-04-20 10:44   ` Ævar Arnfjörð Bjarmason
2021-04-21  4:03     ` Denton Liu
2021-04-20  9:19 ` [PATCH 5/5] git-completion.bash: consolidate no-subcommand case for _git_stash() Denton Liu
2021-04-20 21:10   ` Junio C Hamano
2021-04-21  4:08     ` Denton Liu
2021-04-22 10:00 ` [PATCH v2 0/4] git-completion.bash: fixes on top of 'dl/complete-stash' Denton Liu
2021-04-22 10:00   ` [PATCH v2 1/4] git-completion.bash: separate some commands onto their own line Denton Liu
2021-04-22 10:00   ` [PATCH v2 2/4] git-completion.bash: rename to $__git_cmd_idx Denton Liu
2021-04-22 10:00   ` [PATCH v2 3/4] git-completion.bash: use $__git_cmd_idx in more places Denton Liu
2021-04-22 10:00   ` [PATCH v2 4/4] git-completion.bash: consolidate cases in _git_stash() Denton Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7c7d6de380d1aaa860e86627778bef6c0c78ca08.1618910364.git.liu.denton@gmail.com \
    --to=liu.denton@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.