completion: config --unset/get
v2 cover completion: config --unset/get
Changes since version 1:
- Simplified into one function
- Config file search done in reverse
- No longer messes up your config file
Stephen Boyd (2):
completion: add __git_config_get_set_variables() to get config
variables
completion: complete config variables for
--get/getall/unset/unset-all
contrib/completion/git-completion.bash | 33 ++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-)
PATCH v2 1/2 completion: add __git_config_get_set_variables() to get config variables
This function retrieves the set configuration variables from the appropriate configuration file. For example, if the user has previously specified --global only the global variables are returned. The same applies for --system, and --file. If no location has been specified, all set variables are returned.
--- contrib/completion/git-completion.bash | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)
contrib/completion/git-completion.bash +29 -0
@@ -1322,6 +1322,35 @@ _git_send_email () COMPREPLY=() } +__git_config_get_set_variables () +{ + local prevword word config_file= c=$COMP_CWORD + while [ $c -gt 1 ]; do + word="${COMP_WORDS[c]}" + case "$word" in + --global|--system|--file=*) + config_file="$word" + break + ;; + -f|--file) + config_file="$word $prevword" + break + ;; + esac + prevword=$word + c=$((--c)) + done + + for i in $(git --git-dir="$(__gitdir)" config $config_file --list \ + 2>/dev/null); do + case "$i" in + *.*) + echo "${i/=*/}" + ;; + esac + done +} + _git_config () { local cur="${COMP_WORDS[COMP_CWORD]}"
Signature · 1 line
1.6.3
PATCH v2 2/2 completion: complete config variables for --get/getall/unset/unset-all
This should make it easier for users to get and unset their configuration variables without having to open documentation or dig through their configuration file.
--- contrib/completion/git-completion.bash | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
contrib/completion/git-completion.bash +4 -0
@@ -1417,6 +1417,10 @@ _git_config () __gitcomp "$__git_send_email_suppresscc_options" return ;; + --get|--get-all|--unset|--unset-all) + __gitcomp "$(__git_config_get_set_variables)" + return + ;; *.*) COMPREPLY=() return
Signature · 1 line
1.6.3
Re: [PATCHv2 2/2] completion: complete config variables for --get/getall/unset/unset-all
Quoted 8 lines · Stephen Boyd
This should make it easier for users to get and unset their configuration variables without having to open documentation or dig through their configuration file.
Signed-off-by Stephen Boyd <[email protected]>--- contrib/completion/git-completion.bash | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
These probably could have been one patch, since the function is introduced only to support this one usage, and this patch is only 4 lines larger than the function definition anyway...
But yea, this series is better.
Quoted 18 lines
contrib/completion/git-completion.bash +4
-0@@ -1417,6 +1417,10 @@ _git_config () __gitcomp "$__git_send_email_suppresscc_options" return ;; + --get|--get-all|--unset|--unset-all) + __gitcomp "$(__git_config_get_set_variables)" + return + ;; *.*) COMPREPLY=() returnSignature · 1 line
1.6.3
Signature · 1 line
Shawn.
Re: [PATCHv2 2/2] completion: complete config variables for --get/getall/unset/unset-all
Quoted 3 lines · Shawn O. Pearce
These probably could have been one patch, since the function is introduced only to support this one usage, and this patch is only 4 lines larger than the function definition anyway...
Seeing that this hasn't been picked up yet, I'm fine with this being squashed into one commit. Could you use this combination of the two messages for the commit?
---8<----
Subject: completion: complete config variables for --get/getall/unset/unset-all
This should make it easier for users to get and unset their configuration variables without having to open documentation or dig through their configuration file.
__git_config_get_set_variables() retrieves the set configuration variables
from the appropriate configuration file. For example, if the user has
previously specified --global only the global variables are returned. The same applies for --system, and --file. If no location has been specified, all
set variables are returned.
Re: [PATCHv2 2/2] completion: complete config variables for --get/getall/unset/unset-all
Quoted 5 lines · Stephen Boyd
Quoted 3 lines · Shawn O. Pearce
These probably could have been one patch, since the function is introduced only to support this one usage, and this patch is only 4 lines larger than the function definition anyway...
Quoted 8 lines
Seeing that this hasn't been picked up yet, I'm fine with this being squashed into one commit. Could you use this combination of the two messages for the commit?
---8<----
Subject: completion: complete config variables for --get/getall/unset/unset-all
Hmm, shouldn't this just be
Subject: completion: complete variable names for "git config" command
?
Re: [PATCHv2 2/2] completion: complete config variables for --get/getall/unset/unset-all
Quoted 13 lines · Junio C Hamano
Quoted 11 lines · Stephen Boyd
Quoted 3 lines · Shawn O. Pearce
These probably could have been one patch, since the function is introduced only to support this one usage, and this patch is only 4 lines larger than the function definition anyway...
Seeing that this hasn't been picked up yet, I'm fine with this being squashed into one commit. Could you use this combination of the two messages for the commit?
---8<----
Quoted 9 lines
Quoted 2 lines
Subject: completion: complete config variables for --get/getall/unset/unset-all
Hmm, shouldn't this just be
Subject: completion: complete variable names for "git config" command
?
This patch adds completion for set variable names when --get, --get-all, --set, or --set-all has been specified. Completion of variable names for git config already exists. Maybe this would be more clear:
Subject: completion: complete set variable names for git config --get/get-all/set-set-all
Re: [PATCHv2 2/2] completion: complete config variables for --get/getall/unset/unset-all
Quoted 10 lines · Stephen Boyd
Quoted 9 lines
Quoted 2 lines
Subject: completion: complete config variables for --get/getall/unset/unset-all
Hmm, shouldn't this just be
Subject: completion: complete variable names for "git config" command
?
Quoted 7 lines
This patch adds completion for set variable names when --get, --get-all, --set, or --set-all has been specified. Completion of variable names for git config already exists. Maybe this would be more clear:
Subject: completion: complete set variable names for git config --get/get-all/set-set-all
Actually I was shooting for shorter description. It is more like
bash: complete variable names for "git config" with options
perhaps?
Re: [PATCHv2 2/2] completion: complete config variables for --get/getall/unset/unset-all
Quoted 17 lines · Junio C Hamano
Quoted 15 lines · Stephen Boyd
Quoted 9 lines
Quoted 2 lines
Subject: completion: complete config variables for --get/getall/unset/unset-all
Hmm, shouldn't this just be
Subject: completion: complete variable names for "git config" command
?
This patch adds completion for set variable names when --get, --get-all, --set, or --set-all has been specified. Completion of variable names for git config already exists. Maybe this would be more clear:
Quoted 10 lines
Quoted 2 lines
Subject: completion: complete set variable names for git config --get/get-all/set-set-all
Actually I was shooting for shorter description. It is more like
bash: complete variable names for "git config" with options
perhaps?
Heh, ok. This sounds fine.