Thanks everyone for all the reviews! I rewrote __git_dwim_remote_heads to fork a constant number of times instead of a multiple of the number of remotes. There are still a handful of forks, but I think they can mostly be parallelized. I tried to find a pure shell implementation like a few of you mentioned, but I couldn't think of one that would work in both bash 3.2 (the version on macOS, I think?) and zsh. The only thing I found in https://www.bashcookbook.com/bashinfo/source/bash-3.2/doc/bash.html that looked like it would work to implement GIT_COMPLETION_IGNORE_CASE was the nocasematch arg to shopt, but https://zsh.sourceforge.io/Doc/Release/zsh_14.html#index_split-13_fn_letter-S doesn't list shopt at all. One unintentional difference with this approach is that $cur_ is no longer treated as a glob pattern. Was it supposed to be in the first place though, or was that just because of missing escaping? I.e., this no longer works to complete unique-remote-branch: git checkout unique-remote-br*<Tab> In my original commit message, I mentioned that HEAD was no longer listed, but I think I was wrong about that. I think HEAD went away in a bunch of the tests because I added another remote, so HEAD was no longer unique. Maybe HEAD should be filtered out too, but that seems like a separate issue for a separate patch. David Mandelberg (2): completion: add helper to count path components completion: fix bugs with slashes in remote names contrib/completion/git-completion.bash | 49 +++++- t/t9902-completion.sh | 206 ++++++++++++++++++++++--- 2 files changed, 226 insertions(+), 29 deletions(-) -- 2.47.2