All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 00/49] completion: git-completion 2.0 patches
@ 2023-04-01  8:45 Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 01/49] test: completion add test for __git_cmd_idx Felipe Contreras
                   ` (48 more replies)
  0 siblings, 49 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

This patch series revamps the completion code to git-completion 2.0.

It's meant to be applied on top of the zsh completion test series [1].

The zsh code delta between upstream and git-completion 2.0 results in 12
out of 13 failing tests now passing. This patch series now makes that
clear.

Additionally, it adds and fixes one bash completion test pending since
2020 [2].

This patch series started being relatively small (10 patches) [3], but
upstream has never merged them, so it's now 51 patches.

One patch has been merged to master, so that's progress I guess.

Here's a summary of the differences between upstream and git-completion:

# For zsh
 * Fix alias regression
 * Fix main option handling
 * Fix generic completions
 * Fix option relationships
 * Add improved removable suffix
 * Fix suboptions
 * Fix -C handling
 * Fix -c handling
 * Fix configurations with value (e1e00089da)

# Other
 * Fix `COMP_WORDBREAKS` handling
 * Plenty of reorganizations and cleanups

For more information check git-completion's project page [4].

Changes since v6:

 * Run the zsh completion test script directly in zsh
 * Simplify the zsh zpty code for testing
 * Rebase on top of Git 2.40

Past versions:

 * 1.4: https://lore.kernel.org/git/20220830093138.1581538-1-felipe.contreras@gmail.com/
 * 1.3.3: https://lore.kernel.org/git/20210618182518.697912-1-felipe.contreras@gmail.com/
 * 1.3.1: https://lore.kernel.org/git/20210426161458.49860-1-felipe.contreras@gmail.com/
 * 1.3: https://lore.kernel.org/git/20210101021622.798041-1-felipe.contreras@gmail.com/
 * v2: https://lore.kernel.org/git/20201110212136.870769-1-felipe.contreras@gmail.com/
 * v1: https://lore.kernel.org/git/20201104174716.783348-1-felipe.contreras@gmail.com/

Cheers.

[1] https://lore.kernel.org/git/20230401015632.103581-1-felipe.contreras@gmail.com/
[2] https://lore.kernel.org/git/20201223141950.GA23264@szeder.dev/
[3] https://lore.kernel.org/git/20201104174716.783348-1-felipe.contreras@gmail.com/
[4] https://github.com/felipec/git-completion

Felipe Contreras (48):
  test: completion add test for __git_cmd_idx
  completion: bash: trivial cleanup
  zsh: remove version
  completion: bash: trivial grammar fix
  completion: zsh: add higher-priority location
  zsh: simplify realpath dirname idiom
  test: completion: use global config
  completion: fix __git_cmd_idx regression for zsh
  completion: fix for suboptions with value
  completion: zsh: trivial improvement
  completion: bash: do not modify COMP_WORDBREAKS
  test: completion: fix currently typed words
  test: completion: switch __gitcomp_nl prefix test
  test: completion: add run_func() helper
  completion: bash: remove non-append functionality
  completion: bash: get rid of _append() functions
  completion: bash: get rid of any non-append code
  completion: zsh: fix options with arguments
  completion: zsh: expand --git-dir file argument
  completion: zsh: add support for general -C opts
  completion: zsh: fix for undefined completions
  completion: zsh: add support for general -c opts
  completion: zsh: fix extra space on foo=
  completion: zsh: add excluded options
  completion: zsh: always set compset
  completion: factor out check in __gitcomp
  completion: simplify equal suffix check
  completion: refactor __gitcomp
  completion: simplify __gitcomp
  completion: bash: change suffix check in __gitcomp
  completion: improve __gitcomp suffix code
  test: completion: add missing test
  completion: bash: simplify config_variable_name
  completion: bash: improve __gitcomp description
  completion: add __gitcomp_opts
  completion: bash: cleanup __gitcomp* invocations
  completion: bash: shuffle __gitcomp functions
  completion: zsh: simplify __gitcomp_direct
  completion: zsh: shuffle __gitcomp* functions
  completion: zsh: fix direct quoting
  completion: zsh: add elements individually in __gitcomp_opts
  completion: zsh: add __gitcompadd helper
  completion: zsh: add correct removable suffix
  completion: bash: simplify _get_comp_words_by_ref()
  completion: bash: refactor _get_comp_words_by_ref()
  completion: bash: cleanup _get_comp_words_by_ref()
  completion: bash: trivial cleanup
  completion: bash: rename _get_comp_words_by_ref()

Michael Bianco (1):
  zsh: resolve symlink of script

 contrib/completion/git-completion.bash | 637 +++++++++++--------------
 contrib/completion/git-completion.zsh  | 146 +++---
 t/t9902-completion.sh                  | 167 ++++---
 t/t9904-completion-zsh.sh              |  97 ++--
 4 files changed, 489 insertions(+), 558 deletions(-)

Range-diff against v6:
 1:  e3c5a79c51 =  1:  6d191be41c test: completion add test for __git_cmd_idx
 2:  674c223b68 <  -:  ---------- test: add zsh completion tests
 4:  8a6ec4348b =  2:  a59bf95ff5 completion: bash: trivial cleanup
50:  3dd08cbdf7 =  3:  c5c105bfff zsh: remove version
51:  88beef78a7 =  4:  0217b5641c completion: bash: trivial grammar fix
 5:  c6e3e9c8b4 =  5:  b1548d96a2 completion: zsh: add higher-priority location
 6:  7f34835f6e =  6:  7f2149738a zsh: resolve symlink of script
 7:  b2c9c92c5e =  7:  8af77967ed zsh: simplify realpath dirname idiom
 -:  ---------- >  8:  aeb19ab24c test: completion: use global config
 3:  28fd5901d7 !  9:  152eca2b34 completion: fix __git_cmd_idx regression for zsh
    @@ contrib/completion/git-completion.zsh: __git_zsh_main ()
      	cur=${words[CURRENT]}
      	prev=${words[CURRENT-1]}
     
    - ## t/t9904-zsh-completion.sh ##
    -@@ t/t9904-zsh-completion.sh: test_expect_failure 'options with value' '
    + ## t/t9904-completion-zsh.sh ##
    +@@ t/t9904-completion-zsh.sh: test_expect_failure 'options with value' '
      	EOF
      '
      
 8:  5496fc8ad2 <  -:  ---------- test: reset environment variables
 9:  a70c96e720 <  -:  ---------- completion: prompt: use generic colors
10:  3d949c4ef4 ! 10:  efe2d76308 completion: fix for suboptions with value
    @@ contrib/completion/git-completion.zsh: __gitcomp ()
      	--no-*)
      		local c IFS=$' \t\n'
     
    - ## t/t9904-zsh-completion.sh ##
    -@@ t/t9904-zsh-completion.sh: test_expect_success '__gitcomp - expand/narrow all negative options' '
    + ## t/t9904-completion-zsh.sh ##
    +@@ t/t9904-completion-zsh.sh: test_expect_success '__gitcomp - expand/narrow all negative options' '
      	EOF
      '
      
    @@ t/t9904-zsh-completion.sh: test_expect_success '__gitcomp - expand/narrow all ne
      	test_gitcomp "--option=" "--option=" <<-\EOF &&
      
      	EOF
    -@@ t/t9904-zsh-completion.sh: test_expect_success 'git clone --config= - value' '
    +@@ t/t9904-completion-zsh.sh: test_expect_success 'git clone --config= - value' '
      	EOF
      '
      
11:  39a5e432e8 = 11:  66abcf711f completion: zsh: trivial improvement
12:  d757c1e649 ! 12:  559f5daf27 completion: bash: do not modify COMP_WORDBREAKS
    @@ Commit message
     
      ## contrib/completion/git-completion.bash ##
     @@
    - #     When set to "1" suggest all options, including options which are
    - #     typically hidden (e.g. '--allow-empty' for 'git commit').
    + #     case insensitively, even on systems with case sensitive file systems
    + #     (e.g., completing tag name "FOO" on "git checkout f<TAB>").
      
     -case "$COMP_WORDBREAKS" in
     -*:*) : great ;;
13:  06f0430106 ! 13:  dbb1a7410e test: completion: fix currently typed words
    @@ t/t9902-completion.sh: test_expect_success '__gitcomp - prefix' '
      	branch.master.Z
      	branch.maint.Z
     
    - ## t/t9904-zsh-completion.sh ##
    -@@ t/t9904-zsh-completion.sh: test_expect_success '__gitcomp - option parameter' '
    + ## t/t9904-completion-zsh.sh ##
    +@@ t/t9904-completion-zsh.sh: test_expect_success '__gitcomp - option parameter' '
      '
      
      test_expect_failure '__gitcomp - prefix' '
    @@ t/t9904-zsh-completion.sh: test_expect_success '__gitcomp - option parameter' '
      		"branch.maint." "me" <<-\EOF
      	branch.maint.merge Z
      	branch.maint.mergeoptions Z
    -@@ t/t9904-zsh-completion.sh: test_expect_failure '__gitcomp - prefix' '
    +@@ t/t9904-completion-zsh.sh: test_expect_failure '__gitcomp - prefix' '
      '
      
      test_expect_failure '__gitcomp - suffix' '
14:  a6f4da3602 ! 14:  2f2c240ac1 test: completion: switch __gitcomp_nl prefix test
    @@ t/t9902-completion.sh: test_expect_success '__gitcomp_nl - trailing space' '
      '
      
     
    - ## t/t9904-zsh-completion.sh ##
    -@@ t/t9904-zsh-completion.sh: test_expect_success '__gitcomp_nl - trailing space' '
    + ## t/t9904-completion-zsh.sh ##
    +@@ t/t9904-completion-zsh.sh: test_expect_success '__gitcomp_nl - trailing space' '
      	EOF
      '
      
15:  4e11ca5f72 = 15:  c21c389bb7 test: completion: add run_func() helper
16:  6baf13d85f = 16:  ea93b6cdec completion: bash: remove non-append functionality
17:  2a8298ba7d = 17:  567046e66b completion: bash: get rid of _append() functions
18:  2b6225049f = 18:  1500142923 completion: bash: get rid of any non-append code
19:  dd5e794315 = 19:  655fac83e5 completion: zsh: fix options with arguments
20:  b88875e756 = 20:  9a7591b665 completion: zsh: expand --git-dir file argument
21:  045f42c461 ! 21:  58f8143817 completion: zsh: add support for general -C opts
    @@ contrib/completion/git-completion.zsh: __git_zsh_main ()
      
      		words=( git ${words[@]} )
     
    - ## t/t9904-zsh-completion.sh ##
    -@@ t/t9904-zsh-completion.sh: test_expect_success 'checkout completes ref names' '
    + ## t/t9904-completion-zsh.sh ##
    +@@ t/t9904-completion-zsh.sh: test_expect_success 'checkout completes ref names' '
      	EOF
      '
      
22:  2c69a0d2af ! 22:  3b424c7b78 completion: zsh: fix for undefined completions
    @@ contrib/completion/git-completion.zsh: __git_complete_command ()
      		return 1
      	fi
     
    - ## t/t9904-zsh-completion.sh ##
    -@@ t/t9904-zsh-completion.sh: test_expect_success 'completion used <cmd> completion for alias: !f() { : git <c
    + ## t/t9904-completion-zsh.sh ##
    +@@ t/t9904-completion-zsh.sh: test_expect_success 'completion used <cmd> completion for alias: !f() { : git <c
      	EOF
      '
      
23:  40c6608ce6 ! 23:  1c6eddb71e completion: zsh: add support for general -c opts
    @@ contrib/completion/git-completion.zsh: __git_zsh_main ()
      		local command="${words[1]}" __git_dir __git_cmd_idx=1
      
     
    - ## t/t9904-zsh-completion.sh ##
    -@@ t/t9904-zsh-completion.sh: test_expect_success 'git config - value' '
    + ## t/t9904-completion-zsh.sh ##
    +@@ t/t9904-completion-zsh.sh: test_expect_success 'git config - value' '
      	EOF
      '
      
    @@ t/t9904-zsh-completion.sh: test_expect_success 'git config - value' '
      	test_completion "git -c br" <<-\EOF
      	branch.Z
      	browser.Z
    -@@ t/t9904-zsh-completion.sh: test_expect_failure 'git -c - variable name' '
    +@@ t/t9904-completion-zsh.sh: test_expect_failure 'git -c - variable name' '
      	EOF
      '
      
24:  da05523a98 ! 24:  5ab47aa5e2 completion: zsh: fix extra space on foo=
    @@ contrib/completion/git-completion.zsh: __gitcomp ()
      			esac
      			array+=("$c")
     
    - ## t/t9904-zsh-completion.sh ##
    -@@ t/t9904-zsh-completion.sh: test_expect_success 'git -c - section' '
    + ## t/t9904-completion-zsh.sh ##
    +@@ t/t9904-completion-zsh.sh: test_expect_success 'git -c - section' '
      	EOF
      '
      
    @@ t/t9904-zsh-completion.sh: test_expect_success 'git -c - section' '
      	test_completion "git -c log.d" <<-\EOF
      	log.date=Z
      	log.decorate=Z
    -@@ t/t9904-zsh-completion.sh: test_expect_success 'git clone --config= - section' '
    +@@ t/t9904-completion-zsh.sh: test_expect_success 'git clone --config= - section' '
      	EOF
      '
      
25:  92720f3b4e ! 25:  8d25832207 completion: zsh: add excluded options
    @@ contrib/completion/git-completion.zsh: __git_zsh_main ()
      		'--namespace=[set the git namespace]:' \
      		'--no-replace-objects[do not use replacement refs to replace git objects]' \
     
    - ## t/t9904-zsh-completion.sh ##
    -@@ t/t9904-zsh-completion.sh: test_expect_success 'general options' '
    + ## t/t9904-completion-zsh.sh ##
    +@@ t/t9904-completion-zsh.sh: test_expect_success 'general options' '
      	test_completion "git --no-r" "--no-replace-objects"
      '
      
26:  a4b22cfc5e = 26:  1ef670094b completion: zsh: always set compset
27:  4246b2dd11 = 27:  f2a9a5cf50 completion: factor out check in __gitcomp
28:  549bdf25c8 = 28:  a57311923f completion: simplify equal suffix check
29:  f2dde0eafc = 29:  48be9110f4 completion: refactor __gitcomp
30:  98ed73aec8 = 30:  beb47c2caa completion: simplify __gitcomp
31:  8b53745ef8 = 31:  f2e7c92b0b completion: bash: change suffix check in __gitcomp
32:  b3ca49a9ee = 32:  ec1e4d358d completion: improve __gitcomp suffix code
33:  24b974a7d6 ! 33:  3417863c0f test: completion: add missing test
    @@ t/t9902-completion.sh: test_expect_success 'git config - value' '
      	test_completion "git -c br" <<-\EOF
      	branch.Z
     
    - ## t/t9904-zsh-completion.sh ##
    -@@ t/t9904-zsh-completion.sh: test_expect_success 'git config - value' '
    + ## t/t9904-completion-zsh.sh ##
    +@@ t/t9904-completion-zsh.sh: test_expect_success 'git config - value' '
      	EOF
      '
      
34:  d2a5c05e2b = 34:  4066b8e02a completion: bash: simplify config_variable_name
35:  8c0220b07f = 35:  2efe630d2d completion: bash: improve __gitcomp description
36:  6aaa7f3b5a ! 36:  688046c606 completion: add __gitcomp_opts
    @@ t/t9902-completion.sh: test_expect_success '__gitcomp - ignore optional negative
      
      read -r -d "" refs <<-\EOF
     
    - ## t/t9904-zsh-completion.sh ##
    -@@ t/t9904-zsh-completion.sh: test_completion ()
    + ## t/t9904-completion-zsh.sh ##
    +@@ t/t9904-completion-zsh.sh: test_completion ()
      	test_cmp expected out_sorted
      }
      
    @@ t/t9904-zsh-completion.sh: test_completion ()
      	test_cmp expected out
      }
      
    -@@ t/t9904-zsh-completion.sh: test_expect_success 'setup for __git_find_repo_path/__gitdir tests' '
    +@@ t/t9904-completion-zsh.sh: test_expect_success 'setup for __git_find_repo_path/__gitdir tests' '
      	git init -b main otherrepo
      '
      
    @@ t/t9904-zsh-completion.sh: test_expect_success 'setup for __git_find_repo_path/_
      		--reset-author" <<-EOF
      	--reuse-message=Z
      	--reedit-message=Z
    -@@ t/t9904-zsh-completion.sh: test_expect_success '__gitcomp - trailing space - options' '
    +@@ t/t9904-completion-zsh.sh: test_expect_success '__gitcomp - trailing space - options' '
      	EOF
      '
      
    @@ t/t9904-zsh-completion.sh: test_expect_success '__gitcomp - trailing space - opt
      		branch.autosetuprebase browser." <<-\EOF
      	branch.Z
      	branch.autosetupmerge Z
    -@@ t/t9904-zsh-completion.sh: test_expect_success '__gitcomp - trailing space - config keys' '
    +@@ t/t9904-completion-zsh.sh: test_expect_success '__gitcomp - trailing space - config keys' '
      	EOF
      '
      
    @@ t/t9904-zsh-completion.sh: test_expect_success '__gitcomp - trailing space - con
      	--abc Z
      	--def Z
      	--no-one Z
    -@@ t/t9904-zsh-completion.sh: test_expect_success '__gitcomp - ignore optional negative options' '
    +@@ t/t9904-completion-zsh.sh: test_expect_success '__gitcomp - ignore optional negative options' '
      	EOF
      '
      
37:  d512f5ebc2 = 37:  d74e8977cd completion: bash: cleanup __gitcomp* invocations
38:  b38b1f6e29 ! 38:  3d8e5655d0 completion: bash: shuffle __gitcomp functions
    @@ Commit message
     
      ## contrib/completion/git-completion.bash ##
     @@
    - #     When set to "1" suggest all options, including options which are
    - #     typically hidden (e.g. '--allow-empty' for 'git commit').
    + #     case insensitively, even on systems with case sensitive file systems
    + #     (e.g., completing tag name "FOO" on "git checkout f<TAB>").
      
     +# The following functions are meant to modify COMPREPLY, which should not be
     +# modified directly.  The purpose is to localize the modifications so it's
39:  86ca702ada = 39:  4164cb3b6e completion: zsh: simplify __gitcomp_direct
40:  a5c7949d3f = 40:  866fa2ff1b completion: zsh: shuffle __gitcomp* functions
41:  dcdc3b3626 = 41:  1243854e0d completion: zsh: fix direct quoting
42:  1343263c53 ! 42:  a80b970a46 completion: zsh: add elements individually in __gitcomp_opts
    @@ contrib/completion/git-completion.zsh: __gitcomp_opts ()
      
      __gitcomp_nl ()
     
    - ## t/t9904-zsh-completion.sh ##
    -@@ t/t9904-zsh-completion.sh: test_expect_success '__gitcomp_opts - option parameter' '
    + ## t/t9904-completion-zsh.sh ##
    +@@ t/t9904-completion-zsh.sh: test_expect_success '__gitcomp_opts - option parameter' '
      	EOF
      '
      
    @@ t/t9904-zsh-completion.sh: test_expect_success '__gitcomp_opts - option paramete
      	test_gitcomp_opts "branch.maint.me" "remote merge mergeoptions rebase" \
      		"branch.maint." "me" <<-\EOF
      	branch.maint.merge Z
    -@@ t/t9904-zsh-completion.sh: test_expect_failure '__gitcomp_opts - prefix' '
    +@@ t/t9904-completion-zsh.sh: test_expect_failure '__gitcomp_opts - prefix' '
      	EOF
      '
      
43:  5c3621f224 = 43:  66c429c075 completion: zsh: add __gitcompadd helper
44:  7aaaf8f8ed = 44:  22ab31138d completion: zsh: add correct removable suffix
45:  1ac27ad13d = 45:  290b7e753b completion: bash: simplify _get_comp_words_by_ref()
46:  3b32bfe16b = 46:  4d0de6230c completion: bash: refactor _get_comp_words_by_ref()
47:  32b36425ea = 47:  46b5530d25 completion: bash: cleanup _get_comp_words_by_ref()
48:  35cbf711e8 = 48:  039a43b994 completion: bash: trivial cleanup
49:  3a005ae3c4 = 49:  d33a04e5fd completion: bash: rename _get_comp_words_by_ref()
-- 
2.33.0


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH v7 01/49] test: completion add test for __git_cmd_idx
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 02/49] completion: bash: trivial cleanup Felipe Contreras
                   ` (47 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

When __git_func_wrap was fixed to set correctly __git_cmd_idx in
cea232194d (completion: bash: fix late declaration of __git_cmd_idx,
2021-06-18) no test was added, therefore we could hit the same bug in
the future.

To ensure that doesn't happen add a test which adds an alias for 'git
add' with __git_complete, and then pretend the user typed this alias.

To make sure __git_cmd_idx is correct we add the --update option to
ensure the result of __git_find_on_cmdline (which uses __git_cmd_idx) is
correct. When __git_cmd_idx isn't correct __git_find_on_cmdline fails,
and therefore the --update option isn't interpreted correctly.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/t9902-completion.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index d6c0478d98..561f06b46a 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2689,4 +2689,13 @@ test_expect_success '__git_complete' '
 	test_must_fail __git_complete ga missing
 '
 
+test_expect_success '__git_complete has correct __git_cmd_idx' '
+	__git_complete ga _git_add &&
+	echo modified > file1 &&
+	touch file3 &&
+	_words=(ga --update f) _cword=2 &&
+	__git_wrap_git_add &&
+	test "${COMPREPLY[*]}" = "file1"
+'
+
 test_done
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 02/49] completion: bash: trivial cleanup
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 01/49] test: completion add test for __git_cmd_idx Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 03/49] zsh: remove version Felipe Contreras
                   ` (46 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index dc95c34cc8..45eaea57d5 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -3565,8 +3565,7 @@ fi
 
 __git_func_wrap ()
 {
-	local cur words cword prev
-	local __git_cmd_idx=0
+	local cur words cword prev __git_cmd_idx=0
 	_get_comp_words_by_ref -n =: cur words cword prev
 	$1
 }
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 03/49] zsh: remove version
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 01/49] test: completion add test for __git_cmd_idx Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 02/49] completion: bash: trivial cleanup Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 04/49] completion: bash: trivial grammar fix Felipe Contreras
                   ` (45 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Doesn't seem to be useful.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index cac6f61881..c7bc6a8f8e 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -135,11 +135,6 @@ __gitcomp_file_direct ()
 	__gitcomp_file "$1" ""
 }
 
