Skip to content
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

Does not recognize existing git repo #1624

Open
KRC2000 opened this issue Jan 8, 2025 · 9 comments
Open

Does not recognize existing git repo #1624

KRC2000 opened this issue Jan 8, 2025 · 9 comments
Labels
bug Something isn't working

Comments

@KRC2000
Copy link

KRC2000 commented Jan 8, 2025

Description

Having this issue on windows using WSL(neovim is installed inside of wsl).
Inside of Neovim, when I cd into a folder with a git repo initialized and run require("neogit").open I get

CWD: /mnt/c/Users/krs/Documents/uo/
Initialize repository in /mnt/c/Users/krs/Documents/uo
--path-format=absolute?
(Y)es, [N]o:

I enter N and get:

The current working directory is not a git repository

Even tho folder contains .git folder and I actively work on this repo with other tools, repo is 100% valid.

I started testing and found out that neogit can't detect any repo. I create a new folder, init new repo with neogit itself, and nogit prompts me to init it again right away, like there is no repo.
I use neogit on my other linux machine and it works flawlessly.

Neovim version

NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1713484068

Operating system and version

Windows 10

Steps to reproduce

  1. Open some terminal emulator on windows with installed wsl(Debian distro)
  2. Run wsl(all next steps are happening inside wsl)
  3. Download neovim binary for debian
  4. Create an init.lua file at ~/.config/nvim, write a script to install Lazy plugin manager and then install neogit with it.
  5. Open neovim, navigate to the folder with valid git repo initialized
  6. Run require("neogit").open
  7. Observe behaviour

Expected behavior

I expect to see unstaged changes, recent commits, default dashboard

Actual behavior

CWD: /mnt/c/Users/krs/Documents/uo/
Initialize repository in /mnt/c/Users/krs/Documents/uo
--path-format=absolute?
(Y)es, [N]o:

Minimal config

1 return {
  2   "NeogitOrg/neogit",
  3   dependencies = {
  4     "nvim-lua/plenary.nvim",  -- required
  5     "sindrets/diffview.nvim", -- optional - Diff integration
  6
  7     -- Only one of these is needed.
  8     "nvim-telescope/telescope.nvim", -- optional
  9   },
 10   config = function()
 11     local g = require("neogit")
 12     g.setup()
 13     vim.keymap.set('n', '<leader>g', g.open, { desc = 'Neogit open' })
 14   end
 15 }
@KRC2000 KRC2000 added the bug Something isn't working label Jan 8, 2025
@CKolkey
Copy link
Member

CKolkey commented Jan 9, 2025

So... I don't have access to a windows box to try to figure out what's wrong. If you feel like poking around I'd be happy to help, but otherwise there's not much I can do.

@SheffeyG
Copy link
Contributor

SheffeyG commented Jan 14, 2025

@CKolkey I encountered the same issue, this bug exists in more than just Windows WSL, and my setup is

  • ubuntu 20.04
  • nvim 0.10.3
  • git 2.25.1

I performed a binary search on the past commit history, and figured out the last work commit is the one before 3a2379fe27adb392c251fcfe378fefbd4879e82b, this commit changed the method finding .git folder.

Since that problem only happend recently, so I guess there must be something that has been changed back and forth.

@CKolkey
Copy link
Member

CKolkey commented Jan 14, 2025

Strange that CI seems to work fine, which runs on ubuntu as well. But thanks for narrowing it down - I'll try to find time to figure out whats wrong.

@CKolkey
Copy link
Member

CKolkey commented Jan 14, 2025

If you run git -C . rev-parse --git-common-dir --path-format=absolute in the shell. does that return an expected value?

@SheffeyG
Copy link
Contributor

The output from my computer works is:

❯ git -C . rev-parse --git-common-dir --path-format=absolute
.git

That doesn't work one's output is:

❯ git -C . rev-parse --git-common-dir --path-format=absolute
.git
--path-format=absolute

Maybe some older git version do not support args path-format?

@CKolkey
Copy link
Member

CKolkey commented Jan 14, 2025

Oh, it's echoing the argument there at the end? Could you check the git version there?

@SheffeyG
Copy link
Contributor

I just removed that last argument as

local cmd = { "git", "-C", dir, "rev-parse", "--git-common-dir" }  

it works fine!

The git versions is 2.34.1(work) and 2.25.1(dosen't work)

@CKolkey
Copy link
Member

CKolkey commented Jan 14, 2025

Right on - iirc it's there for worktree support, but I'm sure it could be redone to fix this

@villapx-path
Copy link

The --path-format arg was introduced to git rev-parse in version 2.31.0: https://git-scm.com/docs/git-rev-parse/2.31.0

(previous version, 2.30.0, for reference: https://git-scm.com/docs/git-rev-parse/2.30.0 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants