3 Commits

Author SHA1 Message Date
Tim Pope
61b51c09b7 Fix race conditions generating sequencer sections
Resolves: https://github.com/tpope/vim-fugitive/issues/2411
2025-07-15 17:27:19 -04:00
Tim Pope
e0715fe729 Fix check for revert/cherry-pick
Undoing a bad search and replace in
4bc9d98993
2025-07-15 17:27:19 -04:00
Tim Pope
53d6ba99bc Remove unnecessary include guard 2025-07-15 17:27:19 -04:00

View File

@@ -4,11 +4,6 @@
" The functions contained within this file are for internal use only. For the
" official API, see the commented functions in plugin/fugitive.vim.
if exists('g:autoloaded_fugitive')
finish
endif
let g:autoloaded_fugitive = 1
" Section: Utility
function! s:function(name) abort
@@ -2942,20 +2937,34 @@ function! s:StatusRender(stat) abort
endif
let sequencing = []
if filereadable(fugitive#Find('.git/sequencer/todo', dir))
for line in reverse(readfile(fugitive#Find('.git/sequencer/todo', dir)))
try
let sequencer_todo = reverse(readfile(fugitive#Find('.git/sequencer/todo', dir)))
catch
endtry
if exists('sequencer_todo')
for line in sequencer_todo
let match = matchlist(line, '^\(\l\+\)\s\+\(\x\{4,\}\)\s\+\(.*\)')
if len(match) && match[1] !~# 'exec\|merge\|label'
call add(sequencing, {'type': 'Rebase', 'status': get(s:rebase_abbrevs, match[1], match[1]), 'commit': match[2], 'subject': match[3]})
endif
endfor
elseif filereadable(fugitive#Find('.git/MERGE_MSG', dir))
else
try
let merge_msg = get(readfile(fugitive#Find('.git/MERGE_MSG', dir)), 0, '')
catch
endtry
endif
if exists('merge_msg')
if filereadable(fugitive#Find('.git/CHERRY_PICK_HEAD', dir))
let pick_head = fugitive#Execute(['rev-parse', '--short', 'CHERRY_PICK_HEAD', '--'], dir).stdout[0]
call add(sequencing, {'type': 'Rebase', 'status': 'pick', 'commit': pick_head, 'subject': get(readfile(fugitive#Find('.git/MERGE_MSG', dir)), 0, '')})
if !empty(pick_head)
call add(sequencing, {'type': 'Rebase', 'status': 'pick', 'commit': pick_head, 'subject': merge_msg})
endif
elseif filereadable(fugitive#Find('.git/REVERT_HEAD', dir))
let pick_head = fugitive#Execute(['rev-parse', '--short', 'REVERT_HEAD', '--'], dir).stdout[0]
call add(sequencing, {'type': 'Rebase', 'status': 'revert', 'commit': pick_head, 'subject': get(readfile(fugitive#Find('.git/MERGE_MSG', dir)), 0, '')})
if !empty(pick_head)
call add(sequencing, {'type': 'Rebase', 'status': 'revert', 'commit': pick_head, 'subject': merge_msg})
endif
endif
endif
@@ -2978,7 +2987,7 @@ function! s:StatusRender(stat) abort
endif
call s:AddSection(to, 'Rebasing ' . rebasing_head, rebasing)
call s:AddSection(to, get(get(sequencing, 0, {}), 'tous', '') ==# 'revert' ? 'Reverting' : 'Cherry Picking', sequencing)
call s:AddSection(to, get(get(sequencing, 0, {}), 'status', '') ==# 'revert' ? 'Reverting' : 'Cherry Picking', sequencing)
call s:AddSection(to, 'Untracked', untracked)
call s:AddDiffSection(to, stat, 'Unstaged', unstaged)
call s:AddDiffSection(to, stat, 'Staged', staged)