-_git_zsh ()
-{
-	__gitcomp "v1.1"
-}
-
 __git_complete_command ()
 {
 	emulate -L zsh
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 04/49] completion: bash: trivial grammar fix
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (2 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 03/49] zsh: remove version Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 05/49] completion: zsh: add higher-priority location Felipe Contreras
                   ` (44 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 45eaea57d5..cf6ff0595f 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -3330,7 +3330,7 @@ _git_worktree ()
 		# Here we are not completing an --option, it's either the
 		# path or a ref.
 		case "$prev" in
-		-b|-B)	# Complete refs for branch to be created/reseted.
+		-b|-B)	# Complete refs for branch to be created/reset.
 			__git_complete_refs
 			;;
 		-*)	# The previous word is an -o|--option without an
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 05/49] completion: zsh: add higher-priority location
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (3 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 04/49] completion: bash: trivial grammar fix Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 06/49] zsh: resolve symlink of script Felipe Contreras
                   ` (43 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

bash-completion looks in /usr/local/share first, we should too.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index c7bc6a8f8e..5f2c63236d 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -35,6 +35,7 @@ if [ -z "$script" ]; then
 	locations=(
 		"$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
 		"$HOME/.local/share/bash-completion/completions/git"
+		'/usr/local/share/bash-completion/completions/git'
 		"$bash_completion/git"
 		'/etc/bash_completion.d/git' # old debian
 		)
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 06/49] zsh: resolve symlink of script
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (4 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 05/49] completion: zsh: add higher-priority location Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 07/49] zsh: simplify realpath dirname idiom Felipe Contreras
                   ` (42 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Michael Bianco, Felipe Contreras

From: Michael Bianco <iloveitaly@gmail.com>

When using zinit the completions are symlinked to ~/.zinit/completions,
this causes the zsh script to not be able to find the bash script.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 5f2c63236d..75bb44d41a 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -33,7 +33,7 @@ if [ -z "$script" ]; then
 		bash_completion='/usr/share/bash-completion/completions/'
 
 	locations=(
-		"$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
+		"$(dirname $(realpath ${funcsourcetrace[1]%:*}))"/git-completion.bash
 		"$HOME/.local/share/bash-completion/completions/git"
 		'/usr/local/share/bash-completion/completions/git'
 		"$bash_completion/git"
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 07/49] zsh: simplify realpath dirname idiom
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (5 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 06/49] zsh: resolve symlink of script Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 08/49] test: completion: use global config Felipe Contreras
                   ` (41 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

There's a much simpler way in zsh.

It's a shame that ${0:A:h} doesn't work probably due to a bug in zsh.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 75bb44d41a..4f22e8f85b 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -33,7 +33,7 @@ if [ -z "$script" ]; then
 		bash_completion='/usr/share/bash-completion/completions/'
 
 	locations=(
-		"$(dirname $(realpath ${funcsourcetrace[1]%:*}))"/git-completion.bash
+		"${${funcsourcetrace[1]%:*}:A:h}"/git-completion.bash
 		"$HOME/.local/share/bash-completion/completions/git"
 		'/usr/local/share/bash-completion/completions/git'
 		"$bash_completion/git"
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 08/49] test: completion: use global config
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (6 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 07/49] zsh: simplify realpath dirname idiom Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 09/49] completion: fix __git_cmd_idx regression for zsh Felipe Contreras
                   ` (40 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Aliases are supposed to be global.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/t9902-completion.sh     | 8 ++++----
 t/t9904-completion-zsh.sh | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 561f06b46a..6c3cfe7e5a 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2233,7 +2233,7 @@ test_expect_success 'git --help completion' '
 '
 
 test_expect_success 'completion.commands removes multiple commands' '
-	test_config completion.commands "-cherry -mergetool" &&
+	test_config_global completion.commands "-cherry -mergetool" &&
 	git --list-cmds=list-mainporcelain,list-complete,config >out &&
 	! grep -E "^(cherry|mergetool)$" out
 '
@@ -2430,7 +2430,7 @@ test_expect_success "recursive alias" '
 '
 
 test_expect_success "completion uses <cmd> completion for alias: !sh -c 'git <cmd> ...'" '
-	test_config alias.co "!sh -c '"'"'git checkout ...'"'"'" &&
+	test_config_global alias.co "!sh -c '"'"'git checkout ...'"'"'" &&
 	test_completion "git co m" <<-\EOF
 	main Z
 	mybranch Z
@@ -2439,7 +2439,7 @@ test_expect_success "completion uses <cmd> completion for alias: !sh -c 'git <cm
 '
 
 test_expect_success 'completion uses <cmd> completion for alias: !f () { VAR=val git <cmd> ... }' '
-	test_config alias.co "!f () { VAR=val git checkout ... ; } f" &&
+	test_config_global alias.co "!f () { VAR=val git checkout ... ; } f" &&
 	test_completion "git co m" <<-\EOF
 	main Z
 	mybranch Z
@@ -2448,7 +2448,7 @@ test_expect_success 'completion uses <cmd> completion for alias: !f () { VAR=val
 '
 
 test_expect_success 'completion used <cmd> completion for alias: !f() { : git <cmd> ; ... }' '
-	test_config alias.co "!f() { : git checkout ; if ... } f" &&
+	test_config_global alias.co "!f() { : git checkout ; if ... } f" &&
 	test_completion "git co m" <<-\EOF
 	main Z
 	mybranch Z
diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh
index 65bdaa011e..cb123261ab 100755
--- a/t/t9904-completion-zsh.sh
+++ b/t/t9904-completion-zsh.sh
@@ -1008,7 +1008,7 @@ test_expect_success "recursive alias" '
 '
 
 test_expect_success "completion uses <cmd> completion for alias: !sh -c 'git <cmd> ...'" '
-	test_config alias.co "!sh -c '"'"'git checkout ...'"'"'" &&
+	test_config_global alias.co "!sh -c '"'"'git checkout ...'"'"'" &&
 	test_completion "git co m" <<-\EOF
 	main Z
 	mybranch Z
@@ -1017,7 +1017,7 @@ test_expect_success "completion uses <cmd> completion for alias: !sh -c 'git <cm
 '
 
 test_expect_success 'completion uses <cmd> completion for alias: !f () { VAR=val git <cmd> ... }' '
-	test_config alias.co "!f () { VAR=val git checkout ... ; } f" &&
+	test_config_global alias.co "!f () { VAR=val git checkout ... ; } f" &&
 	test_completion "git co m" <<-\EOF
 	main Z
 	mybranch Z
@@ -1026,7 +1026,7 @@ test_expect_success 'completion uses <cmd> completion for alias: !f () { VAR=val
 '
 
 test_expect_success 'completion used <cmd> completion for alias: !f() { : git <cmd> ; ... }' '
-	test_config alias.co "!f() { : git checkout ; if ... } f" &&
+	test_config_global alias.co "!f() { : git checkout ; if ... } f" &&
 	test_completion "git co m" <<-\EOF
 	main Z
 	mybranch Z
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 09/49] completion: fix __git_cmd_idx regression for zsh
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (7 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 08/49] test: completion: use global config Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 10/49] completion: fix for suboptions with value Felipe Contreras
                   ` (39 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras, Harrison McCullough

The commit 59d85a2a05 (git-completion.bash: use $__git_cmd_idx in more
places, 2021-04-22) caused a regression when using __git_complete and a
command relies on __git_cmd_idx. This was fixed in cea232194d
(completion: bash: fix late declaration of __git_cmd_idx, 2021-06-18)
but only for bash.

We need the function wrapper (__git_func_wrap in bash and _git in zsh)
to define __git_cmd_idx.

Otherwise the equivalent of __git_complete in zsh fails:

  compdef _git ga=git_add
  ga <tab>
  ga __git_find_on_cmdline:[:14: unknown condition: -lt

Reported-by: Harrison McCullough <mccullough.harrison@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 2 +-
 t/t9904-completion-zsh.sh             | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 4f22e8f85b..d11f4765b6 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -267,7 +267,7 @@ __git_zsh_main ()
 _git ()
 {
 	local _ret=1
-	local cur cword prev
+	local cur cword prev __git_cmd_idx=0
 
 	cur=${words[CURRENT]}
 	prev=${words[CURRENT-1]}
diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh
index cb123261ab..b7e4029bf9 100755
--- a/t/t9904-completion-zsh.sh
+++ b/t/t9904-completion-zsh.sh
@@ -1140,4 +1140,10 @@ test_expect_failure 'options with value' '
 	EOF
 '
 
+test_expect_success 'main sets correct __git_cmd_idx' '
+	echo modified > file1 &&
+	touch file3 &&
+	test_completion "compdef _git ga=git_add${LF}ga --update f" "file1"
+'
+
 test_done
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 10/49] completion: fix for suboptions with value
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (8 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 09/49] completion: fix __git_cmd_idx regression for zsh Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 11/49] completion: zsh: trivial improvement Felipe Contreras
                   ` (38 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

We need to ignore options that don't start with -- as well.

Depending on the value of COMP_WORDBREAKS, the last word could be
duplicated otherwise.

Can be tested with:

  git merge -X diff-algorithm=<tab>

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 2 +-
 t/t9904-completion-zsh.sh             | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index d11f4765b6..13809f7894 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -56,7 +56,7 @@ __gitcomp ()
 	local cur_="${3-$cur}"
 
 	case "$cur_" in
-	--*=)
+	*=)
 		;;
 	--no-*)
 		local c IFS=$' \t\n'
diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh
index b7e4029bf9..994d57a67f 100755
--- a/t/t9904-completion-zsh.sh
+++ b/t/t9904-completion-zsh.sh
@@ -176,7 +176,7 @@ test_expect_success '__gitcomp - expand/narrow all negative options' '
 	EOF
 '
 
-test_expect_failure '__gitcomp - equal skip' '
+test_expect_success '__gitcomp - equal skip' '
 	test_gitcomp "--option=" "--option=" <<-\EOF &&
 
 	EOF
@@ -1134,7 +1134,7 @@ test_expect_success 'git clone --config= - value' '
 	EOF
 '
 
-test_expect_failure 'options with value' '
+test_expect_success 'options with value' '
 	test_completion "git merge -X diff-algorithm=" <<-\EOF
 
 	EOF
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 11/49] completion: zsh: trivial improvement
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (9 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 10/49] completion: fix for suboptions with value Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 12/49] completion: bash: do not modify COMP_WORDBREAKS Felipe Contreras
                   ` (37 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

$words has basically all the words we need, except the first one: git.

Lets simply add that instead of passing the original, which contains
options we don't want to pass downstream (like -c and -C).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 13809f7894..790879e319 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -215,9 +215,6 @@ __git_zsh_main ()
 {
 	local curcontext="$curcontext" state state_descr line
 	typeset -A opt_args
-	local -a orig_words
-
-	orig_words=( ${words[@]} )
 
 	_arguments -C \
 		'(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
@@ -257,7 +254,7 @@ __git_zsh_main ()
 
 		(( $+opt_args[--help] )) && command='help'
 
-		words=( ${orig_words[@]} )
+		words=( git ${words[@]} )
 
 		__git_zsh_bash_func $command
 		;;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 12/49] completion: bash: do not modify COMP_WORDBREAKS
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (10 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 11/49] completion: zsh: trivial improvement Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 13/49] test: completion: fix currently typed words Felipe Contreras
                   ` (36 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

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 cf6ff0595f..fd2a43de38 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -65,11 +65,6 @@
 #     case insensitively, even on systems with case sensitive file systems
 #     (e.g., completing tag name "FOO" on "git checkout f<TAB>").
 
-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 790879e319..186c49195b 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -46,6 +46,7 @@ fi
 
 local old_complete="$functions[complete]"
 functions[complete]=:
+COMP_WORDBREAKS=':'
 GIT_SOURCING_ZSH_COMPLETION=y . "$script"
 functions[complete]="$old_complete"
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 13/49] test: completion: fix currently typed words
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (11 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 12/49] completion: bash: do not modify COMP_WORDBREAKS Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 14/49] test: completion: switch __gitcomp_nl prefix test Felipe Contreras
                   ` (35 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

They don't match what we are supposed to be completing.

No functional changes.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/t9902-completion.sh     | 4 ++--
 t/t9904-completion-zsh.sh | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 6c3cfe7e5a..bfd8570885 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -486,7 +486,7 @@ test_expect_success '__gitcomp - option parameter' '
 '
 
 test_expect_success '__gitcomp - prefix' '
-	test_gitcomp "branch.me" "remote merge mergeoptions rebase" \
+	test_gitcomp "branch.maint.me" "remote merge mergeoptions rebase" \
 		"branch.maint." "me" <<-\EOF
 	branch.maint.merge Z
 	branch.maint.mergeoptions Z
@@ -494,7 +494,7 @@ test_expect_success '__gitcomp - prefix' '
 '
 
 test_expect_success '__gitcomp - suffix' '
-	test_gitcomp "branch.me" "master maint next seen" "branch." \
+	test_gitcomp "branch.ma" "master maint next seen" "branch." \
 		"ma" "." <<-\EOF
 	branch.master.Z
 	branch.maint.Z
diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh
index 994d57a67f..9221539296 100755
--- a/t/t9904-completion-zsh.sh
+++ b/t/t9904-completion-zsh.sh
@@ -125,7 +125,7 @@ test_expect_success '__gitcomp - option parameter' '
 '
 
 test_expect_failure '__gitcomp - prefix' '
-	test_gitcomp "branch.me" "remote merge mergeoptions rebase" \
+	test_gitcomp "branch.maint.me" "remote merge mergeoptions rebase" \
 		"branch.maint." "me" <<-\EOF
 	branch.maint.merge Z
 	branch.maint.mergeoptions Z
@@ -133,7 +133,7 @@ test_expect_failure '__gitcomp - prefix' '
 '
 
 test_expect_failure '__gitcomp - suffix' '
-	test_gitcomp "branch.me" "master maint next seen" "branch." \
+	test_gitcomp "branch.ma" "master maint next seen" "branch." \
 		"ma" "." <<-\EOF
 	branch.master.Z
 	branch.maint.Z
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 14/49] test: completion: switch __gitcomp_nl prefix test
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (12 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 13/49] test: completion: fix currently typed words Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 15/49] test: completion: add run_func() helper Felipe Contreras
                   ` (34 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

By default COMP_WORDBREAKS includes =, so it's not realistic to test for
a prefix that almost never will be there.

In bash there are no functional changes, but in zsh this makes the test
pass.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/t9902-completion.sh     | 6 +++---
 t/t9904-completion-zsh.sh | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index bfd8570885..9d973f21ce 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -565,9 +565,9 @@ test_expect_success '__gitcomp_nl - trailing space' '
 '
 
 test_expect_success '__gitcomp_nl - prefix' '
-	test_gitcomp_nl "--fixup=m" "$refs" "--fixup=" "m" <<-EOF
-	--fixup=main Z
-	--fixup=maint Z
+	test_gitcomp_nl "branch.m" "$refs" "branch." "m" <<-EOF
+	branch.main Z
+	branch.maint Z
 	EOF
 '
 
diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh
index 9221539296..ee8cbe3320 100755
--- a/t/t9904-completion-zsh.sh
+++ b/t/t9904-completion-zsh.sh
@@ -199,10 +199,10 @@ test_expect_success '__gitcomp_nl - trailing space' '
 	EOF
 '
 
-test_expect_failure '__gitcomp_nl - prefix' '
-	test_gitcomp_nl "--fixup=m" "$refs" "--fixup=" "m" <<-EOF
-	--fixup=main Z
-	--fixup=maint Z
+test_expect_success '__gitcomp_nl - prefix' '
+	test_gitcomp_nl "branch.m" "$refs" "branch." "m" <<-EOF
+	branch.main Z
+	branch.maint Z
 	EOF
 '
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 15/49] test: completion: add run_func() helper
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (13 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 14/49] test: completion: switch __gitcomp_nl prefix test Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 16/49] completion: bash: remove non-append functionality Felipe Contreras
                   ` (33 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Pretty straightforward: runs functions.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/t9902-completion.sh | 58 ++++++++++++++++++-------------------------
 1 file changed, 24 insertions(+), 34 deletions(-)

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 9d973f21ce..a2f2f9dc09 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -75,6 +75,12 @@ run_completion ()
 	__git_wrap__git_main && print_comp
 }
 
