Skip to content

Commit 7f94b78

Browse files
felipecgitster
authored andcommitted
completion: bash: add __git_have_func helper
This makes the code more readable, and also will help when new code wants to do similar checks. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71ca53e commit 7f94b78

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

contrib/completion/git-completion.bash

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3358,15 +3358,19 @@ __git_support_parseopt_helper () {
33583358
esac
33593359
}
33603360

3361+
__git_have_func () {
3362+
declare -f $1 >/dev/null 2>/dev/null
3363+
}
3364+
33613365
__git_complete_command () {
33623366
local command="$1"
33633367
local completion_func="_git_${command//-/_}"
3364-
if ! declare -f $completion_func >/dev/null 2>/dev/null &&
3365-
declare -f _completion_loader >/dev/null 2>/dev/null
3368+
if ! __git_have_func $completion_func &&
3369+
__git_have_func _completion_loader
33663370
then
33673371
_completion_loader "git-$command"
33683372
fi
3369-
if declare -f $completion_func >/dev/null 2>/dev/null
3373+
if __git_have_func $completion_func
33703374
then
33713375
$completion_func
33723376
return 0

0 commit comments

Comments
 (0)