From 55cb58cd5f129387b78c79e668eb7e8e627b1a34 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Tue, 23 Jul 2019 20:30:55 -0400 Subject: [PATCH] Add :Git add --intent-to-add to :Gstatus P --- autoload/fugitive.vim | 6 ++++++ doc/fugitive.txt | 15 ++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 50297e2..f82feb5 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2970,6 +2970,7 @@ endfunction function! s:StagePatch(lnum1,lnum2) abort let add = [] let reset = [] + let intend = [] for lnum in range(a:lnum1,a:lnum2) let info = s:StageInfo(lnum) @@ -2985,11 +2986,16 @@ function! s:StagePatch(lnum1,lnum2) abort execute lnum if info.section ==# 'Staged' let reset += info.relative + elseif info.section ==# 'Untracked' + let intend += info.paths elseif info.status !~# '^D' let add += info.relative endif endfor try + if !empty(intend) + call s:TreeChomp(['add', '--intent-to-add', '--'] + intend) + endif if !empty(add) execute "Git add --patch -- ".join(map(add,'s:fnameescape(v:val)')) endif diff --git a/doc/fugitive.txt b/doc/fugitive.txt index ed51077..357cd6c 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -270,6 +270,14 @@ X Discard the change under the cursor. This uses *fugitive_>* > Remove the inline diff of the file under the cursor. +P Invoke |:Git| add --patch or reset --patch on the file + under the cursor. On untracked files, this instead + calls |:Git| add --intent-to-add. + + *fugitive_dp* +dp Invoke |:Git!| diff on the file under the cursor. + Deprecated in favor of inline diffs. + *fugitive_dd* dd Perform a |:Gdiffsplit| on the file under the cursor. @@ -280,13 +288,6 @@ dv Perform a |:Gvdiffsplit| on the file under the cursor. ds Perform a |:Ghdiffsplit| on the file under the cursor. dh - *fugitive_dp* -dp Invoke |:Git!| diff on the file under the cursor. - Deprecated in favor of inline diffs. On untracked - files, this instead calls |:Git| add --intent-to-add. - -P Invoke |:Git| add --patch or reset --patch on the file - under the cursor. *fugitive-navigation-mappings* Navigation mappings ~