From: Junio C Hamano <gitster@pobox.com>
To: Denton Liu <liu.denton@gmail.com>
Cc: "Git Mailing List" <git@vger.kernel.org>,
"SZEDER Gábor" <szeder.dev@gmail.com>
Subject: Re: [PATCH 2/5] git-completion.bash: rename to $__git_cmd_idx
Date: Tue, 20 Apr 2021 13:50:19 -0700 [thread overview]
Message-ID: <xmqqr1j44r5g.fsf@gitster.g> (raw)
In-Reply-To: <7c7d6de380d1aaa860e86627778bef6c0c78ca08.1618910364.git.liu.denton@gmail.com> (Denton Liu's message of "Tue, 20 Apr 2021 02:19:48 -0700")
Denton Liu <liu.denton@gmail.com> writes:
> 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.
comand -> command
> "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.
As the patch has already written, I won't complain too much, but to
many people "git" is a command and "add", "commit" etc. are
subcommands of "git", so I do not see git_subcommand_idx so wrong
that it needs to be renamed. I do understand that it is a bit too
long and it may be easier to type if renamed to say git_cmd_idx,
though ;-)
> 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
next prev parent reply other threads:[~2021-04-20 20:50 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 ` [PATCH 2/5] git-completion.bash: rename to $__git_cmd_idx Denton Liu
2021-04-20 20:50 ` Junio C Hamano [this message]
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=xmqqr1j44r5g.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=liu.denton@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).