Closed ylmrx closed 4 years ago
I think the problem is caused by this line:
When file
is empty, then fnamemodify(file, ':p')
returns the full path of the cwd. This means that in some cases this can end up being wrongly set as dotgit
instead of dir
, which makes git-messenger fail with the "not in a git repo" error.
Changing the line to:
let file = empty(file) ? '' : fnamemodify(file, ':p')
fixes this for me, but I haven't verified if this still works for the submodules case (which I think is the reason why this was introduced). Maybe a similar check should be done for let dir = fnamemodify(dir, ':p')
too.
I was working on another PR which just browse up till oblivion. But I’m fully new to vimscript , and I have no idea how to have the same behavior In Windows world. @rafikdraoui ‘s seems like a much better option.
@rhysd could you fix this? Could @rafikdraoui solution do the trick?
Great plugin btw!
I'm sorry for the delay. I was fixing critical issue at github-action-benchmark and prioritized moving CI to GitHub Actions.
I'm not reproducing this issue, but @rafikdraoui's comment looks helpful. I'll try to fix this.
@ylmrx @MeisterTea @rafikdraoui Since I'm not understanding how to reproduce this, would you check 422a933 fixed this issue?
I can confirm that https://github.com/rhysd/git-messenger.vim/commit/422a9334b9fe1dec9ecea6c0a1c48da71340e45f fixes this for me. Thanks!
Here's how I can reproduce the bug with commit d238582b28c (the one just before the fix). I don't have time to test with a minimal config (i.e. perhaps my vimrc or other plugins are interfering) or with vanilla vim, but maybe this could still be helpful:
$ git clone git@github.com:rhysd/git-messenger.vim.git
$ cd git-messenger.vim
$ nvim autoload/gitmessenger.vim
Then inside NeoVim:
:GitMessenger " this works
:cd autoload
:GitMessenger " this doesn't work
@rafikdraoui Thank you for the detailed steps. It is very helpful for me. I also could confirm this issue was fixed by 422a933 on my local machine. I did not notice this issue because I usually set the current directory to a root of repository. I think I should add more test case to confirm relative paths work properly.
Closing as I could confirm the fix.
Can it try to search it in parent folders too instead of just
$PWD
?