All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/45] completion: git-completion 1.3.3 patches
@ 2021-06-18 18:24 Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 01/45] completion: fix __git_cmd_idx regression Felipe Contreras
                   ` (44 more replies)
  0 siblings, 45 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

completion: git-completion 1.3.1 patches

These patches represent what comprises git-completion 1.3.1, a friendly
fork I'm maintaining.

Some of these have already been sent, and should be in "seen", but for
some reason they are not [1]. Others have been sent, but probably won't
receive any review soon.

Since the patches for git-completion 1.3.0 the only differece is a
rebase on top of v2.31.0.

Cheers.

[1] https://lore.kernel.org/git/5fea87e816fff_23821208d4@natae.notmuch/

Felipe Contreras (45):
  completion: fix __git_cmd_idx regression
  completion: bash: fix prefix detection in branch.*
  completion: fix for suboptions with value
  completion: bash: fix for multiple dash commands
  completion: bash: add correct suffix in variables
  completion: zsh: add higher-priority location
  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
  completion: bash: simplify config_variable_name
  test: completion: add missing test
  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()

 contrib/completion/git-completion.bash | 642 +++++++++++--------------
 contrib/completion/git-completion.zsh  | 141 +++---
 t/t9902-completion.sh                  | 159 +++---
 3 files changed, 435 insertions(+), 507 deletions(-)

Range-diff against v1:
 -:  ---------- >  1:  68e7376872 completion: fix __git_cmd_idx regression
 1:  f318584861 =  2:  f942d5884a completion: bash: fix prefix detection in branch.*
 2:  ce536d6e53 =  3:  c073c68d77 completion: fix for suboptions with value
 3:  50a4e412d3 =  4:  60596a5f3a completion: bash: fix for multiple dash commands
 4:  bf7dfb35d1 =  5:  40f67ea5fd completion: bash: add correct suffix in variables
43:  8f1399c468 =  6:  20c22f5337 completion: zsh: add higher-priority location
 -:  ---------- >  7:  120a675092 completion: zsh: trivial improvement
 5:  6338c510b4 =  8:  c58f5f8649 completion: bash: do not modify COMP_WORDBREAKS
 6:  ab79e84b26 =  9:  46bfd0d7ca test: completion: fix currently typed words
 7:  da3b5837df = 10:  4f44215d5e test: completion: switch __gitcomp_nl prefix test
 8:  1f2278ea0f ! 11:  99954f41d4 test: completion: add run_func() helper
    @@ t/t9902-completion.sh: test_path_completion ()
      	test_cmp expected out
      }
     @@ t/t9902-completion.sh: 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
    @@ t/t9902-completion.sh: do
      		test_cmp expected out
      	'
     @@ t/t9902-completion.sh: 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
 9:  106cbd3e72 = 12:  3e2ea37938 completion: bash: remove non-append functionality
10:  5145f47503 = 13:  d1162c8aa7 completion: bash: get rid of _append() functions
11:  1bf917c007 = 14:  ca88e56fa2 completion: bash: get rid of any non-append code
12:  ef1d6a3037 = 15:  54c3401eee completion: zsh: fix options with arguments
13:  b8d3bcb7a0 = 16:  3bca7df93a completion: zsh: expand --git-dir file argument
14:  89599ea5da ! 17:  2a3a5c3220 completion: zsh: add support for general -C opts
    @@ contrib/completion/git-completion.zsh: __git_zsh_main ()
      {
      	local curcontext="$curcontext" state state_descr line
      	typeset -A opt_args
    --	local -a orig_words
    -+	local -a orig_words __git_C_args
    - 
    - 	orig_words=( ${words[@]} )
    ++	local -a __git_C_args
      
    + 	_arguments -C \
    + 		'(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
     @@ 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]' \
    @@ contrib/completion/git-completion.zsh: __git_zsh_main ()
     +
      		(( $+opt_args[--help] )) && command='help'
      
    - 		words=( ${orig_words[@]} )
    + 		words=( git ${words[@]} )
15:  ebc2bf8df1 = 18:  1bfe88f60c completion: zsh: fix for undefined completions
16:  4e2762f040 = 19:  ad75eccb20 completion: zsh: add support for general -c opts
17:  b856d42169 = 20:  d1587d19f7 completion: zsh: fix extra space on foo=
18:  d61682bc45 ! 21:  a18f9d962b completion: zsh: add excluded options
    @@ Commit message
     
      ## contrib/completion/git-completion.zsh ##
     @@ contrib/completion/git-completion.zsh: __git_zsh_main ()
    - 	orig_words=( ${words[@]} )
    + 	local -a __git_C_args
      
      	_arguments -C \
     -		'(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
19:  07819100c1 = 22:  c824921fa5 completion: zsh: always set compset
20:  391372ddf7 = 23:  daf7bc19bb completion: factor out check in __gitcomp
21:  1fd7477427 = 24:  41a9cd3e8d completion: simplify equal suffix check
22:  fc7bcb5122 = 25:  dd47842d0d completion: refactor __gitcomp
23:  85b5e719c7 = 26:  674a7ca73b completion: simplify __gitcomp
24:  30124bf50f = 27:  f3f77bb5a6 completion: bash: change suffix check in __gitcomp
25:  70653f57c0 = 28:  81e518f5a7 completion: improve __gitcomp suffix code
26:  ae6bab5e4f = 29:  9b3242d412 completion: bash: simplify config_variable_name
27:  f67cc99935 = 30:  869fafc5a7 test: completion: add missing test
28:  17bc28a487 = 31:  7b1b05352f completion: bash: improve __gitcomp description
29:  69f6533ef8 ! 32:  282221f9b6 completion: add __gitcomp_opts
    @@ contrib/completion/git-completion.bash: _git_sparse_checkout ()
      		;;
      	*)
      		;;
    -@@ contrib/completion/git-completion.bash: _git_stash ()
    - 	if [ -z "$subcommand" ]; then
    - 		case "$cur" in
    - 		--*)
    --			__gitcomp "$save_opts"
    -+			__gitcomp_opts "$save_opts"
    - 			;;
    - 		sa*)
    - 			if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
    -@@ contrib/completion/git-completion.bash: _git_stash ()
    - 	else
    - 		case "$subcommand,$cur" in
    - 		push,--*)
    --			__gitcomp "$save_opts --message"
    -+			__gitcomp_opts "$save_opts --message"
    - 			;;
    - 		save,--*)
    --			__gitcomp "$save_opts"
    -+			__gitcomp_opts "$save_opts"
    - 			;;
    - 		apply,--*|pop,--*)
    --			__gitcomp "--index --quiet"
    -+			__gitcomp_opts "--index --quiet"
    - 			;;
    - 		drop,--*)
    --			__gitcomp "--quiet"
    -+			__gitcomp_opts "--quiet"
    - 			;;
    - 		list,--*)
    --			__gitcomp "--name-status --oneline --patch-with-stat"
    -+			__gitcomp_opts "--name-status --oneline --patch-with-stat"
    - 			;;
    - 		show,--*)
    --			__gitcomp "$__git_diff_common_options"
    -+			__gitcomp_opts "$__git_diff_common_options"
    - 			;;
    - 		branch,--*)
    - 			;;
     @@ contrib/completion/git-completion.bash: _git_submodule ()
      	if [ -z "$subcommand" ]; then
      		case "$cur" in
    @@ contrib/completion/git-completion.bash: _git_svn ()
      		*)
      			;;
     @@ contrib/completion/git-completion.bash: __git_main ()
    - 			;;
      		esac
      		case "$cur" in
    --		--*)   __gitcomp "
    -+		--*)   __gitcomp_opts "
    + 		--*)
    +-			__gitcomp "
    ++			__gitcomp_opts "
      			--paginate
      			--no-pager
      			--git-dir=
30:  a1a9dbb915 = 33:  2d00a52d65 completion: bash: cleanup __gitcomp* invocations
31:  9c17b3d3af = 34:  c34a4e0f93 completion: bash: shuffle __gitcomp functions
32:  37f2c72c9e = 35:  12de564dae completion: zsh: simplify __gitcomp_direct
33:  57ef037e81 = 36:  5c8aa847da completion: zsh: shuffle __gitcomp* functions
34:  ecb79bc877 = 37:  b2e1bb7a02 completion: zsh: fix direct quoting
35:  ae49a7c597 = 38:  43c3374fb2 completion: zsh: add elements individually in __gitcomp_opts
36:  135f68ca27 = 39:  a1f335b841 completion: zsh: add __gitcompadd helper
37:  e4f8591b72 = 40:  1416f590a7 completion: zsh: add correct removable suffix
38:  49217d4aa3 = 41:  081982e432 completion: bash: simplify _get_comp_words_by_ref()
39:  ef00c6e76e = 42:  2bd0507a7a completion: bash: refactor _get_comp_words_by_ref()
40:  993d5c83ae = 43:  188c8749cc completion: bash: cleanup _get_comp_words_by_ref()
41:  8b13e46fd3 = 44:  e08dc59d07 completion: bash: trivial cleanup
42:  658b5cccc8 ! 45:  893c8527d6 completion: bash: rename _get_comp_words_by_ref()
    @@ contrib/completion/git-completion.bash: if [[ -n ${ZSH_VERSION-} && -z ${GIT_SOU
     +
      __git_func_wrap ()
      {
    - 	local cur words cword prev
    + 	local cur words cword prev __git_cmd_idx=1
     -	_get_comp_words_by_ref -n =: cur words cword prev
     +	__git_get_comp_words_by_ref
      	$1
-- 
2.32.0


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

* [PATCH v2 01/45] completion: fix __git_cmd_idx regression
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:58   ` [PATCH] " Felipe Contreras
  2021-06-18 19:04   ` [PATCH v2 01/45] " Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 02/45] completion: bash: fix prefix detection in branch.* Felipe Contreras
                   ` (43 subsequent siblings)
  44 siblings, 2 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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.

