Skip to content

Commit

Permalink
fix(blame): handle changes from git 2.41
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Jun 7, 2023
1 parent f868d82 commit 4455bb5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
23 changes: 17 additions & 6 deletions lua/gitsigns/git.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions teal/gitsigns/git.tl
Original file line number Diff line number Diff line change
Expand Up @@ -560,16 +560,18 @@ end

--- @async
function Obj:run_blame(lines: {string}, lnum: number, ignore_whitespace: boolean): M.BlameInfo
local not_committed = {
author = 'Not Committed Yet',
['author_mail'] = '<not.committed.yet>',
committer = 'Not Committed Yet',
['committer_mail'] = '<not.committed.yet>',
}

if not self.object_name or self.repo.abbrev_head == '' then
-- As we support attaching to untracked files we need to return something if
-- the file isn't isn't tracked in git.
-- If abbrev_head is empty, then assume the repo has no commits
return {
author = 'Not Committed Yet',
['author_mail'] = '<not.committed.yet>',
committer = 'Not Committed Yet',
['committer_mail'] = '<not.committed.yet>',
}
return not_committed
end

local args = {
Expand Down Expand Up @@ -611,6 +613,15 @@ function Obj:run_blame(lines: {string}, lnum: number, ignore_whitespace: boolean
end
end
end

-- New in git 2.41:
-- The output given by "git blame" that attributes a line to contents
-- taken from the file specified by the "--contents" option shows it
-- differently from a line attributed to the working tree file.
if ret.author_mail == '<external.file>' then
ret = vim.tbl_extend('force', ret, not_committed as table) as {string:any}
end

return ret as M.BlameInfo
end

Expand Down

0 comments on commit 4455bb5

Please sign in to comment.