Hub: Auto-completion stop to work with Git version 2.18.0

Created on 26 Jun 2018  ·  15Comments  ·  Source: github/hub

I use macOS and Homebrew to install/update Git and hub.

After upgrade Git (brew upgrade git) from version 2.17.1 to 2.18.0 the auto-completion of the GitHub commands provided by hub (browse, ci-status, compare, etc...) stop to work in Bash.

Previous configuration with auto-completion working:

$ git --version
git version 2.17.1
hub version 2.4.0

Current configuration with auto-completion not working:

$ git --version
git version 2.18.0
hub version 2.4.0

I was able to reproduce the error in two different machines.

bug

Most helpful comment

All 15 comments

Thank you for reporting! I can see the same.

@mislav I'm still having this issue using hub 2.5.0:

$ hub version
git version 2.18.0
hub version 2.5.0
$ cat ~/.bash_profile
source /usr/local/etc/bash_completion.d/git-completion.bash
source /usr/local/etc/bash_completion.d/hub.bash_completion.sh

It's working for me after install the new version of hub (2.5.0) with Homebrew.

@davishmcclurg Unfortunately, the new workaround in hub 2.5.0 will only work when hub is aliased as git, even if the command invoked is hub. This is sub-optimal and PRs to improve this are welcome.

# without alias
$ hub p
pull      push

$ alias git=hub
$ hub p
pr        pull           pull-request   push

Ok, that works. Thanks @mislav!

Gonna reopen this until alias is no longer needed

I did set alias git=hub.
But, zsh compiletoin is not work.

Environment

❯ brew info zsh-completion
zsh-completions: stable 0.27.0, HEAD

❯ hub --version
git version 2.18.0
hub version 2.5.0

Should I talk about zsh-completion here?

Should I talk about zsh-completion here?

zsh-completion is not relevant. But whether you have the Git-provided _git completion or the _zsh-provided one is. What is your zsh $fpath value, and is /usr/local/share/zsh/site-functions/_zsh present, and if so, what does it point to?

hub folks: what do you think about extending hub --version to examine its zsh environment and print an indication of which source of _zsh completion functions it's working with?

Alias stops working for me recently.

$ type -f git
git is aliased to `hub'
$ hub pu
pull   push
$ hub pull-request -
-F   -M   -a   -b   -f   -h   -i   -l   -m

Same here @ushuz

$ git --version
git version 2.22.0
hub version 2.12.0

I get this with hub 2.12.0 and bash 3.2 on macOS:

$ alias git=hub
$ hub pu
pull           pull-request   push

@ushuz @arturoherrero Could you provide more information about your shell, OS, and how you installed hub and shell completions? Thanks

Ah I see it now when I upgrade to git 2.22:

$ hub pu
pull   push

git must have changed something again in how they organize their shell completions. I think it's too risky that we build on top of their completion script, but then again I have no other ideas on how to hook into git's completions to inject extra hub stuff.

@yasuoza I suspect that will break some use cases because: https://github.com/git/git/blob/7c20df8/contrib/completion/git-completion.bash#L90

Just in case this saves anyone time - these tips may seem obvious, but so many people including myself have been struggling to get this working.

  1. The alias workaround must occur before the sourcing of any git-completion script (e.g., in ~/.bash_profile).

  2. In your excitement, don't forget to source ~/.bash_profile (or whatever your shell config file is), or open a new terminal window before testing it out.

  3. With the alias workaround, you don't need anything like this:

if [ -f $(brew --prefix)/etc/bash_completion.d/hub.bash_completion.sh ]; then
  . $(brew --prefix)/etc/bash_completion.d/hub.bash_completion.sh
fi

@mislav Any update on #1995?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DennisSchiefer picture DennisSchiefer  ·  4Comments

kentcdodds picture kentcdodds  ·  4Comments

iserko picture iserko  ·  4Comments

dsifford picture dsifford  ·  4Comments

segevfiner picture segevfiner  ·  4Comments