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 committed Feb 1, 2023
1 parent 88720f4 commit 34af21d
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 @@ -74,7 +74,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 34af21d

Please sign in to comment.