From 3c4ad5ff72860aee9dbb04fc67aa904568a5a32d Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 28 Jul 2019 21:45:55 -0400 Subject: [PATCH] Avoid unnecessary diffing in :Gstatus --- autoload/fugitive.vim | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 002d068..230799e 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1753,9 +1753,16 @@ function! fugitive#BufReadStatus() abort endfor endif - let b:fugitive_diff = { - \ 'Staged': s:LinesError(['diff', '--color=never', '--no-ext-diff', '--no-prefix', '--cached'])[0], - \ 'Unstaged': s:LinesError(['diff', '--color=never', '--no-ext-diff', '--no-prefix'])[0]} + let diff = {'Staged': [], 'Unstaged': []} + if len(staged) + let diff['Staged'] = + \ s:LinesError(['diff', '--color=never', '--no-ext-diff', '--no-prefix', '--cached'])[0] + endif + if len(unstaged) + let diff['Unstaged'] = + \ s:LinesError(['diff', '--color=never', '--no-ext-diff', '--no-prefix'])[0] + endif + let b:fugitive_diff = diff let expanded = get(b:, 'fugitive_expanded', {'Staged': {}, 'Unstaged': {}}) let b:fugitive_expanded = {'Staged': {}, 'Unstaged': {}}