From 1d2f1503315dab9f428efe687260b90524a5c380 Mon Sep 17 00:00:00 2001 From: kaihowl Date: Sun, 14 May 2017 12:48:03 +0200 Subject: [PATCH] Unstage single files from git move and do not move them back This fixes #824 --- plugin/fugitive.vim | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 52028c2..ea5af32 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -975,11 +975,14 @@ function! s:StageToggle(lnum1,lnum2) abort continue endif execute lnum - if filename =~ ' -> ' - let cmd = ['mv','--'] + reverse(split(filename,' -> ')) - let filename = cmd[-1] - elseif section ==# 'staged' - let cmd = ['reset','-q','--',filename] + if section ==# 'staged' + if filename =~ ' -> ' + let files_to_unstage = split(filename,' -> ') + else + let files_to_unstage = [filename] + endif + let filename = files_to_unstage[-1] + let cmd = ['reset','-q','--'] + files_to_unstage elseif getline(lnum) =~# '^#\tdeleted:' let cmd = ['rm','--',filename] elseif getline(lnum) =~# '^#\tmodified:'