Bug 1687861 - Completion of git commands stopped working
Summary: Completion of git commands stopped working
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: bash-completion
Version: 29
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Siteshwar Vashisht
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-03-12 13:53 UTC by Honza Brázdil
Modified: 2019-08-05 13:21 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-08-05 13:21:48 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
strace -e trace=%file -o strace.txt bash -l (33.33 KB, text/plain)
2019-07-22 14:56 UTC, Honza Brázdil
no flags Details
git stat<TAB> with set -x (2.42 KB, text/x-mpsub)
2019-07-22 17:49 UTC, Honza Brázdil
no flags Details
git stat<TAB> with set -x and sourced git completions (11.32 KB, text/x-mpsub)
2019-07-22 18:07 UTC, Honza Brázdil
no flags Details

Description Honza Brázdil 2019-03-12 13:53:28 UTC
Description of problem:
Somehow (probably during upgrade to F29) bash completion stopped working for completing git commands.

Version-Release number of selected component (if applicable):
bash-completion-1:2.8-3.fc29.noarch
git-core-2.20.1-1.fc29.x86_64

How reproducible:
always

Steps to Reproduce:
1.type: git chec<TAB>

Actual results:
Nothing is completed

Expected results:
It should be completed to: git checkout


Additional info:
I've tried to reinstall:
  dnf reinstall git-core
  dnf reinstall bash-completion
haven't helped.

Doing
  . /usr/share/bash-completion/completions/git
helps, but only for active bash session.

Comment 1 Honza Brázdil 2019-03-29 15:27:41 UTC
Can I do anything to help investigate this?

Comment 2 Honza Brázdil 2019-07-22 14:23:42 UTC
Bump

Comment 3 Kamil Dudka 2019-07-22 14:46:44 UTC
Honza, could you please run the following command and attach strace.txt ?

$ strace -e trace=%file -o strace.txt bash -l

Comment 4 Honza Brázdil 2019-07-22 14:56:58 UTC
Created attachment 1592613 [details]
strace -e trace=%file -o strace.txt bash -l

Comment 5 Kamil Dudka 2019-07-22 16:30:24 UTC
Please try the following:

1. run `set -x` in your interactive bash session
2. try to autocomplete a git command
3. attach the text printed to your terminal

Comment 6 Honza Brázdil 2019-07-22 17:49:13 UTC
Created attachment 1592647 [details]
git stat<TAB> with set -x

Not sure of the relevance, but I noticed in the output:

++++ git help -a
++++ egrep --color=auto '^  [a-zA-Z0-9]'

Doing
$ git help -a | egrep --color=auto '^  [a-zA-Z0-9]'

returns nothing, because the commands have 3 spaces at the beginning of the line:
$ git help -a
See 'git help <command>' to read about a specific subcommand

Main Porcelain Commands
   add                  Add file contents to the index
   am                   Apply a series of patches from a mailbox
[...]

Comment 7 Honza Brázdil 2019-07-22 18:07:32 UTC
Created attachment 1592672 [details]
git stat<TAB> with set -x and sourced git completions

I tried it also with doing the source of  /usr/share/bash-completion/completions/git file, the output looks quite different.

Comment 8 Kamil Dudka 2019-07-23 12:43:46 UTC
Please paste output of the following commands executed in a fresh bash session:

$ complete | grep git\$

$ complete | grep D\$

$ declare -f _completion_loader

Comment 9 Honza Brázdil 2019-07-23 14:50:35 UTC
$ complete | grep git\$
complete -o bashdefault -o default -o nospace -F _git git

$ complete | grep D\$
complete -F _completion_loader -D

$ declare -f _completion_loader
_completion_loader () 
{ 
    local cmd="${1:-_EmptycmD_}";
    __load_completion "$cmd" && return 124;
    complete -F _minimal -- "$cmd" && return 124
}

Comment 10 Kamil Dudka 2019-07-23 15:20:32 UTC
(In reply to Honza Brázdil from comment #9)
> $ complete | grep git\$
> complete -o bashdefault -o default -o nospace -F _git git

Something in your configuration sets a completion hook for git that does not work.  If you get rid of it, _completion_loader() will load the hook provided by git-core, which works fine.

You can try to find culprit like this:

$ grep -r 'complete.*git' /etc/{bash_completion,profile}.d

If there is no match, look at the other sourced files, based on attachment #1592613 [details].

Comment 11 Honza Brázdil 2019-08-05 13:13:52 UTC
Thanks, it was because of third-party branch_in_prompt.sh script. Weird that it worked before but the script was not updated in a long time so it's probably outdated by now.

Removing that script fixed it.

Comment 12 Kamil Dudka 2019-08-05 13:21:48 UTC
Glad to see it resolved.  Thank you for clarifying it!


Note You need to log in before you can comment on or make changes to this bug.