Skip to content

Commit 10ce020

Browse files
committed
Merge branch 'sp/maint-bash-completion-optim'
* sp/maint-bash-completion-optim: bash completion: Don't offer "a.." as a completion for "a." bash completion: Improve responsiveness of git-log completion
2 parents 7498205 + 6c36c9e commit 10ce020

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

contrib/completion/git-completion.bash

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,31 +114,35 @@ __git_ps1 ()
114114
fi
115115
}
116116

117+
__gitcomp_1 ()
118+
{
119+
local c IFS=' '$'\t'$'\n'
120+
for c in $1; do
121+
case "$c$2" in
122+
--*=*) printf %s$'\n' "$c$2" ;;
123+
*.) printf %s$'\n' "$c$2" ;;
124+
*) printf %s$'\n' "$c$2 " ;;
125+
esac
126+
done
127+
}
128+
117129
__gitcomp ()
118130
{
119-
local all c s=$'\n' IFS=' '$'\t'$'\n'
120131
local cur="${COMP_WORDS[COMP_CWORD]}"
121132
if [ $# -gt 2 ]; then
122133
cur="$3"
123134
fi
124135
case "$cur" in
125136
--*=)
126137
COMPREPLY=()
127-
return
128138
;;
129139
*)
130-
for c in $1; do
131-
case "$c$4" in
132-
--*=*) all="$all$c$4$s" ;;
133-
*.) all="$all$c$4$s" ;;
134-
*) all="$all$c$4 $s" ;;
135-
esac
136-
done
140+
local IFS=$'\n'
141+
COMPREPLY=($(compgen -P "$2" \
142+
-W "$(__gitcomp_1 "$1" "$4")" \
143+
-- "$cur"))
137144
;;
138145
esac
139-
IFS=$s
140-
COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
141-
return
142146
}
143147

144148
__git_heads ()
@@ -320,9 +324,6 @@ __git_complete_revlist ()
320324
cur="${cur#*..}"
321325
__gitcomp "$(__git_refs)" "$pfx" "$cur"
322326
;;
323-
*.)
324-
__gitcomp "$cur."
325-
;;
326327
*)
327328
__gitcomp "$(__git_refs)"
328329
;;

0 commit comments

Comments
 (0)