We need the function wrapper to define __git_cmd_idx.

If the function wrapper defines __git_cmd_idx, then it's not necessary
for __git_zsh_main to do so.

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

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index b50c5d0ea3..52a2d283cd 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -3511,7 +3511,7 @@ fi
 
 __git_func_wrap ()
 {
-	local cur words cword prev
+	local cur words cword prev __git_cmd_idx=1
 	_get_comp_words_by_ref -n =: cur words cword prev
 	$1
 }
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index cac6f61881..02ffeae768 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -251,7 +251,7 @@ __git_zsh_main ()
 		done
 		;;
 	(arg)
-		local command="${words[1]}" __git_dir __git_cmd_idx=1
+		local command="${words[1]}" __git_dir
 
 		if (( $+opt_args[--bare] )); then
 			__git_dir='.'
@@ -271,7 +271,7 @@ __git_zsh_main ()
 _git ()
 {
 	local _ret=1
-	local cur cword prev
+	local cur cword prev __git_cmd_idx=1
 
 	cur=${words[CURRENT]}
 	prev=${words[CURRENT-1]}
-- 
2.32.0


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

* [PATCH v2 02/45] completion: bash: fix prefix detection in branch.*
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 01/45] completion: fix __git_cmd_idx regression Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 03/45] completion: fix for suboptions with value Felipe Contreras
                   ` (42 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Otherwise we are completely ignoring the --cur argument.

The issue can be tested with:

  git clone --config=branch.<tab>

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

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 52a2d283cd..f8a751c4ec 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2649,8 +2649,8 @@ __git_complete_config_variable_name ()
 		return
 		;;
 	branch.*)
-		local pfx="${cur%.*}."
-		cur_="${cur#*.}"
+		local pfx="${cur_%.*}."
+		cur_="${cur_#*.}"
 		__gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
 		__gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "$sfx"
 		return
-- 
2.32.0


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

* [PATCH v2 03/45] completion: fix for suboptions with value
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 01/45] completion: fix __git_cmd_idx regression Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 02/45] completion: bash: fix prefix detection in branch.* Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 04/45] completion: bash: fix for multiple dash commands Felipe Contreras
                   ` (41 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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.bash |  2 +-
 contrib/completion/git-completion.zsh  |  2 +-
 t/t9902-completion.sh                  | 15 +++++++++++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index f8a751c4ec..80b7c3eda8 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -356,7 +356,7 @@ __gitcomp ()
 	local cur_="${3-$cur}"
 
 	case "$cur_" in
-	--*=)
+	*=)
 		;;
 	--no-*)
 		local c i=0 IFS=$' \t\n'
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 02ffeae768..4a4df3b37c 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -55,7 +55,7 @@ __gitcomp ()
 	local cur_="${3-$cur}"
 
 	case "$cur_" in
-	--*=)
+	*=)
 		;;
 	--no-*)
 		local c IFS=$' \t\n'
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index cb057ef161..6b56e54fc3 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -540,6 +540,15 @@ test_expect_success '__gitcomp - expand/narrow all negative options' '
 	EOF
 '
 
+test_expect_success '__gitcomp - equal skip' '
+	test_gitcomp "--option=" "--option=" <<-\EOF &&
+
+	EOF
+	test_gitcomp "option=" "option=" <<-\EOF
+
+	EOF
+'
+
 test_expect_success '__gitcomp - doesnt fail because of invalid variable name' '
 	__gitcomp "$invalid_variable_name"
 '
@@ -2380,6 +2389,12 @@ test_expect_success 'git clone --config= - value' '
 	EOF
 '
 
+test_expect_success 'options with value' '
+	test_completion "git merge -X diff-algorithm=" <<-\EOF
+
+	EOF
+'
+
 test_expect_success 'sourcing the completion script clears cached commands' '
 	__git_compute_all_commands &&
 	verbose test -n "$__git_all_commands" &&
-- 
2.32.0


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

* [PATCH v2 04/45] completion: bash: fix for multiple dash commands
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (2 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 03/45] completion: fix for suboptions with value Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 05/45] completion: bash: add correct suffix in variables Felipe Contreras
                   ` (40 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Otherwise commands like 'for-each-ref' are not completed.

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 80b7c3eda8..279d2d8b1e 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -421,7 +421,7 @@ __gitcomp_builtin ()
 	local incl="${2-}"
 	local excl="${3-}"
 
-	local var=__gitcomp_builtin_"${cmd/-/_}"
+	local var=__gitcomp_builtin_"${cmd//-/_}"
 	local options
 	eval "options=\${$var-}"
 
-- 
2.32.0


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

* [PATCH v2 05/45] completion: bash: add correct suffix in variables
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (3 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 04/45] completion: bash: fix for multiple dash commands Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 06/45] completion: zsh: add higher-priority location Felipe Contreras
                   ` (39 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

__gitcomp automatically adds a suffix, but __gitcomp_nl and others
don't, we need to specify a space by default.

Can be tested with:

  git config branch.autoSetupMe<tab>

This fix only works for versions of bash greater than 4.0, before that
"local sfx" creates an empty string, therefore the unset expansion
doesn't work. The same happens in zsh.

Therefore we don't add the test for that for now.

The correct fix for all shells requires semantic changes in __gitcomp,
but that can be done later.

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 279d2d8b1e..943995689f 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2652,7 +2652,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_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }"
 		return
 		;;
 	guitool.*.*)
@@ -2686,7 +2686,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.*.*)
@@ -2702,7 +2702,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_append "pushDefault" "$pfx" "$cur_" "${sfx- }"
 		return
 		;;
 	url.*.*)
-- 
2.32.0


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

* [PATCH v2 06/45] completion: zsh: add higher-priority location
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (4 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 05/45] completion: bash: add correct suffix in variables Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 07/45] completion: zsh: trivial improvement Felipe Contreras
                   ` (38 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 4a4df3b37c..da13c184d1 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.32.0


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

* [PATCH v2 07/45] completion: zsh: trivial improvement
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (5 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 06/45] completion: zsh: add higher-priority location Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 08/45] completion: bash: do not modify COMP_WORDBREAKS Felipe Contreras
                   ` (37 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 da13c184d1..9f0e03e86b 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -220,9 +220,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'']' \
@@ -262,7 +259,7 @@ __git_zsh_main ()
 
 		(( $+opt_args[--help] )) && command='help'
 
-		words=( ${orig_words[@]} )
+		words=( git ${words[@]} )
 
 		__git_zsh_bash_func $command
 		;;
