git.nvim icon indicating copy to clipboard operation
git.nvim copied to clipboard

[QUESTION] Unable to execute git commands

Open kagbodji opened this issue 3 years ago • 5 comments

Hi, I am unable to use this plugin. I get the following message:

[git] Error during running a job: fatal: path 'lua/custom/plugins/others.lua' does not exist in 'HEAD~2'

The file is definitely in the index:

❯ git diff-tree --no-commit-id --name-only -r HEAD~2
tools/vim/nvchad/lua/custom/keymaps.lua
tools/vim/nvchad/lua/custom/plugins/init.lua
tools/vim/nvchad/lua/custom/plugins/others.lua
tools/vim/nvchad/lua/custom/vimopts.lua

I'm therefore not sure what this message means or what's causing it, here's my config.

image

Is this a bug, or is my configuration invalid?

Thanks!

kagbodji avatar Jul 26 '22 15:07 kagbodji

Hi, Sorry for my late response. I was busy with other stuff. Could you please provide me more context about the bug, such as:

  • When does the bug occur?
  • Which command triggers the error?

Thank you

dinhhuy258 avatar Aug 01 '22 13:08 dinhhuy258

Oh silly me... The issue occurs when I issue the GitDiff command, with or without arguments. I also use Gitsigns, which also has a command Gitsigns diffthis, and that works

:!git --version
git version 2.36.1

Other commands, such as GitBlame work.

kagbodji avatar Aug 02 '22 18:08 kagbodji

Ya, I understand... The error is shown when you compare the current file to two versions ago. But the file does not exist at that time, causing an error. You can try the GitDiff command with another file. Besides, I will try to improve the plugin so that I have a better handle in this case. Thanks for reporting...

dinhhuy258 avatar Aug 03 '22 14:08 dinhhuy258

I don't think that's the case as I get the error even when I'm diff'ing against the current index, and I get the error on all files.

[git] Error during running a job: fatal: path 'lua/custom/plugins/others.lua' does not exist in 'HEAD'

I am also certain the file exists in the index two revisions back. The original diff command in my report works if I execute directly at the CLI: image

I thought maybe it was config, so I tried with the default config and still get the error. I'm new to lua in neovim and am still trying to figure out how to debug/trace plugin code, happy to look into this a bit deeper once I ramp. I'll also try to reproduce in a clean env without any other plugins to see.

kagbodji avatar Aug 03 '22 14:08 kagbodji

Hmm, It's weird... I don't think it's related to the config since there is no configuration needed in my plugin... For debugging, you can print out the git command for the GitDiff command using the method: vim.notify

image

Reload the plugin by exiting and entering nvim again. Run the GitDiff command then you can see the message at the bottom image

dinhhuy258 avatar Aug 03 '22 15:08 dinhhuy258

Hi @dinhhuy258 , sorry for the delay. I tried what you said and this is the command I get:

git -C /Users/kagbodji/.config/nvim --literal-pathspecs --no-pager show HEAD:lua/core/options.lua

Interestingly, the plugin works now. I have however updated some plugins and removed others, so I think the issue may not be with your plugin. I'll debug more to see if I can get to the root cause if it comes up again, but I'm going to close this issue for now. Thanks for the help!

kagbodji avatar Aug 09 '22 15:08 kagbodji

Happy to hear that. Thanks for your supporting

dinhhuy258 avatar Aug 09 '22 15:08 dinhhuy258