fix(#1961): harden profiling functions (#1986)

This commit is contained in:
Alexander Courtis
2023-02-11 17:05:01 +11:00
committed by GitHub
parent 02fdc262eb
commit b712b82b0c
11 changed files with 44 additions and 46 deletions

View File

@@ -4,7 +4,7 @@ local log = require "nvim-tree.log"
local has_cygpath = vim.fn.executable "cygpath" == 1
function M.get_toplevel(cwd)
local ps = log.profile_start("git toplevel %s", cwd)
local profile = log.profile_start("git toplevel %s", cwd)
local cmd = { "git", "-C", cwd, "rev-parse", "--show-toplevel" }
log.line("git", "%s", vim.inspect(cmd))
@@ -12,7 +12,7 @@ function M.get_toplevel(cwd)
local toplevel = vim.fn.system(cmd)
log.raw("git", toplevel)
log.profile_end(ps, "git toplevel %s", cwd)
log.profile_end(profile)
if vim.v.shell_error ~= 0 or not toplevel or #toplevel == 0 or toplevel:match "fatal" then
return nil
@@ -41,7 +41,7 @@ function M.should_show_untracked(cwd)
return untracked[cwd]
end
local ps = log.profile_start("git untracked %s", cwd)
local profile = log.profile_start("git untracked %s", cwd)
local cmd = { "git", "-C", cwd, "config", "status.showUntrackedFiles" }
log.line("git", vim.inspect(cmd))
@@ -49,7 +49,7 @@ function M.should_show_untracked(cwd)
local has_untracked = vim.fn.system(cmd)
log.raw("git", has_untracked)
log.profile_end(ps, "git untracked %s", cwd)
log.profile_end(profile)
untracked[cwd] = vim.trim(has_untracked) ~= "no"
return untracked[cwd]