+run_func ()
+{
+	local -a COMPREPLY &&
+	"$@" && print_comp
+}
+
 # Test high-level completion
 # Arguments are:
 # 1: typed text so far (cur)
@@ -452,8 +458,7 @@ test_expect_success '__gitcomp_direct - puts everything into COMPREPLY as-is' '
 	EOF
 	(
 		cur=should_be_ignored &&
-		__gitcomp_direct "$(cat expected)" &&
-		print_comp
+		run_func __gitcomp_direct "$(cat expected)"
 	) &&
 	test_cmp expected out
 '
@@ -547,7 +552,7 @@ test_expect_success '__gitcomp - equal skip' '
 '
 
 test_expect_success '__gitcomp - doesnt fail because of invalid variable name' '
-	__gitcomp "$invalid_variable_name"
+	run_func __gitcomp "$invalid_variable_name"
 '
 
 read -r -d "" refs <<-\EOF
@@ -586,7 +591,7 @@ test_expect_success '__gitcomp_nl - no suffix' '
 '
 
 test_expect_success '__gitcomp_nl - doesnt fail because of invalid variable name' '
-	__gitcomp_nl "$invalid_variable_name"
+	run_func __gitcomp_nl "$invalid_variable_name"
 '
 
 test_expect_success '__git_remotes - list remotes from $GIT_DIR/remotes and from config file' '
@@ -1087,8 +1092,7 @@ test_expect_success '__git_complete_refs - simple' '
 	EOF
 	(
 		cur= &&
-		__git_complete_refs &&
-		print_comp
+		run_func __git_complete_refs
 	) &&
 	test_cmp expected out
 '
@@ -1100,8 +1104,7 @@ test_expect_success '__git_complete_refs - matching' '
 	EOF
 	(
 		cur=mat &&
-		__git_complete_refs &&
-		print_comp
+		run_func __git_complete_refs
 	) &&
 	test_cmp expected out
 '
@@ -1114,8 +1117,7 @@ test_expect_success '__git_complete_refs - remote' '
 	EOF
 	(
 		cur= &&
-		__git_complete_refs --remote=other &&
-		print_comp
+		run_func __git_complete_refs --remote=other
 	) &&
 	test_cmp expected out
 '
@@ -1133,8 +1135,7 @@ test_expect_success '__git_complete_refs - track' '
 	EOF
 	(
 		cur= &&
-		__git_complete_refs --track &&
-		print_comp
+		run_func __git_complete_refs --track
 	) &&
 	test_cmp expected out
 '
@@ -1146,8 +1147,7 @@ test_expect_success '__git_complete_refs - current word' '
 	EOF
 	(
 		cur="--option=mat" &&
-		__git_complete_refs --cur="${cur#*=}" &&
-		print_comp
+		run_func __git_complete_refs --cur="${cur#*=}"
 	) &&
 	test_cmp expected out
 '
@@ -1159,8 +1159,7 @@ test_expect_success '__git_complete_refs - prefix' '
 	EOF
 	(
 		cur=v1.0..mat &&
-		__git_complete_refs --pfx=v1.0.. --cur=mat &&
-		print_comp
+		run_func __git_complete_refs --pfx=v1.0.. --cur=mat
 	) &&
 	test_cmp expected out
 '
@@ -1176,8 +1175,7 @@ test_expect_success '__git_complete_refs - suffix' '
 	EOF
 	(
 		cur= &&
-		__git_complete_refs --sfx=. &&
-		print_comp
+		run_func __git_complete_refs --sfx=.
 	) &&
 	test_cmp expected out
 '
@@ -1190,8 +1188,7 @@ test_expect_success '__git_complete_fetch_refspecs - simple' '
 	EOF
 	(
 		cur= &&
-		__git_complete_fetch_refspecs other &&
-		print_comp
+		run_func __git_complete_fetch_refspecs other
 	) &&
 	test_cmp expected out
 '
@@ -1202,8 +1199,7 @@ test_expect_success '__git_complete_fetch_refspecs - matching' '
 	EOF
 	(
 		cur=br &&
-		__git_complete_fetch_refspecs other "" br &&
-		print_comp
+		run_func __git_complete_fetch_refspecs other "" br
 	) &&
 	test_cmp expected out
 '
@@ -1216,8 +1212,7 @@ test_expect_success '__git_complete_fetch_refspecs - prefix' '
 	EOF
 	(
 		cur="+" &&
-		__git_complete_fetch_refspecs other "+" ""  &&
-		print_comp
+		run_func __git_complete_fetch_refspecs other "+" ""
 	) &&
 	test_cmp expected out
 '
@@ -1230,8 +1225,7 @@ test_expect_success '__git_complete_fetch_refspecs - fully qualified' '
 	EOF
 	(
 		cur=refs/ &&
-		__git_complete_fetch_refspecs other "" refs/ &&
-		print_comp
+		run_func __git_complete_fetch_refspecs other "" refs/
 	) &&
 	test_cmp expected out
 '
@@ -1244,8 +1238,7 @@ test_expect_success '__git_complete_fetch_refspecs - fully qualified & prefix' '
 	EOF
 	(
 		cur=+refs/ &&
-		__git_complete_fetch_refspecs other + refs/ &&
-		print_comp
+		run_func __git_complete_fetch_refspecs other + refs/
 	) &&
 	test_cmp expected out
 '
@@ -1931,8 +1924,7 @@ test_path_completion ()
 		# unusual characters in path names.  By requesting only
 		# untracked files we do not have to bother adding any
 		# paths to the index in those tests.
-		__git_complete_index_file --others &&
-		print_comp
+		run_func __git_complete_index_file --others
 	) &&
 	test_cmp expected out
 }
@@ -2487,8 +2479,7 @@ do
 			words=(git push '$flag' other ma) &&
 			cword=${#words[@]} cur=${words[cword-1]} &&
 			__git_cmd_idx=1 &&
-			__git_complete_remote_or_refspec &&
-			print_comp
+			run_func __git_complete_remote_or_refspec
 		) &&
 		test_cmp expected out
 	'
@@ -2501,8 +2492,7 @@ do
 			words=(git push other '$flag' ma) &&
 			cword=${#words[@]} cur=${words[cword-1]} &&
 			__git_cmd_idx=1 &&
-			__git_complete_remote_or_refspec &&
-			print_comp
+			run_func __git_complete_remote_or_refspec
 		) &&
 		test_cmp expected out
 	'
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 16/49] completion: bash: remove non-append functionality
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (14 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 15/49] test: completion: add run_func() helper Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 17/49] completion: bash: get rid of _append() functions Felipe Contreras
                   ` (32 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

There's no point in setting COMPREPLY only to override it later, and in
fact... we don't do that.

Therefore there's no functional difference between __gitcomp_direct()
and __gitcomp_direct_append(), since __gitcomp_direct() *always*
operates on empty COMPREPLY.

The same goes for __gitcomp_nl().

This patch makes the functionality of append and non-append functions
the same.

No functional changes.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index fd2a43de38..7554c3aeb3 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -318,7 +318,7 @@ __gitcomp_direct ()
 {
 	local IFS=$'\n'
 
-	COMPREPLY=($1)
+	COMPREPLY+=($1)
 }
 
 # Similar to __gitcomp_direct, but appends to COMPREPLY instead.
@@ -470,7 +470,6 @@ __gitcomp_nl_append ()
 #    appended.
 __gitcomp_nl ()
 {
-	COMPREPLY=()
 	__gitcomp_nl_append "$@"
 }
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 17/49] completion: bash: get rid of _append() functions
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (15 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 16/49] completion: bash: remove non-append functionality Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 18/49] completion: bash: get rid of any non-append code Felipe Contreras
                   ` (31 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

There's no need to have duplicated functionality.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 35 ++++++--------------------
 contrib/completion/git-completion.zsh  | 10 --------
 2 files changed, 7 insertions(+), 38 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 7554c3aeb3..3c8f907d45 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -307,8 +307,7 @@ _get_comp_words_by_ref ()
 }
 fi
 
-# Fills the COMPREPLY array with prefiltered words without any additional
-# processing.
+# Appends prefiltered words to COMPREPLY without any additional processing.
 # Callers must take care of providing only words that match the current word
 # to be completed and adding any prefix and/or suffix (trailing space!), if
 # necessary.
@@ -321,19 +320,6 @@ __gitcomp_direct ()
 	COMPREPLY+=($1)
 }
 
-# Similar to __gitcomp_direct, but appends to COMPREPLY instead.
-# Callers must take care of providing only words that match the current word
-# to be completed and adding any prefix and/or suffix (trailing space!), if
-# necessary.
-# 1: List of newline-separated matching completion words, complete with
-#    prefix and suffix.
-__gitcomp_direct_append ()
-{
-	local IFS=$'\n'
-
-	COMPREPLY+=($1)
-}
-
 __gitcompappend ()
 {
 	local x i=${#COMPREPLY[@]}
@@ -451,16 +437,8 @@ __gitcomp_builtin ()
 	__gitcomp "$options"
 }
 
-# Variation of __gitcomp_nl () that appends to the existing list of
-# completion candidates, COMPREPLY.
-__gitcomp_nl_append ()
-{
-	local IFS=$'\n'
-	__gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
-}
-
 # Generates completion reply from newline-separated possible completion words
-# by appending a space to all of them.
+# by appending a space to all of them. The result is appended to COMPREPLY.
 # It accepts 1 to 4 arguments:
 # 1: List of possible completion words, separated by a single newline.
 # 2: A prefix to be added to each possible completion word (optional).
@@ -470,7 +448,8 @@ __gitcomp_nl_append ()
 #    appended.
 __gitcomp_nl ()
 {
-	__gitcomp_nl_append "$@"
+	local IFS=$'\n'
+	__gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
 }
 
 # Fills the COMPREPLY array with prefiltered paths without any additional
@@ -871,7 +850,7 @@ __git_complete_refs ()
 
 	# Append DWIM remote branch names if requested
 	if [ "$dwim" = "yes" ]; then
-		__gitcomp_direct_append "$(__git_dwim_remote_heads "$pfx" "$cur_" "$sfx")"
+		__gitcomp_direct "$(__git_dwim_remote_heads "$pfx" "$cur_" "$sfx")"
 	fi
 }
 
@@ -2670,7 +2649,7 @@ __git_complete_config_variable_name ()
 		local pfx="${cur_%.*}."
 		cur_="${cur_#*.}"
 		__gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
-		__gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }"
+		__gitcomp_nl $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }"
 		return
 		;;
 	guitool.*.*)
@@ -2720,7 +2699,7 @@ __git_complete_config_variable_name ()
 		local pfx="${cur_%.*}."
 		cur_="${cur_#*.}"
 		__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
-		__gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx- }"
+		__gitcomp_nl "pushDefault" "$pfx" "$cur_" "${sfx- }"
 		return
 		;;
 	url.*.*)
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 186c49195b..b31c9894e4 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -122,16 +122,6 @@ __gitcomp_file ()
 	compadd -f -p "${2-}" -- ${(f)1} && _ret=0
 }
 
