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

autoload/magit/git.vim: fix modified/untracked content in submodule (fix #49)

parent f0bae248
No related branches found
No related tags found
No related merge requests found
...@@ -95,13 +95,24 @@ function! magit#git#git_diff(filename, status, mode) ...@@ -95,13 +95,24 @@ function! magit#git#git_diff(filename, status, mode)
silent let diff_list=magit#utils#systemlist(git_cmd) silent let diff_list=magit#utils#systemlist(git_cmd)
if ( empty(diff_list) ) if ( empty(diff_list) )
echohl WarningMsg echohl WarningMsg
echom "diff command \"" . diff_cmd . "\" returned nothing" echom "diff command \"" . git_cmd . "\" returned nothing"
echohl None echohl None
throw 'diff error' throw 'diff error'
endif endif
return diff_list return diff_list
endfunction endfunction
" magit#git#sub_check: this function checks if given submodule has modified or
" untracked content
" param[in] submodule: submodule path
" param[in] check_level: can be modified or untracked
function! magit#git#sub_check(submodule, check_level)
let ignore_flag = ( a:check_level == 'modified' ) ?
\ '--ignore-submodules=untracked' : ''
let git_cmd="git status --porcelain " . ignore_flag . " " . a:submodule
return ( !empty(magit#utils#systemlist(git_cmd)) )
endfunction
" magit#git#git_sub_summary: helper function to get diff of a submodule " magit#git#git_sub_summary: helper function to get diff of a submodule
" nota: when git fail (due to misformated patch for example), an error " nota: when git fail (due to misformated patch for example), an error
" message is raised. " message is raised.
...@@ -113,8 +124,16 @@ function! magit#git#git_sub_summary(filename, mode) ...@@ -113,8 +124,16 @@ function! magit#git#git_sub_summary(filename, mode)
\ .a:filename \ .a:filename
silent let diff_list=magit#utils#systemlist(git_cmd) silent let diff_list=magit#utils#systemlist(git_cmd)
if ( empty(diff_list) ) if ( empty(diff_list) )
if ( a:mode == 'unstaged' )
if ( magit#git#sub_check(a:filename, 'modified') )
return "modified content"
endif
if ( magit#git#sub_check(a:filename, 'untracked') )
return "untracked content"
endif
endif
echohl WarningMsg echohl WarningMsg
echom "diff command \"" . diff_cmd . "\" returned nothing" echom "diff command \"" . git_cmd . "\" returned nothing"
echohl None echohl None
throw 'diff error' throw 'diff error'
endif endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment