git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-completion with bash alias

From
Jeff King <peff@peff.net>
Date
May 19, 2012, 00:41 UTC
Message-ID
<20120519004147.GE765@sigill.intra.peff.net>
In-Reply-To
<CACY+Hvqd6L7gWgDBvjPmLPsfA2o1CVKuqkDZ_j7XYf=WjuwvKQ@mail.gmail.com>
On Fri, May 18, 2012 at 01:35:24PM +0200, Carsten Mattner wrote:
Show 6 quoted lines
> 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
Previous: Carsten MattnerNext: Felipe Contreras
Message 2 of 5 in “git-completion with bash alias”
  1. Carsten MattnerMay 18, 2012
  2. Jeff KingMay 19, 2012
  3. Felipe ContrerasMay 19, 2012
  4. Carsten MattnerMay 19, 2012
  5. Carsten MattnerMay 19, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.