* [PATCH 0/4] completion: bash: a bunch of fixes
@ 2020-11-19 1:52 Felipe Contreras
2020-11-19 1:52 ` [PATCH 1/4] completion: bash: fix prefix detection in branch.* Felipe Contreras
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Felipe Contreras @ 2020-11-19 1:52 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, SZEDER Gábor, Felipe Contreras
This is just the bug fixes from the previous series.
These should be pretty obvious and straightforward.
Felipe Contreras (4):
completion: bash: fix prefix detection in branch.*
completion: bash: add correct suffix in variables
completion: bash: fix for suboptions with value
completion: bash: fix for multiple dash commands
contrib/completion/git-completion.bash | 14 +++++++-------
t/t9902-completion.sh | 22 ++++++++++++++++++++++
2 files changed, 29 insertions(+), 7 deletions(-)
--
2.29.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] completion: bash: fix prefix detection in branch.*
2020-11-19 1:52 [PATCH 0/4] completion: bash: a bunch of fixes Felipe Contreras
@ 2020-11-19 1:52 ` Felipe Contreras
2020-11-19 1:52 ` [PATCH 2/4] completion: bash: add correct suffix in variables Felipe Contreras
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2020-11-19 1:52 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, SZEDER Gábor, 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 7c81e4ba49..b866b68b3c 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2615,8 +2615,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.29.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] completion: bash: add correct suffix in variables
2020-11-19 1:52 [PATCH 0/4] completion: bash: a bunch of fixes Felipe Contreras
2020-11-19 1:52 ` [PATCH 1/4] completion: bash: fix prefix detection in branch.* Felipe Contreras
@ 2020-11-19 1:52 ` Felipe Contreras
2020-11-19 1:52 ` [PATCH 3/4] completion: bash: fix for suboptions with value Felipe Contreras
2020-11-19 1:52 ` [PATCH 4/4] completion: bash: fix for multiple dash commands Felipe Contreras
3 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2020-11-19 1:52 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, SZEDER Gábor, 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>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.bash | 6 +++---
t/t9902-completion.sh | 7 +++++++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index b866b68b3c..bbdb46d87e 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2618,7 +2618,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.*.*)
@@ -2652,7 +2652,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.*.*)
@@ -2668,7 +2668,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.*.*)
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 2be9190425..4a3d3d1597 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2293,6 +2293,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.29.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] completion: bash: fix for suboptions with value
2020-11-19 1:52 [PATCH 0/4] completion: bash: a bunch of fixes Felipe Contreras
2020-11-19 1:52 ` [PATCH 1/4] completion: bash: fix prefix detection in branch.* Felipe Contreras
2020-11-19 1:52 ` [PATCH 2/4] completion: bash: add correct suffix in variables Felipe Contreras
@ 2020-11-19 1:52 ` Felipe Contreras
2020-11-19 1:52 ` [PATCH 4/4] completion: bash: fix for multiple dash commands Felipe Contreras
3 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2020-11-19 1:52 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, SZEDER Gábor, 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 +-
t/t9902-completion.sh | 15 +++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index bbdb46d87e..5b2dff150d 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -347,7 +347,7 @@ __gitcomp ()
local cur_="${3-$cur}"
case "$cur_" in
- --*=)
+ *=)
;;
--no-*)
local c i=0 IFS=$' \t\n'
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 4a3d3d1597..4deda01153 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -537,6 +537,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"
'
@@ -2342,6 +2351,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.29.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] completion: bash: fix for multiple dash commands
2020-11-19 1:52 [PATCH 0/4] completion: bash: a bunch of fixes Felipe Contreras
` (2 preceding siblings ...)
2020-11-19 1:52 ` [PATCH 3/4] completion: bash: fix for suboptions with value Felipe Contreras
@ 2020-11-19 1:52 ` Felipe Contreras
3 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2020-11-19 1:52 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, SZEDER Gábor, 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 5b2dff150d..7e893abf43 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -412,7 +412,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.29.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-11-19 1:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 1:52 [PATCH 0/4] completion: bash: a bunch of fixes Felipe Contreras
2020-11-19 1:52 ` [PATCH 1/4] completion: bash: fix prefix detection in branch.* Felipe Contreras
2020-11-19 1:52 ` [PATCH 2/4] completion: bash: add correct suffix in variables Felipe Contreras
2020-11-19 1:52 ` [PATCH 3/4] completion: bash: fix for suboptions with value Felipe Contreras
2020-11-19 1:52 ` [PATCH 4/4] completion: bash: fix for multiple dash commands Felipe Contreras
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).