diff --git a/autoload/magit/git.vim b/autoload/magit/git.vim index b009105d86deec52a3ae4b2d167e869bc1ce5267..6e5f12f7a5a12c8d4648c77d5c6600e5656c6c03 100644 --- a/autoload/magit/git.vim +++ b/autoload/magit/git.vim @@ -95,13 +95,24 @@ function! magit#git#git_diff(filename, status, mode) silent let diff_list=magit#utils#systemlist(git_cmd) if ( empty(diff_list) ) echohl WarningMsg - echom "diff command \"" . diff_cmd . "\" returned nothing" + echom "diff command \"" . git_cmd . "\" returned nothing" echohl None throw 'diff error' endif return diff_list 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 " nota: when git fail (due to misformated patch for example), an error " message is raised. @@ -113,8 +124,16 @@ function! magit#git#git_sub_summary(filename, mode) \ .a:filename silent let diff_list=magit#utils#systemlist(git_cmd) 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 - echom "diff command \"" . diff_cmd . "\" returned nothing" + echom "diff command \"" . git_cmd . "\" returned nothing" echohl None throw 'diff error' endif