git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git-completion.bash --local
@ 2013-02-09 18:37 Dasa Paddock
  2013-02-11 21:04 ` Jeff King
  2013-02-12 12:20 ` [PATCH] completion: support 'git config --local' Matthieu Moy
  0 siblings, 2 replies; 9+ messages in thread
From: Dasa Paddock @ 2013-02-09 18:37 UTC (permalink / raw)
  To: git@vger.kernel.org

I think this line should include --local:

https://github.com/git/git/blob/next/contrib/completion/git-completion.bash#L1782
    "--global|--system|--file=*)"

This would help for:
    git config -l --local

Thanks,
Dasa Paddock

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

* Re: git-completion.bash --local
  2013-02-09 18:37 git-completion.bash --local Dasa Paddock
@ 2013-02-11 21:04 ` Jeff King
  2013-02-12  5:49   ` [PATCH] completion: recognize "--local" as a config file source Jeff King
  2013-02-12 12:20 ` [PATCH] completion: support 'git config --local' Matthieu Moy
  1 sibling, 1 reply; 9+ messages in thread
From: Jeff King @ 2013-02-11 21:04 UTC (permalink / raw)
  To: Dasa Paddock; +Cc: git@vger.kernel.org

On Sat, Feb 09, 2013 at 06:37:28PM +0000, Dasa Paddock wrote:

> I think this line should include --local:
> 
> https://github.com/git/git/blob/next/contrib/completion/git-completion.bash#L1782
>     "--global|--system|--file=*)"

Yeah, I think that makes sense.

Care to prepare a patch?

-Peff

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

* [PATCH] completion: recognize "--local" as a config file source
  2013-02-11 21:04 ` Jeff King
@ 2013-02-12  5:49   ` Jeff King
  0 siblings, 0 replies; 9+ messages in thread
From: Jeff King @ 2013-02-12  5:49 UTC (permalink / raw)
  To: Dasa Paddock; +Cc: git@vger.kernel.org, Junio C Hamano

When we are trying to show the list of config variables in a
file, we recognize "--system", "--global", and "--file" as
specifying a particular file. This list misses "--local",
which performs a similar function.

Without this patch, completing:

  git config --get --local

shows items from all config files, not just the local one.

Noticed-by: Dasa Paddock <dpaddock@esri.com>
Signed-off-by: Jeff King <peff@peff.net>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c8452fb..0b7b659 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1779,7 +1779,7 @@ __git_config_get_set_variables ()
 	while [ $c -gt 1 ]; do
 		word="${words[c]}"
 		case "$word" in
-		--global|--system|--file=*)
+		--global|--system|--local|--file=*)
 			config_file="$word"
 			break
 			;;
-- 
1.8.1.2.11.g1a2f572

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

* [PATCH] completion: support 'git config --local'
  2013-02-09 18:37 git-completion.bash --local Dasa Paddock
  2013-02-11 21:04 ` Jeff King
@ 2013-02-12 12:20 ` Matthieu Moy
  2013-02-12 17:34   ` Junio C Hamano
  1 sibling, 1 reply; 9+ messages in thread
From: Matthieu Moy @ 2013-02-12 12:20 UTC (permalink / raw)
  To: git, gitster; +Cc: Dasa Paddock, Matthieu Moy

This needs to be done in two places: __git_config_get_set_variables to
allow clever completion of "git config --local --get foo<tab>", and
_git_config to allow "git config --loc<tab>" to complete to --local.

While we're there, change the order of options in the code to match
git-config.txt.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
> I think this line should include --local:
> 
> https://github.com/git/git/blob/next/contrib/completion/git-completion.bash#L1782
>     "--global|--system|--file=*)"
> 
> This would help for:
>     git config -l --local

Yes, but not only ;-)

 contrib/completion/git-completion.bash | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 5770b6f..2e1ad67 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1570,7 +1570,7 @@ __git_config_get_set_variables ()
 	while [ $c -gt 1 ]; do
 		word="${words[c]}"
 		case "$word" in
-		--global|--system|--file=*)
+		--system|--global|--local|--file=*)
 			config_file="$word"
 			break
 			;;
@@ -1676,7 +1676,7 @@ _git_config ()
 	case "$cur" in
 	--*)
 		__gitcomp "
-			--global --system --file=
+			--system --global --local --file=
 			--list --replace-all
 			--get --get-all --get-regexp
 			--add --unset --unset-all
-- 
1.8.1.2.548.g956380a.dirty

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

* Re: [PATCH] completion: support 'git config --local'
  2013-02-12 12:20 ` [PATCH] completion: support 'git config --local' Matthieu Moy
@ 2013-02-12 17:34   ` Junio C Hamano
  2013-02-12 21:11     ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2013-02-12 17:34 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git, Dasa Paddock, Jeff King

Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> This needs to be done in two places: __git_config_get_set_variables to
> allow clever completion of "git config --local --get foo<tab>", and
> _git_config to allow "git config --loc<tab>" to complete to --local.
>
> While we're there, change the order of options in the code to match
> git-config.txt.
>
> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
>> I think this line should include --local:
>> 
>> https://github.com/git/git/blob/next/contrib/completion/git-completion.bash#L1782
>>     "--global|--system|--file=*)"
>> 
>> This would help for:
>>     git config -l --local
>
> Yes, but not only ;-)

I see the second hunk is new.  Comments?

How would this interract with the writing side of "git config"?
"git config --local foo.bar value" and "git config foo.bar value"
are the same, no?

Is it "yes they are the same but it does not hurt?"

