Vim-airline: Can not display git branch name via branch extension and vim-fugitive

Created on 23 Sep 2014  Â·  29Comments  Â·  Source: vim-airline/vim-airline

I want to show the branch name in the status line. I have installed 'tpope/vim-fugitive'. The fugitive version is 2.1. But nothing seems to happen. (No branch symbol or name display in statue line.)

I try to turn on the branch extension in ~/.vimrc

let g:airline#extensions#branch#enabled = 1

Here's a snippet of plugin lists from Vundle.

Plugin 'tpope/vim-fugitive'
Plugin 'airblade/vim-gitgutter'
Plugin 'mhinz/vim-signify'
Plugin 'bling/vim-airline'

I can't find answer on the web. So I might try to ask over here.

BTW, 'hunks' works for me.

Thanks

Most helpful comment

what does :echo fugitive#head() show?

All 29 comments

what does :echo fugitive#head() show?

It seems fugitive#head not existed.

E117: Unknown function: fugitive#head
E15: Invalid expression: fugitive#head()
Press ENTER or type command to continue

well, there's your problem. your version of fugitive is very old.... see if :scriptnames comes up with something weird.

Thanks for looking at it. It ends up my machine have two version of fugitive. (1.2 and 2.1)

vim-airline is a Awesome plugin. :+1:

Marked it as close.

well, there's your problem. your version of fugitive is very old.... see if :scriptnames comes up with something weird.

Thanks :+1:! I was looking for what prevented the branch from being displayed. Actually, I had a mess with two installations of fugitive.

BTW, I agree, vim-airline is really awesome!

Florent

I am having the same problem and ran :scriptnames and didn't see fugitive anywhere in the list but I do have fugitive.vim in my bundle. Does this mean its not being run fro some reason? Also I got the same output as above when I ran :echo fugitive#head()

I am sorry to activate such an old post. I have the same problem now, I cannot see the branch name in the status bar. I can get correct branch name with :echo fugitive#head().

I was having this problem as well, it seems like on June 1st, in vim-fugitive, commit 5d11ff7 caused this to happen
I just reverted vim-fugitive to commit dd4d4c7, and now hope he releases a fix soon

@akashkw thank you so much, it's working now.

Ah, tpope/vim-fugitive@5d11ff7 made fugitive#head() autoloadable. That breaks vim-airline. @tpope what would be the prepared fix to check for instead?

FugitiveHead() is the replacement, but since it's just an existence check, literally any plugin function would work?

@tpope okay great. I'll just want to use something that is not likely to change and considered to be stable enough to check for fugitive installation.

I guess check for exists('*FugitiveStatusline') || exists('*fugitive#head') if you want something with the lowest possible risk of vanishing in the distant future.

I'm more worried about your use of internals in the implementation. Are you trying to get the absolute path to the real file? I've been thinking of adding a helper for that for my own purposes too. Just need a good function name.

thanks. I suppose you are talking about the fugitiveline plugin. I think that came initially from @Cimbali, so he should know for since I do not really understand fugitive internals. However, I suppose this could be useful, so if you decide to implement something like that, ping me back so I can simplifiy the plugin then

Ah I stopped looking when I found that.

Since you are using fugitive#head() you should indeed check for FugitiveHead(). And I recommend switching to actually calling FugitiveHead() if available to avoid a pre-emptive autoload trigger.

I fixed it getting back at the last previous version
git reset --hard cde670ee81e4fd0945e97111d08a901788c3922b

@pbergonzi that should not be needed anymore

I upgraded from 0.9 to the git version, so this isn't for me, but for others, I nominate 30a3c4f54948bc2692a6e218a600d1ebea42f94d to be backported to a new 0.9.1 version, because vim-fugitive v2.4 released on 7/10 includes the breaking commit. For those running on up to date distro packages, vim-airline no longer shows the branch, which IMO is a big feature.

Or, https://github.com/vim-airline/vim-airline/wiki/FAQ (at "You do not see the current Git branch") could be updated to say in the meantime you have to run the vim-airline from git.

