Skip to content

Commit

Permalink
Change git status to use -z in cli. This will prevent git from
Browse files Browse the repository at this point in the history
escaping unicode characters in path names, so we can properly display
characters from all (hopefully) alphabets.
  • Loading branch information
CKolkey committed Dec 27, 2023
1 parent 952e2da commit 5312c67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions lua/neogit/lib/git/cli.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ local configurations = {
short = "-s",
branch = "-b",
verbose = "-v",
null_separated = "-z",
},
options = {
porcelain = "--porcelain",
Expand Down
12 changes: 10 additions & 2 deletions lua/neogit/lib/git/status.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local Path = require("plenary.path")
local util = require("neogit.lib.util")
local Collection = require("neogit.lib.collection")

---@class File: StatusItem
Expand Down Expand Up @@ -49,7 +50,6 @@ local function update_status(state)
-- cwd may change after the status is refreshed and used, especially if using
-- rooter plugins with lsp integration
local cwd = vim.loop.cwd()
local result = git.cli.status.porcelain(2).branch.call { hidden = true }

local head = {}
local upstream = { unmerged = { items = {} }, unpulled = { items = {} }, ref = nil }
Expand All @@ -61,7 +61,15 @@ local function update_status(state)
untracked_files = Collection.new(state.untracked.items or {}):key_by("name"),
}

for _, l in ipairs(result.stdout) do
local result = git.cli.status.null_separated.porcelain(2).branch.call { hidden = true }
result = vim.split(result.stdout_raw[1], "\n")
result = util.filter_map(result, function(l)
if l ~= "" then
return l
end
end)

for _, l in ipairs(result) do
local header, value = l:match("# ([%w%.]+) (.+)")
if header then
if header == "branch.head" then
Expand Down

0 comments on commit 5312c67

Please sign in to comment.