Re: [PATCH v2] completion: improve doc for complex aliases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Philippe Blain via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:

> From: Philippe Blain <levraiphilippeblain@xxxxxxxxx>
>
> The completion code can be told to use a particular completion for
> aliases that shell out by using ': git <cmd> ;' as the first command of
> the alias. This only works if <cmd> and the semicolon are separated by a
> space, since if the space is missing __git_aliased_command returns (for
> example) 'checkout;' instead of just 'checkout', and then
> __git_complete_command fails to find a completion for 'checkout;'.
>
> The examples have that space but it's not clear if it's just for
> style or if it's mandatory. Explicitly mention it.
>
> Signed-off-by: Philippe Blain <levraiphilippeblain@xxxxxxxxx>
> ---

Thanks.  I scanned the case statement in the loop in the function
and thought "hmph, everybody says ': git <cmd> ;' but is 'git'
really needed?"

I had "git l3" alias that invokes "$HOM#/bin/git-l" command, like so:

    [alias]
            l3 = "!sh -c ': git log ; git l \"$@\"' -"

but if I did 's/: git log/: log/' it still completes just fine.

I wonder if this hack is worth adding, instead of (or in addition
to) requiring the user to insert $IFS to please the "parser", we can
honor the rather obvious wish of the user in a more direct way.



 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git c/contrib/completion/git-completion.bash w/contrib/completion/git-completion.bash
index 19139ac121..e31d71955f 100644
--- c/contrib/completion/git-completion.bash
+++ w/contrib/completion/git-completion.bash
@@ -1183,7 +1183,7 @@ __git_aliased_command ()
 			:)	: skip null command ;;
 			\'*)	: skip opening quote after sh -c ;;
 			*)
-				cur="$word"
+				cur="${word%;}"
 				break
 			esac
 		done



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux