Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash completion: add support for git 2.30 and on #3342

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions etc/hub.bash_completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# This script complements the completion script that ships with git.

# If there is no git tab completion, but we have the _completion loader try to load it
if ! declare -F _git > /dev/null && declare -F _completion_loader > /dev/null; then
if ! declare -F __git_complete > /dev/null && declare -F _completion_loader > /dev/null; then
_completion_loader git
fi

# Check that git tab completion is available and we haven't already set up completion
if declare -F _git > /dev/null && ! declare -F __git_list_all_commands_without_hub > /dev/null; then
if declare -F __git_complete > /dev/null && ! declare -F __git_list_all_commands_without_hub > /dev/null; then
# Duplicate and rename the 'list_all_commands' function
eval "$(declare -f __git_list_all_commands | \
sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')"
Expand Down Expand Up @@ -382,6 +382,15 @@ EOF
}

# Enable completion for hub even when not using the alias
complete -o bashdefault -o default -o nospace -F _git hub 2>/dev/null \
|| complete -o default -o nospace -F _git hub
if declare -F _git >/dev/null; then
# git < 2.30
complete -o bashdefault -o default -o nospace -F _git hub 2>/dev/null \
|| complete -o default -o nospace -F _git hub
elif declare -F __git_main >/dev/null; then
# in git 2.30 both __git_complete and __git_main are private
__git_complete hub __git_main
else
# git > 2.31 if __git_main is removed
__git_complete hub git
fi
fi
Loading