-- 
2.32.0


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

* [PATCH v2 08/45] completion: bash: do not modify COMP_WORDBREAKS
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (6 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 07/45] completion: zsh: trivial improvement Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 09/45] test: completion: fix currently typed words Felipe Contreras
                   ` (36 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 943995689f..bede8a7e2a 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -54,11 +54,6 @@
 #     When set to "1" suggest all options, including options which are
 #     typically hidden (e.g. '--allow-empty' for 'git commit').
 
-case "$COMP_WORDBREAKS" in
-*:*) : great ;;
-*)   COMP_WORDBREAKS="$COMP_WORDBREAKS:"
-esac
-
 # Discovers the path to the git repository taking any '--git-dir=<path>' and
 # '-C <path>' options into account and stores it in the $__git_repo_path
 # variable.
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 9f0e03e86b..5ddd2d6771 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.32.0


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

* [PATCH v2 09/45] test: completion: fix currently typed words
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (7 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 08/45] completion: bash: do not modify COMP_WORDBREAKS Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 10/45] test: completion: switch __gitcomp_nl prefix test Felipe Contreras
                   ` (35 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

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

No functional change.

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

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 6b56e54fc3..bffe1b0928 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -489,7 +489,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
@@ -497,7 +497,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
-- 
2.32.0


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

* [PATCH v2 10/45] test: completion: switch __gitcomp_nl prefix test
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (8 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 09/45] test: completion: fix currently typed words Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 11/45] test: completion: add run_func() helper Felipe Contreras
                   ` (34 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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.

No functional changes.

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

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index bffe1b0928..d21dca4abd 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -568,9 +568,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
 '
 
-- 
2.32.0


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

* [PATCH v2 11/45] test: completion: add run_func() helper
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (9 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 10/45] test: completion: switch __gitcomp_nl prefix test Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 12/45] completion: bash: remove non-append functionality Felipe Contreras
                   ` (33 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 d21dca4abd..bb3eebffb7 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -78,6 +78,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)
@@ -455,8 +461,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
 '
@@ -550,7 +555,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
@@ -589,7 +594,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' '
@@ -1090,8 +1095,7 @@ test_expect_success '__git_complete_refs - simple' '
 	EOF
 	(
 		cur= &&
-		__git_complete_refs &&
-		print_comp
+		run_func __git_complete_refs
 	) &&
 	test_cmp expected out
 '
@@ -1103,8 +1107,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
 '
@@ -1117,8 +1120,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
 '
@@ -1136,8 +1138,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
 '
@@ -1149,8 +1150,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
 '
@@ -1162,8 +1162,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
 '
@@ -1179,8 +1178,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
 '
@@ -1193,8 +1191,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
 '
@@ -1205,8 +1202,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
 '
@@ -1219,8 +1215,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
 '
@@ -1233,8 +1228,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
 '
@@ -1247,8 +1241,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
 '
@@ -1779,8 +1772,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
 }
@@ -2302,8 +2294,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
 	'
@@ -2316,8 +2307,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.32.0


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

* [PATCH v2 12/45] completion: bash: remove non-append functionality
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (10 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 11/45] test: completion: add run_func() helper Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 13/45] completion: bash: get rid of _append() functions Felipe Contreras
                   ` (32 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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.

There should be 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 bede8a7e2a..8f72e0f66b 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -307,7 +307,7 @@ __gitcomp_direct ()
 {
 	local IFS=$'\n'
 
-	COMPREPLY=($1)
+	COMPREPLY+=($1)
 }
 
 # Similar to __gitcomp_direct, but appends to COMPREPLY instead.
@@ -459,7 +459,6 @@ __gitcomp_nl_append ()
 #    appended.
 __gitcomp_nl ()
 {
-	COMPREPLY=()
 	__gitcomp_nl_append "$@"
 }
 
-- 
2.32.0


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

* [PATCH v2 13/45] completion: bash: get rid of _append() functions
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (11 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 12/45] completion: bash: remove non-append functionality Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 14/45] completion: bash: get rid of any non-append code Felipe Contreras
                   ` (31 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 8f72e0f66b..c3ea5261fb 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -296,8 +296,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.
@@ -310,19 +309,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[@]}
@@ -440,16 +426,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).
@@ -459,7 +437,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
@@ -846,7 +825,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
 }
 
@@ -2646,7 +2625,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.*.*)
@@ -2696,7 +2675,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 5ddd2d6771..8cbf4f83f5 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.32.0


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

* [PATCH v2 14/45] completion: bash: get rid of any non-append code
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (12 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 13/45] completion: bash: get rid of _append() functions Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 15/45] completion: zsh: fix options with arguments Felipe Contreras
                   ` (30 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 c3ea5261fb..366f255dfc 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -309,7 +309,7 @@ __gitcomp_direct ()
 	COMPREPLY+=($1)
 }
 
-__gitcompappend ()
+__gitcompadd ()
 {
 	local x i=${#COMPREPLY[@]}
 	for x in $1; do
@@ -319,12 +319,6 @@ __gitcompappend ()
 	done
 }
 
-__gitcompadd ()
-{
-	COMPREPLY=()
-	__gitcompappend "$@"
-}
-
 # Generates completion reply, appending a space to possible completion words,
 # if necessary.
 # It accepts 1 to 4 arguments:
@@ -438,7 +432,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
@@ -451,7 +445,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.32.0


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

* [PATCH v2 15/45] completion: zsh: fix options with arguments
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (13 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 14/45] completion: bash: get rid of any non-append code Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 16/45] completion: zsh: expand --git-dir file argument Felipe Contreras
                   ` (29 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 8cbf4f83f5..33bbf3d993 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -215,15 +215,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.32.0


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

* [PATCH v2 16/45] completion: zsh: expand --git-dir file argument
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (14 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 15/45] completion: zsh: fix options with arguments Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 17/45] completion: zsh: add support for general -C opts Felipe Contreras
                   ` (28 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 33bbf3d993..9768f76af3 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -245,7 +245,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.32.0


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

* [PATCH v2 17/45] completion: zsh: add support for general -C opts
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (15 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 16/45] completion: zsh: expand --git-dir file argument Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 18/45] completion: zsh: fix for undefined completions Felipe Contreras
                   ` (27 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

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

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 9768f76af3..f60801741a 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -211,6 +211,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'']' \
@@ -226,6 +227,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
 
@@ -248,6 +250,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[@]} )
-- 
2.32.0


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

* [PATCH v2 18/45] completion: zsh: fix for undefined completions
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (16 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 17/45] completion: zsh: add support for general -C opts Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 19/45] completion: zsh: add support for general -c opts Felipe Contreras
                   ` (26 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 +++
 1 file changed, 3 insertions(+)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index f60801741a..5cfbcfe7a2 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -141,6 +141,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
-- 
2.32.0


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

* [PATCH v2 19/45] completion: zsh: add support for general -c opts
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (17 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 18/45] completion: zsh: fix for undefined completions Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 20/45] completion: zsh: fix extra space on foo= Felipe Contreras
                   ` (25 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 +++++
 1 file changed, 5 insertions(+)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 5cfbcfe7a2..f3e8cb7535 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -231,6 +231,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
 
@@ -244,6 +245,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
 
-- 
2.32.0


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

* [PATCH v2 20/45] completion: zsh: fix extra space on foo=
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (18 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 19/45] completion: zsh: add support for general -c opts Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 21/45] completion: zsh: add excluded options Felipe Contreras
                   ` (24 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index f3e8cb7535..56a1bb16b0 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")
-- 
2.32.0


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

* [PATCH v2 21/45] completion: zsh: add excluded options
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (19 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 20/45] completion: zsh: fix extra space on foo= Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 22/45] completion: zsh: always set compset Felipe Contreras
                   ` (23 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 56a1bb16b0..426eec10a2 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -217,15 +217,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]' \
-- 
2.32.0


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

* [PATCH v2 22/45] completion: zsh: always set compset
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (20 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 21/45] completion: zsh: add excluded options Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 23/45] completion: factor out check in __gitcomp Felipe Contreras
                   ` (22 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 426eec10a2..b9c2c75c79 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
 }
 
@@ -136,6 +131,8 @@ __git_complete_command ()
 {
 	emulate -L zsh
 
+	compset -P '*[=:]'
+
 	local command="$1"
 	local completion_func="_git_${command//-/_}"
 	if (( $+functions[$completion_func] )); then
-- 
2.32.0


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

* [PATCH v2 23/45] completion: factor out check in __gitcomp
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (21 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 22/45] completion: zsh: always set compset Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 24/45] completion: simplify equal suffix check Felipe Contreras
                   ` (21 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 366f255dfc..ad67abff36 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -330,9 +330,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 b9c2c75c79..4dd0a4d821 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.32.0


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

* [PATCH v2 24/45] completion: simplify equal suffix check
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (22 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 23/45] completion: factor out check in __gitcomp Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 25/45] completion: refactor __gitcomp Felipe Contreras
                   ` (20 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 ad67abff36..d0df695b52 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -344,7 +344,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 4dd0a4d821..1fff8437d5 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.32.0


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

* [PATCH v2 25/45] completion: refactor __gitcomp
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (23 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 24/45] completion: simplify equal suffix check Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:24 ` [PATCH v2 26/45] completion: simplify __gitcomp Felipe Contreras
                   ` (19 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

We have to 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 d0df695b52..b4b778da0b 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -334,44 +334,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-}"
-			if [[ $c == "$cur_"* ]]; then
-				case $c in
-				*=|*.) ;;
-				*) c="$c " ;;
-				esac
-				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-}"
+
+			c="--no-...${4-}"
 			if [[ $c == "$cur_"* ]]; then
-				case $c in
-				*=|*.) ;;
-				*) c="$c " ;;
-				esac
-				COMPREPLY[i++]="${2-}$c"
+				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 1fff8437d5..c7e4de15c6 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.32.0


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

* [PATCH v2 26/45] completion: simplify __gitcomp
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (24 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 25/45] completion: refactor __gitcomp Felipe Contreras
@ 2021-06-18 18:24 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 27/45] completion: bash: change suffix check in __gitcomp Felipe Contreras
                   ` (18 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:24 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 b4b778da0b..ebf8df94e8 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -341,9 +341,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 c7e4de15c6..6008a73816 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.32.0


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

* [PATCH v2 27/45] completion: bash: change suffix check in __gitcomp
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (25 preceding siblings ...)
  2021-06-18 18:24 ` [PATCH v2 26/45] completion: simplify __gitcomp Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 28/45] completion: improve __gitcomp suffix code Felipe Contreras
                   ` (17 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 ebf8df94e8..e7308b212f 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -346,8 +346,8 @@ __gitcomp ()
 			fi
 			break
 		fi
-		c="$c${4-}"
 		if [[ $c == "$cur_"* ]]; then
+			c="$c${4-}"
 			case $c in
 			*=|*.) ;;
 			*) c="$c " ;;
