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

Outside repository error on windows with msys/git #57

Open
hokorobi opened this issue Apr 12, 2020 · 10 comments
Open

Outside repository error on windows with msys/git #57

hokorobi opened this issue Apr 12, 2020 · 10 comments
Labels

Comments

@hokorobi
Copy link
Contributor

hokorobi commented Apr 12, 2020

Giving a full path to msys/git doesn't seem to work well.
When :GitMesseger is executed on the C:\Users\hokorobi\vimfiles\vimrc, it will be as follows.

git-messenger: fatal: 'C:\Users\hokorobi\vimfiles\vimrc' is outside repository at '/home/hokorobi/vimfiles': `git --no-pager blame C:\Users\hokorobi\vimfiles\vimrc -L 1,+1 --porcelain` exited with non-zero status 128
@rhysd
Copy link
Owner

rhysd commented Apr 12, 2020

  1. Would you try exactly the same command from command line directly and confirm you can get the same error? It is weird that git -C is not used. My assumption is that git-messenger.vim is always using git -C {dir} to run Git commands in specific directory. It may not be working.
  2. If you have installed Git for Windows, would you also try its git command by setting g:git_messenger_git_command?

@hokorobi
Copy link
Contributor Author

  1. I get the same error on the command line.

    C:\Users\hokorobi\vimfiles>git --no-pager blame C:\Users\hokorobi\vimfiles\vimrc -L 1,+1 --porcelain
    fatal: 'C:\Users\hokorobi\vimfiles\vimrc' is outside repository at '/home/hokorobi/vimfiles'
    

    It seems that msys git expects a UNIX-like path. It's not an error this.
    C:\Users\hokorobi\vimfiles>git --no-pager blame /home/hokorobi/vimfiles/vimrc -L 1,+1 --porcelain

  2. I haven't installed Git for Windows, so I can't try it, but I've heard that VSCode Git doesn't cause an error.

@rhysd
Copy link
Owner

rhysd commented Apr 12, 2020

Thank you for the investigation. Regarding to 1., this command is not what I expected. My expectation was:

git --no-pager -C C:\Users\hokorobi\vimfiles blame C:\Users\hokorobi\vimfiles\vimrc -L 1,+1 --porcelain

Would you ensure above command also does not work?

It seems that msys git expects a UNIX-like path

It looks root cause of this issue. I'm not user of MSYS so not familiar with it. Would you answer below questions if you know the answer?

  • how can we detect MSYS git? (for example, from path of git command)
  • is there any utility which converts Windows file path to MSYS's unix-like path? For example, cygwin has cygpath utility command

@rhysd
Copy link
Owner

rhysd commented Apr 12, 2020

Since using relative path is problematic, I want to solve this issue by converting Windows path to Unix-like path when running git command.

@hokorobi
Copy link
Contributor Author

  1. It was the same result.
    C:\Users\hokorobi\vimfiles>git --no-pager -C C:\Users\hokorobi\vimfiles blame C:\Users\hokorobi\vimfiles\vimrc -L 1,+1 --porcelain
    fatal: 'C:\Users\hokorobi\vimfiles\vimrc' is outside repository at '/home/hokorobi/vimfiles'
    

how can we detect MSYS git? (for example, from path of git command)

$PATH has a path with git in it.

is there any utility which converts Windows file path to MSYS's unix-like path? For example, cygwin has cygpath utility command

I will investigate.

@hokorobi
Copy link
Contributor Author

hokorobi commented Apr 12, 2020

MSYS also has cygpath.

@hokorobi
Copy link
Contributor Author

Git for Windows works fine.
It may be good to say that it doesn't work in MSYS Git.

@rhysd
Copy link
Owner

rhysd commented Apr 13, 2020

Thank you for the investigation. It is very helpful.

$PATH has a path with git in it.

I apologize that my question was bad. My intention was that I wanted to detect git command which was installed with MSYS. Hence we can convert Windows path to Unix-like path only when the git command is installed via MSYS.

If git is installed in MSYS-specific directory (e.g. including 'msys' in its path), we can detect it by return value from exepath().

MSYS also has cygpath.

Thank you. My understanding is that the path converted by cygpath is used for MSYS Git, though I'm not sure this is correct.

It may be good to say that it doesn't work in MSYS Git.

At least for now, it should be noted. Thank you for suggestion. I'll add note to README.

@hokorobi
Copy link
Contributor Author

Thank you for writing the document.
You may also close this issue.

@rhysd
Copy link
Owner

rhysd commented Apr 16, 2020

I'll keep this issue open because this issue is not solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants