Skip to content

Commit 2d491c5

Browse files
committed
Fix show diff details key not found
1 parent 2a8c5f8 commit 2d491c5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

autoload/project/git.vim

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ endfunction
145145

146146
function! s:AddDiffDetails(hash, file)
147147
let changes = []
148-
let is_diff_line = !empty(s:commit_diffs)
148+
let is_diff_line = !empty(s:commit_diffs) && has_key(s:commit_diffs, a:hash)
149149
if is_diff_line
150150
let changes = s:commit_diffs[a:hash]
151151
else
@@ -818,6 +818,7 @@ function! s:ShelfFile() range
818818
endif
819819

820820
for file in files
821+
" TODO: fix file under a directory abc/def/name.txt
821822
let cmd = 'git diff "'.file.'" > '.folder.'/'.file.'.diff'
822823
call project#RunShellCmd(cmd)
823824
if v:shell_error
@@ -1022,9 +1023,17 @@ function! s:GetCurrentFile()
10221023
return s:GetFileByLine(line('.'))
10231024
endfunction
10241025

1026+
function! s:GetDirectoryByLine(lnum)
1027+
return s:GetMatchstrByLine(a:lnum, s:directory_regexp)
1028+
endfunction
1029+
1030+
function! s:GetFilenameByLine(lnum)
1031+
return s:GetMatchstrByLine(a:lnum, s:file_regexp)
1032+
endfunction
1033+
10251034
function! s:GetFileByLine(lnum)
1026-
let name = s:GetMatchstrByLine(a:lnum, s:file_regexp)
1027-
let directory = s:GetMatchstrByLine(a:lnum, s:directory_regexp)
1035+
let name = s:GetFilenameByLine(a:lnum)
1036+
let directory = s:GetDirectoryByLine(a:lnum)
10281037
if empty(directory)
10291038
return name
10301039
endif
@@ -1542,7 +1551,6 @@ function! s:GetCommitMessage()
15421551
let title = ''
15431552
let CustomMessage = project#GetVariable('commit_message')
15441553

1545-
15461554
if !empty(CustomMessage)
15471555
if type(CustomMessage) == type(function('tr'))
15481556
let title = CustomMessage(folder_name)

0 commit comments

Comments
 (0)