-
-
Notifications
You must be signed in to change notification settings - Fork 624
fix(git): git watcher showing error for bare repositories #1819
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
Conversation
use absolutegitdir for watcher instead of toplevel
Unfortunately my git knowledge is insufficient to understand the use case for operating inside a bare repo. Perhaps you could provide me with an example I can replicate locally to test this out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some additional notes:
- should probably use the
git.runner
module - should probably handle
GIT_DIR
andGIT_WORK_TREE
- bumping the requirement to neovim v0.8 will allow using
vim.fs
which has a few useful functions for normalizing paths.
@@ -136,6 +136,8 @@ function M.load_project_status(cwd) | |||
return {} | |||
end | |||
|
|||
local absolutegitdir = git_utils.get_absolutegitdir(cwd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will break existing behavior since get_project_root()
has a few more checks
nvim-tree.lua/lua/nvim-tree/git/init.lua
Lines 72 to 76 in cf90837
function M.get_project_root(cwd) | |
if not M.config.git.enable then | |
return nil | |
end | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1809 will be merged shortly, with some significant refactoring in this area.
We must merge master before testing this PR.
local cmd = { "git", "-C", cwd, "rev-parse", "--absolute-git-dir" } | ||
log.line("git", "%s", vim.inspect(cmd)) | ||
|
||
local absolutegitdir = vim.fn.system(cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can return different errors, what's the plan for handling them? maybe check if the result is a valid dir?
@@ -3,6 +3,37 @@ local log = require "nvim-tree.log" | |||
|
|||
local has_cygpath = vim.fn.executable "cygpath" == 1 | |||
|
|||
function M.get_absolutegitdir(cwd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as mentioned, I think this should partially replace get_project_root
0.8.0 was released ~Oct 2022 I think it's time. @gegoune ? |
Many other popular plugins did that already. It is time. |
@kylo252 you should have permissions to approve/reject/need-work PRs. Your reviews are gratefully appreciated :) |
Done cdb40dc Feels good to remove workarounds... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1809 has been merged; please merge master.
@@ -3,6 +3,37 @@ local log = require "nvim-tree.log" | |||
|
|||
local has_cygpath = vim.fn.executable "cygpath" == 1 | |||
|
|||
function M.get_absolutegitdir(cwd) | |||
local ps = log.profile_start("git absolutegitdir %s", cwd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
@@ -136,6 +136,8 @@ function M.load_project_status(cwd) | |||
return {} | |||
end | |||
|
|||
local absolutegitdir = git_utils.get_absolutegitdir(cwd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1809 will be merged shortly, with some significant refactoring in this area.
We must merge master before testing this PR.
Any progress on this one @Deshdeepak1 ? Please remember to merge master and retest due to the changes in this functional area. |
Closing due to lack of activity. Please reopen if you wish to continue. |
use absolutegitdir for watcher instead of toplevel
toplevel/.git and git dir are same for non bare repositories. But for bare repositories it was showing error.