Commit cf103a81 authored by Jerome Reybert's avatar Jerome Reybert
Browse files

WIP debug

parent 3c3baa32
......@@ -199,6 +199,17 @@ function! magit#state#add_file(mode, status, filename, depth) dict
endif
endfunction
function! magit#state#get_files_lines() dict
let lines = {}
for diff_dict_mode in values(self.dict)
for file in values(diff_dict_mode)
let lines[file.filename] = magit#sign#get_lines(
\ file.sign_start, file.sign_end)
endfor
endfor
return lines
endfunction
" magit#state#update: update self.dict
" if a file does not exists anymore (because all its changes have been
" committed, deleted, discarded), it is removed from g:mg_diff_dict
......@@ -284,6 +295,7 @@ let magit#state#state = {
\ 'add_file': function("magit#state#add_file"),
\ 'set_files_visible': function("magit#state#set_files_visible"),
\ 'update': function("magit#state#update"),
\ 'get_files_lines': function("magit#state#get_files_lines"),
\ 'dict': { 'staged': {}, 'unstaged': {}},
\ }
......@@ -173,3 +173,30 @@ endfunction
function! magit#utils#bufnr()
return s:bufnr
endfunction
function! magit#utils#set_debug()
echom "Log into " . g:magit_log_file
execute "edit " . g:magit_log_file
execute '%delete _'
write!
let g:magit_debug = 1
endfunction
function! magit#utils#debug_cmd(cmd)
if ( g:magit_debug != 0 )
execute "a:cmd"
endif
endfunc
function! magit#utils#debug_log(message)
if ( g:magit_debug != 0 )
if ( type(a:message) == type("") )
let msg = split(a:message, '\n')
elseif ( type(a:message) == type({}) )
let msg = split(string(a:message), '\n')
else
let msg = a:message
endif
call magit#utils#append_file(g:magit_log_file, msg)
endif
endfunction
......@@ -50,6 +50,10 @@ let g:magit_default_fold_level = get(g:, 'magit_default_fold_level',
let g:magit_warning_max_lines = get(g:, 'magit_warning_max_lines', 10000)
let g:magit_debug = get(g:, 'magit_debug', 1)
let g:magit_log_file = get(g:, 'magit_log_file', '/tmp/vimagit.log')
execute "nnoremap <silent> " . g:magit_show_magit_mapping . " :call magit#show_magit('v')<cr>"
" }}}
......@@ -834,4 +838,8 @@ endfunction
command! Magit call magit#show_magit('v')
command! MagitDebugFilesLines call magit#utils#append_file(g:magit_log_file, magit#utils#flatten(items(s:state.get_files_lines())))
command! MagitDebug call magit#utils#set_debug()
" }}}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment