From eb7ad1514015785776bb4536b0aed2458e93af3c Mon Sep 17 00:00:00 2001 From: Diego Caraffini Date: Sun, 31 Jul 2022 23:38:11 -0400 Subject: [PATCH] Amend loads prev. msg. even if CWD is outside repo The path to the ".git" directory returned by git rev-parse --git-dir and stored in "b:magit_git_dir", can be a relative one, which would not work for opening file "COMMIT_EDITMSG" when the currently edited file was opened from outside the repository, so we make "b:magit_git_dir" absolute via "git rev-parse --absolute-git-dir". Thanks to user v-slava for suggesting the use of --absolute-git-dir. --- autoload/magit/git.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/magit/git.vim b/autoload/magit/git.vim index 5455215..8af91be 100644 --- a/autoload/magit/git.vim +++ b/autoload/magit/git.vim @@ -79,7 +79,7 @@ function! magit#git#set_top_dir(path) try let top_dir=magit#utils#strip( \ system(g:magit_git_cmd . " rev-parse --show-toplevel")) . "/" - let git_dir=magit#utils#strip(system(g:magit_git_cmd . " rev-parse --git-dir")) . "/" + let git_dir=magit#utils#strip(system(g:magit_git_cmd . " rev-parse --absolute-git-dir")) . "/" if ( executable("cygpath") ) let top_dir = magit#utils#strip(system("cygpath " . top_dir)) let git_dir = magit#utils#strip(system("cygpath " . git_dir))