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

[Error] Cannot find index file: .../.git/index #47

Closed
tamago324 opened this issue Jan 16, 2021 · 8 comments · Fixed by #50
Closed

[Error] Cannot find index file: .../.git/index #47

tamago324 opened this issue Jan 16, 2021 · 8 comments · Fixed by #50
Labels
bug Something isn't working

Comments

@tamago324
Copy link

Describe the bug

Opening a file in a git project that has never been committed will result in an error
If ./git/index does not exist, an error will occur.

To Reproduce

init.vim:

let $PLUGIN_DIRECTORY = '~/.config/nvim/.plugged'
set runtimepath^=$PLUGIN_DIRECTORY/plenary.nvim
set runtimepath^=$PLUGIN_DIRECTORY/gitsigns.nvim

lua << EOF
require('gitsigns').setup {
  -- config
}
EOF

Steps to reproduce the behavior:

  1. Make empty git project: $ mkdir sample_proj && cd $_ && git init
  2. Create file: $ touch file.vim
  3. Start nvim: $ nvim -u ~/tmp/init.vim -i NONE file.vim
  4. See error

Observed output
Error messages, logs, etc

Error executing luv callback:
...onfig/nvim/.plugged/gitsigns.nvim/lua/gitsigns/async.lua:21: ...324/.config/nvim/.plugged/gitsigns.nvim/lua/gitsigns.lua:328: Cannot find index file: /home/tamago324/tmp/sample_proj/.git/index

Screenshots
If applicable, add screenshots to help explain your problem or to capture error messages.

Additional context
System: Linux
Neovim version: v0.5.0-dev+1012-gfe1ebea33

@tamago324 tamago324 added the bug Something isn't working label Jan 16, 2021
@tamago324
Copy link
Author

You are making an error, explicitly.

local index = gitdir..'/index'
if not path_exists(index) then
error('Cannot find index file: '..index)
return
end

I'm really sorry.
I am so embarrassed.

@tamago324
Copy link
Author

As a suggestion, how about using print instead of error?
I was a little concerned about getting an error every time I open a file.

@tamago324
Copy link
Author

In case of an error(), I had to press Enter each time, which I found annoying.

image

@lewis6991
Copy link
Owner

lewis6991 commented Jan 16, 2021

Thanks for this. I haven't considered this scenario. I'll reopen and try and fix this.

Also many thanks for the minimal steps to reproduce. That makes dealing with this so much easier!

@lewis6991 lewis6991 reopened this Jan 16, 2021
@tamago324
Copy link
Author

Thank you very much.

Thanks to the issues template, I was able to quickly create issues.

@sunjon
Copy link
Contributor

sunjon commented Jan 18, 2021

I'd noticed this bug too, but had been too busy to eliminate wether there was an issue in my setup (I'd been playing with the statusline handlers at the time). FWIW I believe the last commit before this issue was:

9c49451bfd85f397b38ec2362674ac06bf9f3d36

lewis6991 added a commit that referenced this issue Jan 30, 2021
lewis6991 added a commit that referenced this issue Jan 30, 2021
@lewis6991
Copy link
Owner

Could someone kindly try out #50, It should fix this issue.

@lewis6991 lewis6991 linked a pull request Jan 31, 2021 that will close this issue
@tamago324
Copy link
Author

@lewis6991 Thank you! I have confirmed that it has been fixed 👍

lewis6991 added a commit that referenced this issue Jan 31, 2021
lewis6991 added a commit that referenced this issue Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants