Skip to content
Snippets Groups Projects
Commit 18d9fc6c authored by Jerome Reybert's avatar Jerome Reybert
Browse files

Ungraceful behaviour when opening magit outside of a git repo fix #162

The error was not catchup early enough withthe new shell error
management.

It mades a ciphered error message.

Now, no vim error is thrown. It could be improved, setting the magit
file with magit properties, and display the error message in the buffer.
parent 95e7501c
Branches
Tags
No related merge requests found
......@@ -51,13 +51,11 @@ function! magit#git#is_work_tree(path)
let dir = getcwd()
try
call magit#utils#chdir(a:path)
try
let top_dir=magit#utils#strip(
\ system(g:magit_git_cmd . " rev-parse --show-toplevel")) . "/"
catch 'shell_error'
let top_dir=system(g:magit_git_cmd . " rev-parse --show-toplevel")
if ( v:shell_error != 0 )
return ''
endtry
return top_dir
endif
return magit#utils#strip(top_dir) . "/"
finally
call magit#utils#chdir(dir)
endtry
......
......@@ -732,13 +732,13 @@ function! magit#show_magit(display, ...)
if ( git_dir == '' )
echohl ErrorMsg
echom "magit can not find any git repository"
echohl None
echom "make sure that current opened file or vim current directory points to a git repository"
echom "search paths:"
for path in try_paths
echom path
endfor
echohl None
throw 'magit_not_in_git_repo'
return
endif
let buffer_name=fnameescape('magit://' . git_dir)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment