completion: clear cached --options when sourcing the completion script
[gitweb.git] / contrib / completion / git-completion.bash
index 2e30950299fd74a8f11b0cea86d6d8ffb6ca3226..63e34cd588564d77f49aa5ff0505f25439750915 100644 (file)
@@ -280,6 +280,10 @@ __gitcomp ()
        esac
 }
 
+# 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
+
 # This function is equivalent to
 #
 #    __gitcomp "$(git xxx --git-completion-helper) ..."