From f3ccb0c12ee4985b8808f83059830a24cc92821c Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 30 Oct 2017 22:15:41 +0100 Subject: [PATCH] BufReadObject: handle rev-parse errors With `:Gdiff ^` on a file that has just been added, you would get an error via `git rev-parse --verify`: > fatal: Needed a single revision The error message is clearer when not using `--verify`: > fatal: Path 'X' exists on disk, but not in 'SHA'. The behavior depends on if you use `:set hidden`, where the second invocation works, as in will open an empty buffer - apparently since it has been created as "a buffer with read errors" ("x" in `:ls!`) before. Fixes https://github.com/tpope/vim-fugitive/issues/866. --- plugin/fugitive.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 81b519e..3fc0d01 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -2749,6 +2749,8 @@ function! s:BufReadObject() abort endif endtry + return '' + catch /^fugitive: rev-parse/ return '' catch /^fugitive:/ return 'echoerr v:errmsg'