|
6 | 6 | _command_exists git || return
|
7 | 7 |
|
8 | 8 | # Don't handle completion if it's already managed
|
9 |
| -if complete -p git &>/dev/null; then |
10 |
| - _log_warning "completion already loaded - this usually means it is safe to stop using this completion" |
11 |
| - return 0 |
| 9 | +if complete -p git &> /dev/null; then |
| 10 | + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" |
| 11 | + return 0 |
12 | 12 | fi
|
13 | 13 |
|
14 | 14 | _git_bash_completion_xcrun_git=
|
15 | 15 | if _command_exists xcrun; then
|
16 | 16 | _git_bash_completion_xcrun_git="$(xcrun --find git)"
|
17 | 17 | fi
|
18 | 18 | _git_bash_completion_paths=(
|
19 |
| - # Standard locations |
20 |
| - "${GIT_EXE%/*}/../share/git-core/git-completion.bash" |
21 |
| - "${GIT_EXE%/*}/../share/git-core/contrib/completion/git-completion.bash" |
22 |
| - "${GIT_EXE%/*}/../etc/bash_completion.d/git-completion.bash" |
23 |
| - # MacOS non-system locations |
24 |
| - "${_git_bash_completion_xcrun_git%/bin/git}/share/git-core/git-completion.bash" |
| 19 | + # Standard locations |
| 20 | + "${GIT_EXE%/*}/../share/git-core/git-completion.bash" |
| 21 | + "${GIT_EXE%/*}/../share/git-core/contrib/completion/git-completion.bash" |
| 22 | + "${GIT_EXE%/*}/../etc/bash_completion.d/git-completion.bash" |
| 23 | + # MacOS non-system locations |
| 24 | + "${_git_bash_completion_xcrun_git%/bin/git}/share/git-core/git-completion.bash" |
25 | 25 | )
|
26 | 26 |
|
27 | 27 | # Load the first completion file found
|
28 | 28 | _git_bash_completion_found=false
|
29 |
| -for _comp_path in "${_git_bash_completion_paths[@]}" ; do |
30 |
| - if [[ -r "$_comp_path" ]] ; then |
31 |
| - _git_bash_completion_found=true |
32 |
| - source "$_comp_path" |
33 |
| - break |
34 |
| - fi |
| 29 | +for _comp_path in "${_git_bash_completion_paths[@]}"; do |
| 30 | + if [[ -r "$_comp_path" ]]; then |
| 31 | + _git_bash_completion_found=true |
| 32 | + # shellcheck disable=SC1090 # don't follow |
| 33 | + source "$_comp_path" |
| 34 | + break |
| 35 | + fi |
35 | 36 | done
|
36 | 37 |
|
37 | 38 | # Cleanup
|
38 | 39 | if [[ "${_git_bash_completion_found}" == false ]]; then
|
39 |
| - _log_warning "no completion files found - please try enabling the 'system' completion instead." |
| 40 | + _log_warning "no completion files found - please try enabling the 'system' completion instead." |
40 | 41 | fi
|
41 | 42 | unset "${!_git_bash_completion@}"
|
0 commit comments