-__gitcomp_direct_append ()
-{
-	__gitcomp_direct "$@"
-}
-
-__gitcomp_nl_append ()
-{
-	__gitcomp_nl "$@"
-}
-
 __gitcomp_file_direct ()
 {
 	__gitcomp_file "$1" ""
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 18/49] completion: bash: get rid of any non-append code
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (16 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 17/49] completion: bash: get rid of _append() functions Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 19/49] completion: zsh: fix options with arguments Felipe Contreras
                   ` (30 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 3c8f907d45..98eb7c9604 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -320,7 +320,7 @@ __gitcomp_direct ()
 	COMPREPLY+=($1)
 }
 
-__gitcompappend ()
+__gitcompadd ()
 {
 	local x i=${#COMPREPLY[@]}
 	for x in $1; do
@@ -330,12 +330,6 @@ __gitcompappend ()
 	done
 }
 
-__gitcompadd ()
-{
-	COMPREPLY=()
-	__gitcompappend "$@"
-}
-
 # Generates completion reply, appending a space to possible completion words,
 # if necessary.
 # It accepts 1 to 4 arguments:
@@ -449,7 +443,7 @@ __gitcomp_builtin ()
 __gitcomp_nl ()
 {
 	local IFS=$'\n'
-	__gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
+	__gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
 }
 
 # Fills the COMPREPLY array with prefiltered paths without any additional
@@ -462,7 +456,7 @@ __gitcomp_file_direct ()
 {
 	local IFS=$'\n'
 
-	COMPREPLY=($1)
+	COMPREPLY+=($1)
 
 	# use a hack to enable file mode in bash < 4
 	compopt -o filenames +o nospace 2>/dev/null ||
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 19/49] completion: zsh: fix options with arguments
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (17 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 18/49] completion: bash: get rid of any non-append code Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 20/49] completion: zsh: expand --git-dir file argument Felipe Contreras
                   ` (29 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

They support both '--git-dir=value' and '--git-dir value'. Fix the
arguments to support both.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index b31c9894e4..0619d05d34 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -210,15 +210,15 @@ __git_zsh_main ()
 	_arguments -C \
 		'(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
 		'(-p --paginate)--no-pager[do not pipe git output into a pager]' \
-		'--git-dir=-[set the path to the repository]: :_directories' \
+		'--git-dir=[set the path to the repository]: :_directories' \
 		'--bare[treat the repository as a bare repository]' \
 		'(- :)--version[prints the git suite version]' \
-		'--exec-path=-[path to where your core git programs are installed]:: :_directories' \
+		'--exec-path=[path to where your core git programs are installed]:: :_directories' \
 		'--html-path[print the path where git''s HTML documentation is installed]' \
 		'--info-path[print the path where the Info files are installed]' \
 		'--man-path[print the manpath (see `man(1)`) for the man pages]' \
-		'--work-tree=-[set the path to the working tree]: :_directories' \
-		'--namespace=-[set the git namespace]' \
+		'--work-tree=[set the path to the working tree]: :_directories' \
+		'--namespace=[set the git namespace]:' \
 		'--no-replace-objects[do not use replacement refs to replace git objects]' \
 		'(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \
 		'(-): :->command' \
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 20/49] completion: zsh: expand --git-dir file argument
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (18 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 19/49] completion: zsh: fix options with arguments Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 21/49] completion: zsh: add support for general -C opts Felipe Contreras
                   ` (28 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 0619d05d34..b49bce51ac 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -240,7 +240,7 @@ __git_zsh_main ()
 		if (( $+opt_args[--bare] )); then
 			__git_dir='.'
 		else
-			__git_dir=${opt_args[--git-dir]}
+			__git_dir=${~opt_args[--git-dir]}
 		fi
 
 		(( $+opt_args[--help] )) && command='help'
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 21/49] completion: zsh: add support for general -C opts
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (19 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 20/49] completion: zsh: expand --git-dir file argument Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:45 ` [PATCH v7 22/49] completion: zsh: fix for undefined completions Felipe Contreras
                   ` (27 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 6 ++++++
 t/t9904-completion-zsh.sh             | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index b49bce51ac..9e821eab9a 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -206,6 +206,7 @@ __git_zsh_main ()
 {
 	local curcontext="$curcontext" state state_descr line
 	typeset -A opt_args
+	local -a __git_C_args
 
 	_arguments -C \
 		'(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
@@ -221,6 +222,7 @@ __git_zsh_main ()
 		'--namespace=[set the git namespace]:' \
 		'--no-replace-objects[do not use replacement refs to replace git objects]' \
 		'(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \
+		'*-C[run as if git was started in the given path]: :_directories' \
 		'(-): :->command' \
 		'(-)*:: :->arg' && return
 
@@ -243,6 +245,10 @@ __git_zsh_main ()
 			__git_dir=${~opt_args[--git-dir]}
 		fi
 
+		for x in ${(s.:.)opt_args[-C]}; do
+			__git_C_args+=('-C' ${~x})
+		done
+
 		(( $+opt_args[--help] )) && command='help'
 
 		words=( git ${words[@]} )
diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh
index ee8cbe3320..27f5b42318 100755
--- a/t/t9904-completion-zsh.sh
+++ b/t/t9904-completion-zsh.sh
@@ -863,7 +863,7 @@ test_expect_success 'checkout completes ref names' '
 	EOF
 '
 
-test_expect_failure 'git -C <path> checkout uses the right repo' '
+test_expect_success 'git -C <path> checkout uses the right repo' '
 	test_completion "git -C subdir -C subsubdir -C .. -C ../otherrepo checkout b" <<-\EOF
 	branch-in-other Z
 	EOF
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 22/49] completion: zsh: fix for undefined completions
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (20 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 21/49] completion: zsh: add support for general -C opts Felipe Contreras
@ 2023-04-01  8:45 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 23/49] completion: zsh: add support for general -c opts Felipe Contreras
                   ` (26 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:45 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

The parseopt helper can generate the completions even if the function is
unspecified.

  git version --<tab>

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 3 +++
 t/t9904-completion-zsh.sh             | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 9e821eab9a..88157b0867 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -136,6 +136,9 @@ __git_complete_command ()
 	if (( $+functions[$completion_func] )); then
 		emulate ksh -c $completion_func
 		return 0
+	elif emulate ksh -c "__git_support_parseopt_helper $command"; then
+		emulate ksh -c "__git_complete_common $command"
+		return 0
 	else
 		return 1
 	fi
diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh
index 27f5b42318..472b02d3e6 100755
--- a/t/t9904-completion-zsh.sh
+++ b/t/t9904-completion-zsh.sh
@@ -1034,7 +1034,7 @@ test_expect_success 'completion used <cmd> completion for alias: !f() { : git <c
 	EOF
 '
 
-test_expect_failure 'completion without explicit _git_xxx function' '
+test_expect_success 'completion without explicit _git_xxx function' '
 	test_completion "git version --" <<-\EOF
 	--build-options Z
 	--no-build-options Z
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 23/49] completion: zsh: add support for general -c opts
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (21 preceding siblings ...)
  2023-04-01  8:45 ` [PATCH v7 22/49] completion: zsh: fix for undefined completions Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 24/49] completion: zsh: fix extra space on foo= Felipe Contreras
                   ` (25 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

So we can specify configurations.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 5 +++++
 t/t9904-completion-zsh.sh             | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 88157b0867..a7a5efbd13 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -226,6 +226,7 @@ __git_zsh_main ()
 		'--no-replace-objects[do not use replacement refs to replace git objects]' \
 		'(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \
 		'*-C[run as if git was started in the given path]: :_directories' \
+		'*-c[pass a configuration parameter to the command]: :->config' \
 		'(-): :->command' \
 		'(-)*:: :->arg' && return
 
@@ -239,6 +240,10 @@ __git_zsh_main ()
 			let _ret || break
 		done
 		;;
+	(config)
+		compset -P '*[=:]'
+		emulate ksh -c __git_complete_config_variable_name_and_value
+		;;
 	(arg)
 		local command="${words[1]}" __git_dir __git_cmd_idx=1
 
diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh
index 472b02d3e6..1b18bf5363 100755
--- a/t/t9904-completion-zsh.sh
+++ b/t/t9904-completion-zsh.sh
@@ -1090,7 +1090,7 @@ test_expect_success 'git config - value' '
 	EOF
 '
 
-test_expect_failure 'git -c - section' '
+test_expect_success 'git -c - section' '
 	test_completion "git -c br" <<-\EOF
 	branch.Z
 	browser.Z
@@ -1105,7 +1105,7 @@ test_expect_failure 'git -c - variable name' '
 	EOF
 '
 
-test_expect_failure 'git -c - value' '
+test_expect_success 'git -c - value' '
 	test_completion "git -c color.pager=" <<-\EOF
 	false Z
 	true Z
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 24/49] completion: zsh: fix extra space on foo=
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (22 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 23/49] completion: zsh: add support for general -c opts Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 25/49] completion: zsh: add excluded options Felipe Contreras
                   ` (24 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Upstream commit e1e00089da fixed the issue for Bash, but not for Zsh.

When we are typing configurations an = at the end signifies we still
want to type the value.

Can be tested with:

  git -c log.d<tab>

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 2 +-
 t/t9904-completion-zsh.sh             | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index a7a5efbd13..038ab30869 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -87,7 +87,7 @@ __gitcomp ()
 			fi
 			c="$c${4-}"
 			case $c in
-			--*=|*.) ;;
+			*=|*.) ;;
 			*) c="$c " ;;
 			esac
 			array+=("$c")
diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh
index 1b18bf5363..4355552434 100755
--- a/t/t9904-completion-zsh.sh
+++ b/t/t9904-completion-zsh.sh
@@ -1097,7 +1097,7 @@ test_expect_success 'git -c - section' '
 	EOF
 '
 
-test_expect_failure 'git -c - variable name' '
+test_expect_success 'git -c - variable name' '
 	test_completion "git -c log.d" <<-\EOF
 	log.date=Z
 	log.decorate=Z
@@ -1119,7 +1119,7 @@ test_expect_success 'git clone --config= - section' '
 	EOF
 '
 
-test_expect_failure 'git clone --config= - variable name' '
+test_expect_success 'git clone --config= - variable name' '
 	test_completion "git clone --config=log.d" <<-\EOF
 	log.date=Z
 	log.decorate=Z
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 25/49] completion: zsh: add excluded options
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (23 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 24/49] completion: zsh: fix extra space on foo= Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 26/49] completion: zsh: always set compset Felipe Contreras
                   ` (23 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Add more excluded options, for example: --bare excludes --git-dir.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 17 +++++++++--------
 t/t9904-completion-zsh.sh             |  2 +-
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 038ab30869..0c8fdb584f 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -212,15 +212,16 @@ __git_zsh_main ()
 	local -a __git_C_args
 
 	_arguments -C \
-		'(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
-		'(-p --paginate)--no-pager[do not pipe git output into a pager]' \
-		'--git-dir=[set the path to the repository]: :_directories' \
-		'--bare[treat the repository as a bare repository]' \
+		'(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
+		'(-p --paginate -P --no-pager)'{-P,--no-pager}'[do not pipe git output into a pager]' \
+		'(--bare)--git-dir=[set the path to the repository]: :_directories' \
+		'(--git-dir)--bare[treat the repository as a bare repository]' \
 		'(- :)--version[prints the git suite version]' \
-		'--exec-path=[path to where your core git programs are installed]:: :_directories' \
-		'--html-path[print the path where git''s HTML documentation is installed]' \
-		'--info-path[print the path where the Info files are installed]' \
-		'--man-path[print the manpath (see `man(1)`) for the man pages]' \
+		'--exec-path=[path to where your core git programs are installed]: :_directories' \
+		'(- :)--exec-path[print the path where your core git programs are installed]' \
+		'(- :)--html-path[print the path where git''s HTML documentation is installed]' \
+		'(- :)--info-path[print the path where the Info files are installed]' \
+		'(- :)--man-path[print the manpath (see `man(1)`) for the man pages]' \
 		'--work-tree=[set the path to the working tree]: :_directories' \
 		'--namespace=[set the git namespace]:' \
 		'--no-replace-objects[do not use replacement refs to replace git objects]' \
diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh
index 4355552434..c0be5573ee 100755
--- a/t/t9904-completion-zsh.sh
+++ b/t/t9904-completion-zsh.sh
@@ -821,7 +821,7 @@ test_expect_success 'general options' '
 	test_completion "git --no-r" "--no-replace-objects"
 '
 
-test_expect_failure 'general options plus command' '
+test_expect_success 'general options plus command' '
 	test_completion "git --version check" "" &&
 	test_completion "git --paginate check" "checkout" &&
 	test_completion "git --git-dir=foo check" "checkout" &&
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 26/49] completion: zsh: always set compset
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (24 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 25/49] completion: zsh: add excluded options Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 27/49] completion: factor out check in __gitcomp Felipe Contreras
                   ` (22 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

So we don't have to set it every time.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 0c8fdb584f..0b6289af0a 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -73,7 +73,6 @@ __gitcomp ()
 			esac
 			array+=("$c")
 		done
-		compset -P '*[=:]'
 		compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
 		;;
 	*)
@@ -92,7 +91,6 @@ __gitcomp ()
 			esac
 			array+=("$c")
 		done
-		compset -P '*[=:]'
 		compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
 		;;
 	esac
@@ -102,7 +100,6 @@ __gitcomp_direct ()
 {
 	emulate -L zsh
 
-	compset -P '*[=:]'
 	compadd -Q -S '' -- ${(f)1} && _ret=0
 }
 
@@ -110,7 +107,6 @@ __gitcomp_nl ()
 {
 	emulate -L zsh
 
-	compset -P '*[=:]'
 	compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0
 }
 
@@ -118,7 +114,6 @@ __gitcomp_file ()
 {
 	emulate -L zsh
 
-	compset -P '*[=:]'
 	compadd -f -p "${2-}" -- ${(f)1} && _ret=0
 }
 
@@ -131,6 +126,8 @@ __git_complete_command ()
 {
 	emulate -L zsh
 
+	compset -P '*[=:]'
+
 	local command="$1"
 	local completion_func="_git_${command//-/_}"
 	if (( $+functions[$completion_func] )); then
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 27/49] completion: factor out check in __gitcomp
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (25 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 26/49] completion: zsh: always set compset Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 28/49] completion: simplify equal suffix check Felipe Contreras
                   ` (21 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

This way we can reorganize the rest of the function.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 6 ++++--
 contrib/completion/git-completion.zsh  | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 98eb7c9604..e07d5054cb 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -341,9 +341,11 @@ __gitcomp ()
 {
 	local cur_="${3-$cur}"
 
+	if [[ "$cur_" == *= ]]; then
+		return
+	fi
+
 	case "$cur_" in
-	*=)
-		;;
 	--no-*)
 		local c i=0 IFS=$' \t\n'
 		for c in $1; do
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 0b6289af0a..202f66a4f7 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -56,9 +56,9 @@ __gitcomp ()
 
 	local cur_="${3-$cur}"
 
+	[[ "$cur_" == *= ]] && return
+
 	case "$cur_" in
-	*=)
-		;;
 	--no-*)
 		local c IFS=$' \t\n'
 		local -a array
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 28/49] completion: simplify equal suffix check
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (26 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 27/49] completion: factor out check in __gitcomp Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 29/49] completion: refactor __gitcomp Felipe Contreras
                   ` (20 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

We know the prefix is already '--no-', there's no need to check for the
first '--'.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 2 +-
 contrib/completion/git-completion.zsh  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index e07d5054cb..187350dbfc 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -355,7 +355,7 @@ __gitcomp ()
 			c="$c${4-}"
 			if [[ $c == "$cur_"* ]]; then
 				case $c in
-				--*=|*.) ;;
+				*=|*.) ;;
 				*) c="$c " ;;
 				esac
 				COMPREPLY[i++]="${2-}$c"
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 202f66a4f7..c9520589db 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -68,7 +68,7 @@ __gitcomp ()
 			fi
 			c="$c${4-}"
 			case $c in
-			--*=|*.) ;;
+			*=|*.) ;;
 			*) c="$c " ;;
 			esac
 			array+=("$c")
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 29/49] completion: refactor __gitcomp
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (27 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 28/49] completion: simplify equal suffix check Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 30/49] completion: simplify __gitcomp Felipe Contreras
                   ` (19 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

We have two chunks of code doing exactly the same, there's no need for
that.

No functional changes.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 52 +++++++++-----------------
 contrib/completion/git-completion.zsh  | 52 ++++++++------------------
 2 files changed, 34 insertions(+), 70 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 187350dbfc..9de394b223 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -345,44 +345,28 @@ __gitcomp ()
 		return
 	fi
 
-	case "$cur_" in
-	--no-*)
-		local c i=0 IFS=$' \t\n'
-		for c in $1; do
-			if [[ $c == "--" ]]; then
+	local c i=0 IFS=$' \t\n'
+	for c in $1; do
+		if [[ $c == "--" ]]; then
+			if [[ "$cur_" == --no-* ]]; then
 				continue
 			fi
-			c="$c${4-}"
+
+			c="--no-...${4-}"
 			if [[ $c == "$cur_"* ]]; then
-				case $c in
-				*=|*.) ;;
-				*) c="$c " ;;
-				esac
-				COMPREPLY[i++]="${2-}$c"
+				COMPREPLY[i++]="${2-}$c "
 			fi
-		done
-		;;
-	*)
-		local c i=0 IFS=$' \t\n'
-		for c in $1; do
-			if [[ $c == "--" ]]; then
-				c="--no-...${4-}"
-				if [[ $c == "$cur_"* ]]; then
-					COMPREPLY[i++]="${2-}$c "
-				fi
-				break
-			fi
-			c="$c${4-}"
-			if [[ $c == "$cur_"* ]]; then
-				case $c in
-				*=|*.) ;;
-				*) c="$c " ;;
-				esac
-				COMPREPLY[i++]="${2-}$c"
-			fi
-		done
-		;;
-	esac
+			break
+		fi
+		c="$c${4-}"
+		if [[ $c == "$cur_"* ]]; then
+			case $c in
+			*=|*.) ;;
+			*) c="$c " ;;
+			esac
+			COMPREPLY[i++]="${2-}$c"
+		fi
+	done
 }
 
 # Clear the variables caching builtins' options when (re-)sourcing
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index c9520589db..029ca23e50 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -58,42 +58,22 @@ __gitcomp ()
 
 	[[ "$cur_" == *= ]] && return
 
