Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-completion stop to work with Git version 2.18.0 #1792

Closed
arturoherrero opened this issue Jun 26, 2018 · 18 comments · May be fixed by #1995
Closed

Auto-completion stop to work with Git version 2.18.0 #1792

arturoherrero opened this issue Jun 26, 2018 · 18 comments · May be fixed by #1995
Labels

Comments

@arturoherrero
Copy link
Contributor

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.

@mislav
Copy link
Owner

mislav commented Jun 26, 2018

Thank you for reporting! I can see the same.

@mislav mislav added the bug label Jun 26, 2018
mislav added a commit that referenced this issue Jul 7, 2018
Wrap `git --list-cmds=others` command used by git built-in shell
completions to add a list of hub custom commands.

Fixes #1792
@davishmcclurg
Copy link

@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

@arturoherrero
Copy link
Contributor Author

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

@mislav
Copy link
Owner

mislav commented Jul 9, 2018

@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

@davishmcclurg
Copy link

Ok, that works. Thanks @mislav!

@mislav
Copy link
Owner

mislav commented Jul 10, 2018

Gonna reopen this until alias is no longer needed

@engnakagawa
Copy link

engnakagawa commented Aug 8, 2018

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?

@apjanke
Copy link
Contributor

apjanke commented Dec 22, 2018

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?

@ushuz
Copy link

ushuz commented Jun 21, 2019

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

@arturoherrero
Copy link
Contributor Author

Same here @ushuz

$ git --version
git version 2.22.0
hub version 2.12.0

@mislav
Copy link
Owner

mislav commented Jun 21, 2019

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

@mislav
Copy link
Owner

mislav commented Jun 21, 2019

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
Copy link
Contributor

yasuoza commented Aug 5, 2019

Hotfix

alias __git=hub

FYI: https://github.com/git/git/blob/7c20df8/contrib/completion/git-completion.bash#L1029

@mgabeler-lee-6rs
Copy link

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

@knightofiam
Copy link

knightofiam commented Nov 29, 2020

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?

knightofiam added a commit to knightofiam/dotfiles that referenced this issue Nov 29, 2020
- Useful for creating GitHub pull requests from the command line.
- Alias 'git' to 'hub' (mislav/hub#1792).
@radiospiel
Copy link

radiospiel commented Jun 21, 2021

Neither works here. This is macOS 11.4 on a Silicon M1 machine.

This is with home-brew in /opt/homebrew, and with

0:00 ~ > hub version
git version 2.31.1
hub version refs/heads/master

The hub version is the latest one from home-brew, I don't know why it is listed as "refs/heads/master", but apparently this is 2.14.2.

0:00 ~ > brew info hub
hub: stable 2.14.2 (bottled), HEAD

I had to disable asyncpreemptoff because of golang/go#42700

@radiospiel
Copy link

Also doesn't work with the very latest git version on home-brew (2.32.0). I accidentally also discovered that running hub, even without any arguments and any attempt to autocomplete, kills my iTerm session, when both __git and git are aliased to hub.

@aquadesk
Copy link

aquadesk commented Aug 15, 2022

hub --version
git version 2.32.1 (Apple Git-133)
hub version refs/heads/master

I have this

alias git=hub

when I tab on this

git [cursor]

it gives

git (eval):1: command not found: _hub
(eval):1: command not found: _hub
(eval):1: command not found: _hub

I don't know how to fix it

I am using mac os silicon M1

When i remove alias

git
zsh: do you wish to see all 154 possibilities (154 lines)?

git working fine

hub (eval):1: command not found: _hub
(eval):1: command not found: _hub
(eval):1: command not found: _hub

hub gives me an error.

I think this is related to zsh autocomplete but not sure how to solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.