Update 2026-01-25 09:38 OpenBSD/amd64-t14
This commit is contained in:
@@ -18,7 +18,6 @@ function! gitgutter#debug#debug()
|
||||
call s:git_version()
|
||||
call s:separator()
|
||||
|
||||
call s:grep_version()
|
||||
call s:separator()
|
||||
|
||||
call s:option('updatetime')
|
||||
@@ -41,14 +40,6 @@ function! s:git_version()
|
||||
call s:output( substitute(v, '\n$', '', '') )
|
||||
endfunction
|
||||
|
||||
function! s:grep_version()
|
||||
let v = system(g:gitgutter_grep.' --version')
|
||||
call s:output( substitute(v, '\n$', '', '') )
|
||||
|
||||
let v = system(g:gitgutter_grep.' --help')
|
||||
call s:output( substitute(v, '\%x00', '', 'g') )
|
||||
endfunction
|
||||
|
||||
function! s:option(name)
|
||||
if exists('+' . a:name)
|
||||
let v = eval('&' . a:name)
|
||||
|
||||
@@ -10,10 +10,6 @@ let s:counter = 0
|
||||
|
||||
" Returns a diff of the buffer against the index or the working tree.
|
||||
"
|
||||
" After running the diff we pass it through grep where available to reduce
|
||||
" subsequent processing by the plugin. If grep is not available the plugin
|
||||
" does the filtering instead.
|
||||
"
|
||||
" When diffing against the index:
|
||||
"
|
||||
" The buffer contents is not the same as the file on disk so we need to pass
|
||||
@@ -55,12 +51,9 @@ let s:counter = 0
|
||||
"
|
||||
" Arguments:
|
||||
"
|
||||
" bufnr - the number of the buffer to be diffed
|
||||
" from - 'index' or 'working_tree'; what the buffer is diffed against
|
||||
" preserve_full_diff - truthy to return the full diff or falsey to return only
|
||||
" the hunk headers (@@ -x,y +m,n @@); only possible if
|
||||
" grep is available.
|
||||
function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
" bufnr - the number of the buffer to be diffed
|
||||
" from - 'index' or 'working_tree'; what the buffer is diffed against
|
||||
function! gitgutter#diff#run_diff(bufnr, from) abort
|
||||
if gitgutter#utility#repo_path(a:bufnr, 0) == -1
|
||||
throw 'gitgutter path not set'
|
||||
endif
|
||||
@@ -116,7 +109,8 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
|
||||
" Write file from index to temporary file.
|
||||
let index_name = gitgutter#utility#get_diff_base(a:bufnr).':'.gitgutter#utility#base_path(a:bufnr)
|
||||
let cmd .= gitgutter#git(a:bufnr).' --no-pager show --textconv '.index_name.' > '.from_file.' || exit 0) && ('
|
||||
let cmd .= gitgutter#git(a:bufnr).' --no-pager show --textconv '.index_name
|
||||
let cmd .= ' > '.gitgutter#utility#shellescape(from_file).' || exit 0) && ('
|
||||
|
||||
elseif a:from ==# 'working_tree'
|
||||
let from_file = gitgutter#utility#repo_path(a:bufnr, 1)
|
||||
@@ -129,16 +123,11 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
let cmd .= ' -c "diff.noprefix=false"'
|
||||
let cmd .= ' -c "core.safecrlf=false"'
|
||||
endif
|
||||
let cmd .= ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args.' -- '.from_file.' '.buff_file
|
||||
let cmd .= ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args
|
||||
let cmd .= ' -- '.gitgutter#utility#shellescape(from_file).' '.gitgutter#utility#shellescape(buff_file)
|
||||
|
||||
" Pipe git-diff output into grep.
|
||||
if !a:preserve_full_diff && !empty(g:gitgutter_grep)
|
||||
let cmd .= ' | '.g:gitgutter_grep.' '.gitgutter#utility#shellescape('^@@ ')
|
||||
endif
|
||||
|
||||
" grep exits with 1 when no matches are found; git-diff exits with 1 when
|
||||
" differences are found. However we want to treat non-matches and
|
||||
" differences as non-erroneous behaviour; so we OR the command with one
|
||||
" git-diff exits with 1 when differences are found but we want to treat
|
||||
" differences as non-erroneous behaviour. So we OR the command with one
|
||||
" which always exits with success (0).
|
||||
let cmd .= ' || exit 0'
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ function! s:hunk_op(op, ...)
|
||||
if gitgutter#utility#is_active(bufnr)
|
||||
" Get a (synchronous) diff.
|
||||
let [async, g:gitgutter_async] = [g:gitgutter_async, 0]
|
||||
let diff = gitgutter#diff#run_diff(bufnr, g:gitgutter_diff_relative_to, 1)
|
||||
let diff = gitgutter#diff#run_diff(bufnr, g:gitgutter_diff_relative_to)
|
||||
let g:gitgutter_async = async
|
||||
|
||||
call gitgutter#hunk#set_hunks(bufnr, gitgutter#diff#parse_diff(diff))
|
||||
@@ -359,6 +359,11 @@ endfunction
|
||||
|
||||
|
||||
function! s:preview(hunk_diff)
|
||||
if g:gitgutter_preview_win_floating && exists('*nvim_set_current_win') && s:winid != 0
|
||||
call nvim_set_current_win(s:winid)
|
||||
return
|
||||
endif
|
||||
|
||||
let lines = split(a:hunk_diff, '\r\?\n')
|
||||
let header = lines[0:4]
|
||||
let body = lines[5:]
|
||||
|
||||
@@ -312,11 +312,12 @@ function! s:obtain_file_renames(bufnr, base)
|
||||
endfunction
|
||||
|
||||
function! s:abs_path(bufnr, shellesc)
|
||||
let p = resolve(expand('#'.a:bufnr.':p'))
|
||||
|
||||
" Remove extra parts from fugitive's filepaths
|
||||
let p = substitute(substitute(p, '^fugitive:', '', ''), '\v\.git/\x{40,}/', '', '')
|
||||
|
||||
let p = expand('#'.a:bufnr.':p')
|
||||
if p =~ '\v^fugitive:/.*/(\x{40,})/'
|
||||
let p = FugitiveReal(expand('#'.a:bufnr.':p'))
|
||||
else
|
||||
let p = resolve(p)
|
||||
endif
|
||||
return a:shellesc ? gitgutter#utility#shellescape(p) : p
|
||||
endfunction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user