-	case "$cur_" in
-	--no-*)
-		local c IFS=$' \t\n'
-		local -a array
-		for c in ${=1}; do
-			if [[ $c == "--" ]]; then
-				continue
-			fi
-			c="$c${4-}"
-			case $c in
-			*=|*.) ;;
-			*) c="$c " ;;
-			esac
-			array+=("$c")
-		done
-		compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
-		;;
-	*)
-		local c IFS=$' \t\n'
-		local -a array
-		for c in ${=1}; do
-			if [[ $c == "--" ]]; then
-				c="--no-...${4-}"
-				array+=("$c ")
-				break
-			fi
-			c="$c${4-}"
-			case $c in
-			*=|*.) ;;
-			*) c="$c " ;;
-			esac
-			array+=("$c")
-		done
-		compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
-		;;
-	esac
+	local c IFS=$' \t\n'
+	local -a array
+	for c in ${=1}; do
+		if [[ $c == "--" ]]; then
+			[[ "$cur_" == --no-* ]] && continue
+			array+=("--no-...${4-} ")
+			break
+		fi
+		c="$c${4-}"
+		case $c in
+		*=|*.) ;;
+		*) c="$c " ;;
+		esac
+		array+=("$c")
+	done
+	compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
 }
 
 __gitcomp_direct ()
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 30/49] completion: simplify __gitcomp
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (28 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 29/49] completion: refactor __gitcomp Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 31/49] completion: bash: change suffix check in __gitcomp Felipe Contreras
                   ` (18 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

It's not possible for $cur_ to have anything more than --no- at this
point, so there's no need to add a suffix, nor check anything else.

All we are doing is checking that $cur_ matches --no, and adding a
completion if so.

This way the code reflects what we are doing.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 5 ++---
 contrib/completion/git-completion.zsh  | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 9de394b223..502a1657a1 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -352,9 +352,8 @@ __gitcomp ()
 				continue
 			fi
 
-			c="--no-...${4-}"
-			if [[ $c == "$cur_"* ]]; then
-				COMPREPLY[i++]="${2-}$c "
+			if [[ --no == "$cur_"* ]]; then
+				COMPREPLY[i++]="--no-... "
 			fi
 			break
 		fi
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 029ca23e50..04265bcb22 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -63,7 +63,7 @@ __gitcomp ()
 	for c in ${=1}; do
 		if [[ $c == "--" ]]; then
 			[[ "$cur_" == --no-* ]] && continue
-			array+=("--no-...${4-} ")
+			array+=("--no-... ")
 			break
 		fi
 		c="$c${4-}"
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 31/49] completion: bash: change suffix check in __gitcomp
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (29 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 30/49] completion: simplify __gitcomp Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 32/49] completion: improve __gitcomp suffix code Felipe Contreras
                   ` (17 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

We don't match the prefix, we shouldn't match the suffix either.

There are no functional changes since all the callers that add a suffix
add an =, and if $cur_ ended with that suffix, we would return
immediately.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 502a1657a1..63a3235544 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -357,8 +357,8 @@ __gitcomp ()
 			fi
 			break
 		fi
-		c="$c${4-}"
 		if [[ $c == "$cur_"* ]]; then
+			c="$c${4-}"
 			case $c in
 			*=|*.) ;;
 			*) c="$c " ;;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 32/49] completion: improve __gitcomp suffix code
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (30 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 31/49] completion: bash: change suffix check in __gitcomp Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 33/49] test: completion: add missing test Felipe Contreras
                   ` (16 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

There's no point in adding a suffix after a suffix.

If a suffix is provided: we add it, if not: then the default heuristic
is used.

There's no functional change since most callers don't specify a suffix,
and the ones that do, use an =, which by default doesn't add an
additional suffix.

The only exception is __git_complete_config_variable_name, so make sure
we pass the correct suffix.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 19 +++++++++++--------
 contrib/completion/git-completion.zsh  | 18 +++++++++++-------
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 63a3235544..eb7be6aa6c 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -345,7 +345,7 @@ __gitcomp ()
 		return
 	fi
 
-	local c i=0 IFS=$' \t\n'
+	local c i=0 IFS=$' \t\n' sfx
 	for c in $1; do
 		if [[ $c == "--" ]]; then
 			if [[ "$cur_" == --no-* ]]; then
@@ -358,12 +358,15 @@ __gitcomp ()
 			break
 		fi
 		if [[ $c == "$cur_"* ]]; then
-			c="$c${4-}"
-			case $c in
-			*=|*.) ;;
-			*) c="$c " ;;
-			esac
-			COMPREPLY[i++]="${2-}$c"
+			if [[ -z "${4+set}" ]]; then
+				case $c in
+				*=|*.) sfx="" ;;
+				*) sfx=" " ;;
+				esac
+			else
+				sfx="$4"
+			fi
+			COMPREPLY[i++]="${2-}$c$sfx"
 		fi
 	done
 }
@@ -2606,7 +2609,7 @@ __git_complete_config_variable_value ()
 #                 subsections) instead of the default space.
 __git_complete_config_variable_name ()
 {
-	local cur_="$cur" sfx
+	local cur_="$cur" sfx=" "
 
 	while test $# != 0; do
 		case "$1" in
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 04265bcb22..290fd0252d 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -58,7 +58,7 @@ __gitcomp ()
 
 	[[ "$cur_" == *= ]] && return
 
-	local c IFS=$' \t\n'
+	local c IFS=$' \t\n' sfx
 	local -a array
 	for c in ${=1}; do
 		if [[ $c == "--" ]]; then
@@ -66,12 +66,16 @@ __gitcomp ()
 			array+=("--no-... ")
 			break
 		fi
-		c="$c${4-}"
-		case $c in
-		*=|*.) ;;
-		*) c="$c " ;;
-		esac
-		array+=("$c")
+
+		if [[ -z "${4+set}" ]]; then
+			case $c in
+			*=|*.) sfx="" ;;
+			*) sfx=" " ;;
+			esac
+		else
+			sfx="$4"
+		fi
+		array+=("$c$sfx")
 	done
 	compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
 }
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 33/49] test: completion: add missing test
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (31 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 32/49] completion: improve __gitcomp suffix code Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 34/49] completion: bash: simplify config_variable_name Felipe Contreras
                   ` (15 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Once the correct suffix in __git_complete_config_variable_name() is set,
we can add the test again.

Now it should work even in bash < 4.0.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/t9902-completion.sh     | 7 +++++++
 t/t9904-completion-zsh.sh | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index a2f2f9dc09..c33543191f 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2533,6 +2533,13 @@ test_expect_success 'git config - value' '
 	EOF
 '
 
+test_expect_success 'git config - direct completions' '
+	test_completion "git config branch.autoSetup" <<-\EOF
+	branch.autoSetupMerge Z
+	branch.autoSetupRebase Z
+	EOF
+'
+
 test_expect_success 'git -c - section' '
 	test_completion "git -c br" <<-\EOF
 	branch.Z
diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh
index c0be5573ee..1c694bec0d 100755
--- a/t/t9904-completion-zsh.sh
+++ b/t/t9904-completion-zsh.sh
@@ -1090,6 +1090,13 @@ test_expect_success 'git config - value' '
 	EOF
 '
 
+test_expect_success 'git config - direct completions' '
+	test_completion "git config branch.autoSetup" <<-\EOF
+	branch.autoSetupMerge Z
+	branch.autoSetupRebase Z
+	EOF
+'
+
 test_expect_success 'git -c - section' '
 	test_completion "git -c br" <<-\EOF
 	branch.Z
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 34/49] completion: bash: simplify config_variable_name
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (32 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 33/49] test: completion: add missing test Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 35/49] completion: bash: improve __gitcomp description Felipe Contreras
                   ` (14 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Now sfx is never null.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index eb7be6aa6c..2974604e99 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2631,7 +2631,7 @@ __git_complete_config_variable_name ()
 		local pfx="${cur_%.*}."
 		cur_="${cur_#*.}"
 		__gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
-		__gitcomp_nl $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }"
+		__gitcomp_nl $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "$sfx"
 		return
 		;;
 	guitool.*.*)
@@ -2665,7 +2665,7 @@ __git_complete_config_variable_name ()
 		local pfx="${cur_%.*}."
 		cur_="${cur_#*.}"
 		__git_compute_all_commands
-		__gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx- }"
+		__gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "$sfx"
 		return
 		;;
 	remote.*.*)
@@ -2681,7 +2681,7 @@ __git_complete_config_variable_name ()
 		local pfx="${cur_%.*}."
 		cur_="${cur_#*.}"
 		__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
-		__gitcomp_nl "pushDefault" "$pfx" "$cur_" "${sfx- }"
+		__gitcomp_nl "pushDefault" "$pfx" "$cur_" "$sfx"
 		return
 		;;
 	url.*.*)
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 35/49] completion: bash: improve __gitcomp description
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (33 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 34/49] completion: bash: simplify config_variable_name Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 36/49] completion: add __gitcomp_opts Felipe Contreras
                   ` (13 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

It does a lot more than what is stated now.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 2974604e99..6633b866fb 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -330,8 +330,7 @@ __gitcompadd ()
 	done
 }
 
