Navigation Menu

Skip to content

Commit

Permalink
Ensure that _git completion func is replaced only once.
Browse files Browse the repository at this point in the history
This allows the completion script to be sourced more than once while
still behaving correctly. Previously, the script would attempt to
replace `__git_list_all_commands` blindly, which would yield
multiply-replaced calls like
`__git_list_all_commands_without_hub_without_hub`.
  • Loading branch information
voithos committed Oct 17, 2017
1 parent cbcc349 commit e723a63
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions etc/hub.bash_completion.sh
Expand Up @@ -6,8 +6,8 @@ if ! declare -F _git > /dev/null && declare -F _completion_loader > /dev/null; t
_completion_loader git
fi

# Check that git tab completion is available
if declare -F _git > /dev/null; then
# 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
# 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

0 comments on commit e723a63

Please sign in to comment.