fix(git): only honor -> in porcelain output for renames
This commit is contained in:
@@ -161,11 +161,19 @@ local function do_refresh(repo)
|
|||||||
for line in (obj.stdout or ""):gmatch("[^\r\n]+") do
|
for line in (obj.stdout or ""):gmatch("[^\r\n]+") do
|
||||||
if line:sub(1, 2) ~= "##" then
|
if line:sub(1, 2) ~= "##" then
|
||||||
local code = line:sub(1, 2)
|
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 path_part = line:sub(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)
|
local arrow = path_part:find(" -> ", 1, true)
|
||||||
if arrow then
|
if arrow then
|
||||||
path_part = path_part:sub(arrow + 4)
|
path_part = path_part:sub(arrow + 4)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
statuses[vim.fs.joinpath(repo.worktree, path_part)] =
|
statuses[vim.fs.joinpath(repo.worktree, path_part)] =
|
||||||
format(code)
|
format(code)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -165,11 +165,16 @@ local function parse_porcelain(stdout)
|
|||||||
local y = line:sub(2, 2)
|
local y = line:sub(2, 2)
|
||||||
local rest = line:sub(4)
|
local rest = line:sub(4)
|
||||||
local orig
|
local orig
|
||||||
|
-- ` -> ` only appears in renames/copies (R/C codes). Without
|
||||||
|
-- this guard, a literal filename containing the arrow would
|
||||||
|
-- be mis-parsed.
|
||||||
|
if x == "R" or x == "C" or y == "R" or y == "C" then
|
||||||
local arrow = rest:find(" -> ", 1, true)
|
local arrow = rest:find(" -> ", 1, true)
|
||||||
if arrow then
|
if arrow then
|
||||||
orig = rest:sub(1, arrow - 1)
|
orig = rest:sub(1, arrow - 1)
|
||||||
rest = rest:sub(arrow + 4)
|
rest = rest:sub(arrow + 4)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
local entry = {
|
local entry = {
|
||||||
section = nil,
|
section = nil,
|
||||||
path = rest,
|
path = rest,
|
||||||
|
|||||||
Reference in New Issue
Block a user