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

Re: [PATCH 1/4] bash: improve aliased command recognition

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 23, 2010, 22:11 UTC
Message-ID
<7v3a0rd2lz.fsf@alter.siamese.dyndns.org>
In-Reply-To
<90724961a941edd1317514dea0a1c64112dab61d.1266958460.git.szeder@ira.uka.de>
SZEDER Gábor <szeder@ira.uka.de> writes:
Show 11 quoted lines
> [alias]
>     lgm = "!sh -c 'GIT_NOTES_REF=refs/notes/amlog git log \"$@\" || :' -"
>
> The full parsing of a shell command alias like that in the completion
> code is clearly unfeasible.  However, we can easily improve on aliased
> command recognition by eleminating stuff that is definitely not a git
> command: shell commands (anything starting with '!'), command line
> options (anything starting with '-'), environment variables (anything
> with a '=' in it), and git itself.  This way the above alias would be
> handled correctly, and the completion script would correctly recognize
> "log" as the aliased git command.

I personally do not think such a heuristic is worth the trouble (both for writing and maintaining the completion code nor runtime overhead to iterate over words on the expansion).

I vaguely recall somebody floated an idea to tell completion code that "you may not know what lgm is, but it takes the same set of options as log" (either via config or a shell function---I don't recall the details). I think that would be a lot more robust, efficient and easy to explain solution to the same problem.

Previous: SZEDER GáborNext: SZEDER Gábor
Message 13 of 25 in “Custom git completion”
  1. David Rhodes ClymerJan 29, 2010
  2. Shawn O. PearceJan 29, 2010
  3. Junio C HamanoJan 29, 2010
  4. Shawn O. PearceJan 29, 2010
  5. Junio C HamanoJan 29, 2010
  6. bash: support user-supplied completion scripts for user's git commandsSZEDER Gábor, Jan 29, 2010
  7. Shawn O. PearceJan 29, 2010
  8. SZEDER GáborJan 29, 2010
  9. Shawn O. PearceJan 29, 2010
  10. SZEDER GáborJan 31, 2010
  11. 0/4 bash: support user-supplied completion scripts for custom git commands and aliasesSZEDER Gábor, Feb 23, 2010
  12. 1/4 bash: improve aliased command recognitionSZEDER Gábor, Feb 23, 2010
  13. Junio C HamanoFeb 23, 2010
  14. SZEDER GáborFeb 24, 2010
  15. Junio C HamanoFeb 24, 2010
  16. 2/4 bash: support user-supplied completion scripts for user's git commandsSZEDER Gábor, Feb 23, 2010
  17. 3/4 bash: support user-supplied completion scripts for aliasesSZEDER Gábor, Feb 23, 2010
  18. 4/4 bash: completion for gitk aliasesSZEDER Gábor, Feb 23, 2010
  19. Junio C HamanoJan 29, 2010
  20. SZEDER GáborFeb 26, 2010
  21. Junio C HamanoFeb 26, 2010
  22. Shawn O. PearceFeb 26, 2010
  23. David Rhodes ClymerJan 30, 2010
  24. David Rhodes ClymerJan 30, 2010
  25. David Rhodes ClymerJan 30, 2010

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.