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

[PATCH 1/3] completion: be nicer with zsh

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jan 29, 2012, 23:41 UTC
Message-ID
<1327880479-25275-2-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1327880479-25275-1-git-send-email-felipe.contreras@gmail.com>

And yet another bug in zsh[1] causes a mismatch; zsh seems to have problem emulating wordspliting, but only when the ':' command is involved.

Let's avoid it. This has the advantage that the code is now actually understandable (at least to me), while before it looked like voodoo.

I found this issue because __git_compute_porcelain_commands listed all commands (not only porcelain).

[1] http://article.gmane.org/gmane.comp.shells.zsh.devel/24296
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 1496c6d..7051c7a 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -676,7 +676,8 @@ __git_merge_strategies=
 # is needed.
 __git_compute_merge_strategies ()
 {
-	: ${__git_merge_strategies:=$(__git_list_merge_strategies)}
+	test "$__git_merge_strategies" && return
+	__git_merge_strategies=$(__git_list_merge_strategies 2> /dev/null)
 }
 
 __git_complete_revlist_file ()
@@ -854,7 +855,8 @@ __git_list_all_commands ()
 __git_all_commands=
 __git_compute_all_commands ()
 {
-	: ${__git_all_commands:=$(__git_list_all_commands)}
+	test "$__git_all_commands" && return
+	__git_all_commands=$(__git_list_all_commands 2> /dev/null)
 }
 
 __git_list_porcelain_commands ()
@@ -947,7 +949,8 @@ __git_porcelain_commands=
 __git_compute_porcelain_commands ()
 {
 	__git_compute_all_commands
-	: ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
+	test "$__git_porcelain_commands" && return
+	__git_porcelain_commands=$(__git_list_porcelain_commands 2> /dev/null)
 }
 
 __git_pretty_aliases ()
-- 
1.7.8.3
Previous: Felipe ContrerasNext: Junio C Hamano
Message 2 of 28 in “completion: trivial cleanups”
  1. 0/3 completion: trivial cleanupsFelipe Contreras, Jan 29, 2012
  2. 1/3 completion: be nicer with zshFelipe Contreras, Jan 29, 2012
  3. Junio C HamanoJan 30, 2012
  4. Junio C HamanoJan 30, 2012
  5. Felipe ContrerasJan 30, 2012
  6. Felipe ContrerasJan 30, 2012
  7. Junio C HamanoJan 30, 2012
  8. Felipe ContrerasJan 30, 2012
  9. 2/3 completion: remove old codeFelipe Contreras, Jan 29, 2012
  10. Jonathan NiederJan 30, 2012
  11. Felipe ContrerasJan 30, 2012
  12. Jonathan NiederJan 30, 2012
  13. Junio C HamanoJan 30, 2012
  14. Felipe ContrerasJan 30, 2012
  15. Frans KlaverJan 30, 2012
  16. Felipe ContrerasJan 30, 2012
  17. Frans KlaverJan 30, 2012
  18. Felipe ContrerasJan 30, 2012
  19. Jonathan NiederJan 30, 2012
  20. 3/3 completion: remove unused codeFelipe Contreras, Jan 29, 2012
  21. Jonathan NiederJan 30, 2012
  22. Jonathan NiederJan 30, 2012
  23. Felipe ContrerasJan 30, 2012
  24. Thomas RastJan 30, 2012
  25. Junio C HamanoJan 30, 2012
  26. Felipe ContrerasJan 30, 2012
  27. Thomas RastJan 30, 2012
  28. Felipe ContrerasJan 30, 2012

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.