Skip to content

Commit 34af21d

Browse files
author
Diego Caraffini
committed
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.
1 parent 88720f4 commit 34af21d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

autoload/magit/git.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function! magit#git#set_top_dir(path)
7474
try
7575
let top_dir=magit#utils#strip(
7676
\ system(g:magit_git_cmd . " rev-parse --show-toplevel")) . "/"
77-
let git_dir=magit#utils#strip(system(g:magit_git_cmd . " rev-parse --git-dir")) . "/"
77+
let git_dir=magit#utils#strip(system(g:magit_git_cmd . " rev-parse --absolute-git-dir")) . "/"
7878
if ( executable("cygpath") )
7979
let top_dir = magit#utils#strip(system("cygpath " . top_dir))
8080
let git_dir = magit#utils#strip(system("cygpath " . git_dir))

0 commit comments

Comments
 (0)