diff --git a/lua/neogit.lua b/lua/neogit.lua index ecaac9171..4f052e882 100644 --- a/lua/neogit.lua +++ b/lua/neogit.lua @@ -84,7 +84,7 @@ local function construct_opts(opts) if not opts.cwd then local git = require("neogit.lib.git") - opts.cwd = git.cli.git_root(".") + opts.cwd = git.cli.worktree_root(".") if opts.cwd == "" then opts.cwd = vim.uv.cwd() @@ -111,7 +111,7 @@ local function open_status_buffer(opts) -- going to open into. We will use vim.fn.lcd() in the status buffer constructor, so this will eventually be -- correct. local repo = require("neogit.lib.git.repository").instance(opts.cwd) - status.new(config.values, repo.git_root, opts.cwd):open(opts.kind):dispatch_refresh() + status.new(config.values, repo.worktree_root, opts.cwd):open(opts.kind):dispatch_refresh() end ---@alias Popup diff --git a/lua/neogit/buffers/status/actions.lua b/lua/neogit/buffers/status/actions.lua index 2ee8460b2..c378e718e 100644 --- a/lua/neogit/buffers/status/actions.lua +++ b/lua/neogit/buffers/status/actions.lua @@ -406,7 +406,7 @@ end ---@param self StatusBuffer M.v_ignore_popup = function(self) return popups.open("ignore", function(p) - p { paths = self.buffer.ui:get_filepaths_in_selection(), git_root = git.repo.git_root } + p { paths = self.buffer.ui:get_filepaths_in_selection(), worktree_root = git.repo.worktree_root } end) end @@ -638,7 +638,7 @@ end ---@param _self StatusBuffer M.n_show_refs = function(_self) return a.void(function() - require("neogit.buffers.refs_view").new(git.refs.list_parsed(), git.repo.git_root):open() + require("neogit.buffers.refs_view").new(git.refs.list_parsed(), git.repo.worktree_root):open() end) end @@ -1269,7 +1269,7 @@ M.n_ignore_popup = function(self) local path = self.buffer.ui:get_hunk_or_filename_under_cursor() p { paths = { path and path.escaped_path }, - git_root = git.repo.git_root, + worktree_root = git.repo.worktree_root, } end) end @@ -1309,7 +1309,7 @@ M.n_help_popup = function(self) }, ignore = { paths = { path and path.escaped_path }, - git_root = git.repo.git_root, + worktree_root = git.repo.worktree_root, }, remote = {}, fetch = {}, @@ -1364,7 +1364,8 @@ M.n_command = function(self) local runner = require("neogit.runner") return a.void(function() - local cmd = input.get_user_input(("Run command in %s"):format(git.repo.git_root), { prepend = "git " }) + local cmd = + input.get_user_input(("Run command in %s"):format(git.repo.worktree_root), { prepend = "git " }) if not cmd then return end @@ -1375,7 +1376,7 @@ M.n_command = function(self) local proc = process.new { cmd = cmd, - cwd = git.repo.git_root, + cwd = git.repo.worktree_root, env = {}, on_error = function() return false diff --git a/lua/neogit/buffers/status/init.lua b/lua/neogit/buffers/status/init.lua index a45e53260..378a94230 100644 --- a/lua/neogit/buffers/status/init.lua +++ b/lua/neogit/buffers/status/init.lua @@ -260,7 +260,7 @@ function M:chdir(dir) logger.debug("[STATUS] Changing Dir: " .. dir) vim.api.nvim_set_current_dir(dir) require("neogit.lib.git.repository").instance(dir) - self.new(config.values, git.repo.git_root, dir):open("replace"):dispatch_refresh() + self.new(config.values, git.repo.worktree_root, dir):open("replace"):dispatch_refresh() end) end diff --git a/lua/neogit/integrations/diffview.lua b/lua/neogit/integrations/diffview.lua index 1fc7dfe58..dd9cb70c2 100644 --- a/lua/neogit/integrations/diffview.lua +++ b/lua/neogit/integrations/diffview.lua @@ -73,7 +73,7 @@ local function get_local_diff_view(section_name, item_name, opts) local files = update_files() local view = CDiffView { - git_root = git.repo.git_root, + git_root = git.repo.worktree_root, left = left, right = right, files = files, diff --git a/lua/neogit/lib/git/bisect.lua b/lua/neogit/lib/git/bisect.lua index 3542079d9..c552241ef 100644 --- a/lua/neogit/lib/git/bisect.lua +++ b/lua/neogit/lib/git/bisect.lua @@ -17,7 +17,7 @@ local function bisect(cmd) end function M.in_progress() - return git.repo:git_path("BISECT_LOG"):exists() + return git.repo:worktree_git_path("BISECT_LOG"):exists() end function M.is_finished() @@ -74,7 +74,7 @@ M.register = function(meta) local finished - for line in git.repo:git_path("BISECT_LOG"):iter() do + for line in git.repo:worktree_git_path("BISECT_LOG"):iter() do if line:match("^#") and line ~= "" then local action, oid, subject = line:match("^# ([^:]+): %[(.+)%] (.+)") @@ -96,7 +96,7 @@ M.register = function(meta) end end - local expected = vim.trim(git.repo:git_path("BISECT_EXPECTED_REV"):read()) + local expected = vim.trim(git.repo:worktree_git_path("BISECT_EXPECTED_REV"):read()) state.bisect.current = git.log.parse(git.cli.show.format("fuller").args(expected).call({ trim = false }).stdout)[1] diff --git a/lua/neogit/lib/git/branch.lua b/lua/neogit/lib/git/branch.lua index da94146be..e1114d908 100644 --- a/lua/neogit/lib/git/branch.lua +++ b/lua/neogit/lib/git/branch.lua @@ -375,7 +375,7 @@ local function update_branch_information(state) state.head.oid = status.oid state.head.detached = status.detached - if status.oid ~= INITIAL_COMMIT then + if status.oid and status.oid ~= INITIAL_COMMIT then state.head.abbrev = git.rev_parse.abbreviate_commit(status.oid) state.head.commit_message = git.log.message(status.oid) diff --git a/lua/neogit/lib/git/cli.lua b/lua/neogit/lib/git/cli.lua index e4077f3a7..df89df123 100644 --- a/lua/neogit/lib/git/cli.lua +++ b/lua/neogit/lib/git/cli.lua @@ -368,7 +368,9 @@ local runner = require("neogit.runner") ---@field verify-commit GitCommandVerifyCommit ---@field worktree GitCommandWorktree ---@field write-tree GitCommandWriteTree ----@field git_root fun(dir: string):string +---@field worktree_root fun(dir: string):string +---@field git_dir fun(dir: string):string +---@field worktree_git_dir fun(dir: string):string ---@field is_inside_worktree fun(dir: string):boolean ---@field history ProcessResult[] @@ -965,15 +967,34 @@ local configurations = { ["bisect"] = config {}, } ---- NOTE: Use require("neogit.lib.git").repo.git_root instead of calling this function. ---- repository.git_root is used by all other library functions, so it's most likely the one you want to use. ---- git_root_of_cwd() returns the git repo of the cwd, which can change anytime ---- after git_root_of_cwd() has been called. +--- NOTE: Use require("neogit.lib.git").repo.worktree_root instead of calling this function. +--- repository.worktree_root is used by all other library functions, so it's most likely the one you want to use. +--- worktree_root_of_cwd() returns the git repo of the cwd, which can change anytime +--- after worktree_root_of_cwd() has been called. ---@param dir string ----@return string -local function git_root(dir) - local cmd = { "git", "-C", dir, "rev-parse", "--show-toplevel" } +---@return string Absolute path of current worktree +local function worktree_root(dir) + local cmd = { "git", "-C", dir, "rev-parse", "--show-toplevel", "--path-format=absolute" } local result = vim.system(cmd, { text = true }):wait() + + return Path:new(vim.trim(result.stdout)):absolute() +end + +---@param dir string +---@return string Absolute path of `.git/` directory +local function git_dir(dir) + local cmd = { "git", "-C", dir, "rev-parse", "--git-common-dir", "--path-format=absolute" } + local result = vim.system(cmd, { text = true }):wait() + + return Path:new(vim.trim(result.stdout)):absolute() +end + +---@param dir string +---@return string Absolute path of `.git/` directory +local function worktree_git_dir(dir) + local cmd = { "git", "-C", dir, "rev-parse", "--git-dir", "--path-format=absolute" } + local result = vim.system(cmd, { text = true }):wait() + return Path:new(vim.trim(result.stdout)):absolute() end @@ -982,6 +1003,7 @@ end local function is_inside_worktree(dir) local cmd = { "git", "-C", dir, "rev-parse", "--is-inside-work-tree" } local result = vim.system(cmd):wait() + return result.code == 0 end @@ -1152,7 +1174,7 @@ local function new_builder(subcommand) return process.new { cmd = cmd, - cwd = git.repo.git_root, + cwd = git.repo.worktree_root, env = state.env, input = state.input, on_error = opts.on_error, @@ -1229,7 +1251,9 @@ local meta = { local cli = setmetatable({ history = runner.history, - git_root = git_root, + worktree_root = worktree_root, + worktree_git_dir = worktree_git_dir, + git_dir = git_dir, is_inside_worktree = is_inside_worktree, }, meta) diff --git a/lua/neogit/lib/git/hooks.lua b/lua/neogit/lib/git/hooks.lua index b6a2efec1..991a2ab07 100644 --- a/lua/neogit/lib/git/hooks.lua +++ b/lua/neogit/lib/git/hooks.lua @@ -47,13 +47,13 @@ function M.register(meta) meta.update_hooks = function(state) state.hooks = {} - if not Path:new(state.git_root):joinpath(".git", "hooks"):is_dir() then + if not Path:new(state.git_dir):joinpath("hooks"):is_dir() then return end - for file in vim.fs.dir(vim.fs.joinpath(state.git_root, ".git", "hooks")) do + for file in vim.fs.dir(vim.fs.joinpath(state.git_dir, "hooks")) do if not file:match("%.sample$") then - local path = vim.fs.joinpath(state.git_root, ".git", "hooks", file) + local path = vim.fs.joinpath(state.git_dir, "hooks", file) local stat = vim.uv.fs_stat(path) if stat and stat.mode and is_executable(stat.mode) then diff --git a/lua/neogit/lib/git/index.lua b/lua/neogit/lib/git/index.lua index a40210e6b..35b9c8cfe 100644 --- a/lua/neogit/lib/git/index.lua +++ b/lua/neogit/lib/git/index.lua @@ -67,10 +67,10 @@ function M.generate_patch(item, hunk, from, to, reverse) string.format("@@ -%d,%d +%d,%d @@", hunk.index_from, len_start, hunk.index_from, len_start + len_offset) ) - local git_root = git.repo.git_root + local worktree_root = git.repo.worktree_root assert(item.absolute_path, "Item is not a path") - local path = Path:new(item.absolute_path):make_relative(git_root) + local path = Path:new(item.absolute_path):make_relative(worktree_root) table.insert(diff_content, 1, string.format("+++ b/%s", path)) table.insert(diff_content, 1, string.format("--- a/%s", path)) diff --git a/lua/neogit/lib/git/merge.lua b/lua/neogit/lib/git/merge.lua index 77d431484..3bcaa2aa1 100644 --- a/lua/neogit/lib/git/merge.lua +++ b/lua/neogit/lib/git/merge.lua @@ -44,7 +44,7 @@ M.register = function(meta) meta.update_merge_status = function(state) state.merge = { head = nil, branch = nil, msg = "", items = {} } - local merge_head = git.repo:git_path("MERGE_HEAD") + local merge_head = git.repo:worktree_git_path("MERGE_HEAD") if not merge_head:exists() then return end @@ -52,7 +52,7 @@ M.register = function(meta) state.merge.head = merge_head:read():match("([^\r\n]+)") state.merge.subject = git.log.message(state.merge.head) - local message = git.repo:git_path("MERGE_MSG") + local message = git.repo:worktree_git_path("MERGE_MSG") if message:exists() then state.merge.msg = message:read():match("([^\r\n]+)") -- we need \r? to support windows state.merge.branch = state.merge.msg:match("Merge branch '(.*)'$") diff --git a/lua/neogit/lib/git/rebase.lua b/lua/neogit/lib/git/rebase.lua index 330e12a9c..942bd5680 100644 --- a/lua/neogit/lib/git/rebase.lua +++ b/lua/neogit/lib/git/rebase.lua @@ -192,8 +192,8 @@ function M.update_rebase_status(state) state.rebase = { items = {}, onto = {}, head_oid = nil, head = nil, current = nil } local rebase_file - local rebase_merge = git.repo:git_path("rebase-merge") - local rebase_apply = git.repo:git_path("rebase-apply") + local rebase_merge = git.repo:worktree_git_path("rebase-merge") + local rebase_apply = git.repo:worktree_git_path("rebase-apply") if rebase_merge:exists() then rebase_file = rebase_merge diff --git a/lua/neogit/lib/git/refs.lua b/lua/neogit/lib/git/refs.lua index 0c25a2289..1125ab46e 100644 --- a/lua/neogit/lib/git/refs.lua +++ b/lua/neogit/lib/git/refs.lua @@ -132,7 +132,7 @@ M.heads = util.memoize(function() local heads = { "HEAD", "ORIG_HEAD", "FETCH_HEAD", "MERGE_HEAD", "CHERRY_PICK_HEAD" } local present = {} for _, head in ipairs(heads) do - if git.repo:git_path(head):exists() then + if git.repo:worktree_git_path(head):exists() then table.insert(present, head) end end diff --git a/lua/neogit/lib/git/repository.lua b/lua/neogit/lib/git/repository.lua index fd3af277a..a8e55fcc4 100644 --- a/lua/neogit/lib/git/repository.lua +++ b/lua/neogit/lib/git/repository.lua @@ -21,22 +21,25 @@ local modules = { } ---@class NeogitRepoState ----@field git_path fun(self, ...): Path ----@field refresh fun(self, table) ----@field git_root string ----@field head NeogitRepoHead ----@field upstream NeogitRepoRemote ----@field pushRemote NeogitRepoRemote ----@field untracked NeogitRepoIndex ----@field unstaged NeogitRepoIndex ----@field staged NeogitRepoIndex ----@field stashes NeogitRepoStash ----@field recent NeogitRepoRecent ----@field sequencer NeogitRepoSequencer ----@field rebase NeogitRepoRebase ----@field merge NeogitRepoMerge ----@field bisect NeogitRepoBisect ----@field hooks string[] +---@field git_path fun(self, ...): Path +---@field worktree_git_path fun(self, ...): Path +---@field refresh fun(self, table) +---@field worktree_root string Absolute path to the root of the current worktree +---@field worktree_git_dir string Absolute path to the .git/ dir of the current worktree +---@field git_dir string Absolute path of the .git/ dir for the repository +---@field head NeogitRepoHead +---@field upstream NeogitRepoRemote +---@field pushRemote NeogitRepoRemote +---@field untracked NeogitRepoIndex +---@field unstaged NeogitRepoIndex +---@field staged NeogitRepoIndex +---@field stashes NeogitRepoStash +---@field recent NeogitRepoRecent +---@field sequencer NeogitRepoSequencer +---@field rebase NeogitRepoRebase +---@field merge NeogitRepoMerge +---@field bisect NeogitRepoBisect +---@field hooks string[] --- ---@class NeogitRepoHead ---@field branch string|nil @@ -98,7 +101,9 @@ local modules = { ---@return NeogitRepoState local function empty_state() return { - git_root = "", + worktree_root = "", + worktree_git_dir = "", + git_dir = "", head = { branch = nil, detached = false, @@ -165,12 +170,14 @@ local function empty_state() end ---@class NeogitRepo ----@field lib table ----@field state NeogitRepoState ----@field git_root string ----@field running table ----@field interrupt table ----@field tmp_state table +---@field lib table +---@field state NeogitRepoState +---@field worktree_root string Project root, or worktree +---@field worktree_git_dir string Dir to watch for changes in worktree +---@field git_dir string '.git/' directory for repo +---@field running table +---@field interrupt table +---@field tmp_state table ---@field refresh_callbacks function[] local Repo = {} Repo.__index = Repo @@ -205,14 +212,18 @@ function Repo.new(dir) local instance = { lib = {}, state = empty_state(), - git_root = git.cli.git_root(dir), + worktree_root = git.cli.worktree_root(dir), + worktree_git_dir = git.cli.worktree_git_dir(dir), + git_dir = git.cli.git_dir(dir), refresh_callbacks = {}, running = util.weak_table(), interrupt = util.weak_table(), tmp_state = util.weak_table("v"), } - instance.state.git_root = instance.git_root + instance.state.worktree_root = instance.worktree_root + instance.state.worktree_git_dir = instance.worktree_git_dir + instance.state.git_dir = instance.git_dir setmetatable(instance, Repo) @@ -227,8 +238,14 @@ function Repo:reset() self.state = empty_state() end +---@return Path +function Repo:worktree_git_path(...) + return Path:new(self.worktree_git_dir):joinpath(...) +end + +---@return Path function Repo:git_path(...) - return Path:new(self.git_root):joinpath(".git", ...) + return Path:new(self.git_dir):joinpath(...) end function Repo:tasks(filter, state) @@ -277,7 +294,7 @@ function Repo:set_state(id) end function Repo:refresh(opts) - if self.git_root == "" then + if self.worktree_root == "" then logger.debug("[REPO] No git root found - skipping refresh") return end diff --git a/lua/neogit/lib/git/sequencer.lua b/lua/neogit/lib/git/sequencer.lua index e951b0a3b..5c10b6bb2 100644 --- a/lua/neogit/lib/git/sequencer.lua +++ b/lua/neogit/lib/git/sequencer.lua @@ -31,16 +31,16 @@ end function M.update_sequencer_status(state) state.sequencer = { items = {}, head = nil, head_oid = nil, revert = false, cherry_pick = false } - local revert_head = git.repo:git_path("REVERT_HEAD") - local cherry_head = git.repo:git_path("CHERRY_PICK_HEAD") + local revert_head = git.repo:worktree_git_path("REVERT_HEAD") + local cherry_head = git.repo:worktree_git_path("CHERRY_PICK_HEAD") if cherry_head:exists() then state.sequencer.head = "CHERRY_PICK_HEAD" - state.sequencer.head_oid = vim.trim(git.repo:git_path("CHERRY_PICK_HEAD"):read()) + state.sequencer.head_oid = vim.trim(git.repo:worktree_git_path("CHERRY_PICK_HEAD"):read()) state.sequencer.cherry_pick = true elseif revert_head:exists() then state.sequencer.head = "REVERT_HEAD" - state.sequencer.head_oid = vim.trim(git.repo:git_path("REVERT_HEAD"):read()) + state.sequencer.head_oid = vim.trim(git.repo:worktree_git_path("REVERT_HEAD"):read()) state.sequencer.revert = true end @@ -52,7 +52,7 @@ function M.update_sequencer_status(state) subject = git.log.message(HEAD_oid), }) - local todo = git.repo:git_path("sequencer/todo") + local todo = git.repo:worktree_git_path("sequencer/todo") if todo:exists() then for line in todo:iter() do if line:match("^[^#]") and line ~= "" then diff --git a/lua/neogit/lib/git/status.lua b/lua/neogit/lib/git/status.lua index d0c598009..2877789de 100644 --- a/lua/neogit/lib/git/status.lua +++ b/lua/neogit/lib/git/status.lua @@ -124,12 +124,12 @@ local function update_status(state, filter) local mode, _, _, _, _, _, _, _, _, name = rest:match(match_u) table.insert( state.unstaged.items, - update_file("unstaged", state.git_root, old_files.unstaged_files[name], mode, name) + update_file("unstaged", state.worktree_root, old_files.unstaged_files[name], mode, name) ) elseif kind == "?" then table.insert( state.untracked.items, - update_file("untracked", state.git_root, old_files.untracked_files[rest], "?", rest) + update_file("untracked", state.worktree_root, old_files.untracked_files[rest], "?", rest) ) elseif kind == "1" then local mode_staged, mode_unstaged, submodule, mH, mI, mW, hH, _, name = rest:match(match_1) @@ -145,7 +145,7 @@ local function update_status(state, filter) state.staged.items, update_file( "staged", - state.git_root, + state.worktree_root, old_files.staged_files[name], mode_staged, name, @@ -161,7 +161,7 @@ local function update_status(state, filter) state.unstaged.items, update_file( "unstaged", - state.git_root, + state.worktree_root, old_files.unstaged_files[name], mode_unstaged, name, @@ -181,7 +181,7 @@ local function update_status(state, filter) state.staged.items, update_file( "staged", - state.git_root, + state.worktree_root, old_files.staged_files[name], mode_staged, name, @@ -197,7 +197,7 @@ local function update_status(state, filter) state.unstaged.items, update_file( "unstaged", - state.git_root, + state.worktree_root, old_files.unstaged_files[name], mode_unstaged, name, diff --git a/lua/neogit/popups/ignore/actions.lua b/lua/neogit/popups/ignore/actions.lua index 0a3bfef7b..ebbd3b3f3 100644 --- a/lua/neogit/popups/ignore/actions.lua +++ b/lua/neogit/popups/ignore/actions.lua @@ -33,8 +33,8 @@ local function add_rules(path, rules) end function M.shared_toplevel(popup) - local ignore_file = Path:new(git.repo.git_root, ".gitignore") - local rules = make_rules(popup, git.repo.git_root) + local ignore_file = Path:new(git.repo.worktree_root, ".gitignore") + local rules = make_rules(popup, git.repo.worktree_root) add_rules(ignore_file, rules) end @@ -51,15 +51,15 @@ function M.shared_subdirectory(popup) end function M.private_local(popup) - local ignore_file = Path:new(git.worktree.main().path, ".git", "info", "exclude") - local rules = make_rules(popup, git.repo.git_root) + local ignore_file = git.repo:git_path("info", "exclude") + local rules = make_rules(popup, git.repo.worktree_root) add_rules(ignore_file, rules) end function M.private_global(popup) local ignore_file = Path:new(git.config.get_global("core.excludesfile"):read()) - local rules = make_rules(popup, git.repo.git_root) + local rules = make_rules(popup, git.repo.worktree_root) add_rules(ignore_file, rules) end diff --git a/lua/neogit/popups/worktree/actions.lua b/lua/neogit/popups/worktree/actions.lua index a5f13132f..ba4979d7a 100644 --- a/lua/neogit/popups/worktree/actions.lua +++ b/lua/neogit/popups/worktree/actions.lua @@ -129,8 +129,9 @@ function M.delete() local success = false if input.get_permission(("Remove worktree at %q?"):format(selected)) then - if change_dir and status.is_open() then - status.instance():chdir(git.worktree.main().path) + local main = git.worktree.main() -- A bare repo has no main, so check + if change_dir and status.is_open() and main then + status.instance():chdir(main.path) end -- This might produce some error messages that need to get suppressed diff --git a/lua/neogit/vendor/types.lua b/lua/neogit/vendor/types.lua index 54fef393a..68b8fb3fa 100644 --- a/lua/neogit/vendor/types.lua +++ b/lua/neogit/vendor/types.lua @@ -6,6 +6,7 @@ ---@field touch fun(self, opts:table) ---@field write fun(self, txt:string, flag:string) ---@field read fun(self): string|nil +---@field iter fun(self): self ---@class uv_timer_t ---@field start fun(self, time:number, repeat: number, fn: function) diff --git a/lua/neogit/watcher.lua b/lua/neogit/watcher.lua index 1314c2afc..ec233a56b 100644 --- a/lua/neogit/watcher.lua +++ b/lua/neogit/watcher.lua @@ -1,14 +1,13 @@ -- Adapted from https://github.com/lewis6991/gitsigns.nvim/blob/main/lua/gitsigns/watcher.lua#L103 local logger = require("neogit.logger") -local Path = require("plenary.path") local util = require("neogit.lib.util") local git = require("neogit.lib.git") local config = require("neogit.config") local a = require("plenary.async") ---@class Watcher ----@field git_root string +---@field git_dir string ---@field buffers table ---@field running boolean ---@field fs_event_handler uv_fs_event_t @@ -20,7 +19,7 @@ Watcher.__index = Watcher function Watcher.new(root) local instance = { buffers = {}, - git_root = Path:new(root):joinpath(".git"):absolute(), + git_dir = git.cli.worktree_git_dir(root), running = false, fs_event_handler = assert(vim.uv.new_fs_event()), } @@ -83,9 +82,9 @@ function Watcher:start() return self end - logger.debug("[WATCHER] Watching git dir: " .. self.git_root) + logger.debug("[WATCHER] Watching git dir: " .. self.git_dir) self.running = true - self.fs_event_handler:start(self.git_root, {}, self:fs_event_callback()) + self.fs_event_handler:start(self.git_dir, {}, self:fs_event_callback()) return self end @@ -99,7 +98,7 @@ function Watcher:stop() return self end - logger.debug("[WATCHER] Stopped watching git dir: " .. self.git_root) + logger.debug("[WATCHER] Stopped watching git dir: " .. self.git_dir) self.running = false self.fs_event_handler:stop() return self diff --git a/tests/specs/neogit/lib/git/cli_spec.lua b/tests/specs/neogit/lib/git/cli_spec.lua index d80c89e8b..a913e9e7b 100644 --- a/tests/specs/neogit/lib/git/cli_spec.lua +++ b/tests/specs/neogit/lib/git/cli_spec.lua @@ -8,7 +8,7 @@ describe("git cli", function() it( "finds the correct git root for a non symlinked directory", in_prepared_repo(function(root_dir) - local detected_root_dir = git_cli.git_root(".") + local detected_root_dir = git_cli.worktree_root(".") eq(detected_root_dir, root_dir) end) ) @@ -35,7 +35,7 @@ describe("git cli", function() vim.fn.system(cmd) vim.api.nvim_set_current_dir(symlink_dir) - local detected_root_dir = git_cli.git_root(".") + local detected_root_dir = git_cli.worktree_root(".") eq(detected_root_dir, git_dir) end) ) diff --git a/tests/specs/neogit/lib/git/repository_spec.lua b/tests/specs/neogit/lib/git/repository_spec.lua index c5757e820..5b8e9b8c9 100644 --- a/tests/specs/neogit/lib/git/repository_spec.lua +++ b/tests/specs/neogit/lib/git/repository_spec.lua @@ -8,8 +8,8 @@ describe("lib.git.instance", function() it( "creates cached git instance and returns it", in_prepared_repo(function(root_dir) - local dir1 = git_repo.instance(root_dir).git_root - local dir2 = git_repo.instance().git_root + local dir1 = git_repo.instance(root_dir).worktree_root + local dir2 = git_repo.instance().worktree_root eq(dir1, dir2) end) )