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

[PATCH 05/47] completion: bash: do not modify COMP_WORDBREAKS

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jan 1, 2021, 02:15 UTC
Message-ID
<20210101021622.798041-6-felipe.contreras@gmail.com>
In-Reply-To
<20210101021622.798041-1-felipe.contreras@gmail.com>

There was no need for this once __git_reassemble_comp_words_by_ref() was introduced. Now irrespective of the value of COMP_WORDBREAKS, words are always joined together.

By default COMP_WORDBREAKS does contain a colon, and if it doesn't somebody probably has a reason for it.

Completions are not supposed to modify COMP_WORDBREAKS and none of the completions in the bash-completion project do.

We manually set it in Zsh so the Bash script is not confused.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 5 -----
 contrib/completion/git-completion.zsh  | 1 +
 2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 926e9ceb56..9ea31f7d4d 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -45,11 +45,6 @@
 #     When set to "1" suggest all options, including options which are
 #     typically hidden (e.g. '--allow-empty' for 'git commit').
 
-case "$COMP_WORDBREAKS" in
-*:*) : great ;;
-*)   COMP_WORDBREAKS="$COMP_WORDBREAKS:"
-esac
-
 # Discovers the path to the git repository taking any '--git-dir=<path>' and
 # '-C <path>' options into account and stores it in the $__git_repo_path
 # variable.
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 69f90913db..e2ea14fb33 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -45,6 +45,7 @@ fi
 
 local old_complete="$functions[complete]"
 functions[complete]=:
+COMP_WORDBREAKS=':'
 GIT_SOURCING_ZSH_COMPLETION=y . "$script"
 functions[complete]="$old_complete"
 
-- 
2.30.0
Previous: Felipe ContrerasNext: Felipe Contreras
Message 3 of 48 in “completion: git-completion 1.3 patches”
  1. 00/47 completion: git-completion 1.3 patchesFelipe Contreras, Jan 1, 2021
  2. 06/47 test: completion: fix currently typed wordsFelipe Contreras, Jan 1, 2021
  3. 05/47 completion: bash: do not modify COMP_WORDBREAKSFelipe Contreras, Jan 1, 2021
  4. 15/47 completion: zsh: fix for undefined completionsFelipe Contreras, Jan 1, 2021
  5. 02/47 completion: fix for suboptions with valueFelipe Contreras, Jan 1, 2021
  6. 13/47 completion: zsh: expand --git-dir file argumentFelipe Contreras, Jan 1, 2021
  7. 01/47 completion: bash: fix prefix detection in branch.*Felipe Contreras, Jan 1, 2021
  8. 04/47 completion: bash: add correct suffix in variablesFelipe Contreras, Jan 1, 2021
  9. 03/47 completion: bash: fix for multiple dash commandsFelipe Contreras, Jan 1, 2021
  10. 07/47 test: completion: switch __gitcomp_nl prefix testFelipe Contreras, Jan 1, 2021
  11. 10/47 completion: bash: get rid of _append() functionsFelipe Contreras, Jan 1, 2021
  12. 08/47 test: completion: add run_func() helperFelipe Contreras, Jan 1, 2021
  13. 17/47 completion: zsh: fix extra space on foo=Felipe Contreras, Jan 1, 2021
  14. 23/47 completion: simplify __gitcompFelipe Contreras, Jan 1, 2021
  15. 21/47 completion: simplify equal suffix checkFelipe Contreras, Jan 1, 2021
  16. 19/47 completion: zsh: always set compsetFelipe Contreras, Jan 1, 2021
  17. 27/47 test: completion: add missing testFelipe Contreras, Jan 1, 2021
  18. 11/47 completion: bash: get rid of any non-append codeFelipe Contreras, Jan 1, 2021
  19. 25/47 completion: improve __gitcomp suffix codeFelipe Contreras, Jan 1, 2021
  20. 28/47 completion: bash: improve __gitcomp descriptionFelipe Contreras, Jan 1, 2021
  21. 12/47 completion: zsh: fix options with argumentsFelipe Contreras, Jan 1, 2021
  22. 14/47 completion: zsh: add support for general -C optsFelipe Contreras, Jan 1, 2021
  23. 16/47 completion: zsh: add support for general -c optsFelipe Contreras, Jan 1, 2021
  24. 29/47 completion: add __gitcomp_optsFelipe Contreras, Jan 1, 2021
  25. 30/47 completion: bash: cleanup __gitcomp* invocationsFelipe Contreras, Jan 1, 2021
  26. 09/47 completion: bash: remove non-append functionalityFelipe Contreras, Jan 1, 2021
  27. 33/47 completion: zsh: shuffle __gitcomp* functionsFelipe Contreras, Jan 1, 2021
  28. 35/47 completion: zsh: add elements individually in __gitcomp_optsFelipe Contreras, Jan 1, 2021
  29. 36/47 completion: zsh: add __gitcompadd helperFelipe Contreras, Jan 1, 2021
  30. 31/47 completion: bash: shuffle __gitcomp functionsFelipe Contreras, Jan 1, 2021
  31. 38/47 completion: bash: simplify _get_comp_words_by_ref()Felipe Contreras, Jan 1, 2021
  32. 37/47 completion: zsh: add correct removable suffixFelipe Contreras, Jan 1, 2021
  33. 39/47 completion: bash: refactor _get_comp_words_by_ref()Felipe Contreras, Jan 1, 2021
  34. 32/47 completion: zsh: simplify __gitcomp_directFelipe Contreras, Jan 1, 2021
  35. 40/47 completion: bash: cleanup _get_comp_words_by_ref()Felipe Contreras, Jan 1, 2021
  36. 18/47 completion: zsh: add excluded optionsFelipe Contreras, Jan 1, 2021
  37. 20/47 completion: factor out check in __gitcompFelipe Contreras, Jan 1, 2021
  38. 22/47 completion: refactor __gitcompFelipe Contreras, Jan 1, 2021
  39. 24/47 completion: bash: change suffix check in __gitcompFelipe Contreras, Jan 1, 2021
  40. 44/47 completion: bash: improve function detectionFelipe Contreras, Jan 1, 2021
  41. 26/47 completion: bash: simplify config_variable_nameFelipe Contreras, Jan 1, 2021
  42. 45/47 test: completion: add tests for __git_completeFelipe Contreras, Jan 1, 2021
  43. 47/47 completion: zsh: add higher-priority locationFelipe Contreras, Jan 1, 2021
  44. 42/47 completion: bash: rename _get_comp_words_by_ref()Felipe Contreras, Jan 1, 2021
  45. 34/47 completion: zsh: fix direct quotingFelipe Contreras, Jan 1, 2021
  46. 41/47 completion: bash: trivial cleanupFelipe Contreras, Jan 1, 2021
  47. 43/47 completion: bash: add __git_have_func helperFelipe Contreras, Jan 1, 2021
  48. 46/47 completion: add proper public __git_completeFelipe Contreras, Jan 1, 2021

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.