All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 0/2] completion: config --unset/get
@ 2009-05-09  1:23 Stephen Boyd
  2009-05-09  1:23 ` [PATCHv2 1/2] completion: add __git_config_get_set_variables() to get config variables Stephen Boyd
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Boyd @ 2009-05-09  1:23 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

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(-)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCHv2 1/2] completion: add __git_config_get_set_variables() to get config variables
  2009-05-09  1:23 [PATCHv2 0/2] completion: config --unset/get Stephen Boyd
@ 2009-05-09  1:23 ` Stephen Boyd
  2009-05-09  1:23   ` [PATCHv2 2/2] completion: complete config variables for --get/getall/unset/unset-all Stephen Boyd
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Boyd @ 2009-05-09  1:23 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCHv2 2/2] completion: complete config variables for --get/getall/unset/unset-all
  2009-05-09  1:23 ` [PATCHv2 1/2] completion: add __git_config_get_set_variables() to get config variables Stephen Boyd
@ 2009-05-09  1:23   ` Stephen Boyd
  2009-05-09  3:44     ` Shawn O. Pearce
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Boyd @ 2009-05-09  1:23 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

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 <bebarino@gmail.com>
---
 contrib/completion/git-completion.bash |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index e73359c..ad26b7c 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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
-- 
1.6.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCHv2 2/2] completion: complete config variables for --get/getall/unset/unset-all
  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
  0 siblings, 1 reply; 9+ messages in thread
From: Shawn O. Pearce @ 2009-05-09  3:44 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: git, Junio C Hamano

Stephen Boyd <bebarino@gmail.com> wrote:
> 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 <bebarino@gmail.com>
> ---
>  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.

Acked-by: Shawn O. Pearce <spearce@spearce.org>


> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index e73359c..ad26b7c 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -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
> -- 
> 1.6.3
> 

-- 
Shawn.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCHv2 2/2] completion: complete config variables for --get/getall/unset/unset-all
  2009-05-09  3:44     ` Shawn O. Pearce
@ 2009-05-12  5:20       ` Stephen Boyd
  2009-05-12  8:12         ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Boyd @ 2009-05-12  5:20 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git, Junio C Hamano

Shawn O. Pearce wrote:
> 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.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCHv2 2/2] completion: complete config variables for --get/getall/unset/unset-all
  2009-05-12  5:20       ` Stephen Boyd
@ 2009-05-12  8:12         ` Junio C Hamano
  2009-05-12 19:05           ` Stephen Boyd
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2009-05-12  8:12 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: Shawn O. Pearce, git, Junio C Hamano

Stephen Boyd <bebarino@gmail.com> writes:

> Shawn O. Pearce wrote:
>> 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

Hmm, shouldn't this just be

    Subject: completion: complete variable names for "git config" command

?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCHv2 2/2] completion: complete config variables for  --get/getall/unset/unset-all
  2009-05-12  8:12         ` Junio C Hamano
@ 2009-05-12 19:05           ` Stephen Boyd
  2009-05-13 18:33             ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Boyd @ 2009-05-12 19:05 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Shawn O. Pearce, git

On Tue, May 12, 2009 at 1:12 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Stephen Boyd <bebarino@gmail.com> writes:
>
>> Shawn O. Pearce wrote:
>>> 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
>
> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCHv2 2/2] completion: complete config variables for  --get/getall/unset/unset-all
  2009-05-12 19:05           ` Stephen Boyd
@ 2009-05-13 18:33             ` Junio C Hamano
  2009-05-13 18:50               ` Stephen Boyd
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2009-05-13 18:33 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: Junio C Hamano, Shawn O. Pearce, git

Stephen Boyd <bebarino@gmail.com> writes:

>>> 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

Actually I was shooting for shorter description.  It is more like

	bash: complete variable names for "git config" with options

perhaps?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCHv2 2/2] completion: complete config variables for  --get/getall/unset/unset-all
  2009-05-13 18:33             ` Junio C Hamano
@ 2009-05-13 18:50               ` Stephen Boyd
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Boyd @ 2009-05-13 18:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Shawn O. Pearce, git

On Wed, May 13, 2009 at 11:33 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Stephen Boyd <bebarino@gmail.com> writes:
>
>>>> 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
>
> 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-05-13 18:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-09  1:23 [PATCHv2 0/2] completion: config --unset/get Stephen Boyd
2009-05-09  1:23 ` [PATCHv2 1/2] completion: add __git_config_get_set_variables() to get config variables Stephen Boyd
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

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.