Skip to content

Commit

Permalink
Do 'git commit -a' if no file is added to index
Browse files Browse the repository at this point in the history
  • Loading branch information
motemen committed Apr 30, 2009
1 parent 1cbf346 commit 31d7cee
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugin/git.vim
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,23 @@ endfunction
function! GitCommit(args)
let git_dir = <SID>GetGitDir()

let args = a:args

if args !~ '\v\k@<!(-a|--all)>' && s:SystemGit('diff --cached --stat') =~ '^\(\s\|\n\)*$'
let args .= ' -a'
endif

" Create COMMIT_EDITMSG file
let editor_save = $EDITOR
let $EDITOR = ''
let git_output = s:SystemGit('commit ' . a:args)
let git_output = s:SystemGit('commit ' . args)
let $EDITOR = editor_save

execute printf('%s %sCOMMIT_EDITMSG', g:git_command_edit, git_dir)
setlocal filetype=git-status bufhidden=wipe
augroup GitCommit
autocmd BufWritePre <buffer> g/^#\|^\s*$/d | setlocal fileencoding=utf-8
execute printf("autocmd BufWritePost <buffer> call GitDoCommand('commit %s -F ' . expand('%%')) | autocmd! GitCommit * <buffer>", a:args)
execute printf("autocmd BufWritePost <buffer> call GitDoCommand('commit %s -F ' . expand('%%')) | autocmd! GitCommit * <buffer>", args)
augroup END
endfunction

Expand Down

0 comments on commit 31d7cee

Please sign in to comment.