Skip to content

Detect the git root directory #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ encounter some bugs during usage.
## Requirements

- `git`
- `nvim 0.7+`
- `nvim 0.10+`

## Installation

Expand Down
4 changes: 3 additions & 1 deletion lua/git-conflict.lua
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,9 @@ function M.setup(user_config)
api.nvim_create_autocmd({ 'VimEnter', 'BufRead', 'SessionLoadPost', 'DirChanged' }, {
group = AUGROUP_NAME,
callback = function(args)
local gitdir = fn.getcwd() .. sep .. '.git'
local gitroot = vim.fs.root(fn.getcwd(), ".git")
if not gitroot then return end
local gitdir = vim.fs.joinpath(gitroot, ".git")
if not vim.loop.fs_stat(gitdir) or state.current_watcher_dir == fn.getcwd() then return end
stop_running_watchers(gitdir)
fetch_conflicts(args.buf)
Expand Down