All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <bebarino@gmail.com>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: git@vger.kernel.org
Subject: [PATCHv2 1/2] completion: add __git_config_get_set_variables() to get config variables
Date: Fri,  8 May 2009 18:23:32 -0700	[thread overview]
Message-ID: <1241832213-23070-2-git-send-email-bebarino@gmail.com> (raw)
In-Reply-To: <1241832213-23070-1-git-send-email-bebarino@gmail.com>

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.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
 contrib/completion/git-completion.bash |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 1683e6d..e73359c 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]}"
-- 
1.6.3

  reply	other threads:[~2009-05-09  1:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-09  1:23 [PATCHv2 0/2] completion: config --unset/get Stephen Boyd
2009-05-09  1:23 ` Stephen Boyd [this message]
2009-05-09  1:23   ` [PATCHv2 2/2] completion: complete config variables for --get/getall/unset/unset-all Stephen Boyd
2009-05-09  3:44     ` Shawn O. Pearce
2009-05-12  5:20       ` Stephen Boyd
2009-05-12  8:12         ` Junio C Hamano
2009-05-12 19:05           ` Stephen Boyd
2009-05-13 18:33             ` Junio C Hamano
2009-05-13 18:50               ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1241832213-23070-2-git-send-email-bebarino@gmail.com \
    --to=bebarino@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.