@jamespharvey20 its a wiki, feel free to add it. I am not getting what you said about backporting to release 0.9.1 (since that release does not exist) and if you use a packaged version of this plugin by your distribution, you need to tell them about that (see also the last messages at #1815).

Also note, I am planning a new release for December #1820.

@jamespharvey20 its a wiki, feel free to add it.

Thanks for pointing that out! I'll admit I somehow didn't know (at least some) repo wikis were publicly editable. That's awesome. I'll do that.

I am not getting what you said about backporting to release 0.9.1 (since that release does not exist) and if you use a packaged version of this plugin by your distribution, you need to tell them about that (see also the last messages at #1815).

My suggestion was to issue a new release, 0.9.1, identical to 0.9 except with the fixing commit. Many packages issue backports all the time as dependencies change and break them, or security issues come up. (i.e. gcc 6.5.0 was released 18 days ago, even though the latest release is 8.2.0.)

I apologize, and hadn't seen #1815 until just now. I didn't know the issue of tag a release vs distributions having to keep on top of thousands of post-tagged-release patches (_not on a single package, but total across all packages_) had already been discussed, or else I wouldn't have made this duplicate suggestion. I will note that without a 0.9.1, there probably will be several more issues opened up from people not realizing the latest tagged release is broken. Now that I'm looking, I can see there have been quite a few issues on this exact issue that aren't mentioned on this one.

Also note, I am planning a new release for December #1820.

OK, then Arch's package will probably remain broken until December (honestly, I'd rather the Arch package remain broken then become a distribution that deviates from upstream source unless critically necessary), so I'll run a -git version until then.

I use git submodules for managing plugins; updated airline-vim to e3cfd36 and fugitive to 2564c3, i.e. both are latest. Still don't see vcs info.

Nevermind, vim-fugitive doesn not follow symlinks, editing a symlink to a vcs controlled file does not activate it. Works on the file proper.

I too use git submodules and use vim-airline at 6ab14bf and vim-fugitive at 1a3c045, but still don't see the branch.

can you provide a minimal working example that displays the error?

What exactly do you want to see?

I created a new empty repository, created a file "test" with some content and committed it.
Then I opened vim with that file.

echo fugitive#head() displays master
echo g:airline#extensions#branch#enabled displays 1

shot

Is this repository available somewhere so I can test?

Am 12.03.2019 um 18:10 schrieb hupfdule notifications@github.com:

What exactly do you want to see?

I created a new empty repository, created a file "test" with some content and committed it.
Then I opened vim with that file.

echo fugitive#head() displays master
echo g:airline#extensions#branch#enabled displays 1

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

It is not. But it is really not more than I have described above.

And actually, I have that problem with _every_ repository. I have not seen the branch anywhere.

Very strange. Since I suspected an incompatibility with another plugin I removed all of them and tried again.
The branch is correctly shown.

I then reactivated them one by one to find the conflict. While doing so I noticed that even vim-signify is used to fill the git info (which wasn't shown too).

After I reactivated all of my plugins, it was still working!

I removed vim-fugitive and checked it out again (i have my dotfiles in a git repo. My vim plugins are submodules in that repo. Therfore I did a git checkout vim-fugitive). After that vim-fugitives info was missing again!

I removed it and this time recreated it with git submodules update --init --recursive vim-fugitiv and it is shown again.

I have no idea, but it seems to be related to the git submodules somehow.

Very strange. Since I suspected an incompatibility with another plugin I removed all of them and tried again.
The branch is correctly shown.

I then reactivated them one by one to find the conflict. While doing so I noticed that even vim-signify is used to fill the git info (which wasn't shown too).

After I reactivated all of my plugins, it was still working!

I removed vim-fugitive and checked it out again (i have my dotfiles in a git repo. My vim plugins are submodules in that repo. Therfore I did a git checkout vim-fugitive). After that vim-fugitives info was missing again!

I removed it and this time recreated it with git submodules update --init --recursive vim-fugitiv and it is shown again.

I have no idea, but it seems to be related to the git submodules somehow.

exactly some here!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

uri picture uri  Â·  62Comments

svanharmelen picture svanharmelen  Â·  22Comments

svanharmelen picture svanharmelen  Â·  38Comments

notpratheek picture notpratheek  Â·  18Comments

r004 picture r004  Â·  18Comments