-- 
2.32.0


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

* [PATCH v2 28/45] completion: improve __gitcomp suffix code
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (26 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 27/45] completion: bash: change suffix check in __gitcomp Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 29/45] completion: bash: simplify config_variable_name Felipe Contreras
                   ` (16 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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.

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

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index e7308b212f..c246d664c3 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -334,7 +334,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
@@ -347,12 +347,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
 }
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 6008a73816..b81479c814 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.32.0


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

* [PATCH v2 29/45] completion: bash: simplify config_variable_name
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (27 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 28/45] completion: improve __gitcomp suffix code Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 30/45] test: completion: add missing test Felipe Contreras
                   ` (15 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Now that we can actually pass a suffix to __gitcomp function, and it
does the right thing, all the functions can receive the same suffix.

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

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c246d664c3..cb25916f65 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2585,7 +2585,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
@@ -2607,7 +2607,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.*.*)
@@ -2641,7 +2641,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.*.*)
@@ -2657,7 +2657,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.32.0


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

* [PATCH v2 30/45] test: completion: add missing test
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (28 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 29/45] completion: bash: simplify config_variable_name Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 31/45] completion: bash: improve __gitcomp description Felipe Contreras
                   ` (14 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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.

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

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index bb3eebffb7..9803878480 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2335,6 +2335,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.32.0


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

* [PATCH v2 31/45] completion: bash: improve __gitcomp description
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (29 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 30/45] test: completion: add missing test Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 32/45] completion: add __gitcomp_opts Felipe Contreras
                   ` (13 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 cb25916f65..0218ae7eb6 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -319,8 +319,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.32.0


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

* [PATCH v2 32/45] completion: add __gitcomp_opts
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (30 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 31/45] completion: bash: improve __gitcomp description Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 33/45] completion: bash: cleanup __gitcomp* invocations Felipe Contreras
                   ` (12 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 | 100 ++++++++++++++-----------
 contrib/completion/git-completion.zsh  |   8 ++
 t/t9902-completion.sh                  |  58 +++++++-------
 3 files changed, 93 insertions(+), 73 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 0218ae7eb6..8836eab884 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -319,13 +319,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}"
 
@@ -369,7 +381,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
@@ -404,7 +416,7 @@ __gitcomp_builtin ()
 		eval "$var=\"$options\""
 	fi
 
-	__gitcomp "$options"
+	__gitcomp_opts "$options"
 }
 
 # Generates completion reply from newline-separated possible completion words
@@ -1041,7 +1053,7 @@ __git_complete_strategy ()
 		return 0
 		;;
 	-X)
-		__gitcomp "$__git_merge_strategy_options"
+		__gitcomp_opts "$__git_merge_strategy_options"
 		return 0
 		;;
 	esac
@@ -1051,7 +1063,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
@@ -1293,7 +1305,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
@@ -1553,7 +1565,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
 
@@ -1711,7 +1723,7 @@ _git_diff ()
 		return
 		;;
 	--*)
-		__gitcomp "$__git_diff_difftool_options"
+		__gitcomp_opts "$__git_diff_difftool_options"
 		return
 		;;
 	esac
@@ -2005,7 +2017,7 @@ _git_log ()
 		return
 		;;
 	--*)
-		__gitcomp "
+		__gitcomp_opts "
 			$__git_log_common_options
 			$__git_log_shortlog_options
 			$__git_log_gitk_options
@@ -2068,7 +2080,7 @@ _git_mergetool ()
 		return
 		;;
 	--*)
-		__gitcomp "--tool= --prompt --no-prompt --gui --no-gui"
+		__gitcomp_opts "--tool= --prompt --no-prompt --gui --no-gui"
 		return
 		;;
 	esac
@@ -2216,7 +2228,7 @@ _git_range_diff ()
 {
 	case "$cur" in
 	--*)
-		__gitcomp "
+		__gitcomp_opts "
 			--creation-factor= --no-dual-color
 			$__git_diff_common_options
 		"
@@ -2233,11 +2245,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
@@ -2679,7 +2691,7 @@ __git_complete_config_variable_name ()
 					for (s in sections)
 						print s "."
 				}
-				')" "" "$cur_"
+				')" "" "$cur_" ""
 		;;
 	esac
 }
@@ -2857,7 +2869,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
@@ -2889,7 +2901,7 @@ _git_shortlog ()
 
 	case "$cur" in
 	--*)
-		__gitcomp "
+		__gitcomp_opts "
 			$__git_log_common_options
 			$__git_log_shortlog_options
 			--numbered --summary --email
@@ -2927,7 +2939,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
@@ -2960,10 +2972,10 @@ _git_sparse_checkout ()
 
 	case "$subcommand,$cur" in
 	init,--*)
-		__gitcomp "--cone"
+		__gitcomp_opts "--cone"
 		;;
 	set,--*)
-		__gitcomp "--stdin"
+		__gitcomp_opts "--stdin"
 		;;
 	*)
 		;;
@@ -3025,7 +3037,7 @@ _git_submodule ()
 	if [ -z "$subcommand" ]; then
 		case "$cur" in
 		--*)
-			__gitcomp "--quiet"
+			__gitcomp_opts "--quiet"
 			;;
 		*)
 			__gitcomp "$subcommands"
@@ -3036,29 +3048,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"
 		;;
 	*)
 		;;
@@ -3099,64 +3111,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"
 			;;
 		*)
 			;;
@@ -3396,7 +3408,7 @@ __git_main ()
 		esac
 		case "$cur" in
 		--*)
-			__gitcomp "
+			__gitcomp_opts "
 			--paginate
 			--no-pager
 			--git-dir=
@@ -3447,7 +3459,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 b81479c814..e515f464ab 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 9803878480..3dbb5eb121 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -101,17 +101,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
 }
@@ -466,8 +466,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
@@ -475,8 +475,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
@@ -485,32 +485,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
@@ -518,44 +518,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
-- 
2.32.0


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

* [PATCH v2 33/45] completion: bash: cleanup __gitcomp* invocations
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (31 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 32/45] completion: add __gitcomp_opts Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 34/45] completion: bash: shuffle __gitcomp functions Felipe Contreras
                   ` (11 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 8836eab884..7a27347d56 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1369,7 +1369,7 @@ _git_archive ()
 {
 	case "$cur" in
 	--format=*)
-		__gitcomp "$(git archive --list)" "" "${cur##--format=}"
+		__gitcomp_nl "$(git archive --list)" "" "${cur##--format=}"
 		return
 		;;
 	--remote=*)
