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

Re: [PATCH] completion: bash: support recursive aliases

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Nov 10, 2020, 01:10 UTC
Message-ID
<CAMP44s36ThnMondH8w-VDi4vWNL0Cpkx+o1qRkx_giJvyfh0dg@mail.gmail.com>
In-Reply-To
<xmqq4klyb1w2.fsf@gitster.c.googlers.com>
On Mon, Nov 9, 2020 at 4:29 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 7 quoted lines
> >> So the completion should detect such aliases as well.
>
> Two comments.
>
>  - on design, is it possible to make a set of aliases that form a
>    cycle?  do we need to worry about such case?  what does the
>    current implementation do for an "alias" in such a cycle?
Yes. The first try would be stuck in a loop until the user types CTRL+C.
I already sent a second version that fixes that.
Show 6 quoted lines
>  - on implementation, it is done as a recursive call to the same
>    function, but a loop that naturally maps tail recursion would
>    also be a trivial implementation.  is it worth rewriting the
>    recursive calls into a loop?  if we need to solve the circular
>    references (above) by say limiting the length of the cycle, would
>    such a rewrite make sense as a way to help implementation?

Yes, that can be done. I opted for the minimal change so it was easy to understand what the code was trying to do.

The second version works in the way you suggested.
-- 
Felipe Contreras
Previous: Junio C HamanoNext: Felipe Contreras
Message 4 of 8 in “completion: bash: support recursive aliases”
  1. completion: bash: support recursive aliasesFelipe Contreras, Nov 9, 2020
  2. Taylor BlauNov 9, 2020
  3. Junio C HamanoNov 9, 2020
  4. Felipe ContrerasNov 10, 2020
  5. Felipe ContrerasNov 10, 2020
  6. Jeff KingNov 9, 2020
  7. Felipe ContrerasNov 10, 2020
  8. Jeff KingNov 10, 2020

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.