Revert accidentally committed changes

This partially reverts commit 65be0ae749.
This commit is contained in:
Tim Pope 2018-05-27 15:21:05 -04:00
parent eeaadf7255
commit 26433842e9

View File

@ -93,7 +93,7 @@ endfunction
function! s:recall() abort function! s:recall() abort
let rev = s:sub(s:buffer().rev(), '^/', '') let rev = s:sub(s:buffer().rev(), '^/', '')
if rev ==# ':' if rev ==# ':'
return matchstr(getline('.'),'^.\=\t\%([[:alpha:] ]\+: *\)\=\zs.\{-\}\ze\%( ([^()[:digit:]]\+)\)\=$\|^\d\{6} \x\{40\} \d\t\zs.*') return matchstr(getline('.'),'^#\t\%([[:alpha:] ]\+: *\)\=\zs.\{-\}\ze\%( ([^()[:digit:]]\+)\)\=$\|^\d\{6} \x\{40\} \d\t\zs.*')
elseif s:buffer().type('tree') elseif s:buffer().type('tree')
let file = matchstr(getline('.'), '\t\zs.*') let file = matchstr(getline('.'), '\t\zs.*')
if empty(file) && line('.') > 2 if empty(file) && line('.') > 2
@ -867,7 +867,7 @@ function! fugitive#ReloadStatus() abort
endfunction endfunction
function! s:stage_info(lnum) abort function! s:stage_info(lnum) abort
let filename = matchstr(getline(a:lnum),'^.\=\t\zs.\{-\}\ze\%( ([^()[:digit:]]\+)\)\=$') let filename = matchstr(getline(a:lnum),'^#\t\zs.\{-\}\ze\%( ([^()[:digit:]]\+)\)\=$')
let lnum = a:lnum let lnum = a:lnum
if has('multi_byte_encoding') if has('multi_byte_encoding')
let colon = '\%(:\|\%uff1a\)' let colon = '\%(:\|\%uff1a\)'
@ -879,13 +879,13 @@ function! s:stage_info(lnum) abort
endwhile endwhile
if !lnum if !lnum
return ['', ''] return ['', '']
elseif (getline(lnum+1) =~# '^.\= .*\<git \%(reset\|rm --cached\) ' && getline(lnum+2) ==# '#') || getline(lnum) =~# '^\%(. \)\=Changes to be committed:$' elseif (getline(lnum+1) =~# '^# .*\<git \%(reset\|rm --cached\) ' && getline(lnum+2) ==# '#') || getline(lnum) ==# '# Changes to be committed:'
return [matchstr(filename, colon.' *\zs.*'), 'staged'] return [matchstr(filename, colon.' *\zs.*'), 'staged']
elseif (getline(lnum+1) =~# '^.\= .*\<git add ' && getline(lnum+2) ==# '#' && getline(lnum+3) !~# colon.' ') || getline(lnum) =~# '^\(. \)\=Untracked files:$' elseif (getline(lnum+1) =~# '^# .*\<git add ' && getline(lnum+2) ==# '#' && getline(lnum+3) !~# colon.' ') || getline(lnum) ==# '# Untracked files:'
return [filename, 'untracked'] return [filename, 'untracked']
elseif getline(lnum+2) =~# '^.\= .*\<git checkout ' || getline(lnum) =~# '\%(. \)\=Changes not staged for commit:$' elseif getline(lnum+2) =~# '^# .*\<git checkout ' || getline(lnum) ==# '# Changes not staged for commit:'
return [matchstr(filename, colon.' *\zs.*'), 'unstaged'] return [matchstr(filename, colon.' *\zs.*'), 'unstaged']
elseif getline(lnum+2) =~# '^.\= .*\<git \%(add\|rm\)' || getline(lnum) =~# '\%(. \)\=Unmerged paths:$' elseif getline(lnum+2) =~# '^# .*\<git \%(add\|rm\)' || getline(lnum) ==# '# Unmerged paths:'
return [matchstr(filename, colon.' *\zs.*'), 'unmerged'] return [matchstr(filename, colon.' *\zs.*'), 'unmerged']
else else
return ['', 'unknown'] return ['', 'unknown']
@ -894,7 +894,7 @@ endfunction
function! s:StageNext(count) abort function! s:StageNext(count) abort
for i in range(a:count) for i in range(a:count)
call search('^.\=\t.*','W') call search('^#\t.*','W')
endfor endfor
return '.' return '.'
endfunction endfunction
@ -904,7 +904,7 @@ function! s:StagePrevious(count) abort
return 'CtrlP '.fnameescape(s:repo().tree()) return 'CtrlP '.fnameescape(s:repo().tree())
else else
for i in range(a:count) for i in range(a:count)
call search('^.\=\t.*','Wbe') call search('^#\t.*','Wbe')
endfor endfor
return '.' return '.'
endif endif
@ -912,14 +912,14 @@ endfunction
function! s:StageReloadSeek(target,lnum1,lnum2) abort function! s:StageReloadSeek(target,lnum1,lnum2) abort
let jump = a:target let jump = a:target
let f = matchstr(getline(a:lnum1-1),'^.\=\t\%([[:alpha:] ]\+: *\|.*\%uff1a *\)\=\zs.*') let f = matchstr(getline(a:lnum1-1),'^#\t\%([[:alpha:] ]\+: *\|.*\%uff1a *\)\=\zs.*')
if f !=# '' | let jump = f | endif if f !=# '' | let jump = f | endif
let f = matchstr(getline(a:lnum2+1),'^.\=\t\%([[:alpha:] ]\+: *\|.*\%uff1a *\)\=\zs.*') let f = matchstr(getline(a:lnum2+1),'^#\t\%([[:alpha:] ]\+: *\|.*\%uff1a *\)\=\zs.*')
if f !=# '' | let jump = f | endif if f !=# '' | let jump = f | endif
silent! edit! silent! edit!
1 1
redraw redraw
call search('^.\=\t\%([[:alpha:] ]\+: *\|.*\%uff1a *\)\=\V'.jump.'\%( ([^()[:digit:]]\+)\)\=\$','W') call search('^#\t\%([[:alpha:] ]\+: *\|.*\%uff1a *\)\=\V'.jump.'\%( ([^()[:digit:]]\+)\)\=\$','W')
endfunction endfunction
function! s:StageUndo() abort function! s:StageUndo() abort
@ -976,8 +976,8 @@ function! s:StageDiffEdit() abort
if arg ==# '.' if arg ==# '.'
silent! edit! silent! edit!
1 1
if !search('^.*:\n.*\n.\= .*"git checkout \|^\%(# \)=Changes not staged for commit:$','W') if !search('^# .*:\n#.*\n# .*"git checkout \|^# Changes not staged for commit:$','W')
call search(':$','W') call search('^# .*:$','W')
endif endif
else else
call s:StageReloadSeek(arg,line('.'),line('.')) call s:StageReloadSeek(arg,line('.'),line('.'))
@ -997,28 +997,28 @@ function! s:StageToggle(lnum1,lnum2) abort
for lnum in range(a:lnum1,a:lnum2) for lnum in range(a:lnum1,a:lnum2)
let [filename, section] = s:stage_info(lnum) let [filename, section] = s:stage_info(lnum)
let repo = s:repo() let repo = s:repo()
if getline('.') =~# ':$' if getline('.') =~# '^# .*:$'
if section ==# 'staged' if section ==# 'staged'
call repo.git_chomp_in_tree('reset','-q') call repo.git_chomp_in_tree('reset','-q')
silent! edit! silent! edit!
1 1
if !search('^.*:\n.\= .*"git add .*\n#\n\|^\%(. \)\=Untracked files:$','W') if !search('^# .*:\n# .*"git add .*\n#\n\|^# Untracked files:$','W')
call search(':$','W') call search('^# .*:$','W')
endif endif
return '' return ''
elseif section ==# 'unstaged' elseif section ==# 'unstaged'
call repo.git_chomp_in_tree('add','-u') call repo.git_chomp_in_tree('add','-u')
silent! edit! silent! edit!
1 1
if !search('^.*:\n\.\= .*"git add .*\n#\n\|^\%( \)=Untracked files:$','W') if !search('^# .*:\n# .*"git add .*\n#\n\|^# Untracked files:$','W')
call search(':$','W') call search('^# .*:$','W')
endif endif
return '' return ''
else else
call repo.git_chomp_in_tree('add','.') call repo.git_chomp_in_tree('add','.')
silent! edit! silent! edit!
1 1
call search(':$','W') call search('^# .*:$','W')
return '' return ''
endif endif
endif endif
@ -1034,9 +1034,9 @@ function! s:StageToggle(lnum1,lnum2) abort
endif endif
let filename = files_to_unstage[-1] let filename = files_to_unstage[-1]
let cmd = ['reset','-q','--'] + files_to_unstage let cmd = ['reset','-q','--'] + files_to_unstage
elseif getline(lnum) =~# '^.\=\tdeleted:' elseif getline(lnum) =~# '^#\tdeleted:'
let cmd = ['rm','--',filename] let cmd = ['rm','--',filename]
elseif getline(lnum) =~# '^.\=\tmodified:' elseif getline(lnum) =~# '^#\tmodified:'
let cmd = ['add','--',filename] let cmd = ['add','--',filename]
else else
let cmd = ['add','-A','--',filename] let cmd = ['add','-A','--',filename]
@ -1062,11 +1062,11 @@ function! s:StagePatch(lnum1,lnum2) abort
for lnum in range(a:lnum1,a:lnum2) for lnum in range(a:lnum1,a:lnum2)
let [filename, section] = s:stage_info(lnum) let [filename, section] = s:stage_info(lnum)
if getline('.') =~# ':$' && section ==# 'staged' if getline('.') =~# '^# .*:$' && section ==# 'staged'
return 'Git reset --patch' return 'Git reset --patch'
elseif getline('.') =~# ':$' && section ==# 'unstaged' elseif getline('.') =~# '^# .*:$' && section ==# 'unstaged'
return 'Git add --patch' return 'Git add --patch'
elseif getline('.') =~# ':$' && section ==# 'untracked' elseif getline('.') =~# '^# .*:$' && section ==# 'untracked'
return 'Git add -N .' return 'Git add -N .'
elseif filename ==# '' elseif filename ==# ''
continue continue
@ -1079,7 +1079,7 @@ function! s:StagePatch(lnum1,lnum2) abort
let reset += [split(filename,' -> ')[1]] let reset += [split(filename,' -> ')[1]]
elseif section ==# 'staged' elseif section ==# 'staged'
let reset += [filename] let reset += [filename]
elseif getline(lnum) !~# '^.\=\tdeleted:' elseif getline(lnum) !~# '^#\tdeleted:'
let add += [filename] let add += [filename]
endif endif
endfor endfor
@ -1094,7 +1094,7 @@ function! s:StagePatch(lnum1,lnum2) abort
silent! edit! silent! edit!
1 1
redraw redraw
call search('^.\=\t\%([[:alpha:] ]\+: *\)\=\V'.first_filename.'\%( ([^()[:digit:]]\+)\)\=\$','W') call search('^#\t\%([[:alpha:] ]\+: *\)\=\V'.first_filename.'\%( ([^()[:digit:]]\+)\)\=\$','W')
endif endif
catch /^fugitive:/ catch /^fugitive:/
return 'echoerr v:errmsg' return 'echoerr v:errmsg'
@ -2931,25 +2931,25 @@ function! s:cfile() abort
let file = ':'.s:sub(matchstr(getline('.'),'\d\t.*'),'\t',':') let file = ':'.s:sub(matchstr(getline('.'),'\d\t.*'),'\t',':')
return [file] return [file]
elseif getline('.') =~# '^.\=\trenamed:.* -> ' elseif getline('.') =~# '^#\trenamed:.* -> '
let file = '/'.matchstr(getline('.'),' -> \zs.*') let file = '/'.matchstr(getline('.'),' -> \zs.*')
return [file] return [file]
elseif getline('.') =~# '^.\=\t\(\k\| \)\+\p\?: *.' elseif getline('.') =~# '^#\t\(\k\| \)\+\p\?: *.'
let file = '/'.matchstr(getline('.'),': *\zs.\{-\}\ze\%( ([^()[:digit:]]\+)\)\=$') let file = '/'.matchstr(getline('.'),': *\zs.\{-\}\ze\%( ([^()[:digit:]]\+)\)\=$')
return [file] return [file]
elseif getline('.') =~# '^.\=\t.' elseif getline('.') =~# '^#\t.'
let file = '/'.matchstr(getline('.'),'\t\zs.*') let file = '/'.matchstr(getline('.'),'#\t\zs.*')
return [file] return [file]
elseif getline('.') =~# ': needs merge$' elseif getline('.') =~# ': needs merge$'
let file = '/'.matchstr(getline('.'),'.*\ze: needs merge$') let file = '/'.matchstr(getline('.'),'.*\ze: needs merge$')
return [file, 'Gdiff!'] return [file, 'Gdiff!']
elseif getline('.') =~# '^\%(. \)\=Not currently on any branch.$' elseif getline('.') ==# '# Not currently on any branch.'
return ['HEAD'] return ['HEAD']
elseif getline('.') =~# '^\%(. \)\=On branch ' elseif getline('.') =~# '^# On branch '
let file = 'refs/heads/'.getline('.')[12:] let file = 'refs/heads/'.getline('.')[12:]
return [file] return [file]
elseif getline('.') =~# "^\\%(. \\)\=Your branch .*'" elseif getline('.') =~# "^# Your branch .*'"
let file = matchstr(getline('.'),"'\\zs\\S\\+\\ze'") let file = matchstr(getline('.'),"'\\zs\\S\\+\\ze'")
return [file] return [file]
endif endif