git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-completion.zsh: do not clobber complete()

From
MLMark Lodato <lodato@google.com>
Date
Feb 14, 2014, 21:24 UTC
Message-ID
<1392413040-28436-1-git-send-email-lodato@google.com>

Previously, git-completion.zsh redefined complete() to make __git_complete() a no-op. This broke zsh's built-in bash completion compatibility layer (bashcompinit), which defines its own complete().

Sadly, since there is no way in zsh to restore the original defintion of complete() after bash-completion.bash is sourced, we must pass in a flag to git-completion.bash to change its behavior.

Signed-off-by: Mark Lodato <lodato@google.com>
---
 contrib/completion/git-completion.bash | 1 +
 contrib/completion/git-completion.zsh  | 8 +-------
 2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 9525343..36aa8bb 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2650,6 +2650,7 @@ __git_func_wrap ()
 # This is NOT a public function; use at your own risk.
 __git_complete ()
 {
+	[[ -n $GIT_DO_NOT_CALL_COMPLETE ]] && return
 	local wrapper="__git_wrap${2}"
 	eval "$wrapper () { __git_func_wrap $2 ; }"
 	complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 6b77968..9f68d63 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -16,12 +16,6 @@
 #
 #  fpath=(~/.zsh $fpath)
 
-complete ()
-{
-	# do nothing
-	return 0
-}
-
 zstyle -T ':completion:*:*:git:*' tag-order && \
 	zstyle ':completion:*:*:git:*' tag-order 'common-commands'
 
@@ -39,7 +33,7 @@ if [ -z "$script" ]; then
 		test -f $e && script="$e" && break
 	done
 fi
-ZSH_VERSION='' . "$script"
+GIT_DO_NOT_CALL_COMPLETE=1 ZSH_VERSION='' . "$script"
 
 __gitcomp ()
 {
-- 
1.9.0.rc1.175.g0b1dcb5
Next: Felipe Contreras
Message 1 of 3 in “git-completion.zsh: do not clobber complete()”
  1. git-completion.zsh: do not clobber complete()Mark Lodato, Feb 14, 2014
  2. Felipe ContrerasApr 30, 2014
  3. Felipe ContrerasApr 30, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.