>  contrib/completion/git-completion.bash | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 5770b6f..2e1ad67 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1570,7 +1570,7 @@ __git_config_get_set_variables ()
>  	while [ $c -gt 1 ]; do
>  		word="${words[c]}"
>  		case "$word" in
> -		--global|--system|--file=*)
> +		--system|--global|--local|--file=*)
>  			config_file="$word"
>  			break
>  			;;
> @@ -1676,7 +1676,7 @@ _git_config ()
>  	case "$cur" in
>  	--*)
>  		__gitcomp "
> -			--global --system --file=
> +			--system --global --local --file=
>  			--list --replace-all
>  			--get --get-all --get-regexp
>  			--add --unset --unset-all

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

* Re: [PATCH] completion: support 'git config --local'
  2013-02-12 17:34   ` Junio C Hamano
@ 2013-02-12 21:11     ` Jeff King
  2013-02-12 22:13       ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff King @ 2013-02-12 21:11 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthieu Moy, git, Dasa Paddock

On Tue, Feb 12, 2013 at 09:34:39AM -0800, Junio C Hamano wrote:

> I see the second hunk is new.  Comments?
> [...]
> > @@ -1676,7 +1676,7 @@ _git_config ()
> >  	case "$cur" in
> >  	--*)
> >  		__gitcomp "
> > -			--global --system --file=
> > +			--system --global --local --file=
> >  			--list --replace-all
> >  			--get --get-all --get-regexp
> >  			--add --unset --unset-all

It makes sense to me. It just means that "--local" itself gets completed
(while the other hunk is about using the presence of "--local" impacting
other completion). It's an orthogonal issue, but I don't mind them in
the same patch.

> How would this interract with the writing side of "git config"?
> "git config --local foo.bar value" and "git config foo.bar value"
> are the same, no?
> 
> Is it "yes they are the same but it does not hurt?"

It doesn't affect writing at all. The change is in
__git_config_get_set_variables, which is used only here:

  --get|--get-all|--unset|--unset-all)
        __gitcomp_nl "$(__git_config_get_set_variables)"

So it is purely about completing existing variables, and it's right to
limit itself to a particular file if we know that is what has been
given.

I'm not sure I understand the original poster's point about "git config
-l --local". "-l" does not take a limiter, does it?

-Peff

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

* Re: [PATCH] completion: support 'git config --local'
  2013-02-12 21:11     ` Jeff King
@ 2013-02-12 22:13       ` Junio C Hamano
  2013-02-13  0:05         ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2013-02-12 22:13 UTC (permalink / raw)
  To: Jeff King; +Cc: Matthieu Moy, git, Dasa Paddock

Jeff King <peff@peff.net> writes:

> I'm not sure I understand the original poster's point about "git config
> -l --local". "-l" does not take a limiter, does it?

"git config -l core.\*" will just die without limiting the output to
everything under core. hierarchy, so you are right---the combination
does not make any sense.  You have to say

    git config -l | grep ^core\\.

or something like that.

Completing "git config -l --lo<TAB>" still may help, though.

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

* Re: [PATCH] completion: support 'git config --local'
  2013-02-12 22:13       ` Junio C Hamano
@ 2013-02-13  0:05         ` Jeff King
  2013-02-13  7:44           ` Matthieu Moy
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff King @ 2013-02-13  0:05 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthieu Moy, git, Dasa Paddock

On Tue, Feb 12, 2013 at 02:13:05PM -0800, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> > I'm not sure I understand the original poster's point about "git config
> > -l --local". "-l" does not take a limiter, does it?
> 
> "git config -l core.\*" will just die without limiting the output to
> everything under core. hierarchy, so you are right---the combination
> does not make any sense.  You have to say
> 
>     git config -l | grep ^core\\.
> 
> or something like that.
> 
> Completing "git config -l --lo<TAB>" still may help, though.

Ah, I think I see Dasa's original point now. He was interested in fixing
"--lo<TAB>" to complete "--local". But the line he pointed to in his
original message is not the right place for that; it is the site of an
unrelated spot which should _also_ be fixed to use "--local", but for a
different reason (restricting the variables suggested for "--local --get
<TAB>" properly).

So yeah. Matthieu's patch is the right thing to do, as it covers both
(mine fixed only half of it).

-Peff

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

* Re: [PATCH] completion: support 'git config --local'
  2013-02-13  0:05         ` Jeff King
@ 2013-02-13  7:44           ` Matthieu Moy
  0 siblings, 0 replies; 9+ messages in thread
From: Matthieu Moy @ 2013-02-13  7:44 UTC (permalink / raw)
  To: Jeff King; +Cc: Junio C Hamano, git, Dasa Paddock

Jeff King <peff@peff.net> writes:

> So yeah. Matthieu's patch is the right thing to do, as it covers both

Thanks,

> (mine fixed only half of it).

(Sorry, I had missed yours)

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

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

end of thread, other threads:[~2013-02-13  7:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-09 18:37 git-completion.bash --local Dasa Paddock
2013-02-11 21:04 ` Jeff King
2013-02-12  5:49   ` [PATCH] completion: recognize "--local" as a config file source Jeff King
2013-02-12 12:20 ` [PATCH] completion: support 'git config --local' Matthieu Moy
2013-02-12 17:34   ` Junio C Hamano
2013-02-12 21:11     ` Jeff King
2013-02-12 22:13       ` Junio C Hamano
2013-02-13  0:05         ` Jeff King
2013-02-13  7:44           ` Matthieu Moy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).