Skip to content

Gitsigns fails to attach in msys2 #1349

@goulf-3m

Description

@goulf-3m

Description

The debug messages showed that extra '\n' are present in git commands.

This fixes. Please apply or do similar newline striping!

diff --git a/lua/gitsigns/git/repo.lua b/lua/gitsigns/git/repo.lua
index 3ed6196..cdad8cb 100644
--- a/lua/gitsigns/git/repo.lua
+++ b/lua/gitsigns/git/repo.lua
@@ -168,6 +168,9 @@ local function normalize_path(path)
     -- through cygpath
     --- @type string
     path = async.await(3, system, { 'cygpath', '-aw', path }).stdout
+    if path:sub(-1) == '\n' then
+      path = path:sub(1, -2)
+    end
   end
   return path
 end

Neovim version

Not relevant

Operating system and version

Windows 11

Expected behavior

No response

Actual behavior

Gitsigns failed to attach

Minimal config

for name, url in pairs{
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
  -- ADD OTHER PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE
} do
  local install_path = vim.fn.fnamemodify('gitsigns_issue/'..name, ':p')
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
  vim.opt.runtimepath:append(install_path)
end

require('gitsigns').setup{
  debug_mode = true, -- You must add this to enable debug messages
  -- ADD GITSIGNS CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE
}

-- ADD INIT.LUA SETTINGS THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE

Steps to reproduce

Run nvim in MSYS2

Gitsigns debug messages


Gitsigns cache

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions