Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

Deshdeepak1
Copy link

@Deshdeepak1 Deshdeepak1 commented Dec 10, 2022

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.

use absolutegitdir for watcher instead of toplevel
@alex-courtis
Copy link
Member

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.

Copy link
Collaborator

@kylo252 kylo252 left a 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 and GIT_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)
Copy link
Collaborator

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

function M.get_project_root(cwd)
if not M.config.git.enable then
return nil
end

Copy link
Member

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)
Copy link
Collaborator

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)
Copy link
Collaborator

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

@alex-courtis
Copy link
Member

  • bumping the requirement to neovim v0.8 will allow using vim.fs which has a few useful functions for normalizing paths.

0.8.0 was released ~Oct 2022

I think it's time.

@gegoune ?

@gegoune
Copy link
Collaborator

gegoune commented Dec 12, 2022

Many other popular plugins did that already. It is time.

@alex-courtis
Copy link
Member

@kylo252 you should have permissions to approve/reject/need-work PRs.

Your reviews are gratefully appreciated :)

@alex-courtis
Copy link
Member

Many other popular plugins did that already. It is time.

Done cdb40dc

Feels good to remove workarounds...

Copy link
Member

@alex-courtis alex-courtis left a 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)
Copy link
Member

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)
Copy link
Member

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.

@alex-courtis alex-courtis changed the base branch from master-reverting to master January 9, 2023 02:43
@alex-courtis
Copy link
Member

alex-courtis commented Jan 14, 2023

Any progress on this one @Deshdeepak1 ?

Please remember to merge master and retest due to the changes in this functional area.

@alex-courtis
Copy link
Member

Closing due to lack of activity. Please reopen if you wish to continue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants