Skip to content

Commit 30bd55f

Browse files
phil-blaingitster
authored andcommitted
completion: add space after config variable names also in Bash 3
In be6444d (completion: bash: add correct suffix in variables, 2021-08-16), __git_complete_config_variable_name was changed to use "${sfx- }" instead of "$sfx" as the fourth argument of _gitcomp_nl and _gitcomp_nl_append, such that this argument evaluates to a space if sfx is unset. This was to ensure that e.g. git config branch.autoSetupMe[TAB] correctly completes to 'branch.autoSetupMerge ' with the trailing space. This commits notes that the fix only works in Bash 4 because in Bash 3 the 'local sfx' construct at the beginning of __git_complete_config_variable_name creates an empty string. Make the fix also work for Bash 3 by using the "unset or null' parameter expansion syntax ("${sfx:- }"), such that the parameter is also expanded to a space if it is set but null, as is the behaviour of 'local sfx' in Bash 3. Signed-off-by: Philippe Blain <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b50a608 commit 30bd55f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

contrib/completion/git-completion.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,7 +2750,7 @@ __git_complete_config_variable_name ()
27502750
local pfx="${cur_%.*}."
27512751
cur_="${cur_#*.}"
27522752
__gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
2753-
__gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }"
2753+
__gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx:- }"
27542754
return
27552755
;;
27562756
guitool.*.*)
@@ -2784,7 +2784,7 @@ __git_complete_config_variable_name ()
27842784
local pfx="${cur_%.*}."
27852785
cur_="${cur_#*.}"
27862786
__git_compute_all_commands
2787-
__gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx- }"
2787+
__gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx:- }"
27882788
return
27892789
;;
27902790
remote.*.*)
@@ -2800,7 +2800,7 @@ __git_complete_config_variable_name ()
28002800
local pfx="${cur_%.*}."
28012801
cur_="${cur_#*.}"
28022802
__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
2803-
__gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx- }"
2803+
__gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx:- }"
28042804
return
28052805
;;
28062806
url.*.*)

0 commit comments

Comments
 (0)