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

Re: [PATCH 5/5] completion: fix completion of certain aliases

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 9, 2014, 20:36 UTC
Message-ID
<5345af56dec8c_537810af310b9@nysa.notmuch>
In-Reply-To
<xmqqa9bu1enk.fsf@gitster.dls.corp.google.com>
Junio C Hamano wrote:
Show 17 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
> 
> > Some commands need the first word to determine the actual action that is
> > being executed, however, the command is wrong when we use an alias, for
> > example 'alias.p=push', if we try to complete 'git p origin ', the
> > result would be wrong because __git_complete_remote_or_refspec() doesn't
> > know where it come from.
> >
> > So let's override words[1], so the alias 'p' is override by the actual
> > command, 'push'.
> >
> > Reported-by: Aymeric Beaumet <aymeric.beaumet@gmail.com>
> > Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> > ---
> 
> Does "some commands" above refer to anything that uses
> __git_complete_remote_or_refspec, or is the set of commands larger than that?
For this particular issue, yes, the former.
> But perhaps we muck with the contents of words[] in a similar way in many
> different places in the existing completion code often enough that such an
> attempt not to touch the words[] array does not buy us much safety anyway.  I
> didn't check (and that is why I am asking with "I am wondering...").

The 'words' array is already messed up and not used correctly, so I wouldn't worry too much about this patch messing it more (I don't see how that can be).

For example:
  % git --git-dir=$PWD/.git fetch or<tab>
-- 
Felipe Contreras
Previous: Junio C Hamano
Message 8 of 8 in “Fixes”
  1. 0/5 FixesFelipe Contreras, Apr 9, 2014
  2. 1/5 remote-helpers: allow all tests running from any dirFelipe Contreras, Apr 9, 2014
  3. 2/5 remote-hg: always normalize pathsFelipe Contreras, Apr 9, 2014
  4. 3/5 remote-bzr: add support for older versionsFelipe Contreras, Apr 9, 2014
  5. 4/5 remote-bzr: include authors field in pushed commitsFelipe Contreras, Apr 9, 2014
  6. 5/5 completion: fix completion of certain aliasesFelipe Contreras, Apr 9, 2014
  7. Junio C HamanoApr 9, 2014
  8. Felipe ContrerasApr 9, 2014

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.