mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-08 03:23:46 -05:00
Compare commits
9 Commits
540b6a8b8a
...
5c9172cc72
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c9172cc72 | ||
|
|
d74a7cff4c | ||
|
|
f4e8453ce7 | ||
|
|
de42a732ee | ||
|
|
32e2cd9e47 | ||
|
|
d5edbd75d8 | ||
|
|
0101f49718 | ||
|
|
c7bfb8241f | ||
|
|
6f06629eeb |
@@ -2162,14 +2162,57 @@ function! s:TreeInfo(dir, commit) abort
|
||||
return [{}, -1]
|
||||
endfunction
|
||||
|
||||
let s:index_info = {}
|
||||
function! s:IndexInfo(dir, commit_stage, path) abort
|
||||
let cache_key = 'cache://' . a:dir . '//' . a:path
|
||||
let index = get(s:index_info, cache_key, [])
|
||||
let newftime = getftime(fugitive#Find('.git/index', a:dir))
|
||||
|
||||
if get(index, 0, -1) == newftime
|
||||
return get(get(index, 1, {}), a:commit_stage, [])
|
||||
endif
|
||||
|
||||
let indexes = {'0': [], '1': [], '2': [], '3': []}
|
||||
let s:index_info[cache_key] = [newftime, indexes]
|
||||
|
||||
let result = fugitive#Execute(['--literal-pathspecs', 'ls-files', '--stage', '--', a:path])
|
||||
if result.exit_status
|
||||
return []
|
||||
endif
|
||||
for line in result.stdout[:2]
|
||||
" Inspect up to the first three lines to find the correct stage
|
||||
if empty(line)
|
||||
break
|
||||
endif
|
||||
let [info, filename] = split(line, "\t")
|
||||
let [mode, sha, stage] = split(info, '\s\+')
|
||||
if filename ==# a:path
|
||||
let indexes[stage] = [newftime, mode, 'blob', sha, -2]
|
||||
else
|
||||
" Only support stage '0' for tree objects
|
||||
let indexes['0'] = [newftime, '040000', 'tree', '', 0]
|
||||
endif
|
||||
endfor
|
||||
return get(indexes, a:commit_stage, [])
|
||||
endfunction
|
||||
|
||||
function! s:PathInfo(url) abort
|
||||
let [dir, commit, file] = s:DirCommitFile(a:url)
|
||||
if empty(dir) || !get(g:, 'fugitive_file_api', 1)
|
||||
return [-1, '000000', '', '', -1]
|
||||
endif
|
||||
let path = substitute(file[1:-1], '/*$', '', '')
|
||||
let [tree, ftime] = s:TreeInfo(dir, commit)
|
||||
let entry = empty(path) ? [ftime, '040000', 'tree', '', -1] : get(tree, path, [])
|
||||
|
||||
if empty(path)
|
||||
let [_, ftime] = s:TreeInfo(dir, commit)
|
||||
let entry = [ftime, '040000', 'tree', '', -1]
|
||||
elseif commit =~# '^:\=[0-3]$'
|
||||
let entry = s:IndexInfo(dir, commit[-1:-1], path)
|
||||
else
|
||||
let [tree, ftime] = s:TreeInfo(dir, commit)
|
||||
let entry = get(tree, path, [])
|
||||
endif
|
||||
|
||||
if empty(entry) || file =~# '/$' && entry[2] !=# 'tree'
|
||||
return [-1, '000000', '', '', -1]
|
||||
else
|
||||
@@ -5191,7 +5234,7 @@ function! s:DoToggleHeadHeader(value) abort
|
||||
endfunction
|
||||
|
||||
function! s:DoToggleHelpHeader(value) abort
|
||||
exe 'help fugitive-map'
|
||||
exe 'help fugitive-maps'
|
||||
endfunction
|
||||
|
||||
function! s:DoStagePushHeader(value) abort
|
||||
@@ -7917,6 +7960,7 @@ function! s:MapGitOps(is_ftplugin) abort
|
||||
exe s:Map('n', 'cc', ':<C-U>Git commit<CR>', '<silent>', ft)
|
||||
exe s:Map('n', 'ce', ':<C-U>Git commit --amend --no-edit<CR>', '<silent>', ft)
|
||||
exe s:Map('n', 'cw', ':<C-U>Git commit --amend --only<CR>', '<silent>', ft)
|
||||
exe s:Map('n', 'cW', ':<C-U>Git commit --fixup=reword:<C-R>=<SID>SquashArgument()<CR>', '', ft)
|
||||
exe s:Map('n', 'cva', ':<C-U>tab Git commit -v --amend<CR>', '<silent>', ft)
|
||||
exe s:Map('n', 'cvc', ':<C-U>tab Git commit -v<CR>', '<silent>', ft)
|
||||
exe s:Map('n', 'cRa', ':<C-U>Git commit --reset-author --amend<CR>', '<silent>', ft)
|
||||
@@ -7926,7 +7970,8 @@ function! s:MapGitOps(is_ftplugin) abort
|
||||
exe s:Map('n', 'cF', ':<C-U><Bar>Git -c sequence.editor=true rebase --interactive --autosquash<C-R>=<SID>RebaseArgument()<CR><Home>Git commit --fixup=<C-R>=<SID>SquashArgument()<CR>', '', ft)
|
||||
exe s:Map('n', 'cs', ':<C-U>Git commit --no-edit --squash=<C-R>=<SID>SquashArgument()<CR>', '', ft)
|
||||
exe s:Map('n', 'cS', ':<C-U><Bar>Git -c sequence.editor=true rebase --interactive --autosquash<C-R>=<SID>RebaseArgument()<CR><Home>Git commit --no-edit --squash=<C-R>=<SID>SquashArgument()<CR>', '', ft)
|
||||
exe s:Map('n', 'cA', ':<C-U>Git commit --edit --squash=<C-R>=<SID>SquashArgument()<CR>', '', ft)
|
||||
exe s:Map('n', 'cn', ':<C-U>Git commit --edit --squash=<C-R>=<SID>SquashArgument()<CR>', '', ft)
|
||||
exe s:Map('n', 'cA', ':<C-U>echoerr "Use cn"<CR>', '<silent><unique>', ft)
|
||||
exe s:Map('n', 'c?', ':<C-U>help fugitive_c<CR>', '<silent>', ft)
|
||||
|
||||
exe s:Map('n', 'cr<Space>', ':Git revert<Space>', '', ft)
|
||||
@@ -8045,8 +8090,8 @@ function! fugitive#MapJumps(...) abort
|
||||
|
||||
call s:Map('n', '.', ":<C-U> <C-R>=<SID>fnameescape(fugitive#Real(@%))<CR><Home>")
|
||||
call s:Map('x', '.', ":<C-U> <C-R>=<SID>fnameescape(fugitive#Real(@%))<CR><Home>")
|
||||
call s:Map('n', 'g?', ":<C-U>help fugitive-map<CR>", '<silent>')
|
||||
call s:Map('n', '<F1>', ":<C-U>help fugitive-map<CR>", '<silent>')
|
||||
call s:Map('n', 'g?', ":<C-U>help fugitive-maps<CR>", '<silent>')
|
||||
call s:Map('n', '<F1>', ":<C-U>help fugitive-maps<CR>", '<silent>')
|
||||
endif
|
||||
|
||||
let old_browsex = maparg('<Plug>NetrwBrowseX', 'n')
|
||||
|
||||
@@ -465,15 +465,18 @@ Commit maps ~
|
||||
|
||||
cc Create a commit.
|
||||
|
||||
cvc Create a commit with -v.
|
||||
|
||||
ca Amend the last commit and edit the message.
|
||||
|
||||
cva Amend the last commit with -v.
|
||||
|
||||
ce Amend the last commit without editing the message.
|
||||
|
||||
cw Reword the last commit.
|
||||
|
||||
cvc Create a commit with -v.
|
||||
|
||||
cva Amend the last commit with -v
|
||||
cW Create an `amend!` commit that rewords the commit
|
||||
under the cursor.
|
||||
|
||||
cf Create a `fixup!` commit for the commit under the
|
||||
cursor.
|
||||
@@ -487,8 +490,8 @@ cs Create a `squash!` commit for the commit under the
|
||||
cS Create a `squash!` commit for the commit under the
|
||||
cursor and immediately rebase it.
|
||||
|
||||
cA Create a `squash!` commit for the commit under the
|
||||
cursor and edit the message.
|
||||
cn Create a `squash!` commit for the commit under the
|
||||
(formerly cA) cursor and edit the message.
|
||||
|
||||
c<Space> Populate command line with ":Git commit ".
|
||||
|
||||
|
||||
Reference in New Issue
Block a user