completion: bash: a bunch of fixes
cover completion: bash: a bunch of fixes
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(-)
Signature · 1 line
2.29.2
PATCH 1/4 completion: bash: fix prefix detection in branch.*
Otherwise we are completely ignoring the --cur argument.
The issue can be tested with:
git clone --config=branch.<tab>
--- contrib/completion/git-completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
contrib/completion/git-completion.bash +2 -2
@@ -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
Signature · 1 line
2.29.2
PATCH 2/4 completion: bash: add correct suffix in variables
In reply to 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>
--- contrib/completion/git-completion.bash | 6 +++--- t/t9902-completion.sh | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-)
contrib/completion/git-completion.bash +3 -3
@@ -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.*.*)
t/t9902-completion.sh +7 -0
@@ -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
Signature · 1 line
2.29.2
PATCH 3/4 completion: bash: fix for suboptions with value
In reply to Felipe ContrerasWe 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>
--- contrib/completion/git-completion.bash | 2 +- t/t9902-completion.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)
contrib/completion/git-completion.bash +1 -1
@@ -347,7 +347,7 @@ __gitcomp () local cur_="${3-$cur}" case "$cur_" in - --*=) + *=) ;; --no-*) local c i=0 IFS=$' \t\n'
t/t9902-completion.sh +15 -0
@@ -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" &&
Signature · 1 line
2.29.2
PATCH 4/4 completion: bash: fix for multiple dash commands
In reply to Felipe ContrerasOtherwise commands like 'for-each-ref' are not completed.
--- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/completion/git-completion.bash +1 -1
@@ -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-}"
Signature · 1 line
2.29.2