From 54b9df401b8f21f4e6ca537ec47a109394aaccd7 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 7 Jun 2024 10:58:16 +0100 Subject: [PATCH] fix(attach): fix worktree attaching Fixes #1020 --- lua/gitsigns/attach.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/gitsigns/attach.lua b/lua/gitsigns/attach.lua index fc3c2e512..9b6bfe419 100644 --- a/lua/gitsigns/attach.lua +++ b/lua/gitsigns/attach.lua @@ -138,15 +138,16 @@ end --- @param _bufnr integer --- @param file string +--- @param revision string? --- @param encoding string --- @return Gitsigns.GitObj? -local function try_worktrees(_bufnr, file, encoding) +local function try_worktrees(_bufnr, file, revision, encoding) if not config.worktrees then return end for _, wt in ipairs(config.worktrees) do - local git_obj = git.Obj.new(file, encoding, wt.gitdir, wt.toplevel) + local git_obj = git.Obj.new(file, revision, encoding, wt.gitdir, wt.toplevel) if git_obj and git_obj.object_name then dprintf('Using worktree %s', vim.inspect(wt)) return git_obj @@ -273,7 +274,7 @@ local attach_throttled = throttle_by_id(function(cbuf, ctx, aucmd) local git_obj = git.Obj.new(file, revision, encoding, ctx.gitdir, ctx.toplevel) if not git_obj and not passed_ctx then - git_obj = try_worktrees(cbuf, file, encoding) + git_obj = try_worktrees(cbuf, file, revision, encoding) async.scheduler() if not api.nvim_buf_is_valid(cbuf) then return