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

Handle undefined __git_complete #1055

Merged
merged 3 commits into from
Dec 13, 2020
Merged
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
23 changes: 22 additions & 1 deletion contrib/tig-completion.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# bash/zsh completion for tig
#
#
# Copyright (C) 2019 Roland Hieber, Pengutronix
# Copyright (C) 2007-2010 Jonas fonseca
#
Expand Down Expand Up @@ -29,6 +29,27 @@
# at source time then all lookups will be done on demand,
# which may be slightly slower.

#tig-completion requires __git_complete
#* If not defined, source git completions script so __git_complete is available
if ! declare -f __git_complete &>/dev/null; then
_bash_completion=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null) ||
_bash_completion='/usr/share/bash-completion/completions/'
_locations=(
"$(dirname "${BASH_SOURCE[0]%:*}")"/git-completion.bash #in same dir as this
"$HOME/.local/share/bash-completion/completions/git"
"$_bash_completion/git"
'/etc/bash_completion.d/git' # old debian
)
for _e in "${_locations[@]}"; do
# shellcheck disable=1090
test -f "$_e" && . "$_e" && break
done
unset _bash_completion _locations _e
if ! declare -f __git_complete &>/dev/null; then
return #silently return without completions
fi
fi

__tig_options="
-v --version
-h --help
Expand Down