Skip to content

Commit 7c5c074

Browse files
mj2068alex-courtisAndrew15-5Akmadan23
authored
fix(#2467): remove newline in git paths when using cygwin_support (#2478)
* fix(#2467): remove newline in git paths * fix: info size suffix and formatting (#2492) - Now there is a whitespace between value and unit. - Now values >= 1024 YiB are shown in YiB instead of B. - To reuse same code a new local function was added: round(). * feat(#2312): fire `TextYankPost` event on path copy (#2489) * feat(#2312): fire `TextYankPost` event on path copy * stylua * Bug fix --------- Co-authored-by: Alexander Courtis <[email protected]> * feat: mapping and options to sort entries in help window (#2482) * feat: add option to sort entries in help window * stylua * Add keymap to toggle sorting methods * Bug fix --------- Co-authored-by: Alexander Courtis <[email protected]> * fix(#2467): remove newline in git paths * fix(#2467): change cygpath calls to array format To avoid shell compatibility issues in msys2 environment on Windows * stylua nit --------- Co-authored-by: Alexander Courtis <[email protected]> Co-authored-by: Andrew Voynov <[email protected]> Co-authored-by: Azad <[email protected]>
1 parent 78a9ca5 commit 7c5c074

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lua/nvim-tree/git/utils.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,20 @@ function M.get_toplevel(cwd)
3636
-- git always returns path with forward slashes
3737
if vim.fn.has "win32" == 1 then
3838
-- msys2 git support
39+
-- cygpath calls must in array format to avoid shell compatibility issues
3940
if M.use_cygpath then
40-
toplevel = vim.fn.system("cygpath -w " .. vim.fn.shellescape(toplevel))
41+
toplevel = vim.fn.system { "cygpath", "-w", toplevel }
4142
if vim.v.shell_error ~= 0 then
4243
return nil, nil
4344
end
44-
git_dir = vim.fn.system("cygpath -w " .. vim.fn.shellescape(git_dir))
45+
-- remove trailing newline(\n) character added by vim.fn.system
46+
toplevel = toplevel:gsub("\n", "")
47+
git_dir = vim.fn.system { "cygpath", "-w", git_dir }
4548
if vim.v.shell_error ~= 0 then
4649
return nil, nil
4750
end
51+
-- remove trailing newline(\n) character added by vim.fn.system
52+
git_dir = git_dir:gsub("\n", "")
4853
end
4954
toplevel = toplevel:gsub("/", "\\")
5055
git_dir = git_dir:gsub("/", "\\")

0 commit comments

Comments
 (0)