-# Generates completion reply, appending a space to possible completion words,
-# if necessary.
+# Creates completion replies, reorganizing options and adding suffixes as needed.
 # It accepts 1 to 4 arguments:
 # 1: List of possible completion words.
 # 2: A prefix to be added to each possible completion word (optional).
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 36/49] completion: add __gitcomp_opts
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (34 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 35/49] completion: bash: improve __gitcomp description Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 37/49] completion: bash: cleanup __gitcomp* invocations Felipe Contreras
                   ` (12 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Create a new simplified version of __gitcomp for most callers, and
__gitcomp_opts for the ones that need reorganizing all the options.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 94 +++++++++++++++-----------
 contrib/completion/git-completion.zsh  |  8 +++
 t/t9902-completion.sh                  | 58 ++++++++--------
 t/t9904-completion-zsh.sh              | 54 +++++++--------
 4 files changed, 117 insertions(+), 97 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 6633b866fb..ba225e999a 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -330,13 +330,25 @@ __gitcompadd ()
 	done
 }
 
-# Creates completion replies, reorganizing options and adding suffixes as needed.
+# Creates completion replies.
 # It accepts 1 to 4 arguments:
 # 1: List of possible completion words.
 # 2: A prefix to be added to each possible completion word (optional).
 # 3: Generate possible completion matches for this word (optional).
 # 4: A suffix to be appended to each possible completion word (optional).
 __gitcomp ()
+{
+	local IFS=$' \t\n'
+	__gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
+}
+
+# Creates completion replies, reorganizing options and adding suffixes as needed.
+# It accepts 1 to 4 arguments:
+# 1: List of possible completion words.
+# 2: A prefix to be added to each possible completion word (optional).
+# 3: Generate possible completion matches for this word (optional).
+# 4: A suffix to be appended to each possible completion word (optional).
+__gitcomp_opts ()
 {
 	local cur_="${3-$cur}"
 
@@ -380,7 +392,7 @@ fi
 
 # This function is equivalent to
 #
-#    __gitcomp "$(git xxx --git-completion-helper) ..."
+#    __gitcomp_opts "$(git xxx --git-completion-helper) ..."
 #
 # except that the output is cached. Accept 1-3 arguments:
 # 1: the git command to execute, this is also the cache key
@@ -415,7 +427,7 @@ __gitcomp_builtin ()
 		eval "$var=\"$options\""
 	fi
 
-	__gitcomp "$options"
+	__gitcomp_opts "$options"
 }
 
 # Generates completion reply from newline-separated possible completion words
@@ -1066,7 +1078,7 @@ __git_complete_strategy ()
 		return 0
 		;;
 	-X)
-		__gitcomp "$__git_merge_strategy_options"
+		__gitcomp_opts "$__git_merge_strategy_options"
 		return 0
 		;;
 	esac
@@ -1076,7 +1088,7 @@ __git_complete_strategy ()
 		return 0
 		;;
 	--strategy-option=*)
-		__gitcomp "$__git_merge_strategy_options" "" "${cur##--strategy-option=}"
+		__gitcomp_opts "$__git_merge_strategy_options" "" "${cur##--strategy-option=}"
 		return 0
 		;;
 	esac
@@ -1318,7 +1330,7 @@ _git_am ()
 {
 	__git_find_repo_path
 	if [ -d "$__git_repo_path"/rebase-apply ]; then
-		__gitcomp "$__git_am_inprogress_options"
+		__gitcomp_opts "$__git_am_inprogress_options"
 		return
 	fi
 	case "$cur" in
@@ -1578,7 +1590,7 @@ _git_cherry_pick ()
 {
 	__git_find_repo_path
 	if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then
-		__gitcomp "$__git_cherry_pick_inprogress_options"
+		__gitcomp_opts "$__git_cherry_pick_inprogress_options"
 		return
 	fi
 
@@ -1737,7 +1749,7 @@ _git_diff ()
 		return
 		;;
 	--*)
-		__gitcomp "$__git_diff_difftool_options"
+		__gitcomp_opts "$__git_diff_difftool_options"
 		return
 		;;
 	esac
@@ -2031,7 +2043,7 @@ _git_log ()
 		return
 		;;
 	--*)
-		__gitcomp "
+		__gitcomp_opts "
 			$__git_log_common_options
 			$__git_log_shortlog_options
 			$__git_log_gitk_options
@@ -2094,7 +2106,7 @@ _git_mergetool ()
 		return
 		;;
 	--*)
-		__gitcomp "--tool= --prompt --no-prompt --gui --no-gui"
+		__gitcomp_opts "--tool= --prompt --no-prompt --gui --no-gui"
 		return
 		;;
 	esac
@@ -2242,7 +2254,7 @@ _git_range_diff ()
 {
 	case "$cur" in
 	--*)
-		__gitcomp "
+		__gitcomp_opts "
 			--creation-factor= --no-dual-color
 			$__git_diff_common_options
 		"
@@ -2259,11 +2271,11 @@ _git_rebase ()
 {
 	__git_find_repo_path
 	if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
-		__gitcomp "$__git_rebase_interactive_inprogress_options"
+		__gitcomp_opts "$__git_rebase_interactive_inprogress_options"
 		return
 	elif [ -d "$__git_repo_path"/rebase-apply ] || \
 	     [ -d "$__git_repo_path"/rebase-merge ]; then
-		__gitcomp "$__git_rebase_inprogress_options"
+		__gitcomp_opts "$__git_rebase_inprogress_options"
 		return
 	fi
 	__git_complete_strategy && return
@@ -2877,7 +2889,7 @@ _git_revert ()
 {
 	__git_find_repo_path
 	if [ -f "$__git_repo_path"/REVERT_HEAD ]; then
-		__gitcomp "$__git_revert_inprogress_options"
+		__gitcomp_opts "$__git_revert_inprogress_options"
 		return
 	fi
 	__git_complete_strategy && return
@@ -2909,7 +2921,7 @@ _git_shortlog ()
 
 	case "$cur" in
 	--*)
-		__gitcomp "
+		__gitcomp_opts "
 			$__git_log_common_options
 			$__git_log_shortlog_options
 			--numbered --summary --email
@@ -2947,7 +2959,7 @@ _git_show ()
 		return
 		;;
 	--*)
-		__gitcomp "--pretty= --format= --abbrev-commit --no-abbrev-commit
+		__gitcomp_opts "--pretty= --format= --abbrev-commit --no-abbrev-commit
 			--oneline --show-signature
 			--expand-tabs --expand-tabs= --no-expand-tabs
 			$__git_diff_common_options
@@ -3073,7 +3085,7 @@ _git_submodule ()
 	if [ -z "$subcommand" ]; then
 		case "$cur" in
 		--*)
-			__gitcomp "--quiet"
+			__gitcomp_opts "--quiet"
 			;;
 		*)
 			__gitcomp "$subcommands"
@@ -3084,29 +3096,29 @@ _git_submodule ()
 
 	case "$subcommand,$cur" in
 	add,--*)
-		__gitcomp "--branch --force --name --reference --depth"
+		__gitcomp_opts "--branch --force --name --reference --depth"
 		;;
 	status,--*)
-		__gitcomp "--cached --recursive"
+		__gitcomp_opts "--cached --recursive"
 		;;
 	deinit,--*)
-		__gitcomp "--force --all"
+		__gitcomp_opts "--force --all"
 		;;
 	update,--*)
-		__gitcomp "
+		__gitcomp_opts "
 			--init --remote --no-fetch
 			--recommend-shallow --no-recommend-shallow
 			--force --rebase --merge --reference --depth --recursive --jobs
 		"
 		;;
 	set-branch,--*)
-		__gitcomp "--default --branch"
+		__gitcomp_opts "--default --branch"
 		;;
 	summary,--*)
-		__gitcomp "--cached --files --summary-limit"
+		__gitcomp_opts "--cached --files --summary-limit"
 		;;
 	foreach,--*|sync,--*)
-		__gitcomp "--recursive"
+		__gitcomp_opts "--recursive"
 		;;
 	*)
 		;;
@@ -3147,64 +3159,64 @@ _git_svn ()
 
 		case "$subcommand,$cur" in
 		fetch,--*)
-			__gitcomp "--revision= --fetch-all $fc_opts"
+			__gitcomp_opts "--revision= --fetch-all $fc_opts"
 			;;
 		clone,--*)
-			__gitcomp "--revision= $fc_opts $init_opts"
+			__gitcomp_opts "--revision= $fc_opts $init_opts"
 			;;
 		init,--*)
-			__gitcomp "$init_opts"
+			__gitcomp_opts "$init_opts"
 			;;
 		dcommit,--*)
-			__gitcomp "
+			__gitcomp_opts "
 				--merge --strategy= --verbose --dry-run
 				--fetch-all --no-rebase --commit-url
 				--revision --interactive $cmt_opts $fc_opts
 				"
 			;;
 		set-tree,--*)
-			__gitcomp "--stdin $cmt_opts $fc_opts"
+			__gitcomp_opts "--stdin $cmt_opts $fc_opts"
 			;;
 		create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
 		show-externals,--*|mkdirs,--*)
-			__gitcomp "--revision="
+			__gitcomp_opts "--revision="
 			;;
 		log,--*)
-			__gitcomp "
+			__gitcomp_opts "
 				--limit= --revision= --verbose --incremental
 				--oneline --show-commit --non-recursive
 				--authors-file= --color
 				"
 			;;
 		rebase,--*)
-			__gitcomp "
+			__gitcomp_opts "
 				--merge --verbose --strategy= --local
 				--fetch-all --dry-run $fc_opts
 				"
 			;;
 		commit-diff,--*)
-			__gitcomp "--message= --file= --revision= $cmt_opts"
+			__gitcomp_opts "--message= --file= --revision= $cmt_opts"
 			;;
 		info,--*)
-			__gitcomp "--url"
+			__gitcomp_opts "--url"
 			;;
 		branch,--*)
-			__gitcomp "--dry-run --message --tag"
+			__gitcomp_opts "--dry-run --message --tag"
 			;;
 		tag,--*)
-			__gitcomp "--dry-run --message"
+			__gitcomp_opts "--dry-run --message"
 			;;
 		blame,--*)
-			__gitcomp "--git-format"
+			__gitcomp_opts "--git-format"
 			;;
 		migrate,--*)
-			__gitcomp "
+			__gitcomp_opts "
 				--config-dir= --ignore-paths= --minimize
 				--no-auth-cache --username=
 				"
 			;;
 		reset,--*)
-			__gitcomp "--revision= --parent"
+			__gitcomp_opts "--revision= --parent"
 			;;
 		*)
 			;;
@@ -3444,7 +3456,7 @@ __git_main ()
 		esac
 		case "$cur" in
 		--*)
-			__gitcomp "
+			__gitcomp_opts "
 			--paginate
 			--no-pager
 			--git-dir=
@@ -3501,7 +3513,7 @@ __gitk_main ()
 	fi
 	case "$cur" in
 	--*)
-		__gitcomp "
+		__gitcomp_opts "
 			$__git_log_common_options
 			$__git_log_gitk_options
 			$merge
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 290fd0252d..83d2bc99a1 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -54,6 +54,14 @@ __gitcomp ()
 {
 	emulate -L zsh
 
+	local IFS=$' \t\n'
+	compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
+}
+
+__gitcomp_opts ()
+{
+	emulate -L zsh
+
 	local cur_="${3-$cur}"
 
 	[[ "$cur_" == *= ]] && return
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index c33543191f..b4ed415245 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -98,17 +98,17 @@ test_completion ()
 	test_cmp expected out_sorted
 }
 
-# Test __gitcomp.
+# Test __gitcomp_opts.
 # The first argument is the typed text so far (cur); the rest are
-# passed to __gitcomp.  Expected output comes is read from the
+# passed to __gitcomp_opts.  Expected output comes is read from the
 # standard input, like test_completion().
-test_gitcomp ()
+test_gitcomp_opts ()
 {
 	local -a COMPREPLY &&
 	sed -e 's/Z$//' >expected &&
 	local cur="$1" &&
 	shift &&
-	__gitcomp "$@" &&
+	__gitcomp_opts "$@" &&
 	print_comp &&
 	test_cmp expected out
 }
@@ -463,8 +463,8 @@ test_expect_success '__gitcomp_direct - puts everything into COMPREPLY as-is' '
 	test_cmp expected out
 '
 
-test_expect_success '__gitcomp - trailing space - options' '
-	test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message=
+test_expect_success '__gitcomp_opts - trailing space - options' '
+	test_gitcomp_opts "--re" "--dry-run --reuse-message= --reedit-message=
 		--reset-author" <<-EOF
 	--reuse-message=Z
 	--reedit-message=Z
@@ -472,8 +472,8 @@ test_expect_success '__gitcomp - trailing space - options' '
 	EOF
 '
 
-test_expect_success '__gitcomp - trailing space - config keys' '
-	test_gitcomp "br" "branch. branch.autosetupmerge
+test_expect_success '__gitcomp_opts - trailing space - config keys' '
+	test_gitcomp_opts "br" "branch. branch.autosetupmerge
 		branch.autosetuprebase browser." <<-\EOF
 	branch.Z
 	branch.autosetupmerge Z
@@ -482,32 +482,32 @@ test_expect_success '__gitcomp - trailing space - config keys' '
 	EOF
 '
 
-test_expect_success '__gitcomp - option parameter' '
-	test_gitcomp "--strategy=re" "octopus ours recursive resolve subtree" \
+test_expect_success '__gitcomp_opts - option parameter' '
+	test_gitcomp_opts "--strategy=re" "octopus ours recursive resolve subtree" \
 		"" "re" <<-\EOF
 	recursive Z
 	resolve Z
 	EOF
 '
 
-test_expect_success '__gitcomp - prefix' '
-	test_gitcomp "branch.maint.me" "remote merge mergeoptions rebase" \
+test_expect_success '__gitcomp_opts - prefix' '
+	test_gitcomp_opts "branch.maint.me" "remote merge mergeoptions rebase" \
 		"branch.maint." "me" <<-\EOF
 	branch.maint.merge Z
 	branch.maint.mergeoptions Z
 	EOF
 '
 
-test_expect_success '__gitcomp - suffix' '
-	test_gitcomp "branch.ma" "master maint next seen" "branch." \
+test_expect_success '__gitcomp_opts - suffix' '
+	test_gitcomp_opts "branch.ma" "master maint next seen" "branch." \
 		"ma" "." <<-\EOF
 	branch.master.Z
 	branch.maint.Z
 	EOF
 '
 
-test_expect_success '__gitcomp - ignore optional negative options' '
-	test_gitcomp "--" "--abc --def --no-one -- --no-two" <<-\EOF
+test_expect_success '__gitcomp_opts - ignore optional negative options' '
+	test_gitcomp_opts "--" "--abc --def --no-one -- --no-two" <<-\EOF
 	--abc Z
 	--def Z
 	--no-one Z
@@ -515,44 +515,44 @@ test_expect_success '__gitcomp - ignore optional negative options' '
 	EOF
 '
 
-test_expect_success '__gitcomp - ignore/narrow optional negative options' '
-	test_gitcomp "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF
+test_expect_success '__gitcomp_opts - ignore/narrow optional negative options' '
+	test_gitcomp_opts "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF
 	--abc Z
 	--abcdef Z
 	EOF
 '
 
-test_expect_success '__gitcomp - ignore/narrow optional negative options' '
-	test_gitcomp "--n" "--abc --def --no-one -- --no-two" <<-\EOF
+test_expect_success '__gitcomp_opts - ignore/narrow optional negative options' '
+	test_gitcomp_opts "--n" "--abc --def --no-one -- --no-two" <<-\EOF
 	--no-one Z
 	--no-... Z
 	EOF
 '
 
-test_expect_success '__gitcomp - expand all negative options' '
-	test_gitcomp "--no-" "--abc --def --no-one -- --no-two" <<-\EOF
+test_expect_success '__gitcomp_opts - expand all negative options' '
+	test_gitcomp_opts "--no-" "--abc --def --no-one -- --no-two" <<-\EOF
 	--no-one Z
 	--no-two Z
 	EOF
 '
 
-test_expect_success '__gitcomp - expand/narrow all negative options' '
-	test_gitcomp "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF
+test_expect_success '__gitcomp_opts - expand/narrow all negative options' '
+	test_gitcomp_opts "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF
 	--no-one Z
 	EOF
 '
 
-test_expect_success '__gitcomp - equal skip' '
-	test_gitcomp "--option=" "--option=" <<-\EOF &&
+test_expect_success '__gitcomp_opts - equal skip' '
+	test_gitcomp_opts "--option=" "--option=" <<-\EOF &&
 
 	EOF
-	test_gitcomp "option=" "option=" <<-\EOF
+	test_gitcomp_opts "option=" "option=" <<-\EOF
 
 	EOF
 '
 
-test_expect_success '__gitcomp - doesnt fail because of invalid variable name' '
-	run_func __gitcomp "$invalid_variable_name"
+test_expect_success '__gitcomp_opts - doesnt fail because of invalid variable name' '
+	run_func __gitcomp_opts "$invalid_variable_name"
 '
 
 read -r -d "" refs <<-\EOF
diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh
index 1c694bec0d..79c1368769 100755
--- a/t/t9904-completion-zsh.sh
+++ b/t/t9904-completion-zsh.sh
@@ -56,16 +56,16 @@ test_completion ()
 	test_cmp expected out_sorted
 }
 
-# Test __gitcomp.
+# Test __gitcomp_opts.
 # The first argument is the typed text so far (cur); the rest are
-# passed to __gitcomp.  Expected output comes is read from the
+# passed to __gitcomp_opts.  Expected output comes is read from the
 # standard input, like test_completion().
-test_gitcomp ()
+test_gitcomp_opts ()
 {
 	sed -e 's/Z$//' >expected &&
 	local cur="$1" &&
 	shift &&
-	run_completion "git func __gitcomp $(printf "%q " "$@") $cur" &&
+	run_completion "git func __gitcomp_opts $(printf "%q " "$@") $cur" &&
 	test_cmp expected out
 }
 
@@ -97,8 +97,8 @@ test_expect_success 'setup for __git_find_repo_path/__gitdir tests' '
 	git init -b main otherrepo
 '
 
-test_expect_success '__gitcomp - trailing space - options' '
-	test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message=
+test_expect_success '__gitcomp_opts - trailing space - options' '
+	test_gitcomp_opts "--re" "--dry-run --reuse-message= --reedit-message=
 		--reset-author" <<-EOF
 	--reuse-message=Z
 	--reedit-message=Z
@@ -106,8 +106,8 @@ test_expect_success '__gitcomp - trailing space - options' '
 	EOF
 '
 
-test_expect_success '__gitcomp - trailing space - config keys' '
-	test_gitcomp "br" "branch. branch.autosetupmerge
+test_expect_success '__gitcomp_opts - trailing space - config keys' '
+	test_gitcomp_opts "br" "branch. branch.autosetupmerge
 		branch.autosetuprebase browser." <<-\EOF
 	branch.Z
 	branch.autosetupmerge Z
@@ -116,32 +116,32 @@ test_expect_success '__gitcomp - trailing space - config keys' '
 	EOF
 '
 
-test_expect_success '__gitcomp - option parameter' '
-	test_gitcomp "--strategy=re" "octopus ours recursive resolve subtree" \
+test_expect_success '__gitcomp_opts - option parameter' '
+	test_gitcomp_opts "--strategy=re" "octopus ours recursive resolve subtree" \
 		"" "re" <<-\EOF
 	recursive Z
 	resolve Z
 	EOF
 '
 
-test_expect_failure '__gitcomp - prefix' '
-	test_gitcomp "branch.maint.me" "remote merge mergeoptions rebase" \
+test_expect_failure '__gitcomp_opts - prefix' '
+	test_gitcomp_opts "branch.maint.me" "remote merge mergeoptions rebase" \
 		"branch.maint." "me" <<-\EOF
 	branch.maint.merge Z
 	branch.maint.mergeoptions Z
 	EOF
 '
 
-test_expect_failure '__gitcomp - suffix' '
-	test_gitcomp "branch.ma" "master maint next seen" "branch." \
+test_expect_failure '__gitcomp_opts - suffix' '
+	test_gitcomp_opts "branch.ma" "master maint next seen" "branch." \
 		"ma" "." <<-\EOF
 	branch.master.Z
 	branch.maint.Z
 	EOF
 '
 
-test_expect_success '__gitcomp - ignore optional negative options' '
-	test_gitcomp "--" "--abc --def --no-one -- --no-two" <<-\EOF
+test_expect_success '__gitcomp_opts - ignore optional negative options' '
+	test_gitcomp_opts "--" "--abc --def --no-one -- --no-two" <<-\EOF
 	--abc Z
 	--def Z
 	--no-one Z
@@ -149,38 +149,38 @@ test_expect_success '__gitcomp - ignore optional negative options' '
 	EOF
 '
 
-test_expect_success '__gitcomp - ignore/narrow optional negative options' '
-	test_gitcomp "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF
+test_expect_success '__gitcomp_opts - ignore/narrow optional negative options' '
+	test_gitcomp_opts "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF
 	--abc Z
 	--abcdef Z
 	EOF
 '
 
-test_expect_success '__gitcomp - ignore/narrow optional negative options' '
-	test_gitcomp "--n" "--abc --def --no-one -- --no-two" <<-\EOF
+test_expect_success '__gitcomp_opts - ignore/narrow optional negative options' '
+	test_gitcomp_opts "--n" "--abc --def --no-one -- --no-two" <<-\EOF
 	--no-one Z
 	--no-... Z
 	EOF
 '
 
-test_expect_success '__gitcomp - expand all negative options' '
-	test_gitcomp "--no-" "--abc --def --no-one -- --no-two" <<-\EOF
+test_expect_success '__gitcomp_opts - expand all negative options' '
+	test_gitcomp_opts "--no-" "--abc --def --no-one -- --no-two" <<-\EOF
 	--no-one Z
 	--no-two Z
 	EOF
 '
 
-test_expect_success '__gitcomp - expand/narrow all negative options' '
-	test_gitcomp "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF
+test_expect_success '__gitcomp_opts - expand/narrow all negative options' '
+	test_gitcomp_opts "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF
 	--no-one Z
 	EOF
 '
 
-test_expect_success '__gitcomp - equal skip' '
-	test_gitcomp "--option=" "--option=" <<-\EOF &&
+test_expect_success '__gitcomp_opts - equal skip' '
+	test_gitcomp_opts "--option=" "--option=" <<-\EOF &&
 
 	EOF
-	test_gitcomp "option=" "option=" <<-\EOF
+	test_gitcomp_opts "option=" "option=" <<-\EOF
 
 	EOF
 '
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 37/49] completion: bash: cleanup __gitcomp* invocations
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (35 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 36/49] completion: add __gitcomp_opts Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 38/49] completion: bash: shuffle __gitcomp functions Felipe Contreras
                   ` (11 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Some __gitcomp calls should be __gitcomp_nl, and vice versa.

No functional changes.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index ba225e999a..bc6f83adce 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1394,7 +1394,7 @@ _git_archive ()
 {
 	case "$cur" in
 	--format=*)
-		__gitcomp "$(git archive --list)" "" "${cur##--format=}"
+		__gitcomp_nl "$(git archive --list)" "" "${cur##--format=}"
 		return
 		;;
 	--remote=*)
@@ -1808,9 +1808,7 @@ _git_format_patch ()
 {
 	case "$cur" in
 	--thread=*)
-		__gitcomp "
-			deep shallow
-			" "" "${cur##--thread=}"
+		__gitcomp "deep shallow" "" "${cur##--thread=}"
 		return
 		;;
 	--base=*|--interdiff=*|--range-diff=*)
@@ -2316,7 +2314,7 @@ _git_send_email ()
 {
 	case "$prev" in
 	--to|--cc|--bcc|--from)
-		__gitcomp "$(__git send-email --dump-aliases)"
+		__gitcomp_nl "$(__git send-email --dump-aliases)"
 		return
 		;;
 	esac
@@ -2340,9 +2338,7 @@ _git_send_email ()
 		return
 		;;
 	--thread=*)
-		__gitcomp "
-			deep shallow
-			" "" "${cur##--thread=}"
+		__gitcomp "deep shallow" "" "${cur##--thread=}"
 		return
 		;;
 	--to=*|--cc=*|--bcc=*|--from=*)
@@ -2642,7 +2638,7 @@ __git_complete_config_variable_name ()
 		local pfx="${cur_%.*}."
 		cur_="${cur_#*.}"
 		__gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
-		__gitcomp_nl $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "$sfx"
+		__gitcomp "autoSetupMerge autoSetupRebase" "$pfx" "$cur_" "$sfx"
 		return
 		;;
 	guitool.*.*)
@@ -2692,7 +2688,7 @@ __git_complete_config_variable_name ()
 		local pfx="${cur_%.*}."
 		cur_="${cur_#*.}"
 		__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
-		__gitcomp_nl "pushDefault" "$pfx" "$cur_" "$sfx"
+		__gitcomp "pushDefault" "$pfx" "$cur_" "$sfx"
 		return
 		;;
 	url.*.*)
@@ -2707,7 +2703,7 @@ __git_complete_config_variable_name ()
 		;;
 	*)
 		__git_compute_config_sections
-		__gitcomp "$__git_config_sections" "" "$cur_" "."
+		__gitcomp_nl "$__git_config_sections" "" "$cur_" "."
 		;;
 	esac
 }
@@ -2801,7 +2797,7 @@ _git_remote ()
 		__gitcomp_builtin remote_update
 		;;
 	update,*)
-		__gitcomp "$(__git_remotes) $(__git_get_config_variables "remotes")"
+		__gitcomp_nl "$(__git_remotes) $(__git_get_config_variables "remotes")"
 		;;
 	set-url,--*)
 		__gitcomp_builtin remote_set-url
@@ -3484,7 +3480,7 @@ __git_main ()
 				then
 					list_cmds=builtins,$list_cmds
 				fi
-				__gitcomp "$(__git --list-cmds=$list_cmds)"
+				__gitcomp_nl "$(__git --list-cmds=$list_cmds)"
 			fi
 			;;
 		esac
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 38/49] completion: bash: shuffle __gitcomp functions
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (36 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 37/49] completion: bash: cleanup __gitcomp* invocations Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 39/49] completion: zsh: simplify __gitcomp_direct Felipe Contreras
                   ` (10 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

They are the ones that actually do the completion, put them at the top.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 270 +++++++++++++------------
 1 file changed, 139 insertions(+), 131 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index bc6f83adce..3f48b61cbe 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -65,6 +65,145 @@
 #     case insensitively, even on systems with case sensitive file systems
 #     (e.g., completing tag name "FOO" on "git checkout f<TAB>").
 
+# The following functions are meant to modify COMPREPLY, which should not be
+# modified directly.  The purpose is to localize the modifications so it's
+# easier to emulate it in Zsh. Every time a new __gitcomp* function is added,
+# the corresponding function should be added to Zsh.
+
+__gitcompadd ()
+{
+	local x i=${#COMPREPLY[@]}
+	for x in $1; do
+		if [[ "$x" == "$3"* ]]; then
+			COMPREPLY[i++]="$2$x$4"
+		fi
+	done
+}
+
+# Creates completion replies.
+# It accepts 1 to 4 arguments:
+# 1: List of possible completion words.
+# 2: A prefix to be added to each possible completion word (optional).
+# 3: Generate possible completion matches for this word (optional).
+# 4: A suffix to be appended to each possible completion word (optional).
+__gitcomp ()
+{
+	local IFS=$' \t\n'
+	__gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
+}
+
+# Generates completion reply from newline-separated possible completion words
+# by appending a space to all of them. The result is appended to COMPREPLY.
+# It accepts 1 to 4 arguments:
+# 1: List of possible completion words, separated by a single newline.
+# 2: A prefix to be added to each possible completion word (optional).
+# 3: Generate possible completion matches for this word (optional).
+# 4: A suffix to be appended to each possible completion word instead of
+#    the default space (optional).  If specified but empty, nothing is
+#    appended.
+__gitcomp_nl ()
+{
+	local IFS=$'\n'
+	__gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
+}
+
+# Appends prefiltered words to COMPREPLY without any additional processing.
+# Callers must take care of providing only words that match the current word
+# to be completed and adding any prefix and/or suffix (trailing space!), if
+# necessary.
+# 1: List of newline-separated matching completion words, complete with
+#    prefix and suffix.
+__gitcomp_direct ()
+{
+	local IFS=$'\n'
+
+	COMPREPLY+=($1)
+}
+
+# Generates completion reply with compgen from newline-separated possible
+# completion filenames.
+# It accepts 1 to 3 arguments:
+# 1: List of possible completion filenames, separated by a single newline.
+# 2: A directory prefix to be added to each possible completion filename
+#    (optional).
+# 3: Generate possible completion matches for this word (optional).
+__gitcomp_file ()
+{
+	local IFS=$'\n'
+
+	# XXX does not work when the directory prefix contains a tilde,
+	# since tilde expansion is not applied.
+	# This means that COMPREPLY will be empty and Bash default
+	# completion will be used.
+	__gitcompadd "$1" "${2-}" "${3-$cur}" ""
+
+	# use a hack to enable file mode in bash < 4
+	compopt -o filenames +o nospace 2>/dev/null ||
+	compgen -f /non-existing-dir/ >/dev/null ||
+	true
+}
+
+# Fills the COMPREPLY array with prefiltered paths without any additional
+# processing.
+# Callers must take care of providing only paths that match the current path
+# to be completed and adding any prefix path components, if necessary.
+# 1: List of newline-separated matching paths, complete with all prefix
+#    path components.
+__gitcomp_file_direct ()
+{
+	local IFS=$'\n'
+
+	COMPREPLY+=($1)
+
+	# use a hack to enable file mode in bash < 4
+	compopt -o filenames +o nospace 2>/dev/null ||
+	compgen -f /non-existing-dir/ >/dev/null ||
+	true
+}
+
+# Creates completion replies, reorganizing options and adding suffixes as needed.
+# It accepts 1 to 4 arguments:
+# 1: List of possible completion words.
+# 2: A prefix to be added to each possible completion word (optional).
+# 3: Generate possible completion matches for this word (optional).
+# 4: A suffix to be appended to each possible completion word (optional).
+__gitcomp_opts ()
+{
+	local cur_="${3-$cur}"
+
+	if [[ "$cur_" == *= ]]; then
+		return
+	fi
+
+	local c i=0 IFS=$' \t\n' sfx
+	for c in $1; do
+		if [[ $c == "--" ]]; then
+			if [[ "$cur_" == --no-* ]]; then
+				continue
+			fi
+
+			if [[ --no == "$cur_"* ]]; then
+				COMPREPLY[i++]="--no-... "
+			fi
+			break
+		fi
+		if [[ $c == "$cur_"* ]]; then
+			if [[ -z "${4+set}" ]]; then
+				case $c in
+				*=|*.) sfx="" ;;
+				*) sfx=" " ;;
+				esac
+			else
+				sfx="$4"
+			fi
+			COMPREPLY[i++]="${2-}$c$sfx"
+		fi
+	done
+}
+
+# __gitcomp functions end here
+# ==============================================================================
+
 # 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.
@@ -307,81 +446,6 @@ _get_comp_words_by_ref ()
 }
 fi
 
-# Appends prefiltered words to COMPREPLY without any additional processing.
-# Callers must take care of providing only words that match the current word
-# to be completed and adding any prefix and/or suffix (trailing space!), if
-# necessary.
-# 1: List of newline-separated matching completion words, complete with
-#    prefix and suffix.
-__gitcomp_direct ()
-{
-	local IFS=$'\n'
-
-	COMPREPLY+=($1)
-}
-
-__gitcompadd ()
-{
-	local x i=${#COMPREPLY[@]}
-	for x in $1; do
-		if [[ "$x" == "$3"* ]]; then
-			COMPREPLY[i++]="$2$x$4"
-		fi
-	done
-}
-
-# Creates completion replies.
-# It accepts 1 to 4 arguments:
-# 1: List of possible completion words.
-# 2: A prefix to be added to each possible completion word (optional).
-# 3: Generate possible completion matches for this word (optional).
-# 4: A suffix to be appended to each possible completion word (optional).
-__gitcomp ()
-{
-	local IFS=$' \t\n'
-	__gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
-}
-
-# Creates completion replies, reorganizing options and adding suffixes as needed.
-# It accepts 1 to 4 arguments:
-# 1: List of possible completion words.
-# 2: A prefix to be added to each possible completion word (optional).
-# 3: Generate possible completion matches for this word (optional).
-# 4: A suffix to be appended to each possible completion word (optional).
-__gitcomp_opts ()
-{
-	local cur_="${3-$cur}"
-
-	if [[ "$cur_" == *= ]]; then
-		return
-	fi
-
-	local c i=0 IFS=$' \t\n' sfx
-	for c in $1; do
-		if [[ $c == "--" ]]; then
-			if [[ "$cur_" == --no-* ]]; then
-				continue
-			fi
-
-			if [[ --no == "$cur_"* ]]; then
-				COMPREPLY[i++]="--no-... "
-			fi
-			break
-		fi
-		if [[ $c == "$cur_"* ]]; then
-			if [[ -z "${4+set}" ]]; then
-				case $c in
-				*=|*.) sfx="" ;;
-				*) sfx=" " ;;
-				esac
-			else
-				sfx="$4"
-			fi
-			COMPREPLY[i++]="${2-}$c$sfx"
-		fi
-	done
-}
-
 # Clear the variables caching builtins' options when (re-)sourcing
 # the completion script.
 if [[ -n ${ZSH_VERSION-} ]]; then
@@ -430,62 +494,6 @@ __gitcomp_builtin ()
 	__gitcomp_opts "$options"
 }
 
-# Generates completion reply from newline-separated possible completion words
-# by appending a space to all of them. The result is appended to COMPREPLY.
-# It accepts 1 to 4 arguments:
-# 1: List of possible completion words, separated by a single newline.
-# 2: A prefix to be added to each possible completion word (optional).
-# 3: Generate possible completion matches for this word (optional).
-# 4: A suffix to be appended to each possible completion word instead of
-#    the default space (optional).  If specified but empty, nothing is
-#    appended.
-__gitcomp_nl ()
-{
-	local IFS=$'\n'
-	__gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
-}
-
-# Fills the COMPREPLY array with prefiltered paths without any additional
-# processing.
-# Callers must take care of providing only paths that match the current path
-# to be completed and adding any prefix path components, if necessary.
-# 1: List of newline-separated matching paths, complete with all prefix
-#    path components.
-__gitcomp_file_direct ()
-{
-	local IFS=$'\n'
-
-	COMPREPLY+=($1)
-
-	# use a hack to enable file mode in bash < 4
-	compopt -o filenames +o nospace 2>/dev/null ||
-	compgen -f /non-existing-dir/ >/dev/null ||
-	true
-}
-
-# Generates completion reply with compgen from newline-separated possible
-# completion filenames.
-# It accepts 1 to 3 arguments:
-# 1: List of possible completion filenames, separated by a single newline.
-# 2: A directory prefix to be added to each possible completion filename
-#    (optional).
-# 3: Generate possible completion matches for this word (optional).
-__gitcomp_file ()
-{
-	local IFS=$'\n'
-
-	# XXX does not work when the directory prefix contains a tilde,
-	# since tilde expansion is not applied.
-	# This means that COMPREPLY will be empty and Bash default
-	# completion will be used.
-	__gitcompadd "$1" "${2-}" "${3-$cur}" ""
-
-	# use a hack to enable file mode in bash < 4
-	compopt -o filenames +o nospace 2>/dev/null ||
-	compgen -f /non-existing-dir/ >/dev/null ||
-	true
-}
-
 # Execute 'git ls-files', unless the --committable option is specified, in
 # which case it runs 'git diff-index' to find out the files that can be
 # committed.  It return paths relative to the directory specified in the first
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 39/49] completion: zsh: simplify __gitcomp_direct
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (37 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 38/49] completion: bash: shuffle __gitcomp functions Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 40/49] completion: zsh: shuffle __gitcomp* functions Felipe Contreras
                   ` (9 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Not much different from __gitcomp_nl.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 83d2bc99a1..170f3d7f5e 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -90,9 +90,7 @@ __gitcomp_opts ()
 
 __gitcomp_direct ()
 {
-	emulate -L zsh
-
-	compadd -Q -S '' -- ${(f)1} && _ret=0
+	__gitcomp_nl "$1" "" "" ""
 }
 
 __gitcomp_nl ()
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 40/49] completion: zsh: shuffle __gitcomp* functions
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (38 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 39/49] completion: zsh: simplify __gitcomp_direct Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 41/49] completion: zsh: fix direct quoting Felipe Contreras
                   ` (8 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 170f3d7f5e..dc04c5b703 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -88,11 +88,6 @@ __gitcomp_opts ()
 	compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
 }
 
-__gitcomp_direct ()
-{
-	__gitcomp_nl "$1" "" "" ""
-}
-
 __gitcomp_nl ()
 {
 	emulate -L zsh
@@ -107,6 +102,11 @@ __gitcomp_file ()
 	compadd -f -p "${2-}" -- ${(f)1} && _ret=0
 }
 
+__gitcomp_direct ()
+{
+	__gitcomp_nl "$1" "" "" ""
+}
+
 __gitcomp_file_direct ()
 {
 	__gitcomp_file "$1" ""
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 41/49] completion: zsh: fix direct quoting
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (39 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 40/49] completion: zsh: shuffle __gitcomp* functions Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 42/49] completion: zsh: add elements individually in __gitcomp_opts Felipe Contreras
                   ` (7 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Apparently using "compadd -Q" is almost always wrong, we want zsh to add
quoting when necessary. However, if we remove the -Q option, that would
make zsh add an extra "\ " at the end of some completions.

We can manually remove the spaces from the completions that have them,
and then add the suffix with the -S option, thus there's no more need
for the -Q option.

This makes completions like "stash@{0}" complete correctly:

  git stash show <tab>

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index dc04c5b703..e2a7f55539 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -55,7 +55,7 @@ __gitcomp ()
 	emulate -L zsh
 
 	local IFS=$' \t\n'
-	compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
+	compadd -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
 }
 
 __gitcomp_opts ()
@@ -85,14 +85,17 @@ __gitcomp_opts ()
 		fi
 		array+=("$c$sfx")
 	done
-	compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
+	compadd -S '' -p "${2-}" -a -- array && _ret=0
 }
 
 __gitcomp_nl ()
 {
 	emulate -L zsh
 
-	compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0
+	# words that don't end up in space
+	compadd -p "${2-}" -S "${4- }" -q -- ${${(f)1}:#*\ } && _ret=0
+	# words that end in space
+	compadd -p "${2-}" -S " ${4- }" -q -- ${${(M)${(f)1}:#*\ }% } && _ret=0
 }
 
 __gitcomp_file ()
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 42/49] completion: zsh: add elements individually in __gitcomp_opts
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (40 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 41/49] completion: zsh: fix direct quoting Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 43/49] completion: zsh: add __gitcompadd helper Felipe Contreras
                   ` (6 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

It's useful to specify specific suffixes for specific words.

This will be useful later on.

Additionally two tests now pass because we are not using an array
anymore.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 6 ++----
 t/t9904-completion-zsh.sh             | 4 ++--
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index e2a7f55539..ba7b0a7dbc 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -67,11 +67,10 @@ __gitcomp_opts ()
 	[[ "$cur_" == *= ]] && return
 
 	local c IFS=$' \t\n' sfx
-	local -a array
 	for c in ${=1}; do
 		if [[ $c == "--" ]]; then
 			[[ "$cur_" == --no-* ]] && continue
-			array+=("--no-... ")
+			compadd -S " " -- "--no-..." && _ret=0
 			break
 		fi
 
@@ -83,9 +82,8 @@ __gitcomp_opts ()
 		else
 			sfx="$4"
 		fi
-		array+=("$c$sfx")
+		compadd -S "$sfx" -p "${2-}" -- "$c" && _ret=0
 	done
-	compadd -S '' -p "${2-}" -a -- array && _ret=0
 }
 
 __gitcomp_nl ()
diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh
index 79c1368769..24fb2dda00 100755
--- a/t/t9904-completion-zsh.sh
+++ b/t/t9904-completion-zsh.sh
@@ -124,7 +124,7 @@ test_expect_success '__gitcomp_opts - option parameter' '
 	EOF
 '
 
-test_expect_failure '__gitcomp_opts - prefix' '
+test_expect_success '__gitcomp_opts - prefix' '
 	test_gitcomp_opts "branch.maint.me" "remote merge mergeoptions rebase" \
 		"branch.maint." "me" <<-\EOF
 	branch.maint.merge Z
@@ -132,7 +132,7 @@ test_expect_failure '__gitcomp_opts - prefix' '
 	EOF
 '
 
-test_expect_failure '__gitcomp_opts - suffix' '
+test_expect_success '__gitcomp_opts - suffix' '
 	test_gitcomp_opts "branch.ma" "master maint next seen" "branch." \
 		"ma" "." <<-\EOF
 	branch.master.Z
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 43/49] completion: zsh: add __gitcompadd helper
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (41 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 42/49] completion: zsh: add elements individually in __gitcomp_opts Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 44/49] completion: zsh: add correct removable suffix Felipe Contreras
                   ` (5 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

So we don't have to do the same over and over.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index ba7b0a7dbc..522b59cf5b 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -50,12 +50,16 @@ COMP_WORDBREAKS=':'
 GIT_SOURCING_ZSH_COMPLETION=y . "$script"
 functions[complete]="$old_complete"
 
+__gitcompadd ()
+{
+	compadd -p "${2-}" -S "${3- }" -- ${=1} && _ret=0
+}
+
 __gitcomp ()
 {
 	emulate -L zsh
 
-	local IFS=$' \t\n'
-	compadd -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
+	IFS=$' \t\n' __gitcompadd "$1" "${2-}" "${4- }"
 }
 
 __gitcomp_opts ()
@@ -70,7 +74,7 @@ __gitcomp_opts ()
 	for c in ${=1}; do
 		if [[ $c == "--" ]]; then
 			[[ "$cur_" == --no-* ]] && continue
-			compadd -S " " -- "--no-..." && _ret=0
+			__gitcompadd "--no-..."
 			break
 		fi
 
@@ -82,7 +86,7 @@ __gitcomp_opts ()
 		else
 			sfx="$4"
 		fi
-		compadd -S "$sfx" -p "${2-}" -- "$c" && _ret=0
+		__gitcompadd "$c" "${2-}" "$sfx"
 	done
 }
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 44/49] completion: zsh: add correct removable suffix
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (42 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 43/49] completion: zsh: add __gitcompadd helper Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 45/49] completion: bash: simplify _get_comp_words_by_ref() Felipe Contreras
                   ` (4 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Zsh has a nice feature that allows a suffix to be automatically removed
if followed by a space.

For example:

  git log --prety=

If a space is typed, the suffix '=' is removed.

But we have to set the correct prefix first.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 522b59cf5b..31bf88c1c5 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -52,7 +52,7 @@ functions[complete]="$old_complete"
 
 __gitcompadd ()
 {
-	compadd -p "${2-}" -S "${3- }" -- ${=1} && _ret=0
+	compadd -p "${2-}" -S "${3- }" -q -- ${=1} && _ret=0
 }
 
 __gitcomp ()
@@ -80,7 +80,8 @@ __gitcomp_opts ()
 
 		if [[ -z "${4+set}" ]]; then
 			case $c in
-			*=|*.) sfx="" ;;
+			*=) c="${c%=}"; sfx="=" ;;
+			*.) sfx="" ;;
 			*) sfx=" " ;;
 			esac
 		else
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 45/49] completion: bash: simplify _get_comp_words_by_ref()
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (43 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 44/49] completion: zsh: add correct removable suffix Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 46/49] completion: bash: refactor _get_comp_words_by_ref() Felipe Contreras
                   ` (3 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

We don't need the whole functionality of _get_comp_words_by_ref(), we
know exactly what we need from that function, so only do that.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 30 ++++++--------------------
 t/t9902-completion.sh                  | 21 ++++--------------
 2 files changed, 10 insertions(+), 41 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 3f48b61cbe..7b46ce503d 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -419,30 +419,12 @@ __git_reassemble_comp_words_by_ref()
 if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
 _get_comp_words_by_ref ()
 {
-	local exclude cur_ words_ cword_
-	if [ "$1" = "-n" ]; then
-		exclude=$2
-		shift 2
-	fi
-	__git_reassemble_comp_words_by_ref "$exclude"
-	cur_=${words_[cword_]}
-	while [ $# -gt 0 ]; do
-		case "$1" in
-		cur)
-			cur=$cur_
-			;;
-		prev)
-			prev=${words_[$cword_-1]}
-			;;
-		words)
-			words=("${words_[@]}")
-			;;
-		cword)
-			cword=$cword_
-			;;
-		esac
-		shift
-	done
+	local words_ cword_
+	__git_reassemble_comp_words_by_ref "=:"
+	cword=$cword_
+	cur=${words_[cword]}
+	prev=${words_[cword-1]}
+	words=("${words_[@]}")
 }
 fi
 
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index b4ed415245..fdc81d5d3f 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -40,23 +40,10 @@ GIT_TESTING_PORCELAIN_COMMAND_LIST='add checkout rebase'
 # So let's override it with a minimal version for testing purposes.
 _get_comp_words_by_ref ()
 {
-	while [ $# -gt 0 ]; do
-		case "$1" in
-		cur)
-			cur=${_words[_cword]}
-			;;
-		prev)
-			prev=${_words[_cword-1]}
-			;;
-		words)
-			words=("${_words[@]}")
-			;;
-		cword)
-			cword=$_cword
-			;;
-		esac
-		shift
-	done
+	cword=$_cword
+	cur=${_words[cword]}
+	prev=${_words[cword-1]}
+	words=("${_words[@]}")
 }
 
 print_comp ()
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 46/49] completion: bash: refactor _get_comp_words_by_ref()
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (44 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 45/49] completion: bash: simplify _get_comp_words_by_ref() Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 47/49] completion: bash: cleanup _get_comp_words_by_ref() Felipe Contreras
                   ` (2 subsequent siblings)
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

We don't need a separate function to do what we already know we want to
do.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 109 +++++++++++--------------
 1 file changed, 47 insertions(+), 62 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 7b46ce503d..63a9409b0e 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -345,21 +345,11 @@ __git_dequote ()
 #
 #   RELEASE: 2.x
 
-# This function can be used to access a tokenized list of words
-# on the command line:
-#
-#	__git_reassemble_comp_words_by_ref '=:'
-#	if test "${words_[cword_-1]}" = -w
-#	then
-#		...
-#	fi
-#
-# The argument should be a collection of characters from the list of
-# word completion separators (COMP_WORDBREAKS) to treat as ordinary
-# characters.
+# This function reorganizes the words on the command line to be processed by
+# the rest of the script.
 #
 # This is roughly equivalent to going back in time and setting
-# COMP_WORDBREAKS to exclude those characters.  The intent is to
+# COMP_WORDBREAKS to exclude '=' and ':'.  The intent is to
 # make option types like --date=<type> and <rev>:<path> easy to
 # recognize by treating each shell word as a single token.
 #
@@ -367,60 +357,55 @@ __git_dequote ()
 # shared with other completion scripts.  By the time the completion
 # function gets called, COMP_WORDS has already been populated so local
 # changes to COMP_WORDBREAKS have no effect.
-#
-# Output: words_, cword_, cur_.
-
-__git_reassemble_comp_words_by_ref()
-{
-	local exclude i j first
-	# Which word separators to exclude?
-	exclude="${1//[^$COMP_WORDBREAKS]}"
-	cword_=$COMP_CWORD
-	if [ -z "$exclude" ]; then
-		words_=("${COMP_WORDS[@]}")
-		return
-	fi
-	# List of word completion separators has shrunk;
-	# re-assemble words to complete.
-	for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
-		# Append each nonempty word consisting of just
-		# word separator characters to the current word.
-		first=t
-		while
-			[ $i -gt 0 ] &&
-			[ -n "${COMP_WORDS[$i]}" ] &&
-			# word consists of excluded word separators
-			[ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
-		do
-			# Attach to the previous token,
-			# unless the previous token is the command name.
-			if [ $j -ge 2 ] && [ -n "$first" ]; then
-				((j--))
-			fi
-			first=
-			words_[$j]=${words_[j]}${COMP_WORDS[i]}
-			if [ $i = $COMP_CWORD ]; then
-				cword_=$j
-			fi
-			if (($i < ${#COMP_WORDS[@]} - 1)); then
-				((i++))
-			else
-				# Done.
-				return
-			fi
-		done
-		words_[$j]=${words_[j]}${COMP_WORDS[i]}
-		if [ $i = $COMP_CWORD ]; then
-			cword_=$j
-		fi
-	done
-}
 
 if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
 _get_comp_words_by_ref ()
 {
 	local words_ cword_
-	__git_reassemble_comp_words_by_ref "=:"
+	local exclude i j first
+
+	# Which word separators to exclude?
+	exclude="${COMP_WORDBREAKS//[^=:]}"
+	cword_=$COMP_CWORD
+	if [ -z "$exclude" ]; then
+		words_=("${COMP_WORDS[@]}")
+	else
+		# List of word completion separators has shrunk;
+		# re-assemble words to complete.
+		for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
+			# Append each nonempty word consisting of just
+			# word separator characters to the current word.
+			first=t
+			while
+				[ $i -gt 0 ] &&
+				[ -n "${COMP_WORDS[$i]}" ] &&
+				# word consists of excluded word separators
+				[ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
+			do
+				# Attach to the previous token,
+				# unless the previous token is the command name.
+				if [ $j -ge 2 ] && [ -n "$first" ]; then
+					((j--))
+				fi
+				first=
+				words_[$j]=${words_[j]}${COMP_WORDS[i]}
+				if [ $i = $COMP_CWORD ]; then
+					cword_=$j
+				fi
+				if (($i < ${#COMP_WORDS[@]} - 1)); then
+					((i++))
+				else
+					# Done.
+					break 2
+				fi
+			done
+			words_[$j]=${words_[j]}${COMP_WORDS[i]}
+			if [ $i = $COMP_CWORD ]; then
+				cword_=$j
+			fi
+		done
+	fi
+
 	cword=$cword_
 	cur=${words_[cword]}
 	prev=${words_[cword-1]}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 47/49] completion: bash: cleanup _get_comp_words_by_ref()
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (45 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 46/49] completion: bash: refactor _get_comp_words_by_ref() Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 48/49] completion: bash: trivial cleanup Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 49/49] completion: bash: rename _get_comp_words_by_ref() Felipe Contreras
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Remove temporary variables.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 63a9409b0e..1b594f01cb 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -361,14 +361,13 @@ __git_dequote ()
 if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
 _get_comp_words_by_ref ()
 {
-	local words_ cword_
 	local exclude i j first
 
 	# Which word separators to exclude?
 	exclude="${COMP_WORDBREAKS//[^=:]}"
-	cword_=$COMP_CWORD
+	cword=$COMP_CWORD
 	if [ -z "$exclude" ]; then
-		words_=("${COMP_WORDS[@]}")
+		words=("${COMP_WORDS[@]}")
 	else
 		# List of word completion separators has shrunk;
 		# re-assemble words to complete.
@@ -388,9 +387,9 @@ _get_comp_words_by_ref ()
 					((j--))
 				fi
 				first=
-				words_[$j]=${words_[j]}${COMP_WORDS[i]}
+				words[$j]=${words[j]}${COMP_WORDS[i]}
 				if [ $i = $COMP_CWORD ]; then
-					cword_=$j
+					cword=$j
 				fi
 				if (($i < ${#COMP_WORDS[@]} - 1)); then
 					((i++))
@@ -399,17 +398,15 @@ _get_comp_words_by_ref ()
 					break 2
 				fi
 			done
-			words_[$j]=${words_[j]}${COMP_WORDS[i]}
+			words[$j]=${words[j]}${COMP_WORDS[i]}
 			if [ $i = $COMP_CWORD ]; then
-				cword_=$j
+				cword=$j
 			fi
 		done
 	fi
 
-	cword=$cword_
-	cur=${words_[cword]}
-	prev=${words_[cword-1]}
-	words=("${words_[@]}")
+	cur=${words[cword]}
+	prev=${words[cword-1]}
 }
 fi
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 48/49] completion: bash: trivial cleanup
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (46 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 47/49] completion: bash: cleanup _get_comp_words_by_ref() Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  2023-04-01  8:46 ` [PATCH v7 49/49] completion: bash: rename _get_comp_words_by_ref() Felipe Contreras
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

