Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:48:20

SZEDER Gábor [off-list ref] writes:
[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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help