Skip to content

Commit a67c42d

Browse files
committed
feat: add msys2 support
1 parent 4516612 commit a67c42d

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

lua/diffview/vcs/adapters/git/init.lua

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,16 @@ local function get_toplevel(path)
177177
if code ~= 0 then
178178
return nil
179179
end
180-
return out[1] and vim.trim(out[1])
180+
181+
local path = out[1] and vim.trim(out[1])
182+
183+
if path then
184+
if vim.fn.has('win32') == 1 and string.sub(path, 1, 1) == '/' then
185+
path = string.gsub(string.sub(path, 2, 2) .. ':' .. string.sub(path, 3), '/', '\\')
186+
end
187+
end
188+
189+
return path
181190
end
182191

183192
---Try to find the top-level of a working tree by using the given indicative
@@ -279,7 +288,16 @@ function GitAdapter:get_dir(path)
279288
if code ~= 0 then
280289
return nil
281290
end
282-
return out[1] and vim.trim(out[1])
291+
292+
local path = out[1] and vim.trim(out[1])
293+
294+
if path then
295+
if vim.fn.has('win32') == 1 and string.sub(path, 1, 1) == '/' then
296+
path = string.gsub(string.sub(path, 2, 2) .. ':' .. string.sub(path, 3), '/', '\\')
297+
end
298+
end
299+
300+
return path
283301
end
284302

285303
---Verify that a given git rev is valid.

0 commit comments

Comments
 (0)