All of lore.kernel.org
 help / color / mirror / Atom feed
* git-completion with bash alias
@ 2012-05-18 11:35 Carsten Mattner
  2012-05-19  0:41 ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Carsten Mattner @ 2012-05-18 11:35 UTC (permalink / raw)
  To: git

Completion works when used as "git checkout foo" but fails with
"bash: [: 1: unary operator expected" when trying to complete
via a single character shell alias like "alias g=git" as in
"g checkout foo".

git version 1.7.10.2.548.g9de9681

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

* Re: git-completion with bash alias
  2012-05-18 11:35 git-completion with bash alias Carsten Mattner
@ 2012-05-19  0:41 ` Jeff King
  2012-05-19  2:28   ` Felipe Contreras
  2012-05-19  7:48   ` Carsten Mattner
  0 siblings, 2 replies; 5+ messages in thread
From: Jeff King @ 2012-05-19  0:41 UTC (permalink / raw)
  To: Carsten Mattner; +Cc: Felipe Contreras, git

On Fri, May 18, 2012 at 01:35:24PM +0200, Carsten Mattner wrote:

> Completion works when used as "git checkout foo" but fails with
> "bash: [: 1: unary operator expected" when trying to complete
> via a single character shell alias like "alias g=git" as in
> "g checkout foo".
> 
> git version 1.7.10.2.548.g9de9681

Hmm. Are you invoking the completion like:

  complete -F _git g

? That used to work, but was broken by the recent 6b179ad (completion:
add new __git_complete helper, 2012-05-14).

The "new" way seems to be:

  __git_complete g _git

but that function is explicitly labeled as "not public". It looks like
there was a follow-on patch that was discussed to make a public version,
but it got dropped.

I'm not sure if this regression is intentional, or if the "old" way even
worked reliably (I seem to recall people running into issues with
_get_comp_words_by_ref not being called properly sometimes, but I don't
remember the details). So it's not clear to me if the right way forward
is fixing "complete -F _git" to work again, or if that way is just
broken, and a public version of __git_complete is the right path.

Felipe, can you comment?

-Peff

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

* Re: git-completion with bash alias
  2012-05-19  0:41 ` Jeff King
@ 2012-05-19  2:28   ` Felipe Contreras
  2012-05-19  7:50     ` Carsten Mattner
  2012-05-19  7:48   ` Carsten Mattner
  1 sibling, 1 reply; 5+ messages in thread
From: Felipe Contreras @ 2012-05-19  2:28 UTC (permalink / raw)
  To: Jeff King; +Cc: Carsten Mattner, git

On Sat, May 19, 2012 at 2:41 AM, Jeff King <peff@peff.net> wrote:
> On Fri, May 18, 2012 at 01:35:24PM +0200, Carsten Mattner wrote:
>
>> Completion works when used as "git checkout foo" but fails with
>> "bash: [: 1: unary operator expected" when trying to complete
>> via a single character shell alias like "alias g=git" as in
>> "g checkout foo".
>>
>> git version 1.7.10.2.548.g9de9681
>
> Hmm. Are you invoking the completion like:
>
>  complete -F _git g

s/_git/__git_wrap_git/

> ? That used to work, but was broken by the recent 6b179ad (completion:
> add new __git_complete helper, 2012-05-14).
>
> The "new" way seems to be:
>
>  __git_complete g _git
>
> but that function is explicitly labeled as "not public". It looks like
> there was a follow-on patch that was discussed to make a public version,
> but it got dropped.

Well, _git was probably not public either.

> I'm not sure if this regression is intentional, or if the "old" way even
> worked reliably (I seem to recall people running into issues with
> _get_comp_words_by_ref not being called properly sometimes, but I don't
> remember the details). So it's not clear to me if the right way forward
> is fixing "complete -F _git" to work again, or if that way is just
> broken, and a public version of __git_complete is the right path.
>
> Felipe, can you comment?

The problem is with certain functions (e.g. _git_fetch), which are
broken not only for aliases: try 'git --git-dir=$PWD fetch <tab>'.

Should be easy to provide backward compatibility though.

I'll send a patch soon.

-- 
Felipe Contreras

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

* Re: git-completion with bash alias
  2012-05-19  0:41 ` Jeff King
  2012-05-19  2:28   ` Felipe Contreras
@ 2012-05-19  7:48   ` Carsten Mattner
  1 sibling, 0 replies; 5+ messages in thread
