aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorStephen Boyd <bebarino@gmail.com>2009-05-08 18:23:32 -0700
committerJunio C Hamano <gitster@pobox.com>2009-05-13 12:59:06 -0700
commit00652369ff285f84e440f5d41d708283e30825d7 (patch)
treec44993a3591efc6b8156bf8d956f3131d906708f /contrib
parent4bf1f68ee7a894e7e4936217eec7e6ae5fa4db77 (diff)
downloadgit-00652369ff285f84e440f5d41d708283e30825d7.tar.gz
git-00652369ff285f84e440f5d41d708283e30825d7.tar.xz
bash completion: complete variable names for "git config" with options
This makes 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. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/completion/git-completion.bash33
1 files changed, 33 insertions, 0 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 1683e6d7b..ad26b7c5a 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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]}"
@@ -1388,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