git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Felipe ContrerasNext: Harrison McCullough
Message 5 of 6 in “Error in bash completion”
  1. Harrison McCulloughJun 16, 2021
  2. Denton LiuJun 16, 2021
  3. Harrison McCulloughJun 16, 2021
  4. Felipe ContrerasJun 16, 2021
  5. Felipe ContrerasJun 17, 2021
  6. Harrison McCulloughJun 17, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.