@@ -1782,9 +1782,7 @@ _git_format_patch ()
 {
 	case "$cur" in
 	--thread=*)
-		__gitcomp "
-			deep shallow
-			" "" "${cur##--thread=}"
+		__gitcomp "deep shallow" "" "${cur##--thread=}"
 		return
 		;;
 	--base=*|--interdiff=*|--range-diff=*)
@@ -2290,7 +2288,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
@@ -2314,9 +2312,7 @@ _git_send_email ()
 		return
 		;;
 	--thread=*)
-		__gitcomp "
-			deep shallow
-			" "" "${cur##--thread=}"
+		__gitcomp "deep shallow" "" "${cur##--thread=}"
 		return
 		;;
 	--to=*|--cc=*|--bcc=*|--from=*)
@@ -2618,7 +2614,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.*.*)
@@ -2668,7 +2664,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.*.*)
@@ -2683,7 +2679,7 @@ __git_complete_config_variable_name ()
 		;;
 	*)
 		__git_compute_config_vars
-		__gitcomp "$(echo "$__git_config_vars" |
+		__gitcomp_nl "$(echo "$__git_config_vars" |
 				awk -F . '{
 					sections[$1] = 1
 				}
@@ -2785,7 +2781,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
@@ -3430,7 +3426,7 @@ __git_main ()
 			then
 				__gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
 			else
-				__gitcomp "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
+				__gitcomp_nl "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
 			fi
 			;;
 		esac
-- 
2.32.0


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

* [PATCH v2 34/45] completion: bash: shuffle __gitcomp functions
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (32 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 33/45] completion: bash: cleanup __gitcomp* invocations Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 35/45] completion: zsh: simplify __gitcomp_direct Felipe Contreras
                   ` (10 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 7a27347d56..47c96b918e 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -54,6 +54,145 @@
 #     When set to "1" suggest all options, including options which are
 #     typically hidden (e.g. '--allow-empty' for 'git commit').
 
+# 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.
@@ -296,81 +435,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
@@ -419,62 +483,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.32.0


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

* [PATCH v2 35/45] completion: zsh: simplify __gitcomp_direct
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (33 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 34/45] completion: bash: shuffle __gitcomp functions Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 36/45] completion: zsh: shuffle __gitcomp* functions Felipe Contreras
                   ` (9 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 e515f464ab..bfb5c38a3c 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.32.0


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

* [PATCH v2 36/45] completion: zsh: shuffle __gitcomp* functions
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (34 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 35/45] completion: zsh: simplify __gitcomp_direct Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 37/45] completion: zsh: fix direct quoting Felipe Contreras
                   ` (8 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 bfb5c38a3c..c4510a3180 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.32.0


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

* [PATCH v2 37/45] completion: zsh: fix direct quoting
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (35 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 36/45] completion: zsh: shuffle __gitcomp* functions Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 38/45] completion: zsh: add elements individually in __gitcomp_opts Felipe Contreras
                   ` (7 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 c4510a3180..3818291950 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.32.0


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

* [PATCH v2 38/45] completion: zsh: add elements individually in __gitcomp_opts
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (36 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 37/45] completion: zsh: fix direct quoting Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 39/45] completion: zsh: add __gitcompadd helper Felipe Contreras
                   ` (6 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

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

This will be useful later on.

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

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 3818291950..a4b5e7dcc4 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 ()
-- 
2.32.0


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

* [PATCH v2 39/45] completion: zsh: add __gitcompadd helper
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (37 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 38/45] completion: zsh: add elements individually in __gitcomp_opts Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 40/45] completion: zsh: add correct removable suffix Felipe Contreras
                   ` (5 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 a4b5e7dcc4..0f2f0e5eb0 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.32.0


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

* [PATCH v2 40/45] completion: zsh: add correct removable suffix
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (38 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 39/45] completion: zsh: add __gitcompadd helper Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 41/45] completion: bash: simplify _get_comp_words_by_ref() Felipe Contreras
                   ` (4 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 0f2f0e5eb0..d425ff1d81 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.32.0


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

* [PATCH v2 41/45] completion: bash: simplify _get_comp_words_by_ref()
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (39 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 40/45] completion: zsh: add correct removable suffix Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 42/45] completion: bash: refactor _get_comp_words_by_ref() Felipe Contreras
                   ` (3 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 47c96b918e..2c0b869aba 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -408,30 +408,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 3dbb5eb121..8745f6afe9 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -43,23 +43,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.32.0


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

* [PATCH v2 42/45] completion: bash: refactor _get_comp_words_by_ref()
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (40 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 41/45] completion: bash: simplify _get_comp_words_by_ref() Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 43/45] completion: bash: cleanup _get_comp_words_by_ref() Felipe Contreras
                   ` (2 subsequent siblings)
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 | 93 +++++++++++---------------
 1 file changed, 39 insertions(+), 54 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 2c0b869aba..9976009951 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -334,21 +334,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.
 #
@@ -356,60 +346,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()
+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="${1//[^$COMP_WORDBREAKS]}"
+	exclude="${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=
+	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
-			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
-}
+	fi
 
-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 "=:"
 	cword=$cword_
 	cur=${words_[cword]}
 	prev=${words_[cword-1]}
-- 
2.32.0


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

* [PATCH v2 43/45] completion: bash: cleanup _get_comp_words_by_ref()
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (41 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 42/45] completion: bash: refactor _get_comp_words_by_ref() Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 44/45] completion: bash: trivial cleanup Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 45/45] completion: bash: rename _get_comp_words_by_ref() Felipe Contreras
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 9976009951..0433713242 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -350,14 +350,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.
@@ -377,9 +376,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++))
@@ -388,17 +387,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.32.0


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

* [PATCH v2 44/45] completion: bash: trivial cleanup
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (42 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 43/45] completion: bash: cleanup _get_comp_words_by_ref() Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  2021-06-18 18:25 ` [PATCH v2 45/45] completion: bash: rename _get_comp_words_by_ref() Felipe Contreras
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 0433713242..cef064795d 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -355,9 +355,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
@@ -392,6 +390,8 @@ _get_comp_words_by_ref ()
 				cword=$j
 			fi
 		done
+	else
+		words=("${COMP_WORDS[@]}")
 	fi
 
 	cur=${words[cword]}
-- 
2.32.0


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

* [PATCH v2 45/45] completion: bash: rename _get_comp_words_by_ref()
  2021-06-18 18:24 [PATCH v2 00/45] completion: git-completion 1.3.3 patches Felipe Contreras
                   ` (43 preceding siblings ...)
  2021-06-18 18:25 ` [PATCH v2 44/45] completion: bash: trivial cleanup Felipe Contreras
@ 2021-06-18 18:25 ` Felipe Contreras
  44 siblings, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:25 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 | 184 ++++++++++++-------------
 t/t9902-completion.sh                  |   2 +-
 2 files changed, 92 insertions(+), 94 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index cef064795d..aaff13dbb1 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -307,98 +307,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
@@ -3443,10 +3351,100 @@ 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.
+
+__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]}
+}
+
 __git_func_wrap ()
 {
 	local cur words cword prev __git_cmd_idx=1
-	_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 8745f6afe9..90f1236a00 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -41,7 +41,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.32.0


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

* [PATCH] completion: fix __git_cmd_idx regression
  2021-06-18 18:24 ` [PATCH v2 01/45] completion: fix __git_cmd_idx regression Felipe Contreras
@ 2021-06-18 18:58   ` Felipe Contreras
  2021-06-18 19:04   ` [PATCH v2 01/45] " Felipe Contreras
  1 sibling, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 18:58 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras, Harrison McCullough, Fabian Wermelinger

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.

We need the function wrapper to define __git_cmd_idx.

Reported-by: Harrison McCullough <mccullough.harrison@gmail.com>
Helped-by: Fabian Wermelinger <fabianw@mavt.ethz.ch>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 git-completion.bash | 2 +-
 git-completion.zsh  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-completion.bash b/git-completion.bash
index b50c5d0..c053a62 100644
--- a/git-completion.bash
+++ b/git-completion.bash
@@ -3511,7 +3511,7 @@ fi
 
 __git_func_wrap ()
 {
-	local cur words cword prev
+	local cur words cword prev __git_cmd_idx=0
 	_get_comp_words_by_ref -n =: cur words cword prev
 	$1
 }
diff --git a/git-completion.zsh b/git-completion.zsh
index cac6f61..a1f2d27 100644
--- a/git-completion.zsh
+++ b/git-completion.zsh
@@ -271,7 +271,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]}
-- 
2.32.0


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

* RE: [PATCH v2 01/45] completion: fix __git_cmd_idx regression
  2021-06-18 18:24 ` [PATCH v2 01/45] completion: fix __git_cmd_idx regression Felipe Contreras
  2021-06-18 18:58   ` [PATCH] " Felipe Contreras
@ 2021-06-18 19:04   ` Felipe Contreras
  1 sibling, 0 replies; 48+ messages in thread
From: Felipe Contreras @ 2021-06-18 19:04 UTC (permalink / raw)
  To: Felipe Contreras, git; +Cc: Felipe Contreras, Harrison McCullough

Felipe Contreras wrote:
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -3511,7 +3511,7 @@ fi
>  
>  __git_func_wrap ()
>  {
> -	local cur words cword prev
> +	local cur words cword prev __git_cmd_idx=1

I just realized this isn't 100% correct thanks to Fabian Wermelinger.
If we use __git_complete then the index should be 0. The above fixes the
annoying errors, but some commands don't complete correctly (e.g.
git_fetch).

I've sent an updated fix [1].

[1] https://lore.kernel.org/git/20210618185832.700477-1-felipe.contreras@gmail.com/

-- 
Felipe Contreras

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

end of thread, other threads:[~2021-06-18 19:04 UTC | newest]

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