commit 3366704c8f3f5df476bd34afb723f59ed4fb1dbf (tree)
parent a71120ca8f49cca08587ec9b569d41f4235327b2
Author: Tim Pope <code@tpope.net>
Date: Sat, 23 Apr 2011 22:15:28 -0400
Enable `-` on headings in :Gstatus
Diffstat:
2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/doc/fugitive.txt b/doc/fugitive.txt
@@ -53,11 +53,13 @@ that are part of Git repositories).
:Gstatus Bring up the output of git-status in the preview
window. In addition to standard motions, you can
use <C-N> and <C-P> to jump from filename to
- filename. Press D to |:Gdiff| the file on the cursor
- line, or ds to |:Gsdiff|. Press - to stage or unstage
- the file on the cursor line. Press p to do so on a
- per hunk basis (--patch). Press C to invoke
- |:Gcommit|.
+ filename. Press C to invoke |:Gcommit|. Press D to
+ |:Gdiff| the file on the cursor line, or ds to
+ |:Gsdiff|. Press - to stage or unstage the file on
+ the cursor line. Press p to do so on a per hunk basis
+ (--patch). All of D, -, and p have a different,
+ sensible (and hopefully intuitive) behavior when
+ invoked on a heading rather than a file name.
*fugitive-:Gcommit*
:Gcommit [args] A wrapper around git-commit. If there is nothing
diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim
@@ -592,8 +592,30 @@ function! s:StageToggle(lnum1,lnum2) abort
let output = ''
for lnum in range(a:lnum1,a:lnum2)
let line = getline(lnum)
- if getline('.') == '# Changes to be committed:'
- return 'Gcommit'
+ if line ==# '# Changes to be committed:'
+ call s:repo().git_chomp_in_tree('reset','-q')
+ silent! edit!
+ 1
+ if !search('^# Untracked files:$','W')
+ call search('^# Change','W')
+ endif
+ return ''
+ elseif line =~# '^# Change\%(d but not updated\|s not staged for commit\):$'
+ call s:repo().git_chomp_in_tree('add','-u')
+ silent! edit!
+ 1
+ if !search('^# Untracked files:$','W')
+ call search('^# Change','W')
+ endif
+ return ''
+ elseif line ==# '# Untracked files:'
+ call s:repo().git_chomp_in_tree('add','-N','.')
+ silent! edit!
+ 1
+ if !search('^# Change\%(d but not updated\|s not staged for commit\):$','W')
+ call search('^# Change','W')
+ endif
+ return ''
endif
let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.\{-\}\ze\%( (new commits)\)\=$')
if filename ==# ''