From: Matheus Tavares <matheus.bernardino@usp.br>
To: asottile@umich.edu
Cc: git@vger.kernel.org
Subject: Re: git git<tab> completes non-existent command `git gitk`
Date: Sun, 24 May 2020 18:38:08 -0300 [thread overview]
Message-ID: <20200524213808.24849-1-matheus.bernardino@usp.br> (raw)
In-Reply-To: <CA+dzEBnpheB-ZT5+bajKphux-+7gYFx1Msws7mXM=LOJO7pukw@mail.gmail.com>
Hi, Anthony
On Sat, May 23, 2020 at 7:25 PM Anthony Sottile <asottile@umich.edu> wrote:
>
> easiest to reproduce is with docker
>
> ```dockerfile
> FROM ubuntu:focal
> RUN : \
> && apt-get update \
> && DEBIAN_FRONTEND=noninteractive apt-get install -y
> --no-install-recommends \
> bash-completion \
> git \
> && apt-get clean \
> && rm -rf /var/lib/apt/lists/*
> ```
>
> ```console
> $ docker run --rm -ti test bash
> root@23e691ecc7ba:/# [ -f /etc/bash_completion ] && . /etc/bash_completion
> root@23e691ecc7ba:/# git gitk
> ```
>
> (I typed git git<tab>)
>
> ```console
> $ git gitk
> git: 'gitk' is not a git command. See 'git --help'.
> ```
> this is a bit annoying because I have some aliases/commands for git-github-*
>
> the git version I have is 2.25.1:
Thanks for the report. This is also reproducible in Git 2.27.0-rc1. To complete
subcommands, git-completion.bash uses[1] the output of:
git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config
And the list returned by the line above contains "gitk", because this
command is in the "mainporcelain" category (in command-list.txt).
One possible solution to the invalid completion you mentioned, without having
to re-categorize "gitk", is to explicitly exclude it in git-completion.bash:
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index b1d6e5ebed..f07394584f 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -3214,7 +3214,10 @@ __git_main ()
then
__gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
else
- __gitcomp "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
+ local cmds="$(__git --list-cmds=list-mainporcelain,others,nohelpers,list-complete,config | \
+ sed -e '/^gitk$/d')"
+ local aliases="$(__git --list-cmds=alias,config)"
+ __gitcomp "$cmds $aliases"
fi
;;
esac
(I had to split the list into "cmds" and "aliases" so that we could still give
completion for a valid "git gitk" alias, if present.)
This should solve the problem, althought it's admittedly not very elegant...
Nevertheless, I'd be happy to send a complete patch if folks are happy with the
workaround.
In the meantime, you could use:
git config completion.commands -gitk
To locally remove the completion for "gitk".
Thanks,
Matheus
[1]: See contrib/completion/git-completion.bash +3218
(https://github.com/git/git/blob/master/contrib/completion/git-completion.bash#L3218)
next prev parent reply other threads:[~2020-05-24 21:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-23 22:25 git git<tab> completes non-existent command `git gitk` Anthony Sottile
2020-05-24 21:38 ` Matheus Tavares [this message]
2020-05-25 0:27 ` Junio C Hamano
2020-05-25 1:53 ` Matheus Tavares Bernardino
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200524213808.24849-1-matheus.bernardino@usp.br \
--to=matheus.bernardino@usp.br \
--cc=asottile@umich.edu \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).