diff --git a/lua/gitsigns/git/repo.lua b/lua/gitsigns/git/repo.lua index f176781b1..f927e7ced 100644 --- a/lua/gitsigns/git/repo.lua +++ b/lua/gitsigns/git/repo.lua @@ -136,7 +136,12 @@ end function M:unref() local gitdir = self.gitdir - local refcount = repo_cache[gitdir][1] + local repo = repo_cache[gitdir] + if not repo then + -- Already reclaimed by GC + return + end + local refcount = repo[1] if refcount <= 1 then repo_cache[gitdir] = nil else