So we don't have to do the same over and over. Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx> --- contrib/completion/git-completion.zsh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 82a4d6f470..4e9699f542 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -49,12 +49,16 @@ COMP_WORDBREAKS=':' GIT_SOURCING_ZSH_COMPLETION=y . "$script" functions[complete]="$old_complete" +__gitcompadd () +{ + compadd -p "${2-}" -S "${3- }" -- ${=1} && _ret=0 +} + __gitcomp () { emulate -L zsh - local IFS=$' \t\n' - compadd -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 + IFS=$' \t\n' __gitcompadd "$1" "${2-}" "${4- }" } __gitcomp_opts () @@ -69,7 +73,7 @@ __gitcomp_opts () for c in ${=1}; do if [[ $c == "--" ]]; then [[ "$cur_" == --no-* ]] && continue - compadd -S " " -- "--no-..." && _ret=0 + __gitcompadd "--no-..." break fi @@ -81,7 +85,7 @@ __gitcomp_opts () else sfx="$4" fi - compadd -S "$sfx" -p "${2-}" -- "$c" && _ret=0 + __gitcompadd "$c" "${2-}" "$sfx" done } -- 2.31.0