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

Don't error if git tab completion is not available. Fixes #1011 #1016

Closed
wants to merge 2 commits into from

Conversation

solarkennedy
Copy link

@solarkennedy solarkennedy commented Jun 9, 2020

Seems like tab completion should always be a nice-to have, so made it just exit silently if git tab completions were not available. If you want I can make it print a friendly error message.

As is, users get a pretty mysterious:

-bash: __git_complete: command not found
$

And it is a little hard to know where it came from.

Fixes #1011

jsbronder added a commit to jsbronder/gentoo that referenced this pull request Sep 29, 2020
The patch applied in the last bump is incorrect and effectively disables
bash completion no matter what order the completions were loaded in as
`type -f` will not find `__git_complete`.

```
$ type -f __git_complete
bash: type: __git_complete: not found
$ type __git_complete | grep 'is a'
__git_complete is a function
```

There is a pull-request upstream that properly addresses the issue of
`__git_complete` not being found but it's not accepted yet,
jonas/tig#1016

Package-Manager: Portage-3.0.4, Repoman-3.0.1
Signed-off-by: Justin Bronder <jsbronder@gentoo.org>
jsbronder added a commit to jsbronder/gentoo that referenced this pull request Sep 29, 2020
The patch applied in the last bump is incorrect and effectively disables
bash completion no matter what order the completions were loaded in as
`type -f` will not find `__git_complete`.

```
$ type -f __git_complete
bash: type: __git_complete: not found
$ type __git_complete | grep 'is a'
__git_complete is a function
```

There is a pull-request upstream that properly addresses the issue of
`__git_complete` not being found but it's not accepted yet,
jonas/tig#1016

Package-Manager: Portage-3.0.4, Repoman-3.0.1
Signed-off-by: Justin Bronder <jsbronder@cold-front.org>
Co-authored-by: Ilya A. Kriveshko <iillyyaa@gmail.com>
gentoo-bot pushed a commit to gentoo/gentoo that referenced this pull request Oct 3, 2020
The patch applied in the last bump is incorrect and effectively disables
bash completion no matter what order the completions were loaded in as
`type -f` will not find `__git_complete`.

```
$ type -f __git_complete
bash: type: __git_complete: not found
$ type __git_complete | grep 'is a'
__git_complete is a function
```

There is a pull-request upstream that properly addresses the issue of
`__git_complete` not being found but it's not accepted yet,
jonas/tig#1016

Package-Manager: Portage-3.0.4, Repoman-3.0.1
Signed-off-by: Justin Bronder <jsbronder@cold-front.org>
Closes: #17715
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
NeddySeagoon pushed a commit to NeddySeagoon/gentoo-arm64 that referenced this pull request Oct 6, 2020
The patch applied in the last bump is incorrect and effectively disables
bash completion no matter what order the completions were loaded in as
`type -f` will not find `__git_complete`.

```
$ type -f __git_complete
bash: type: __git_complete: not found
$ type __git_complete | grep 'is a'
__git_complete is a function
```

There is a pull-request upstream that properly addresses the issue of
`__git_complete` not being found but it's not accepted yet,
jonas/tig#1016

Package-Manager: Portage-3.0.4, Repoman-3.0.1
Signed-off-by: Justin Bronder <jsbronder@cold-front.org>
Closes: gentoo#17715
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
# variables (like cword and prev) to be defined
__git_complete tig _tig
if [ "$(type -t __git_complete)" = function ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick... if ! declare -f __git_complete &>/dev/null; then is a better test for existence of function because it doesn't spawn shell with $()

@darcyparker
Copy link
Contributor

See #1011 (comment). I did some analysis and found that sourcing git completions is alterative to exiting silently.

@darcyparker
Copy link
Contributor

#1055 is an alternate solution that attempts to define __git_complete and exits silently if it cannot.

@rohieb
Copy link

rohieb commented Dec 8, 2020

Yes, the approach in #1055 looks more reasonable to me than just silently doing nothing if the git completion is not loaded yet.

@solarkennedy
Copy link
Author

Cool. I'll go ahead and close. Hopefully someone with write access can merge?

@solarkennedy solarkennedy deleted the fix_completion branch December 8, 2020 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] -bash: __git_complete: command not found
4 participants