fix: correctly parse filenames with special chars in git_status (#2296)

This commit is contained in:
Jonas Strittmatter
2023-01-06 12:04:15 +01:00
committed by GitHub
parent 0326347eba
commit b24fdfdb25
2 changed files with 9 additions and 3 deletions

View File

@@ -314,7 +314,7 @@ git.status = function(opts)
local gen_new_finder = function()
local expand_dir = vim.F.if_nil(opts.expand_dir, true)
local git_cmd = { "git", "status", "-s", "--", "." }
local git_cmd = { "git", "status", "-z", "--", "." }
if expand_dir then
table.insert(git_cmd, #git_cmd - 1, "-u")
@@ -332,7 +332,7 @@ git.status = function(opts)
end
return finders.new_table {
results = output,
results = vim.split(output[1], "", { trimempty = true }),
entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_status(opts)),
}
end

View File

@@ -1352,7 +1352,13 @@ function make_entry.gen_from_git_status(opts)
if entry == "" then
return nil
end
local mod, file = string.match(entry, "(..).*%s[->%s]?(.+)")
local mod, file = entry:match "^(..) (.+)$"
-- Ignore entries that are the PATH in XY ORIG_PATH PATH
-- (renamed or copied files)
if not mod then
return nil
end
return setmetatable({
value = file,