The most typical case first (COMP_WORDBREAKS contains our wanted words).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 1b594f01cb..912e9bace0 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -366,9 +366,7 @@ _get_comp_words_by_ref ()
 	# Which word separators to exclude?
 	exclude="${COMP_WORDBREAKS//[^=:]}"
 	cword=$COMP_CWORD
-	if [ -z "$exclude" ]; then
-		words=("${COMP_WORDS[@]}")
-	else
+	if [ -n "$exclude" ]; then
 		# List of word completion separators has shrunk;
 		# re-assemble words to complete.
 		for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
@@ -403,6 +401,8 @@ _get_comp_words_by_ref ()
 				cword=$j
 			fi
 		done
+	else
+		words=("${COMP_WORDS[@]}")
 	fi
 
 	cur=${words[cword]}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH v7 49/49] completion: bash: rename _get_comp_words_by_ref()
  2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
                   ` (47 preceding siblings ...)
  2023-04-01  8:46 ` [PATCH v7 48/49] completion: bash: trivial cleanup Felipe Contreras
@ 2023-04-01  8:46 ` Felipe Contreras
  48 siblings, 0 replies; 50+ messages in thread
From: Felipe Contreras @ 2023-04-01  8:46 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

It's only used in one place, rename it, and use it even if
bash-completion's more inefficient version of _get_comp_words_by_ref()
is available.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 186 ++++++++++++-------------
 t/t9902-completion.sh                  |   2 +-
 2 files changed, 94 insertions(+), 94 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 912e9bace0..b36db3f845 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -318,98 +318,6 @@ __git_dequote ()
 	done
 }
 
-# The following function is based on code from:
-#
-#   bash_completion - programmable completion functions for bash 3.2+
-#
-#   Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
-#             © 2009-2010, Bash Completion Maintainers
-#                     <bash-completion-devel@lists.alioth.debian.org>
-#
-#   This program is free software; you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation; either version 2, or (at your option)
-#   any later version.
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#   GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with this program; if not, see <http://www.gnu.org/licenses/>.
-#
-#   The latest version of this software can be obtained here:
-#
-#   http://bash-completion.alioth.debian.org/
-#
-#   RELEASE: 2.x
-
-# This function reorganizes the words on the command line to be processed by
-# the rest of the script.
-#
-# This is roughly equivalent to going back in time and setting
-# COMP_WORDBREAKS to exclude '=' and ':'.  The intent is to
-# make option types like --date=<type> and <rev>:<path> easy to
-# recognize by treating each shell word as a single token.
-#
-# It is best not to set COMP_WORDBREAKS directly because the value is
-# shared with other completion scripts.  By the time the completion
-# function gets called, COMP_WORDS has already been populated so local
-# changes to COMP_WORDBREAKS have no effect.
-
-if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
-_get_comp_words_by_ref ()
-{
-	local exclude i j first
-
-	# Which word separators to exclude?
-	exclude="${COMP_WORDBREAKS//[^=:]}"
-	cword=$COMP_CWORD
-	if [ -n "$exclude" ]; then
-		# List of word completion separators has shrunk;
-		# re-assemble words to complete.
-		for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
-			# Append each nonempty word consisting of just
-			# word separator characters to the current word.
-			first=t
-			while
-				[ $i -gt 0 ] &&
-				[ -n "${COMP_WORDS[$i]}" ] &&
-				# word consists of excluded word separators
-				[ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
-			do
-				# Attach to the previous token,
-				# unless the previous token is the command name.
-				if [ $j -ge 2 ] && [ -n "$first" ]; then
-					((j--))
-				fi
-				first=
-				words[$j]=${words[j]}${COMP_WORDS[i]}
-				if [ $i = $COMP_CWORD ]; then
-					cword=$j
-				fi
-				if (($i < ${#COMP_WORDS[@]} - 1)); then
-					((i++))
-				else
-					# Done.
-					break 2
-				fi
-			done
-			words[$j]=${words[j]}${COMP_WORDS[i]}
-			if [ $i = $COMP_CWORD ]; then
-				cword=$j
-			fi
-		done
-	else
-		words=("${COMP_WORDS[@]}")
-	fi
-
-	cur=${words[cword]}
-	prev=${words[cword-1]}
-}
-fi
-
 # Clear the variables caching builtins' options when (re-)sourcing
 # the completion script.
 if [[ -n ${ZSH_VERSION-} ]]; then
@@ -3497,10 +3405,102 @@ if [[ -n ${ZSH_VERSION-} && -z ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then
 	return
 fi
 
+# The following function is based on code from:
+#
+#   bash_completion - programmable completion functions for bash 3.2+
+#
+#   Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
+#             © 2009-2010, Bash Completion Maintainers
+#                     <bash-completion-devel@lists.alioth.debian.org>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2, or (at your option)
+#   any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+#   The latest version of this software can be obtained here:
+#
+#   http://bash-completion.alioth.debian.org/
+#
+#   RELEASE: 2.x
+
+# This function reorganizes the words on the command line to be processed by
+# the rest of the script.
+#
+# This is roughly equivalent to going back in time and setting
+# COMP_WORDBREAKS to exclude '=' and ':'.  The intent is to
+# make option types like --date=<type> and <rev>:<path> easy to
+# recognize by treating each shell word as a single token.
+#
+# It is best not to set COMP_WORDBREAKS directly because the value is
+# shared with other completion scripts.  By the time the completion
+# function gets called, COMP_WORDS has already been populated so local
+# changes to COMP_WORDBREAKS have no effect.
+
+if ! type __git_get_comp_words_by_ref >/dev/null 2>&1; then
+__git_get_comp_words_by_ref ()
+{
+	local exclude i j first
+
+	# Which word separators to exclude?
+	exclude="${COMP_WORDBREAKS//[^=:]}"
+	cword=$COMP_CWORD
+	if [ -n "$exclude" ]; then
+		# List of word completion separators has shrunk;
+		# re-assemble words to complete.
+		for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
+			# Append each nonempty word consisting of just
+			# word separator characters to the current word.
+			first=t
+			while
+				[ $i -gt 0 ] &&
+				[ -n "${COMP_WORDS[$i]}" ] &&
+				# word consists of excluded word separators
+				[ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
+			do
+				# Attach to the previous token,
+				# unless the previous token is the command name.
+				if [ $j -ge 2 ] && [ -n "$first" ]; then
+					((j--))
+				fi
+				first=
+				words[$j]=${words[j]}${COMP_WORDS[i]}
+				if [ $i = $COMP_CWORD ]; then
+					cword=$j
+				fi
+				if (($i < ${#COMP_WORDS[@]} - 1)); then
+					((i++))
+				else
+					# Done.
+					break 2
+				fi
+			done
+			words[$j]=${words[j]}${COMP_WORDS[i]}
+			if [ $i = $COMP_CWORD ]; then
+				cword=$j
+			fi
+		done
+	else
+		words=("${COMP_WORDS[@]}")
+	fi
+
+	cur=${words[cword]}
+	prev=${words[cword-1]}
+}
+fi
+
 __git_func_wrap ()
 {
 	local cur words cword prev __git_cmd_idx=0
-	_get_comp_words_by_ref -n =: cur words cword prev
+	__git_get_comp_words_by_ref
 	$1
 }
 
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index fdc81d5d3f..18f88133de 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -38,7 +38,7 @@ GIT_TESTING_PORCELAIN_COMMAND_LIST='add checkout rebase'
 # We don't need this function to actually join words or do anything special.
 # Also, it's cleaner to avoid touching bash's internal completion variables.
 # So let's override it with a minimal version for testing purposes.
-_get_comp_words_by_ref ()
+__git_get_comp_words_by_ref ()
 {
 	cword=$_cword
 	cur=${_words[cword]}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2023-04-01  8:50 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-01  8:45 [PATCH v7 00/49] completion: git-completion 2.0 patches Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 01/49] test: completion add test for __git_cmd_idx Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 02/49] completion: bash: trivial cleanup Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 03/49] zsh: remove version Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 04/49] completion: bash: trivial grammar fix Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 05/49] completion: zsh: add higher-priority location Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 06/49] zsh: resolve symlink of script Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 07/49] zsh: simplify realpath dirname idiom Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 08/49] test: completion: use global config Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 09/49] completion: fix __git_cmd_idx regression for zsh Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 10/49] completion: fix for suboptions with value Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 11/49] completion: zsh: trivial improvement Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 12/49] completion: bash: do not modify COMP_WORDBREAKS Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 13/49] test: completion: fix currently typed words Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 14/49] test: completion: switch __gitcomp_nl prefix test Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 15/49] test: completion: add run_func() helper Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 16/49] completion: bash: remove non-append functionality Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 17/49] completion: bash: get rid of _append() functions Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 18/49] completion: bash: get rid of any non-append code Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 19/49] completion: zsh: fix options with arguments Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 20/49] completion: zsh: expand --git-dir file argument Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 21/49] completion: zsh: add support for general -C opts Felipe Contreras
2023-04-01  8:45 ` [PATCH v7 22/49] completion: zsh: fix for undefined completions Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 23/49] completion: zsh: add support for general -c opts Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 24/49] completion: zsh: fix extra space on foo= Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 25/49] completion: zsh: add excluded options Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 26/49] completion: zsh: always set compset Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 27/49] completion: factor out check in __gitcomp Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 28/49] completion: simplify equal suffix check Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 29/49] completion: refactor __gitcomp Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 30/49] completion: simplify __gitcomp Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 31/49] completion: bash: change suffix check in __gitcomp Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 32/49] completion: improve __gitcomp suffix code Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 33/49] test: completion: add missing test Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 34/49] completion: bash: simplify config_variable_name Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 35/49] completion: bash: improve __gitcomp description Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 36/49] completion: add __gitcomp_opts Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 37/49] completion: bash: cleanup __gitcomp* invocations Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 38/49] completion: bash: shuffle __gitcomp functions Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 39/49] completion: zsh: simplify __gitcomp_direct Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 40/49] completion: zsh: shuffle __gitcomp* functions Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 41/49] completion: zsh: fix direct quoting Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 42/49] completion: zsh: add elements individually in __gitcomp_opts Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 43/49] completion: zsh: add __gitcompadd helper Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 44/49] completion: zsh: add correct removable suffix Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 45/49] completion: bash: simplify _get_comp_words_by_ref() Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 46/49] completion: bash: refactor _get_comp_words_by_ref() Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 47/49] completion: bash: cleanup _get_comp_words_by_ref() Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 48/49] completion: bash: trivial cleanup Felipe Contreras
2023-04-01  8:46 ` [PATCH v7 49/49] completion: bash: rename _get_comp_words_by_ref() Felipe Contreras

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.