Skip to content

Commit

Permalink
fallback to inline diff if possible
Browse files Browse the repository at this point in the history
This enables committia.vim in ammend commit!

- This fixes #14
- This fixes #6
  • Loading branch information
rhysd committed Feb 7, 2016
1 parent 4b2e752 commit 91e9e06
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ If the width of window is narrower than the value, committia.vim employs single
- Cooperate with [vim-fugitive](https://github.com/tpope/vim-fugitive).
- Add more VCS supports
- Test all features
- Support `git commit --amend` (now fallback to normal a commit buffer)

## Contribution

Expand Down
11 changes: 10 additions & 1 deletion autoload/committia/git.vim
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ function! committia#git#diff(...) abort
if exists('l:index_file_was_not_found')
let $GIT_INDEX_FILE = ''
endif
return split(diff, '\n')

if diff ==# ''
let inline_diff_start_line = search('# Everything below will be removed.\ndiff ', 'cW') - 1
if inline_diff_start_line ==# -1
return ['']
endif
return getline(inline_diff_start_line, '$')
else
return split(diff, '\n')
endif
endfunction

function! committia#git#status(...) abort
Expand Down

0 comments on commit 91e9e06

Please sign in to comment.