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

Re: [PATCH] bash: support user-supplied completion scripts for user's git commands

From: SZEDER Gábor <hidden>
Date: 2016-06-15 22:48:07

Possibly related (same subject, not in this thread)

Hi Shawn,

On Fri, Jan 29, 2010 at 11:13:26AM -0800, Shawn O. Pearce wrote:
SZEDER G?bor [off-list ref] wrote:
quoted
How about something like this for subcommands (not aliases)?  It's a
good code size reduction anyway.
Hmm, I like this.  I just didn't know how to implement it...  :-)

Acked-by: Shawn O. Pearce <redacted>
quoted
+	local completion_func="_git_${command//-/_}"
+	declare -F $completion_func >/dev/null && $completion_func
Yay for knowing bash.  :-)
Heh.  I've found out about this 'declare -F' thing about two hours ago
(;


However.

I thought this should actually "Just Work" for aliases, too.  e.g.
Junio could use the following completion function to get 'git log's
options for his lgm alias:

_git_lgm () {
        _git_log
}

Unfortunately, it doesn't work at all.

In _git() first we have 'lgm' in $command, which is ok, but then comes
this alias handling thing

        local expansion=$(__git_aliased_command "$command")
        [ "$expansion" ] && command="$expansion"

which writes '!sh' into $command, and that doesn't look quite right
for me, although I admit that I can't seem to figure out how this
__git_aliased_command() is supposed to work (so much about knowing
bash ;).  Any insight?


Best,
Gábor
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help