@@ -82,18 +82,29 @@ function! s:directory_of_current_file()
8282 return shellescape (expand (" %:p:h" ))
8383endfunction
8484
85+ function ! s: discard_stdout_and_stderr ()
86+ if ! exists (' s:discard' )
87+ if &shellredir == ? ' >%s 2>&1'
88+ let s: discard = ' > /dev/null 2>&1'
89+ else
90+ let s: discard = ' >& /dev/null'
91+ endif
92+ endif
93+ return s: discard
94+ endfunction
95+
8596function ! s: command_in_directory_of_current_file (cmd)
8697 return ' cd ' . s: directory_of_current_file () . ' && ' . a: cmd
8798endfunction
8899
89100function ! s: is_in_a_git_repo ()
90- let cmd = ' git rev-parse > /dev/null 2>&1 '
101+ let cmd = ' git rev-parse' . s: discard_stdout_and_stderr ()
91102 call system (s: command_in_directory_of_current_file (cmd))
92103 return ! v: shell_error
93104endfunction
94105
95106function ! s: is_tracked_by_git ()
96- let cmd = ' git ls-files --error-unmatch > /dev/null 2>&1 ' . shellescape (s: current_file ())
107+ let cmd = ' git ls-files --error-unmatch' . s: discard_stdout_and_stderr () . ' ' . shellescape (s: current_file ())
97108 call system (s: command_in_directory_of_current_file (cmd))
98109 return ! v: shell_error
99110endfunction
@@ -323,41 +334,41 @@ function! GitGutter()
323334endfunction
324335command GitGutter call GitGutter ()
325336
326- function ! DisableGitGutter ()
337+ function ! GitGutterDisable ()
327338 let g: gitgutter_enabled = 0
328339 call s: clear_signs (s: current_file ())
329340endfunction
330- command DisableGitGutter call DisableGitGutter ()
341+ command GitGutterDisable call GitGutterDisable ()
331342
332- function ! EnableGitGutter ()
343+ function ! GitGutterEnable ()
333344 let g: gitgutter_enabled = 1
334345 call GitGutter ()
335346endfunction
336- command EnableGitGutter call EnableGitGutter ()
347+ command GitGutterEnable call GitGutterEnable ()
337348
338- function ! ToggleGitGutter ()
349+ function ! GitGutterToggle ()
339350 if g: gitgutter_enabled
340- call DisableGitGutter ()
351+ call GitGutterDisable ()
341352 else
342- call EnableGitGutter ()
353+ call GitGutterEnable ()
343354 endif
344355endfunction
345- command ToggleGitGutter call ToggleGitGutter ()
356+ command GitGutterToggle call GitGutterToggle ()
346357
347- function ! DisableGitGutterLineHighlights ()
358+ function ! GitGutterLineHighlightsDisable ()
348359 call s: update_line_highlights (0 )
349360endfunction
350- command DisableGitGutterLineHighlights call DisableGitGutterLineHighlights ()
361+ command GitGutterLineHighlightsDisable call GitGutterLineHighlightsDisable ()
351362
352- function ! EnableGitGutterLineHighlights ()
363+ function ! GitGutterLineHighlightsEnable ()
353364 call s: update_line_highlights (1 )
354365endfunction
355- command EnableGitGutterLineHighlights call EnableGitGutterLineHighlights ()
366+ command GitGutterLineHighlightsEnable call GitGutterLineHighlightsEnable ()
356367
357- function ! ToggleGitGutterLineHighlights ()
368+ function ! GitGutterLineHighlightsToggle ()
358369 call s: update_line_highlights (s: highlight_lines ? 0 : 1 )
359370endfunction
360- command ToggleGitGutterLineHighlights call ToggleGitGutterLineHighlights ()
371+ command GitGutterLineHighlightsToggle call GitGutterLineHighlightsToggle ()
361372
362373function ! GitGutterNextHunk ()
363374 if s: is_active ()
@@ -408,7 +419,7 @@ endfunction
408419
409420augroup gitgutter
410421 autocmd !
411- autocmd BufReadPost ,BufWritePost ,FileReadPost ,FileWritePost * call GitGutter ()
422+ autocmd BufReadPost ,BufWritePost ,FileReadPost ,FileWritePost , FocusGained * call GitGutter ()
412423augroup END
413424
414425" }}}
0 commit comments