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

:Gcommit not editing .git\COMMIT_EDITMSG on windows #31

Closed
bsisco opened this issue Jan 11, 2011 · 4 comments
Closed

:Gcommit not editing .git\COMMIT_EDITMSG on windows #31

bsisco opened this issue Jan 11, 2011 · 4 comments

Comments

@bsisco
Copy link

bsisco commented Jan 11, 2011

When I run :Gcommit it tries to add the file ..gitCOMMIT_EDITMSG to the root dir instead of editing my ..git\COMMIT_EDITMSG like it should.

Steps to reproduce:

  • Edit a file in a local repo
  • Make some changes
  • :w
  • :Gcommit
  • Edit message
  • :wq
  • Notice ..gitCOMMIT_EDITMSG instead of ..git\COMMIT_EDITMSG

I'm using:

  • Vim72 (compiled August 5 2010)
  • MS-Windows 32-bit GUI version
  • Windows XP SP3
  • Msys GIT/TortoiseGIT
@tpope
Copy link
Owner

tpope commented Aug 9, 2011

Recently got a clue about this. Do you have git.vim installed? Remove it.

I can say this works fine for me.

@tpope
Copy link
Owner

tpope commented Aug 14, 2019

In the year 2019 this is definitely working.

@tpope tpope closed this as completed Aug 14, 2019
@gotnone
Copy link

gotnone commented Nov 21, 2024

I am seeing a similar error when using msys2 bash as the shell and attempting to :Git cc. The buffer that is opened looks for a strange combination of windows style and unix style paths.

In my example I created a git repository in C:\src\test.

To reproduce:

  1. Open msys2 bash shell
  2. cd /c/src/test
  3. nvim somefile.txt
  4. Edit file and then :Git cc
  5. command spawns a buffer for a COMMIT_EDITMSG pointing at C:/src/test//c/src/test/.git/COMMIT_EDITMSG. This does not resolve to any file and the buffer is blank instead of showing the default commit message boilerplate comments.

Additional data

  1. start in /c/src/test/
  2. md foo
  3. cd foo
  4. pwd output is now /c/src/test/foo
  5. nvim ../somefile.txt
  6. Edit file and then :Git cc
  7. command spawns a buffer for a COMMIT_EDITMSG pointing at C:/src/test/foo//c/src/test/.git/COMMIT_EDITMSG.

It appears that the current working directory is somehow getting pasted to the front of the COMMIT_EDITMSG path

I am not certain if there may be some mixup / misconfiguration between my shell configuration and any auto detection functions in the fugitive codebase that attempt to work around windows shell / path issues.

In my init.lua I use the following shell configuration:

if vim.fn.executable 'bash' then
  vim.o.shell = 'bash'
  vim.o.shellcmdflag = '-c'
  vim.o.shellredir = '>%s 2>&1'
  vim.o.shellquote = ''
  vim.o.shellxquote = ''
  vim.o.shellxescape = ''
  vim.o.shellpipe = '2>&1| tee'
  vim.o.shellslash = true
end

I am able to run :checkhealth without any errors as well as run :! commands with and without arguments successfully

OS : Windows 10
Editor: nvim 0.10.1
Futitive: 320b18f
Git: :!which git: /usr/bin/git git version 2.47.0
Shell: GNU bash, version 5.2.37(1)-release (x86_64-pc-msys)
Other packages:

  Loaded (21)
~                   ● cmp-nvim-lsp 0.38ms 🔌 nvim-lspconfig
~                   ● fidget.nvim 21.35ms 🔌 nvim-lspconfig
~                   ● gitsigns.nvim 13.96ms 🚀 start
~                   ● lazy.nvim 20.03ms 📄 init.lua
~                   ● mason-lspconfig.nvim 0.33ms 🔌 nvim-lspconfig
~                   ● mason-tool-installer.nvim 8.34ms 🔌 nvim-lspconfig
~                   ● mason.nvim 9.83ms 🔌 nvim-lspconfig
~                   ● mini.nvim 5.86ms 🚀 start
~                   ● nvim-lspconfig 61.41ms 🚀 start
~                   ● nvim-treesitter 41.38ms 🚀 start
~                   ● plenary.nvim 4.68ms 🔌 todo-comments.nvim
~                   ● recover.vim 3.57ms 🚀 start
~                   ● telescope-fzf-native.nvim 4.56ms 🔌 telescope.nvim
~                   ● telescope-ui-select.nvim 4.28ms 🔌 telescope.nvim
~                   ● telescope.nvim 49.57ms 📅 VimEnter
~                   ● todo-comments.nvim 12.26ms 📅 VimEnter
~                   ● tokyonight.nvim 0.27ms colorscheme tokyonight-night
~                   ● vim-fugitive 3.69ms 🚀 start
~                   ● vim-rhubarb 3.82ms 🚀 start
~                   ● vim-sleuth 4.16ms 🚀 start
~                   ● which-key.nvim 5.57ms 📅 VimEnter

Note: I do have Git for Windows installed in C:\Program Files\Git, but it is not in the PATH accessible to Msys2. :G --version also replies with the msys git version git version 2.47.0and not the Git for Windows version git version 2.47.0.windows.2

@tpope
Copy link
Owner

tpope commented Nov 21, 2024

The buffer that is opened looks for a strange combination of windows style and unix style paths.

Because you've combined a version of Neovim that uses Windows paths with a version of Git that uses UNIX style paths.

Note: I do have Git for Windows installed in C:\Program Files\Git, but it is not in the PATH accessible to Msys2.

Making it PATH accessible will solve this.

Or you could install an Msys2 version of Neovim.

Or you could provide custom implementations of FugitiveVimPath() and FugitiveGitPath() that translate between the 2 kinds of paths. This shouldn't be terribly difficult, as long as you're just trying to solve "works for me" rather than "works for everyone". But it's probably harder than just using a less problematic setup.

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

No branches or pull requests

3 participants