mbox series

[0/3] completion: fix bugs with slashes in remote names

Message ID pull.1901.git.git.1740901525.gitgitgadget@gmail.com (mailing list archive)
Headers show
Series completion: fix bugs with slashes in remote names | expand

Message

David Mandelberg via GitGitGadget March 2, 2025, 7:45 a.m. UTC
Previously, some calls to for-each-ref passed fixed numbers of path
components to strip from refs, assuming that remote names had no slashes in
them. This made completions like:

git push github/dseomn :com

Result in:

git push github/dseomn :dseomn/completion-remote-slash

With this patch, it instead results in:

git push github/dseomn :completion-remote-slash

In addition, the change to __git_dwim_remote_heads() restricts it to only
list remote branches, not HEAD. I think that actually improves the
completion where it's used though, since HEAD doesn't seem to be valid
anyway:

$ git switch HEAD fatal: a branch is expected, got 'HEAD'

David Mandelberg (3):
  completion: add helper to escape strings for fnmatch
  completion: add helper to count path components
  completion: fix bugs with slashes in remote names

 contrib/completion/git-completion.bash |  40 ++++-
 t/t9902-completion.sh                  | 213 ++++++++++++++++++++++---
 2 files changed, 225 insertions(+), 28 deletions(-)


base-commit: cb0ae672aeabefca9704477ea8018ac94f523970
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1901%2Fdseomn%2Fcompletion-remote-slash-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1901/dseomn/completion-remote-slash-v1
Pull-Request: https://github.com/git/git/pull/1901