Skip to content

Commit

Permalink
feat(blame): autodetect .git-blame-ignore-revs
Browse files Browse the repository at this point in the history
Git blame has a --ignore-revs-file option for specifying a list of SHA's
to exclude. The common convention (according to a quick Google) is to
call this file .git-blame-ignore-revs. Gitsigns will now look for this
file at the top level of the repo and use it if found.

Resolves #459
  • Loading branch information
lewis6991 committed Apr 15, 2022
1 parent 318a93b commit e899189
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
19 changes: 14 additions & 5 deletions lua/gitsigns/git.lua

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

29 changes: 19 additions & 10 deletions teal/gitsigns/git.tl
Original file line number Diff line number Diff line change
Expand Up @@ -411,16 +411,25 @@ Obj.run_blame = function(self: Obj, lines: {string}, lnum: number, ignore_whites
['committer-mail'] = '<not.committed.yet>',
}
end
local results = self:command({
'blame',
'--contents', '-',
'-L', lnum..',+1',
'--line-porcelain',
self.file,
ignore_whitespace and '-w' or nil,
}, {
writer = lines,
})

local args = {
'blame',
'--contents', '-',
'-L', lnum..',+1',
'--line-porcelain',
self.file
}

if ignore_whitespace then
args[#args+1] = '-w'
end

local ignore_file = self.repo.toplevel ..'/.git-blame-ignore-revs'
if uv.fs_stat(ignore_file) then
vim.list_extend(args, {'--ignore-revs-file', ignore_file})
end

local results = self:command(args, { writer = lines })
if #results == 0 then
return
end
Expand Down

0 comments on commit e899189

Please sign in to comment.