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 1 commit
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
21 changes: 21 additions & 0 deletions contrib/tig-completion.bash
Original file line number Diff line number Diff line change
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) ||
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: the indentation should be consistent with the rest of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I will fix that.

_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