RE: Error in bash completion
- From
Felipe Contreras <felipe.contreras@gmail.com>
- Date
- Jun 17, 2021, 02:06 UTC
- Message-ID
- <60caae2f893ec_894e2085d@natae.notmuch>
- In-Reply-To
- <CAHLeu+y3DxLv7M4SM2f5yVxtKXbpAWD7Ad2m+rVKpKfKiA6PVw@mail.gmail.com>
Harrison McCullough wrote:
Show 6 quoted lines
> What did you do before the bug happened? (Steps to reproduce your issue)
>
> 1. Create a Bash function, e.g. `ga() { git add "${@:-.}"; }`
> 2. Use the `__git_complete` function to add Bash tab completion for your custom
> Bash function, e.g. `__git_complete ga git_add`
> 3. Attempt to tab complete a file path, e.g. `ga my-incomplete-file-path<TAB>`I can reproduce this issue; it's caused by 59d85a2a05 (git-completion.bash: use $__git_cmd_idx in more places, 2021-04-22) which is present in v2.32.
The problem is that __git_find_on_cmdline now relies on __git_cmd_idx, which is not defined when you do __git_complete.
The solution is to add __git_cmd_idx=1 to __git_func_wrap.
zsh is also broken by the same change, and the fix is to do the same in the _git service.
I've fixed this in git-completion's master branch [1].
You are welcome to trying the fix.
Cheers.
[1] https://github.com/felipec/git-completion/commit/95b3b49 [2] https://github.com/git/git/commit/59d85a2a05
-- Felipe Contreras