From 630ecc8c3a57cb187152f72a0403ed60b8f12a82 Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Mon, 13 Sep 2021 13:02:20 +0400 Subject: [PATCH] Use --filters in cat-file whenever possible Starting with Git 2.11 cat-file provides --filters option that can be specified instead of "blob" type. This option tells Git to use all filters specified in .gitattributes. This enables diffs for files with filters, for example, git-crypt. Closes #1509 --- autoload/fugitive.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 976b7ba..e679ec1 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2109,7 +2109,8 @@ function! s:BlobTemp(url) abort endif if commit =~# '^\d$' || !filereadable(tempfile) let rev = s:DirRev(a:url)[1] - let exec_error = s:StdoutToFile(tempfile, [dir, 'cat-file', 'blob', rev])[1] + let blob_or_filters = fugitive#GitVersion(2, 11) ? '--filters' : 'blob' + let exec_error = s:StdoutToFile(tempfile, [dir, 'cat-file', blob_or_filters, rev])[1] if exec_error call delete(tempfile) return '' @@ -2952,7 +2953,8 @@ function! fugitive#BufReadCmd(...) abort elseif b:fugitive_type ==# 'stage' call s:ReplaceCmd([dir, 'ls-files', '--stage']) elseif b:fugitive_type ==# 'blob' - call s:ReplaceCmd([dir, 'cat-file', b:fugitive_type, rev]) + let blob_or_filters = rev =~# ':' && fugitive#GitVersion(2, 11) ? '--filters' : 'blob' + call s:ReplaceCmd([dir, 'cat-file', blob_or_filters, rev]) endif finally keepjumps call setpos('.',pos)