Skip to content
Snippets Groups Projects
Commit 35570fa0 authored by Jérôme Reybert's avatar Jérôme Reybert
Browse files

Merge pull request #55 from bakunyo/close-commit-for-next

Commit 'Write commit message to .git/COMMIT_EDITMSG' must be completed.
parents 10033811 d8adf2d5
Branches
Tags
No related merge requests found
......@@ -200,6 +200,9 @@ Following mappings are set locally, for magit buffer only, in normal mode.
##### CF
* Amend the staged changes into the previous commit, without modifying previous commit message.
##### CU
* Close a commit section (If you need soon after open or editing commit message, pressing 'u' is good enough).
##### I
* Add the file under the cursor in .gitgnore
......
......@@ -236,6 +236,11 @@ Following mappings are set locally, for magit buffer only, in normal mode.
CF Amend the staged changes into the previous commit, without
modifying previous commit message
*vimagit-CU* *magit#close_commit()*
*vimagit-g:magit_close_commit_mapping*
CU Close a commit section (If you need soon after open or editing
Ucommit message, pressing 'u' is good enough).
*vimagit-I* *magit#ignore_file()*
*vimagit-g:magit_ignore_mapping*
I Add the file under the cursor in .gitgnore
......
......@@ -27,6 +27,7 @@ let g:magit_discard_hunk_mapping = get(g:, 'magit_discard_hunk_mapping',
let g:magit_commit_mapping = get(g:, 'magit_commit_mapping', 'CC' )
let g:magit_commit_amend_mapping = get(g:, 'magit_commit_amend_mapping', 'CA' )
let g:magit_commit_fixup_mapping = get(g:, 'magit_commit_fixup_mapping', 'CF' )
let g:magit_close_commit_mapping = get(g:, 'magit_close_commit_mapping', 'CU' )
let g:magit_reload_mapping = get(g:, 'magit_reload_mapping', 'R' )
let g:magit_ignore_mapping = get(g:, 'magit_ignore_mapping', 'I' )
let g:magit_close_mapping = get(g:, 'magit_close_mapping', 'q' )
......@@ -661,6 +662,7 @@ function! magit#show_magit(display, ...)
execute "nnoremap <buffer> <silent> " . g:magit_commit_mapping . " :call magit#commit_command('CC')<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_commit_amend_mapping . " :call magit#commit_command('CA')<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_commit_fixup_mapping . " :call magit#commit_command('CF')<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_close_commit_mapping . " :call magit#close_commit()<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_ignore_mapping . " :call magit#ignore_file()<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_close_mapping . " :call magit#close_magit()<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_toggle_help_mapping . " :call magit#toggle_help()<cr>"
......@@ -926,6 +928,24 @@ function! magit#commit_command(mode)
call magit#update_buffer()
endfunction
" magit#close_commit: cancel for commit mode
" close commit section if opened
function! magit#close_commit()
if ( b:magit_current_commit_mode == '' )
return
endif
let git_dir=magit#git#git_dir()
let commit_editmsg=git_dir . 'COMMIT_EDITMSG'
if ( filereadable(commit_editmsg) )
let commit_msg=s:mg_get_commit_msg()
call writefile(commit_msg, commit_editmsg)
endif
let b:magit_current_commit_mode=''
call magit#update_buffer()
endfunction
" magit#jump_hunk: function to jump among hunks
" it closes the current fold (if any), jump to next hunk and unfold it
" param[in] dir: can be 'N' (for next) or 'P' (for previous)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment