diff --git a/common/magit_common.vim b/common/magit_common.vim index d183399dc5819b23a98a9930a4932ef6bc2cb04a..88528436a8786a5bac154e1b397834986991da36 100644 --- a/common/magit_common.vim +++ b/common/magit_common.vim @@ -2,6 +2,7 @@ " These are used to beautify the magit buffer and to help for some block " selection let g:magit_sections = { + \ 'info': 'Info', \ 'staged': 'Staged changes', \ 'unstaged': 'Unstaged changes', \ 'commit_start': 'Commit message', diff --git a/plugin/magit.vim b/plugin/magit.vim index 001ae1061a32f2113a8190b635cda55c22969fea..1463daa590059a76f9d2556b4cd61ea1352fc28b 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -275,6 +275,21 @@ function! s:mg_section_help(section) endif endfunction +" s:mg_get_info: this function writes in current buffer current git state +" WARNING: this function writes in file, it should only be called through +" protected functions like magit#update_buffer +function! s:mg_get_info() + silent put ='' + silent put =g:magit_sections['info'] + silent put =<SID>mg_underline(g:magit_sections['info']) + silent put ='' + let branch=<SID>mg_system("git rev-parse --abbrev-ref HEAD") + let commit=<SID>mg_system("git show -s --oneline") + silent put ='Current branch: ' . branch + silent put ='Last commit: ' . commit + silent put ='' +endfunction + " s:mg_get_staged: this function writes in current buffer all staged files " WARNING: this function writes in file, it should only be called through " protected functions like magit#update_buffer @@ -589,6 +604,7 @@ function! magit#update_buffer() let l:winview = winsaveview() silent! %d + call <SID>mg_get_info() call <SID>mg_section_help('global') if ( s:magit_commit_mode != '' ) call <SID>mg_get_commit_section()