From: SZEDER Gábor Date: Thu, 19 Dec 2019 15:09:18 +0000 (+0100) Subject: completion: return the index of found word from __git_find_on_cmdline() X-Git-Tag: v2.26.0-rc0~111^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=367efd54b34883889068255c370a4b9f079cec2d;p=thirdparty%2Fgit.git completion: return the index of found word from __git_find_on_cmdline() When using the __git_find_on_cmdline() helper function so far we've only been interested in which one of a set of words appear on the command line. To complete options for some of 'git worktree's subcommands in the following patches we'll need not only that, but the index of that word on the command line as well. Extend __git_find_on_cmdline() to optionally show the index of the found word on the command line (IOW in the $words array) when the '--show-idx' option is given. Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano --- diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 84ce84d65c..340d8defce 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1069,18 +1069,32 @@ __git_aliased_command () done } -# __git_find_on_cmdline requires 1 argument # Check whether one of the given words is present on the command line, # and print the first word found. +# +# Usage: __git_find_on_cmdline [