]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'sg/completion-clear-cached'
authorJunio C Hamano <gitster@pobox.com>
Tue, 8 May 2018 06:59:25 +0000 (15:59 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 May 2018 06:59:25 +0000 (15:59 +0900)
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

contrib/completion/git-completion.bash

index 86a13fca28ef7e0db5c45a5a20f78133a1f339ca..159e6407dfbc2e50fbd08cdb72a63ab3b33a1f40 100644 (file)
@@ -284,7 +284,11 @@ __gitcomp ()
 
 # Clear the variables caching builtins' options when (re-)sourcing
 # the completion script.
-unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null
+if [[ -n ${ZSH_VERSION-} ]]; then
+       unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null
+else
+       unset $(compgen -v __gitcomp_builtin_)
+fi
 
 # This function is equivalent to
 #