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

Re: [PATCH/RFC] git.c: support "!!" aliases that do not move cwd

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Oct 11, 2016, 11:51 UTC
Message-ID
<20161011135107.Horde.XsPGOYSpK0L1qW2xMcGqD1i@webmail.informatik.kit.edu>
In-Reply-To
<CACsJy8Bip0mscutDHib-2O1g+eN2twO0m+OyOg2BTUudjOdwfw@mail.gmail.com>
Quoting Duy Nguyen <pclouds@gmail.com>:
Show 23 quoted lines
> On Fri, Oct 7, 2016 at 10:55 PM, Jakub Narębski <jnareb@gmail.com> wrote:
>> W dniu 07.10.2016 o 16:19, Johannes Schindelin pisze:
>>> On Fri, 7 Oct 2016, Jakub Narębski wrote:
>>
>>>> Note that we would have to teach git completion about new syntax;
>>>> or new configuration variable if we go that route.
>>>
>>> Why would we? Git's completion does not expand aliases, it only completes
>>> the aliases' names, not their values.
>>
>> Because Git completion finds out which _options_ and _arguments_
>> to complete for an alias based on its expansion.
>>
>> Yes, this is nice bit of trickery...
>
> It's c63437c (bash: improve aliased command recognition - 2010-02-23)
> isn't it? This may favor j6t's approach [1] because retrieving alias
> attributes is much easier.
>
> [1]
> https://public-inbox.org/git/20161006190720.4ecf3ptl6msztoya@sigill.intra.peff.net/T/#mb1d7b8f31d595b05105b8ea2137756761e13dbf4
> --
> Duy
The completion script is concerned in three ways:
   1. it has to get the names of all aliases, to offer them along with
      git commands for 'git <TAB>' or 'git help <TAB>',
   2. it has to get the command executed in place of the alias, and
   3. strip everything that can't be a git command, so it can offer the
      right options for the aliased command.

The '!!' syntax is the easiest, I think it will just work even with the current completion code, no changes necessary.

The '(nocd)' form is still easy, we only have to add this '(nocd)' to that list of stripped words for (3), but no further changes necessary for (1) and (2).

'alias.d2u.command' is tricky. Both (1) and (2) require adjustments, preferably in a way that doesn't involve additional git processes, at least for (1), as it is executed often, for every 'git <TAB>', for the sake of users on platforms with not particularly stellar fork()+exec() performance. I think it would be possible to have only one 'git config --get-regexp' and a little bit of post processing in each case, but I didn't think too hard about possible pitfalls, especially when dealing with ambiguity when both 'alias.d2u' and 'alias.d2u.command' are set. And I won't think any more about it until a conclusion is reached that we'll go this route :)

Previous: Duy NguyenNext: Jakub Narębski
Message 31 of 34 in “git.c: support "!!" aliases that do not move cwd”
  1. git.c: support "!!" aliases that do not move cwdNguyễn Thái Ngọc Duy, Oct 6, 2016
  2. Junio C HamanoOct 6, 2016
  3. Johannes SchindelinOct 7, 2016
  4. Duy NguyenOct 7, 2016
  5. Matthieu MoyOct 7, 2016
  6. Duy NguyenOct 7, 2016
  7. Johannes SchindelinOct 7, 2016
  8. Matthieu MoyOct 7, 2016
  9. Johannes SchindelinOct 7, 2016
  10. Jeff KingOct 7, 2016
  11. Johannes SixtOct 7, 2016
  12. Jeff KingOct 7, 2016
  13. Johannes SchindelinOct 8, 2016
  14. Jeff KingOct 9, 2016
  15. Jeff KingOct 9, 2016
  16. Duy NguyenOct 9, 2016
  17. Jeff KingOct 9, 2016
  18. Junio C HamanoOct 10, 2016
  19. Jeff KingOct 10, 2016
  20. Junio C HamanoOct 10, 2016
  21. Johannes SchindelinOct 11, 2016
  22. Duy NguyenOct 11, 2016
  23. Johannes SchindelinOct 11, 2016
  24. Jeff KingOct 11, 2016
  25. Duy NguyenOct 26, 2016
  26. Junio C HamanoOct 26, 2016
  27. Jakub NarębskiOct 7, 2016
  28. Johannes SchindelinOct 7, 2016
  29. Jakub NarębskiOct 7, 2016
  30. Duy NguyenOct 8, 2016
  31. SZEDER GáborOct 11, 2016
  32. Jakub NarębskiOct 11, 2016
  33. Jeff KingOct 6, 2016
  34. Jeff KingOct 6, 2016

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.