Skip to content

Commit

Permalink
Amend loads prev. msg. even if CWD is outside repo
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Diego Caraffini authored and Diego Caraffini committed May 29, 2024
1 parent fc7eda9 commit eb7ad15
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion autoload/magit/git.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit eb7ad15

Please sign in to comment.