From: SZEDER Gábor Date: Tue, 13 Aug 2019 12:26:49 GMT Subject: [PATCH 08/11] completion: complete configuration sections and variable names for 'git -c' Message-ID: <20190813122652.16468-9-szeder.dev@gmail.com> In-Reply-To: <20190813122652.16468-1-szeder.dev@gmail.com> 'git config' expects a configuration variable's name and value in separate arguments, so we let the __gitcomp() helper append a space character to each variable name by default, like we do for most other things (--options, refs, paths, etc.). 'git -c', however, expects them in a single option joined by a '=' character, i.e. 'section.name=value', so we should append a '=' character to each fully completed variable name, but no space, so the user can continue typing the value right away. Add an option to the __git_complete_config_variable_name() function to allow callers to specify an alternate suffix to add, and use it to append that '=' character to configuration variables. Update the __gitcomp() helper function to not append a trailing space to any completion words ending with a '=', not just to those option with a stuck argument. Signed-off-by: SZEDER Gábor --- contrib/completion/git-completion.bash | 59 ++++++++++++++++++++------ t/t9902-completion.sh | 14 ++++++ 2 files changed, 60 insertions(+), 13 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 3e9c5b6b71..367b1c50f4 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -360,7 +360,7 @@ __gitcomp () c="$c${4-}" if [[ $c == "$cur_"* ]]; then case $c in - --*=|*.) ;; + *=|*.) ;; *) c="$c " ;; esac COMPREPLY[i++]="${2-}$c" @@ -2328,18 +2328,33 @@ __git_complete_config_variable_value () } # Completes configuration sections, subsections, variable names. +# +# Usage: __git_complete_config_variable_name [