Skip to content

[feat] msys2 support #574

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = off
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Plug 'sindrets/diffview.nvim'

```lua
-- Packer
use "sindrets/diffview.nvim"
use "sindrets/diffview.nvim"
```

## Merge Tool
Expand Down
1 change: 0 additions & 1 deletion lua/diffview/debounce.lua
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,3 @@ function M.set_timeout(func, delay)
end

return M

24 changes: 22 additions & 2 deletions lua/diffview/vcs/adapters/git/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ local logger = DiffviewGlobal.logger
local pl = lazy.access(utils, "path") ---@type PathLib
local uv = vim.loop

local has_cygpath
local function normalize_cygwin_path(path)
if path and vim.fn.has('win32') == 1 and string.sub(path, 1, 1) == '/' then
if has_cygpath == nil then
has_cygpath = vim.fn.executable('cygpath') == 1
end

if has_cygpath then
path = vim.fn.system({"cygpath", "--absolute", "--windows", path})

-- remove "\n"
path = string.sub(path, 1, #path -1)
end
end

return path
end

local M = {}

---@class GitAdapter : VCSAdapter
Expand Down Expand Up @@ -177,7 +195,8 @@ local function get_toplevel(path)
if code ~= 0 then
return nil
end
return out[1] and vim.trim(out[1])

return normalize_cygwin_path(out[1])
end

---Try to find the top-level of a working tree by using the given indicative
Expand Down Expand Up @@ -279,7 +298,8 @@ function GitAdapter:get_dir(path)
if code ~= 0 then
return nil
end
return out[1] and vim.trim(out[1])

return normalize_cygwin_path(out[1])
end

---Verify that a given git rev is valid.
Expand Down