From: Carsten Mattner @ 2012-05-19  7:48 UTC (permalink / raw)
  To: Jeff King; +Cc: Felipe Contreras, git

On Sat, May 19, 2012 at 2:41 AM, Jeff King <peff@peff.net> wrote:
> On Fri, May 18, 2012 at 01:35:24PM +0200, Carsten Mattner wrote:
>
>> Completion works when used as "git checkout foo" but fails with
>> "bash: [: 1: unary operator expected" when trying to complete
>> via a single character shell alias like "alias g=git" as in
>> "g checkout foo".
>>
>> git version 1.7.10.2.548.g9de9681
>
> Hmm. Are you invoking the completion like:
>
>  complete -F _git g

Is that supposed to be enough to get it working?

> ? That used to work, but was broken by the recent 6b179ad (completion:
> add new __git_complete helper, 2012-05-14).
>
> The "new" way seems to be:
>
>  __git_complete g _git

Found that in 6b179adf in next and it worked.
I used to have this
complete -o bashdefault -o default -o nospace -F _git g \
  2>/dev/null || complete -o default -o nospace -F _git g

> but that function is explicitly labeled as "not public". It looks like
> there was a follow-on patch that was discussed to make a public version,
> but it got dropped.
>
> I'm not sure if this regression is intentional, or if the "old" way even
> worked reliably (I seem to recall people running into issues with
> _get_comp_words_by_ref not being called properly sometimes, but I don't
> remember the details). So it's not clear to me if the right way forward
> is fixing "complete -F _git" to work again, or if that way is just
> broken, and a public version of __git_complete is the right path.
>
> Felipe, can you comment?
>
> -Peff

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

* Re: git-completion with bash alias
  2012-05-19  2:28   ` Felipe Contreras
@ 2012-05-19  7:50     ` Carsten Mattner
  0 siblings, 0 replies; 5+ messages in thread
From: Carsten Mattner @ 2012-05-19  7:50 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Jeff King, git

On Sat, May 19, 2012 at 4:28 AM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> On Sat, May 19, 2012 at 2:41 AM, Jeff King <peff@peff.net> wrote:
>> On Fri, May 18, 2012 at 01:35:24PM +0200, Carsten Mattner wrote:
>>
>>> Completion works when used as "git checkout foo" but fails with
>>> "bash: [: 1: unary operator expected" when trying to complete
>>> via a single character shell alias like "alias g=git" as in
>>> "g checkout foo".
>>>
>>> git version 1.7.10.2.548.g9de9681
>>
>> Hmm. Are you invoking the completion like:
>>
>>  complete -F _git g
>
> s/_git/__git_wrap_git/
>
>> ? That used to work, but was broken by the recent 6b179ad (completion:
>> add new __git_complete helper, 2012-05-14).
>>
>> The "new" way seems to be:
>>
>>  __git_complete g _git
>>
>> but that function is explicitly labeled as "not public". It looks like
>> there was a follow-on patch that was discussed to make a public version,
>> but it got dropped.
>
> Well, _git was probably not public either.
>
>> I'm not sure if this regression is intentional, or if the "old" way even
>> worked reliably (I seem to recall people running into issues with
>> _get_comp_words_by_ref not being called properly sometimes, but I don't
>> remember the details). So it's not clear to me if the right way forward
>> is fixing "complete -F _git" to work again, or if that way is just
>> broken, and a public version of __git_complete is the right path.
>>
>> Felipe, can you comment?
>
> The problem is with certain functions (e.g. _git_fetch), which are
> broken not only for aliases: try 'git --git-dir=$PWD fetch <tab>'.
>
> Should be easy to provide backward compatibility though.
>
> I'll send a patch soon.

Any advice what I should put after alias g=git to enable
completion for g? Temporarily using "__git_complete g _git".

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

end of thread, other threads:[~2012-05-19  7:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-18 11:35 git-completion with bash alias Carsten Mattner
2012-05-19  0:41 ` Jeff King
2012-05-19  2:28   ` Felipe Contreras
2012-05-19  7:50     ` Carsten Mattner
2012-05-19  7:48   ` Carsten Mattner

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.