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

[PATCH v4] completion: ignore chpwd_functions when cding on zsh

From
Brandon Turner <bt@brandonturner.net>
Date
Oct 9, 2014, 19:01 UTC
Message-ID
<1412881298-64117-1-git-send-email-bt@brandonturner.net>
In-Reply-To
<xmqqlhop6rmj.fsf@gitster.dls.corp.google.com>

Software, such as RVM (ruby version manager), may set chpwd functions that result in an endless loop when cding. chpwd functions should be ignored.

As I've only seen this so far on ZSH, I'm applying this change only to the git-completion.zsh overrides.

Signed-off-by: Brandon Turner <bt@brandonturner.net>
---
As Øystein pointed out, on zsh we can use "cd -q" to ignore
chpwd_functions.
Junio - from my testing, unsetting CDPATH is sufficient on zsh.
 contrib/completion/git-completion.zsh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 9f6f0fa..04ed348 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -93,6 +93,20 @@ __gitcomp_file ()
 	compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
 }
 
+__git_ls_files_helper ()
+{
+	(
+		test -n "${CDPATH+set}" && unset CDPATH
+		cd -q "$1"
+		if [ "$2" == "--committable" ]; then
+			git diff-index --name-only --relative HEAD
+		else
+			# NOTE: $2 is not quoted in order to support multiple options
+			git ls-files --exclude-standard $2
+		fi
+	) 2>/dev/null
+}
+
 __git_zsh_bash_func ()
 {
 	emulate -L ksh
-- 
2.1.2
Previous: Junio C HamanoNext: Øystein Walle
Message 7 of 16 in “completion: ignore chpwd_functions when cding”
  1. completion: ignore chpwd_functions when cdingBrandon Turner, Oct 8, 2014
  2. Junio C HamanoOct 8, 2014
  3. completion: ignore chpwd_functions when cdingBrandon Turner, Oct 8, 2014
  4. completion: ignore chpwd_functions when cding on zshBrandon Turner, Oct 8, 2014
  5. Øystein WalleOct 9, 2014
  6. Junio C HamanoOct 9, 2014
  7. completion: ignore chpwd_functions when cding on zshBrandon Turner, Oct 9, 2014
  8. Øystein WalleOct 9, 2014
  9. Junio C HamanoOct 9, 2014
  10. Junio C HamanoOct 9, 2014
  11. Brandon TurnerOct 9, 2014
  12. Junio C HamanoOct 9, 2014
  13. Brandon TurnerOct 9, 2014
  14. Øystein WalleOct 16, 2014
  15. Øystein WalleOct 9, 2014
  16. Brandon TurnerOct 8, 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.