fix(git): only honor -> in porcelain output for renames
This commit is contained in:
+11
-3
@@ -161,10 +161,18 @@ local function do_refresh(repo)
|
||||
for line in (obj.stdout or ""):gmatch("[^\r\n]+") do
|
||||
if line:sub(1, 2) ~= "##" then
|
||||
local code = line:sub(1, 2)
|
||||
local x = code:sub(1, 1)
|
||||
local y = code:sub(2, 2)
|
||||
local path_part = line:sub(4)
|
||||
local arrow = path_part:find(" -> ", 1, true)
|
||||
if arrow then
|
||||
path_part = path_part:sub(arrow + 4)
|
||||
-- ` -> ` only appears in renames/copies. Without
|
||||
-- this guard, a literal filename containing the
|
||||
-- arrow (rare with `core.quotePath=false`) would
|
||||
-- be mis-parsed.
|
||||
if x == "R" or x == "C" or y == "R" or y == "C" then
|
||||
local arrow = path_part:find(" -> ", 1, true)
|
||||
if arrow then
|
||||
path_part = path_part:sub(arrow + 4)
|
||||
end
|
||||
end
|
||||
statuses[vim.fs.joinpath(repo.worktree, path_part)] =
|
||||
format(code)
|
||||
|
||||
Reference in New Issue
Block a user