Skip to content

Commit 1dfb929

Browse files
committed
Merge branch 'sg/completion-clear-cached'
The completion script (in contrib/) learned to clear cached list of command line options upon dot-sourcing it again in a more efficient way. * sg/completion-clear-cached: completion: reduce overhead of clearing cached --options
2 parents 90186fa + 94408dc commit 1dfb929

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

contrib/completion/git-completion.bash

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,11 @@ __gitcomp ()
284284

285285
# Clear the variables caching builtins' options when (re-)sourcing
286286
# the completion script.
287-
unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null
287+
if [[ -n ${ZSH_VERSION-} ]]; then
288+
unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null
289+
else
290+
unset $(compgen -v __gitcomp_builtin_)
291+
fi
288292

289293
# This function is equivalent to
290294
#

0 commit comments

Comments
 (0)