Skip to content

Commit

Permalink
fix(gitblame): validate buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Jan 23, 2024
1 parent 1182fb9 commit e55bfa8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lua/tinygit/gitblame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ local fn = vim.fn
---@return string blame
---@nodiscard
local function getBlame(bufnr)
local bufPath = vim.api.nvim_buf_get_name(bufnr or 0)
bufnr = bufnr or 0
if not vim.api.nvim_buf_is_valid(bufnr) then return "" end
local bufPath = vim.api.nvim_buf_get_name(bufnr)
local gitLogLine = trim(
vim.fn.system { "git", "log", "--format=%H\t%an\t%cr\t%s", "--max-count=1", "--", bufPath }
)
Expand Down

0 comments on commit e55bfa8

Please sign in to comment.