Conversation
lua/gitsigns/git/repo.lua
Outdated
| @@ -168,6 +168,8 @@ local function normalize_path(path) | |||
| -- through cygpath | |||
| --- @type string | |||
| path = async.await(3, system, { 'cygpath', '-aw', path }).stdout | |||
There was a problem hiding this comment.
Stdout probably just has a single trailing \n that should be stripped.
lua/gitsigns/git/repo.lua
Outdated
| if string.sub(path, 1, string.len(toplevel)) == toplevel then | ||
| path = string.sub(path, string.len(toplevel) + 1) | ||
| end |
There was a problem hiding this comment.
| if string.sub(path, 1, string.len(toplevel)) == toplevel then | |
| path = string.sub(path, string.len(toplevel) + 1) | |
| end | |
| if path:sub(1, #toplevel) == toplevel then | |
| path = path:sub(#toplevel + 1) | |
| end |
|
So generally it is ready. Some tests aren't passed. This is because debug log changed, because file path changed to relative. |
|
Aren't you able to pass |
Yes, this is possible, but this will make things more complex. Much easier is to convert path to relative, and this will work under all conditions. |
|
We already do this in some places. We just also need to do this when we create the git_obj for the |
|
Just use |
|
Yes I have already reviewed the code. I am suggesting it can be simplified by just fixing All you need to do is:
This will ensure there are 0 functional changes for non-windows users. That's unless you know of a situation that using relative paths fixes/improves for non-windows? |
|
Yes, you are right. Better to store flie as repative from the beginning. I will try this. |
|
I am not sure about tests, seems they were broken before? Code is ready to merge (except tests). |
|
Tests need fixing. |
|
Is there a reason you couldn't just do:
What you have done looks more complicated. |
| -- windows | ||
| if vim.fn.has('win32') then | ||
| if not string.match(file, '^[A-Za-z]:[/\\]') then | ||
| file = toplevel .. util.path_sep .. file | ||
| end | ||
|
|
||
| -- unix | ||
| elseif not vim.startswith(file, '/') then | ||
| file = toplevel .. util.path_sep .. file | ||
| end |
There was a problem hiding this comment.
I don't agree with this change. You are special casing when file starts with a drive AND is on Windows, and haven't explained it.
| -- windows | |
| if vim.fn.has('win32') then | |
| if not string.match(file, '^[A-Za-z]:[/\\]') then | |
| file = toplevel .. util.path_sep .. file | |
| end | |
| -- unix | |
| elseif not vim.startswith(file, '/') then | |
| file = toplevel .. util.path_sep .. file | |
| end | |
| if not vim.startswith(file, '/') and toplevel then | |
| file = toplevel .. util.path_sep .. file | |
| end | |
| file = util.normalize_path(file) |
And move normalize_path from repo.lua to util.lua.
There was a problem hiding this comment.
I'm not sure this change will be necessary if we change the commands to use the relative path.
This will also need the helper function for better absolute path detection I added in the other PR.
If it wasn't compatible you would know as |
Path, started with a drive letter under Windows - is absolute path. With my improvements it become portable and works correctly. What is wrong? |
You did not explain this. It's taken a long discussion to get to you to explain this.
I do not think it did. It prepended it with |
|
Can you check if #1254 works? |
Yes, will check. I don't understand, why you want to use Here is the summary of changes:
Please, tell me, what is wrong or confusing at the list above? |
|
Maybe this is confusing for you. We are using native windows paths only (not cygwin), because this is portable, and will work for any git. |
|
You keep explaining what your changes are, but you are not explaining what bug you are fixing. The current code works well for unix, so I find most of these changes unnecessary. One issue I can find is the |
|
The bug: The fix - use relative paths: |
|
Hi. |
|
I've looked into it and I agree now that we should use relative paths for most/all I still need to review this and will likely want to combine it with parts from the other PR. Additionally I will want both Windows and Unix to use relative paths, similar to your first version of this PR. Thanks for bearing with me. I know it was difficult, but I wanted to make sure I understood this properly as this code has gone back and forth a few times. |
| --- @type string | ||
| path = async.await(3, system, { 'cygpath', '-aw', path }).stdout | ||
| if path and vim.fn.has('win32') == 1 and string.sub(path, 1, 1) == '/' then | ||
| path = string.gsub(string.sub(path, 2, 2) .. ':' .. string.sub(path, 3), '/', '\\') |
There was a problem hiding this comment.
Can you explain this, I don't understand it. Don't we need to use cygpath in some cases?
|
Soon we will forget what we are talking about here. |
|
Hey, how are you? |
|
Closed because the Dunning-Kruger effect. |
|
Are there any temporary fixes for this? I'm running MSYS2 and still doesn't work |
This patch apply fixes to make it work with
CygwinbasedGit.The main problem is that under
Cygwinall path ingitcommand should be absolute in the unix style (/c/pathinstead ofc:/path) or be relative to thegitroot dir.It is hard to convert paths to the unix style for
Cygwinonly, better if just use relative paths everywhere.Also this patch fixes problem in
Windowd Terminal, then strings returned with the trailing\n.