[PATCHv2 13/21] completion: don't offer commands when 'git --opt' needs an argument
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Feb 3, 2017, 02:48 UTC
- Message-ID
- <20170203024829.8071-14-szeder.dev@gmail.com>
- In-Reply-To
- <20170203024829.8071-1-szeder.dev@gmail.com>
The main git options '--git-dir', '-c', '-C', '--worktree' and '--namespace' require an argument, but attempting completion right after them lists git commands.
Don't offer anything right after these options, thus let Bash fall back to filename completion, because
- the three options '--git-dir', '-C' and '--worktree' do actually
require a path argument, and - we don't complete the required argument of '-c' and '--namespace',
and in that case the "standard" behavior of our completion script
is to not offer anything, but fall back to filename completion.Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> --- contrib/completion/git-completion.bash | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 4ded44977..7d25b33b8 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2808,6 +2808,17 @@ __git_main () done if [ -z "$command" ]; then + case "$prev" in + --git-dir|-C|--work-tree) + # these need a path argument, let's fall back to + # Bash filename completion + return + ;; + -c|--namespace) + # we don't support completing these options' arguments + return + ;; + esac case "$cur" in --*) __gitcomp " --paginate
-- 2.11.0.555.g967c1bcb3